Adventure: Difference between revisions
imported>StDoodle mNo edit summary |
imported>Bale interesting example |
||
Line 44: | Line 44: | ||
code2={{CodeSample| | code2={{CodeSample| | ||
title=Example of a Combat Filter| | |||
description=This uses the combat filter to automatically olfact Goth Giants while adventuring.| | description=This uses the combat filter to automatically olfact Goth Giants while adventuring.| | ||
code= | code= | ||
Line 61: | Line 62: | ||
}}| | }}| | ||
code3={{CodeSample| | |||
description=Uses a combat filter to ensure that all sewer monsters are being cleeshed while you try to make your way to Hobopolis.| | |||
code= | |||
<syntaxhighlight> | |||
string combat_cleesh(int round, string opp, string text) { | |||
if (opp == $monster[frog].to_string() || opp == $monster[newt].to_string() | |||
|| opp == $monster[salamander].to_string()) { | |||
return "attack"; | |||
} | |||
return "skill CLEESH"; | |||
} | |||
adventure(1, $location[a maze of sewer tunnels], "combat_cleesh"); | |||
</syntaxhighlight> | |||
}}| | |||
code4={{CodeSample| | |||
description=This makes use of the combat filter to ensure that salve is being used.| | description=This makes use of the combat filter to ensure that salve is being used.| | ||
code= | code= |
Revision as of 23:27, 15 March 2010
Function Syntax
boolean adventure(int adventures ,location place )
boolean adventure(int adventures ,location place ,string filter )
- int is the number of adventures to spend.
- place is the adventuring location.
- filter is the combat action filter. This is the name of a function which modifies the current CCS. The combat filter takes the parameters of a consult script, but returns lines like a CCS, not like a consult script. Essentially this allows the scripter to put a CCS into a script.
This function runs the specified number of adventures at the given place, keeping up your current mood & obeying restore settings.
If filter is omitted or assigned an empty string, this function will use your current CCS / battle action.
This function does not have to make use of its return value, but if you wish to do so, it will return true if all adventures were used, and false if it is unable to do so for any reason (not enough adventures, location unavailable, etc.).
Note that adventures is the number of adventures to spend, and any "free" turns will not count towards this total.
Note also that adventure() checks against goals set via add_item_condition() or via other methods of specifying goals in KoLmafia.
Code Sample
Adventure 5 times at the Giant's Castle:
adventure(5 , $location[giant's castle]);
Example of a Combat Filter
This uses the combat filter to automatically olfact Goth Giants while adventuring.
string olfact_goth(int round, string opp, string text) {
if(opp != "Goth Giant")
return get_ccs_action(round);
if(round == 1 && have_effect($effect[On the Trail]) < 1)
return "skill transcendent olfaction"
else
return get_ccs_action(round - 1);
}
adventure(5 , $location[giant castle], "olfact_goth");
Uses a combat filter to ensure that all sewer monsters are being cleeshed while you try to make your way to Hobopolis.
string combat_cleesh(int round, string opp, string text) {
if (opp == $monster[frog].to_string() || opp == $monster[newt].to_string()
|| opp == $monster[salamander].to_string()) {
return "attack";
}
return "skill CLEESH";
}
adventure(1, $location[a maze of sewer tunnels], "combat_cleesh");
This makes use of the combat filter to ensure that salve is being used.
// Adds salve to beginning of combat if it doesn't already exist in the CCS.
// Otherwise it simply returns the current CCS.
string insert_salve(int round, string opp, string text) {
boolean salve = false;
for i from 1 to 30
if(get_ccs_action(round) == "skill saucy salve")
salve = true;
if(salve)
return get_ccs_action(round);
else {
if(round == 1)
return "skill saucy salve";
if(round > 1)
round = round - 1; // compensate for insertion
return get_ccs_action(round); // for the rest of the combat, executes your existing ccs
}
}
adventure(5 , $location[giant castle], "insert_salve");
CLI Equivalent
The CLI command "adv" works similarly.
See Also
Special
This function will return false if KoLmafia conditions are met before completing the specified number of turns.