Difference between pages "Waitq" and "Monster initiative"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>StDoodle
(Created page with '{{ #vardefine:name|waitq}}{{ #vardefine:return_type|void}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}| return_t…')
 
imported>Eliteofdelete
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|waitq}}{{
+
#vardefine:name|monster_initiative}}{{
#vardefine:return_type|void}}{{
+
#vardefine:return_type|int}}{{
  
 
FunctionPage|
 
FunctionPage|
 +
name={{#var:name}}|
  
 +
function1={{Function|
 
name={{#var:name}}|
 
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
}}|
  
function1={{Function|
+
function2={{Function|
 
name={{#var:name}}|
 
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
aggregate={{#var:aggregate}}|
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1={{Param|int|secs}}|
+
parameter1={{Param|monster|check_me}}|
p1desc={{pspan|secs}} is the number of seconds you want to delay further action.
+
p1desc={{Pspan|check_me}} is the (optional) monster to get the initiative value of|
 
}}|
 
}}|
 +
function_description=Returns the initiative value of the specified monster {{pspan|check_me}}. If {{pspan|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.</p>
 +
<p>When the function is given a monster as a parameter it will return the monster's initiative at the start of a fight including all monster level modifications. This means that for monsters with unknown initiative, the return value will only take into account monster level.|
  
function_description=This function will initiate a countdown from {{pspan|secs}} seconds to 0, during which time nothing else will be acted on. It essentially pauses a script. This is the "quiet" version, which will not print a countdown on the gCLI during the delay.|
+
code1={{CodeSample|
 +
title=Code Samples|
 +
description=|
 +
code=
 +
<syntaxhighlight>
 +
void jump (string monstername) {
 +
  monster mon  = to_monster(monstername);
 +
  int mon_ini = monster_initiative(mon);
 +
  int my_ini = numeric_modifier("initiative");
 +
  int chance = max(0, 100+my_ini-mon_ini+max(0, my_basestat(my_primestat())-monster_attack(mon)));
 +
  chance = min(100, chance);
 +
  print("You have a current jump chance on "+mon+" of "+chance+"% which is same as "+jump_chance(mon)+"%.", "blue");
 +
}
 +
jump("bar");
 +
</syntaxhighlight>|
 +
moreinfo= There is already a KoLMafia built in function called jump_chance() that does the same as the above example, but better. For more information on jump opponents visit KoL Wiki's [http://kol.coldfront.net/thekolwiki/index.php/Talk:Combat_Initiative Combat Initiative]
 +
}}|
  
needscode=yes|
+
see_also={{SeeAlso|monster_attack|monster_defense|monster_element|monster_hp}}|
see_also={{SeeAlso|wait}}|
+
more_info=|
cli_equiv=The CLI command "waitq" functions the same and can be used to pause basic .txt scripts.|
+
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 {{f|last_monster}} when it logs out.|
 
}}
 
}}
  
[[Category:Miscellaneous Functions]]
+
[[Category:Adventuring]][[Category:In-combat Consulting]]

Latest revision as of 14:31, 17 January 2015

Function Syntax

int monster_initiative()

int monster_initiative(monster check_me )

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

Returns the initiative 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 initiative at the start of a fight including all monster level modifications. This means that for monsters with unknown initiative, the return value will only take into account monster level.

Code Samples

void jump (string monstername) {
   monster mon  = to_monster(monstername);
   int mon_ini = monster_initiative(mon);
   int my_ini = numeric_modifier("initiative");
   int chance = max(0, 100+my_ini-mon_ini+max(0, my_basestat(my_primestat())-monster_attack(mon)));
   chance = min(100, chance);
   print("You have a current jump chance on "+mon+" of "+chance+"% which is same as "+jump_chance(mon)+"%.", "blue");
}
jump("bar");

There is already a KoLMafia built in function called jump_chance() that does the same as the above example, but better. For more information on jump opponents visit KoL Wiki's Combat Initiative

See Also

monster_attack() | monster_defense() | monster_element() | monster_hp()

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.