Use familiar: Difference between revisions
Jump to navigation
Jump to search
imported>Slyz return value is boolean, not familiar |
imported>Eliteofdelete No edit summary |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
FunctionPage| | FunctionPage| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
function1={{Function| | function1={{Function| | ||
Line 17: | Line 16: | ||
function_description=Switches your current familiar for the the familiar {{pspan|buddy}} specified. Returns true if the specified familiar {{pspan|buddy}} is your current familiar after the function's completion (so it will return true if you try to switch to your current familiar).| | function_description=Switches your current familiar for the the familiar {{pspan|buddy}} specified. Returns true if the specified familiar {{pspan|buddy}} is your current familiar after the function's completion (so it will return true if you try to switch to your current familiar).| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Following example is a function that will look through all possible familiars based on the numeric modifier given and return the best one to use. If you have it, it will use it. | | |||
code= | |||
<syntaxhighlight> | |||
familiar my_bestfam (string check) { | |||
familiar current = $familiar[none]; | |||
float best = 0.0; | |||
foreach it in $familiars[] { //checks based on your familiars current weight and equipment | |||
float drop = numeric_modifier(it, check, familiar_weight(it), familiar_equipped_equipment(it)); | |||
if (drop > best) { | |||
best = drop; | |||
current = it; | |||
print(""+it+" has "+check+" rate of "+drop+".", "blue"); | |||
} | |||
} | |||
print("Best found familiar for "+check+" was "+current, "green"); | |||
return current; | |||
} | |||
familiar best_fam; | |||
best_fam = my_bestfam("meat drop"); //Some common possibilities for my_bestfam: meat drop, item drop, monster level, initiative, experience | |||
if (have_familiar(best_fam)) { | |||
print("Equipping "+best_fam+".", "green"); | |||
use_familiar(best_fam); | |||
} | |||
else print("You currently do not have "+best_fam+".", "red"); | |||
</syntaxhighlight>| | |||
moreinfo= For a full list of numeric modifiers, see the following thread: [http://kolmafia.us/showthread.php?802 List].| | |||
}}| | |||
see_also={{SeeAlso|have_familiar}}| | see_also={{SeeAlso|have_familiar}}| | ||
cli_equiv=The CLI command "familiar" has the same function when a familiar type is specified as the only parameter.| | cli_equiv=The CLI command "familiar" has the same function when a familiar type is specified as the only parameter.| | ||
}} | }} | ||
[[Category:Equipment]] |
Latest revision as of 23:04, 21 January 2015
Function Syntax
boolean use_familiar(familiar buddy )
- buddy is the familiar to equip
Switches your current familiar for the the familiar buddy specified. Returns true if the specified familiar buddy is your current familiar after the function's completion (so it will return true if you try to switch to your current familiar).
Code Samples
Following example is a function that will look through all possible familiars based on the numeric modifier given and return the best one to use. If you have it, it will use it.
familiar my_bestfam (string check) {
familiar current = $familiar[none];
float best = 0.0;
foreach it in $familiars[] { //checks based on your familiars current weight and equipment
float drop = numeric_modifier(it, check, familiar_weight(it), familiar_equipped_equipment(it));
if (drop > best) {
best = drop;
current = it;
print(""+it+" has "+check+" rate of "+drop+".", "blue");
}
}
print("Best found familiar for "+check+" was "+current, "green");
return current;
}
familiar best_fam;
best_fam = my_bestfam("meat drop"); //Some common possibilities for my_bestfam: meat drop, item drop, monster level, initiative, experience
if (have_familiar(best_fam)) {
print("Equipping "+best_fam+".", "green");
use_familiar(best_fam);
}
else print("You currently do not have "+best_fam+".", "red");
For a full list of numeric modifiers, see the following thread: List.
CLI Equivalent
The CLI command "familiar" has the same function when a familiar type is specified as the only parameter.