Buffed hit stat: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Grotfang
Conform to template
imported>AlbinoRhino
mNo edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{#vardefine:name|buffed_hit_stat}}
{{
{{#vardefine:return_type|int}}
#vardefine:name|buffed_hit_stat}}{{
#vardefine:return_type|int}}{{


{{FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Your Character|


function1={{Function|
function1={{Function|
Line 21: Line 21:
<syntaxhighlight>
<syntaxhighlight>
boolean safe_to_attack() {
boolean safe_to_attack() {
   int x = buffed_hit_stat;
   int x = buffed_hit_stat();
   monster [int] monster_list = get_monsters($location[Fantasy Airship]);
   monster [int] monster_list = get_monsters($location[Fantasy Airship]);
   foreach int in monster_list {
   foreach int in monster_list {
       float fumble = 1/22;
       float fumble = 1/22;
       float hit_percentage = (((6 + (x - monster_base_defense(monster_list[int]))) / 10.5) * (100 - fumble))
       float hit_percentage = (((6 + (x - monster_defense(monster_list[int]))) / 10.5) * (100 - fumble));
       if(hit_percentage < 50) {
       if(hit_percentage < 50) {
         return false;
         return false;
Line 31: Line 31:
   }
   }
   return true;
   return true;
  }
}
}
</syntaxhighlight>
</syntaxhighlight>
}}|
}}|


see_also={{SeeAlso|get_monsters|monster_base_defense}}|
see_also={{SeeAlso|get_monsters|monster_defense|current_hit_stat}}|
more_info=<a href="http://kol.coldfront.net/thekolwiki/index.php/Hit_Chance">Hit Chance</a>|
more_info=http://kol.coldfront.net/thekolwiki/index.php/Hit_Chance|
special=This function returns ?? when not logged in (needs spading).
special=This function returns 0 when not logged in.
}}
}}
[[Category:Your Character]]

Latest revision as of 06:57, 27 December 2017

Function Syntax

int buffed_hit_stat()

Returns the buffed value of the stat that is currently used to calculate hit percentages. Note, ranged weapons use moxie to calculate hit percentage, melee weapons use muscle.

Code Samples

This code will check your hit percentage against every monster in a specified location to make sure it is 50% or over for every monster.

boolean safe_to_attack() {
   int x = buffed_hit_stat();
   monster [int] monster_list = get_monsters($location[Fantasy Airship]);
   foreach int in monster_list {
      float fumble = 1/22;
      float hit_percentage = (((6 + (x - monster_defense(monster_list[int]))) / 10.5) * (100 - fumble));
      if(hit_percentage < 50) {
         return false;
      }
   }
   return true;
}

See Also

get_monsters() | monster_defense() | current_hit_stat()

More Information

http://kol.coldfront.net/thekolwiki/index.php/Hit_Chance

Special

This function returns 0 when not logged in.