From e0fa6d8f158f4962c043ea72079c6ed569c582eb Mon Sep 17 00:00:00 2001 From: jasonch Date: Wed, 11 Sep 2024 03:20:08 +0800 Subject: [PATCH] `getmobdrops` doc update --- doc/script_commands.txt | 47 ++++++++--------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1c4bb8aa3ab..675ad568f0a 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4333,54 +4333,25 @@ Example: --------------------------------------- -*getmobdrops() +*getmobdrops(, {, }); -This command will find all drops of the specified mob and return the item -IDs and drop percentages into arrays of temporary global variables. -getmobdrops() returns true if successful and false if the mob ID doesn't -exist. - -Upon executing this, - -$@MobDrop_item[] is a global temporary number array which contains the - item IDs of the monster's drops. - -$@MobDrop_rate[] is a global temporary number array which contains the - drop percentages of each item. (1 = .01%) - -$@MobDrop_count is the number of item drops found. - -Be sure to use $@MobDrop_count to go through the arrays, and not -'getarraysize', because the temporary global arrays are not cleared -between runs of 'getmobdrops'. If a mob with 7 item drops is looked up, -the arrays would have 7 elements. But if another mob is looked up and it -only has 5 item drops, the server will not clear the arrays for you, -overwriting the values instead. So in addition to returning the 5 item -drops, the 6th and 7th elements from the last call remain, and you will -get 5+2 item drops, of which the last 2 don't belong to the new mob. -$@MobDrop_count will always contain the correct number (5), unlike -getarraysize() which would return 7 in this case. +This command will find drops information of the specified , copy the +item ids on to and drop rate on to if provided. +Returns the number of items found. Will return 0 if is invalid. Example: - // get a Mob ID from the user input(.@mob_id); - if (getmobdrops(.@mob_id)) { // getmobdrops() returns true on success - // immediately copy global temporary variables into scope - // variables, since we don't know when getmobdrops() will get - // called again for another mob, overwriting your global temporary - // variables. - .@count = $@MobDrop_count; - copyarray(.@item[0], $@MobDrop_item[0], .@count); - copyarray(.@rate[0], $@MobDrop_rate[0], .@count); - + .@count = getmobdrops(.@mob_id, .@item, .@rate); + + if (.@count == 0) { + mes("No drops found."); + } else { mes(getmonsterinfo(.@mob_id, MOB_NAME) + " - " + .@count + " drops found:"); for (.@i = 0; .@i < .@count; ++.@i) { mes(.@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%"); } - } else { - mes("Unknown monster ID."); } close();