Difference between revisions of "Item drops array"

From Kolmafia
Jump to navigation Jump to search
imported>Slyz
(added the different values for 'type')
imported>Slyz
Line 17: Line 17:
 
name={{#var:name}}|
 
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
aggregate={{#var:aggregate}}|
parameter1={{Param|monster|m}}|
 
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
return_also={{#var:return_also}}
+
return_also={{#var:return_also}}|
 +
parameter1={{Param|monster|check_me}}|
 +
p1desc={{Pspan|check_me}} is the (optional) monster to check.|
 
}}|
 
}}|
  
Line 39: Line 40:
 
* "b" - bounty item, 'rate' is meaningless.
 
* "b" - bounty item, 'rate' is meaningless.
 
</p><p>
 
</p><p>
Since this is the first function to return a record, it cannot be stored to a variable, and thus the only way to access the data is by iterating over the elements in the array.|
+
Since this is the first function to return a record, it cannot be stored to a variable, and thus the only way to access the data is by iterating over the elements in the array.
 +
</p><p>
 +
If {{pspan|check_me}} is not specified, it defaults to the last monster you encountered or the one currently being fought.|
  
 
code1={{CodeSample|
 
code1={{CodeSample|

Revision as of 14:52, 5 April 2010

Function Syntax

record [int] item_drops_array()

record [int] item_drops_array(monster check_me )

  • check_me is the (optional) monster to check.

Returns an array of records with three fields:

record {
   item drop;
   int rate;
   string type;
}

The 'type' field has these currently possible values:

  • "" - normal item drop, base drop rate in the 'rate' field.
  • "0" - no drop rate information available, 'rate' will be zero.
  • "n" - not pickpocketable, but otherwise drops according to 'rate'.
  • "c" - conditional drop.
  • "p" - pickpocket-only. Currently 'rate' will always be zero.
  • "b" - bounty item, 'rate' is meaningless.

Since this is the first function to return a record, it cannot be stored to a variable, and thus the only way to access the data is by iterating over the elements in the array.

If check_me is not specified, it defaults to the last monster you encountered or the one currently being fought.

Code Samples

Prints all information Mafia has regarding the item drops of a certain monster.

void drops(monster mob){
   print("Monster: " + mob);
   foreach index, rec in item_drops_array(mob) 
      print("item: "+rec.drop+", drop rate: "+rec.rate+", type: "+rec.type);
}

See Also

meat_drop() | item_drops()

More Information

see this thread.

Special

The zero-parameter form returns the last monster encountered (the current one, if used in combat).