Numeric modifier: Difference between revisions
imported>Eliteofdelete typo |
imported>Fredg1 add the use of effect_modifier() to get potions' effect modifiers |
||
Line 99: | Line 99: | ||
return false; | 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>}}| | </syntaxhighlight>}}| | ||
Line 106: | Line 116: | ||
more_info= For a full list of numeric modifiers, see the following thread: [http://kolmafia.us/showthread.php?802 List].| | more_info= For a full list of numeric modifiers, see the following thread: [http://kolmafia.us/showthread.php?802 List].| | ||
}} | }} | ||
{{SeeAlso|effect_modifier}} | |||
[[Category:Modifier Functions]] | [[Category:Modifier Functions]] |
Revision as of 20:47, 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 numeric modifiers, see the following thread: List.