Difference between revisions of "Numeric modifier"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
imported>Fredg1
m
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
numeric_modifier accesses fields of your current modifiers, which are the sum of the individual modifier values (from modifiers.txt) for all of your current equipment.  This is the same mechanism that lets mafia calculate a total item drop bonus, given that you have perhaps a weapon, an accessory, and a familiar that each have an item drop bonus.
+
{{
 +
#vardefine:name|numeric_modifier}}{{
 +
#vardefine:return_type|float}}{{
  
Here is the current list of fields you can inquire about (but note that many of these have specific ASH functions for retrieving them, which would generally be better to use):
+
FunctionPage|
 +
name={{#var:name}}|
  
"Familiar Weight", "Monster Level", "Combat Rate", "Initiative", "Experience", "Item Drop", "Meat Drop", "Damage Absorption", "Damage Reduction", "Cold Resistance", "Hot Resistance", "Sleaze Resistance", "Spooky Resistance", "Stench Resistance", "Mana Cost", "Moxie", "Moxie Percent", "Muscle", "Muscle Percent", "Mysticality", "Mysticality Percent", "Maximum HP", "Maximum HP Percent", "Maximum MP", "Maximum MP Percent", "Melee Damage", "Ranged Damage", "Spell Damage", "Spell Damage Percent", "Cold Damage", "Hot Damage", "Sleaze Damage", "Spooky Damage", "Stench Damage", "Cold Spell Damage", "Hot Spell Damage", "Sleaze Spell Damage", "Spooky Spell Damage", "Stench Spell Damage", "Critical", "Fumble", "HP Regen Min", "HP Regen Max", "MP Regen Min", "MP Regen Max", "Adventures", "Familiar Weight Percent", "Melee Damage Percent", "Ranged Damage Percent", "Stackable Mana Cost", "Hobo Power", "Base Resting HP", "Resting HP Percent", "Bonus Resting HP", "Base Resting MP", "Resting MP Percent", "Bonus Resting MP"
+
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|string|modifier_name}}|
 +
}}|
  
There is also a 2-parameter version of numeric_modifier, that lets you inquire about a modifier value from a specific item/effect/outfit/etc., whether or not you have it equipped at the moment.  For example, numeric_modifier($item[Hobo fortress blueprints], "Base Resting MP") would return 85.
+
function2={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|string|check_me}}|
 +
parameter2={{Param|string|modifier_name}}|
 +
}}|
  
New modifiers needed for undersea use: "Meat Drop Penalty" and "Familiar Weight (hidden)".
+
function3={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|item|check_me}}|
 +
parameter2={{Param|string|modifier_name}}|
 +
}}|
 +
 
 +
function4={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|effect|check_me}}|
 +
parameter2={{Param|string|modifier_name}}|
 +
}}|
 +
 
 +
function5={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|skill|check_me}}|
 +
parameter2={{Param|string|modifier_name}}|
 +
p1desc={{Pspan|check_me}} is the string, item, effect or skill to check|
 +
p2desc={{Pspan|modifier_name}} is the <b>[[modifiers|modifier]]</b> to check|
 +
}}|
 +
 
 +
function_description=Returns your current modifier total for {{pspan|modifier_name}}, or the amount of modification from {{pspan|check_me}} if specified.</p>
 +
===Special Syntax for Familiars===
 +
{{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|familiar|buddy}}|
 +
parameter2={{Param|string|check_me}}|
 +
parameter3={{Param|int|weight}}|
 +
parameter4={{Param|item|equipment}}|
 +
p1desc={{Pspan|buddy}} is the familiar to check|
 +
p2desc={{Pspan|check_me}} is the modifier to check|
 +
p3desc={{Pspan|weight}} is the familiar's weight (buffed, not including equipment)|
 +
p4desc={{Pspan|equipment}} is the familiar's equipment|
 +
}}
 +
<p>Returns the familiar's effect on this modifier (for instance, a baby gravy fairy would return some positive float for "Item Drop").|
 +
 
 +
