Run combat: Difference between revisions
imported>Bale mNo edit summary |
imported>Fluxxdog m asq should be ashq |
||
Line 15: | Line 15: | ||
function_description=Proceeds to run a combat using your current KoLmafia settings. This function returns the HTML from the final round of combat (not just what is displayed, but all markup). Most commonly used to finish up combats started via [[visit_url|visit_url()]].</p><p> | function_description=Proceeds to run a combat using your current KoLmafia settings. This function returns the HTML from the final round of combat (not just what is displayed, but all markup). Most commonly used to finish up combats started via [[visit_url|visit_url()]].</p><p> | ||
Another handy use for this function is to finish up combats that were started in the relay browser, or were interrupted (causing mafia to pop up the minibrowser). Typing " | Another handy use for this function is to finish up combats that were started in the relay browser, or were interrupted (causing mafia to pop up the minibrowser). Typing "ashq run_combat()" into the CLI will finish up the combat for you using your current CCS/battle action. Note that "ashq" is necessary rather than "ash" to avoid spewing the entire combat results page into the CLI.| | ||
code1={{CodeSample| | code1={{CodeSample| |
Revision as of 15:42, 16 December 2010
Function Syntax
buffer run_combat()
Proceeds to run a combat using your current KoLmafia settings. This function returns the HTML from the final round of combat (not just what is displayed, but all markup). Most commonly used to finish up combats started via visit_url().
Another handy use for this function is to finish up combats that were started in the relay browser, or were interrupted (causing mafia to pop up the minibrowser). Typing "ashq run_combat()" into the CLI will finish up the combat for you using your current CCS/battle action. Note that "ashq" is necessary rather than "ash" to avoid spewing the entire combat results page into the CLI.
Code Sample
This is a personalized version of adv1() that is capable of returning information about which adventure is encountered so that you can look for a specific choice adventure. If a combat is encountered instead of a choice adventure, run_combat() is used.
int run_adv(location place) {
string page_text = to_url(place).visit_url();
string choiceAdventure = "-1";
matcher m_choice = create_matcher("whichchoice value=(\\d+)", page_text);
while(page_text.contains_text("choice.php")) {
m_choice.reset(page_text);
m_choice.find();
choiceAdventure = m_choice.group(1);
string choice_num = get_property("choiceAdventure"+ choiceAdventure);
if(choice_num == "0") abort("Manual Control for "+ choiceAdventure);
if(choice_num == "") abort("Unsupported Choice Adventure!");
page_text = visit_url("choice.php?pwd&whichchoice="+ choiceAdventure +"&option="+ choice_num);
}
if(page_text.contains_text("Combat"))
run_combat();
return choiceAdventure.to_int();
}
See Also
Special
Will return the text of the last combat encounter when called independently of a fight page.