Run combat: Difference between revisions
imported>AlbinoRhino No edit summary |
imported>AlbinoRhino No edit summary |
||
Line 54: | Line 54: | ||
see_also={{SeeAlso|adventure|adv1|visit_url}}| | see_also={{SeeAlso|adventure|adv1|visit_url|run_choice|run_turn}}| | ||
special=Will return the text of the last combat encounter when called independently of a fight page. | special=Will return the text of the last combat encounter when called independently of a fight page. |
Revision as of 22:06, 24 May 2017
Function Syntax
buffer run_combat()
buffer run_combat(string filter )
- filter is a macro or the name of a combat filter function defined elsewhere in your script, with the same behavior as in the 3-paramater version of adventure(). An empty string can be passed to use your battle action or CCS as normal. Essentially, this allows the scripter to put a CCS or macro into a script.
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.
Using run_combat() to execute fights will not do the normal post-fight processing that mafia normally performs with adv1 or adventure.
- run_combat() will not cause your afterAdventureScript to run
- run combat() will not trigger post-combat restoration
- run combat() will not check if adventuring goals have been met
- run combat() does not obey counter aborts (e.g. fortune cookie)
- run combat() does not update mafia's custom quest progress properties (e.g. palindomeDudesDefeated)