code1={{CodeSample|
 +
title=Code Sample|
 +
description=Prints your current Initiative:|
 +
code=
 +
<syntaxhighlight>
 +
float init = numeric_modifier( "initiative" );
 +
print(init);
 +
</syntaxhighlight>}}
 +
{{CodeSample|
 +
description=Function that checks if a single effect from a given list will buff your muscle over an amount goal. The name of the first effect to satisfy the goal is printed, or you are warned if none is found.|
 +
code=
 +
<syntaxhighlight>
 +
boolean buffMuscleTo( int goal ) {
 +
  int current_muscle = my_buffedstat( $stat[Muscle] ) ;
 +
  int base_muscle = my_basestat( $stat[Muscle] ) ;
 +
  int muscle_increase ;
 +
  if ( current_muscle >= goal ) return true ;
 +
 
 +
  foreach it in $effects[Tomato Power, Phorcefullness, Gr8tness, Incredibly Hulking] {
 +
      if ( have_effect(it) > 0 ) continue ;
 +
      muscle_increase = floor( base_muscle * numeric_modifier( it, "Muscle Percent" ) / 100 );
 +
      if ( current_muscle + muscle_increase >= goal ) {
 +
        print(it + " will bring your muscle over " + goal);
 +
        return true;
 +
      }
 +
  }
 +
  print("No effect found");
 +
  return false;
 +
}
 +
</syntaxhighlight>}}|
 +
 
 +
code2={{CodeSample|
 +
title=Potion/effect-giving items|
 +
description=To get a modifier from a consumable which gives an effect, it is first necessary to convert the item into its given effect with [[effect_modifier]]. <br> This snippet calculates what your meat drop bonus would be after eating a {{kolwiki|sweet roll alabama}}:|
 +
code=<syntaxhighlight>
 +
float meat_boost = numeric_modifier( "meat drop" );
 +
effect effect_from_item = effect_modifier( $item[Sweet roll Alabama] , "effect" );
 +
 
 +
meat_boost += numeric_modifier( effect_from_item , "meat drop" );
 +
</syntaxhighlight>}}|
 +
 
 +
cli_equiv=The CLI command "modtrace" gives access to the same information when the correct parameters are specified.|
 +
 
 +
 
 +
more_info= For a full list of modifiers, see [[modifiers]].<br>
 +
For more information about numeric_modifier(), see the following thread: [http://kolmafia.us/showthread.php?802  List].|
 +
}}
 +
 
 +
{{SeeAlso|boolean_modifier|effect_modifier|string_modifier}}
 +
 
 +
[[Category:Modifier Functions]]

Latest revision as of 21:19, 1 July 2020

Function Syntax

float numeric_modifier(string modifier_name )

float numeric_modifier(string check_me ,string modifier_name )

float numeric_modifier(item check_me ,string modifier_name )

float numeric_modifier(effect check_me ,string modifier_name )

float numeric_modifier(skill check_me ,string modifier_name )

  • check_me is the string, item, effect or skill to check
  • modifier_name is the modifier to check

Returns your current modifier total for modifier_name, or the amount of modification from check_me if specified.

Special Syntax for Familiars

float numeric_modifier(familiar buddy ,string check_me ,int weight ,item equipment )

  • buddy is the familiar to check
  • check_me is the modifier to check
  • weight is the familiar's weight (buffed, not including equipment)
  • equipment is the familiar's equipment

Returns the familiar's effect on this modifier (for instance, a baby gravy fairy would return some positive float for "Item Drop").

Code Sample

Prints your current Initiative:

float init = numeric_modifier( "initiative" );
print(init);

Function that checks if a single effect from a given list will buff your muscle over an amount goal. The name of the first effect to satisfy the goal is printed, or you are warned if none is found.

boolean buffMuscleTo( int goal ) {
   int current_muscle = my_buffedstat( $stat[Muscle] ) ;
   int base_muscle = my_basestat( $stat[Muscle] ) ;
   int muscle_increase ;
   if ( current_muscle >= goal ) return true ;
   
   foreach it in $effects[Tomato Power, Phorcefullness, Gr8tness, Incredibly Hulking] {
      if ( have_effect(it) > 0 ) continue ;
      muscle_increase = floor( base_muscle * numeric_modifier( it, "Muscle Percent" ) / 100 );
      if ( current_muscle + muscle_increase >= goal ) {
         print(it + " will bring your muscle over " + goal);
         return true;
      }
   }
   print("No effect found");
   return false;
}

Potion/effect-giving items

To get a modifier from a consumable which gives an effect, it is first necessary to convert the item into its given effect with effect_modifier.
This snippet calculates what your meat drop bonus would be after eating a sweet roll alabama:

float meat_boost = numeric_modifier( "meat drop" );
effect effect_from_item = effect_modifier( $item[Sweet roll Alabama] , "effect" );

meat_boost += numeric_modifier( effect_from_item , "meat drop" );

CLI Equivalent

The CLI command "modtrace" gives access to the same information when the correct parameters are specified.

More Information

For a full list of modifiers, see modifiers.
For more information about numeric_modifier(), see the following thread: List.


See Also

boolean_modifier() | effect_modifier() | string_modifier()