Appearance rates: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
No edit summary
imported>Heeheehee
No edit summary
Line 18: Line 18:
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0; ultra-rare monsters have a negative value (the actual value varies; test by looking for value < 0, not value == -1). Does not account for combat rate modifiers, olfaction, etc.|
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0; ultra-rare monsters have a negative value (the actual value varies; test by looking for value < 0, not value == -1). Does not account for combat rate modifiers, olfaction, etc.|


needscode=yes|
code1={{CodeSample|
title=Simple Example|
description=Prints the encounters in a zone and their rates of appearing.|
code=
<syntaxhighlight>
float[monster] freq = appearance_rates($location[Castle]);
print(
foreach m in freq {
  string str = m.to_string();
  if(str=="none") str = "Noncombats";
  if(freq[m]>0 && m != $monster[none]) print("Frequency of " + str + ": " + freq[m] + "%");
  if(freq[m]==-1) print("Frequency of " + str + ": Unknown");
  else print("Frequency of " + str + ": Unlikely (either semirare, boss, or ultra-rare)");
}
</syntaxhighlight>}}
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.|
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.|
}}
}}

Revision as of 19:05, 6 March 2010



Function Syntax

float [monster] appearance_rates(location place )

  • place is the adventuring location to parse

Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0; ultra-rare monsters have a negative value (the actual value varies; test by looking for value < 0, not value == -1). Does not account for combat rate modifiers, olfaction, etc.

Simple Example

Prints the encounters in a zone and their rates of appearing.

float[monster] freq = appearance_rates($location[Castle]);
print(
foreach m in freq {
   string str = m.to_string();
   if(str=="none") str = "Noncombats";
   if(freq[m]>0 && m != $monster[none]) print("Frequency of " + str + ": " + freq[m] + "%");
   if(freq[m]==-1) print("Frequency of " + str + ": Unknown");
   else print("Frequency of " + str + ": Unlikely (either semirare, boss, or ultra-rare)");
}

special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.