Difference between revisions of "Initiative modifier"

From Kolmafia
Jump to navigation Jump to search
imported>Grotfang
(A second, more detailed and useful example)
 
imported>Bale
m
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[initiative_modifier()]]
+
{{
 +
#vardefine:name|initiative_modifier}}{{
 +
#vardefine:return_type|float}}{{
  
Returns your current percentage initiative modifier in the form of a float.
+
FunctionPage|
 +
name={{#var:name}}|
 +
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}
 +
}}|
 +
function_description=Returns your current percentage initiative modifier in the form of a float.|
 +
code1={{CodeSample|
 +
title=Code Samples|
 +
description=Checks to see whether your initiative modifier is positive.|
 +
code=
 +
<syntaxhighlight>
 +
boolean positive_initiative() {
 +
  if(initiative_modifier() < 0){
 +
      return false;
 +
  }
 +
  return true;
 +
}
 +
</syntaxhighlight>
 +
}}
 +
{{CodeSample|
 +
description=Uses your initiative result to determine whether it will adventure in the sewers (where a +60% initiative guarantees getting the jump). There is also a check for my_familiar().|
 +
code=
 +
<syntaxhighlight>
 +
boolean first_yellow_ray() {
 +
  if(initiative_modifier() >= 60) {
 +
      if(my_familiar() == $familiar[he-boulder]) {
 +
        adventure(1 , $location[A Maze of Sewer Tunnels]);
 +
        return true;
 +
      }
 +
      else {
 +
        print("You should use the He-Boulder for this");
 +
      }
 +
  }
 +
  else {
 +
      print("Your initiative is too low");
 +
  }
 +
  return false;
 +
}
 +
</syntaxhighlight>
 +
}}|
 +
see_also={{SeeAlso|my_familiar}}|
 +
special=When not logged in the function returns 0.0
 +
}}
  
The following [[function]] will return false if you have a negative initiative modifier.
+
[[Category:Your Character]]
 
 
<code>
 
  [[boolean]] positive_initiative()
 
  {
 
    if( '''initiative_modifier()''' < 0 )
 
        return false;
 
    else
 
        return true;
 
  }
 
</code>
 
 
 
The following function is a little more involved and uses your initiative result to determine whether it will adventure in the sewers (where a +60% initiative guarantees getting the jump). There is also a check for [[my_familiar()]]. The function will return true if it's a success, false otherwise.
 
 
 
<code>
 
  [[boolean]] first_yellow_ray()
 
  {
 
    if( '''initiative_modifier()''' >= 60 )
 
    {
 
        if( my_familiar() == $familiar[he-boulder] )
 
        {
 
            adventure( 1 , $location[A Maze of Sewer Tunnels] );
 
            return true;
 
        }
 
        else
 
            print( "You should use the He-Boulder for this" );
 
    }
 
    else
 
        print( "Your initiative is too low" );
 
    return false;
 
  }
 
</code>
 
 
 
[[Category:Your Character | elemental_resistance()]]
 
[[Category:Ash Functions | elemental_resistance()]]
 
 
 
When not logged in the function returns 0 (needs spading).
 

Latest revision as of 21:36, 21 May 2010

Function Syntax

float initiative_modifier()

Returns your current percentage initiative modifier in the form of a float.

Code Samples

Checks to see whether your initiative modifier is positive.

boolean positive_initiative() {
   if(initiative_modifier() < 0){
      return false;
   }
   return true;
}

Uses your initiative result to determine whether it will adventure in the sewers (where a +60% initiative guarantees getting the jump). There is also a check for my_familiar().

boolean first_yellow_ray() {
   if(initiative_modifier() >= 60) {
      if(my_familiar() == $familiar[he-boulder]) {
         adventure(1 , $location[A Maze of Sewer Tunnels]);
         return true;
      }
      else {
         print("You should use the He-Boulder for this");
      }
   }
   else {
      print("Your initiative is too low");
   }
   return false;
}

See Also

my_familiar()

Special

When not logged in the function returns 0.0