Jump to content
  • 0

How to add on % on give out item?


ahloi007

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  10/15/12
  • Last Seen:  

Quote

30024,Lucky_Draw_Box1,Lucky Draw Box1,2,0,,0,,,,,0xFFFFFFFF,7,2,,,,,,{ getitem callfunc("F_Rand",30016,30007,30012,30008,30018,30015,30011,30010),1; },{},{}

function	script	F_Rand	{
	return getarg(rand(getargcount()));
}

Hi there, this is the random box script that I am using right now.

Can I know how to add on the % to the item give out through this script ?

 

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

you could use these instead.

*groupranditem <group id>{,<sub_group>};

Returns the item_id of a random item picked from the group specified. The
different groups and their group number are specified in 'db/(pre-)re/item_group_db.txt'.

When used in conjunction with other functions, you can get a random item. For
example, for a random pet lure:

getitem groupranditem(IG_Taming),1;

'sub_group' is used to get the available random items of item group from specified random
group. 0 for 'must' item group, and random item group is 1 until 5 (MAX_ITEMGROUP_RANDGROUP+1).

More info, see doc/item_group.txt.

---------------------------------------

*getrandgroupitem <group_id>{,<quantity>{,<sub_group>{,<identify>{,<char_id>}}}};

Similar to the above example, this command allows players to obtain the specified
quantity of a random item from the group "<group id>". The different groups and
their group number are specified in db/(pre-)re/item_group_db.txt

If 'quantity' is not defined or 0, it will uses defined amount from Item Group list.

If 'sub_group' is not defined the value will be 1 (since random group is 1 ~ 5, and 0 is
'must' item group).

For item with type IT_WEAPON, IT_ARMOR, IT_PETARMOR, and IT_SHADOWGEAR will be given
as unidentified item (as defined by itemdb_isidentified in src/map/itemdb.cpp) except
if 'identify' is defined with value 1.

More info, see doc/item_group.txt.

---------------------------------------

*getgroupitem <group_id>{,<identify>{,<char_id>}};

Gives item(s) to the attached player based on item group contents.
This is not working like 'getrandgroupitem' which only give 1 item for specified
item group & sub_group.

For item with type IT_WEAPON, IT_ARMOR, IT_PETARMOR, and IT_SHADOWGEAR will be given
as unidentified item (as defined by itemdb_isidentified in src/map/itemdb.cpp) except
if 'identify' is defined with value 1.

More info, see doc/item_group.txt.

 

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

if(getarg(1)>0){

targetIndex = n;

if(rand(0,100)<=getarg(2))

getitem array[targetIndex];

}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  10/15/12
  • Last Seen:  

On 9/6/2019 at 12:49 AM, Start_ said:

if(getarg(1)>0){

targetIndex = n;

if(rand(0,100)<=getarg(2))

getitem array[targetIndex];

}

 

I'm sorry, can you please explained in details? Because I'm still new to this... *lol

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

You call this

getitem callfunc("F_Rand",30016,30007,30012,30008,30018,30015,30011,30010),1;

 

That's function F_Rand take 1 arguments is item id.

Then you can easy send more argument to function like how much percent do you want to increase chance at index or whatever.

 

By the way there are many ways to it.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  10/15/12
  • Last Seen:  

On 9/7/2019 at 12:22 PM, Start_ said:

You call this


getitem callfunc("F_Rand",30016,30007,30012,30008,30018,30015,30011,30010),1;

 

That's function F_Rand take 1 arguments is item id.

Then you can easy send more argument to function like how much percent do you want to increase chance at index or whatever.

 

By the way there are many ways to it.

Okay Thanks! I got it xD

23 hours ago, Emistry said:

you could use these instead.


*groupranditem <group id>{,<sub_group>};

Returns the item_id of a random item picked from the group specified. The
different groups and their group number are specified in 'db/(pre-)re/item_group_db.txt'.

When used in conjunction with other functions, you can get a random item. For
example, for a random pet lure:

getitem groupranditem(IG_Taming),1;

'sub_group' is used to get the available random items of item group from specified random
group. 0 for 'must' item group, and random item group is 1 until 5 (MAX_ITEMGROUP_RANDGROUP+1).

More info, see doc/item_group.txt.

---------------------------------------

*getrandgroupitem <group_id>{,<quantity>{,<sub_group>{,<identify>{,<char_id>}}}};

Similar to the above example, this command allows players to obtain the specified
quantity of a random item from the group "<group id>". The different groups and
their group number are specified in db/(pre-)re/item_group_db.txt

If 'quantity' is not defined or 0, it will uses defined amount from Item Group list.

If 'sub_group' is not defined the value will be 1 (since random group is 1 ~ 5, and 0 is
'must' item group).

For item with type IT_WEAPON, IT_ARMOR, IT_PETARMOR, and IT_SHADOWGEAR will be given
as unidentified item (as defined by itemdb_isidentified in src/map/itemdb.cpp) except
if 'identify' is defined with value 1.

More info, see doc/item_group.txt.

---------------------------------------

*getgroupitem <group_id>{,<identify>{,<char_id>}};

Gives item(s) to the attached player based on item group contents.
This is not working like 'getrandgroupitem' which only give 1 item for specified
item group & sub_group.

For item with type IT_WEAPON, IT_ARMOR, IT_PETARMOR, and IT_SHADOWGEAR will be given
as unidentified item (as defined by itemdb_isidentified in src/map/itemdb.cpp) except
if 'identify' is defined with value 1.

More info, see doc/item_group.txt.

 

Thanks ya! just figure it out xD

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...