Feature Track combat loss when adventuring

Baden

Member
As a scripter, I want to know when a user loses a combat that my script started since it is a failure state. This information can be parsed from the result of run_combat() but is not available from adv1(), which is what I and many other scripters use to automate adventuring. Losing a combat can be somewhat tracked using the number of turns of Beaten Up but this is unreliable since Beaten Up has several sources and automatic removal methods. Therefore, I would like to kindly request that some form of combat loss tracking be added to mafia, perhaps as a preference such as _lastCombatLost.
 
This would be very very nice for me.

Also it seems that even tracking via beaten up can be difficult if you also run a recoveryScript like Universal Recovery, because it will remove the beaten up before your script checks it.
 

fronobulax

Developer
Staff member
Gausie's Excavator functionality https://kolmafia.us/threads/excavator-gausies-spading-script.25076/ allows for some event driven actions.

I have local changes that log when I get beaten up or lose a fight. The trigger is the end of a combat round.

1110 20220927 cafebabe 497 Irritating Series of Random Encounters true false
1111 20220927 cafebabe 518 Alphabet Giant true false
1112 20220927 cafebabe 526 Neckbeard Giant true false

It reports to a local data file and I originally did it because I was concerned with SimpleSmack's failure to win fights that I could "one-shot" manually.

Entry number, date, character, turn count, monster, true if response contained "You lose", true if character is beaten up.

If that is of interest or scratches this itch we can negotiate with @gausie to get my changes 'published".
 

Ryo_Sangnoir

Developer
Staff member
I think the pref is reasonable, it can go in FightRequest.updateFinalRoundData.

We will need a debug log of the HTML for losing a fight for tests, though.

And also to decide whether _lastCombatLost is a boolean (was the last combat lost or won?) or an int (which turn was a combat last lost on?)
 
Last edited:

AlbinoRhino

Active member
Maybe I'm wrong, but I think run_combat() contains the last combat text even when called independent of fight.php. ??
 

Baden

Member
I think the pref is reasonable, it can go in FightRequest.updateFinalRoundData.

We will need a debug log of the HTML for losing a fight for tests, though.

And also to decide whether _lastCombatLost is a boolean (was the last combat lost or won?) or an int (which turn was a combat last lost on?)
 

Attachments

  • message.txt
    23.2 KB · Views: 6

Ryo_Sangnoir

Developer
Staff member
Implemented in r26803 as "_lastCombatWon", a boolean telling you whether you won your last combat.

If you ran away, this counts as not winning.

We check wins instead of losses because we can easily see whether we won by checking if "WINWINWIN" was in the HTML. If you want to distinguish fleeing and losing, petition CDM to add "RANRANRAN" or "LOSTLOSTLOST".
 

Baden

Member
Unfortunately that doesn't solve my use case but I'm glad more information is accessible, thank you!
 

Baden

Member
Implemented in r26803 as "_lastCombatWon", a boolean telling you whether you won your last combat.

If you ran away, this counts as not winning.

We check wins instead of losses because we can easily see whether we won by checking if "WINWINWIN" was in the HTML. If you want to distinguish fleeing and losing, petition CDM to add "RANRANRAN" or "LOSTLOSTLOST".
LOSELOSELOSE was just recently added :)
Screen_Shot_2022-12-12_at_3.13.35_PM.png
 
Top