Monster attack

From Kolmafia
Revision as of 14:26, 17 January 2015 by imported>Eliteofdelete
Jump to navigation Jump to search

Function Syntax

int monster_attack()

int monster_attack(monster check_me )

  • check_me is the (optional) monster to get the attack value of

Returns the attack value of the specified monster check_me. If check_me is not specified, it will use the current monster if you are in a fight (i.e. you're calling the function from an In-combat Consulting script), or the last monster you encountered otherwise.

When the function is given a monster as a parameter it will return the monster's attack at the start of a fight including all monster level modifications. This means that for monsters with unknown attack, the return value will be equivalent to monster_level_adjustment(). If the zero parameter version is called and the character is currently in a fight, then the function will include all current combat deleveling modifiers from the current combat.

If you want to know the monster's raw attack without being modified by monster level adjustments, it is available through the monster.raw_attack proxy field.

Code Samples

Following example is a function that uses the monster's attack to determine hit chance based on your moxie.

boolean safecheck(string monstername) {
   int att = monster_attack(to_monster(monstername));
   if (att+10 <= my_buffedstat($stat[moxie])) {
      print("Monster "+monstername+" will always miss! (except for crits)", "green");
      return true;
   }
   else if (att-10 >= my_buffedstat($stat[moxie])){
      print(att+10);
      print("Monster "+monstername+" will always hit you! (except for fumbles)", "red");
      return false;
   }
   else {
      print(att);
      int hitchance = (att+10-my_buffedstat($stat[moxie]))*5;
      print("Monster "+monstername+" will hit you "+hitchance+"% of the time.", "blue");
      return false;
   }
return false;
}

safecheck("bar");

See Also

monster_defense() | monster_initiative() | monster_element() | monster_hp()

More Information

For the current discussion of what's being tracked in-combat for monster level adjustments, please see this thread.

Special

If no monster is specified and no monster has been fought in this session, this function returns 0. This is because mafia forgets the value of last_monster() when it logs out.