Run combat: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
Added idea about CLI usage, can be removed if deemed irrelevant.
imported>Taltamir
as of r20210 mafia no longer requires special abort procedure for combat filter function
 
(8 intermediate revisions by 5 users not shown)
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Adventuring|


function1={{Function|
function1={{Function|
Line 14: Line 13:
}}|
}}|


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()]].
function2={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|string|filter}}|
p1desc={{Pspan|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.|
}}|
 


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 "asq 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.|
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 "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|
Line 45: 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.
 
 
Using run_combat() to execute fights will not do the normal post-fight processing that mafia normally performs with [[adv1]] or [[adventure]].
*it will not cause your afterAdventureScript to run
*it will not trigger post-combat restoration
*it will not check if adventuring goals have been met
*it does not obey counter aborts (e.g. fortune cookie)
*it does not update mafia's custom quest progress properties (e.g. palindomeDudesDefeated)
|
}}
}}
[[Category:Adventuring]]

Latest revision as of 04:07, 28 June 2020

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

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.


Using run_combat() to execute fights will not do the normal post-fight processing that mafia normally performs with adv1 or adventure.

  • it will not cause your afterAdventureScript to run
  • it will not trigger post-combat restoration
  • it will not check if adventuring goals have been met
  • it does not obey counter aborts (e.g. fortune cookie)
  • it does not update mafia's custom quest progress properties (e.g. palindomeDudesDefeated)