Bug - Cannot Reproduce Getting to 0 hp while automating adventures causes an abort

Malibu Stacey

Active member
No idea if this is a bug or just user error but my feeling is a bug.

With the following properties set
hpAutoRecovery = -0.05
hpAutoRecoveryTarget = -0.05
mpAutoRecovery = -0.05
mpAutoRecoveryTarget = -0.05
manaBurningTrigger = -0.05
manaBurningThreshold = -0.05
autoAbortThreshold = -0.05
So effectively, everything should be disabled according to the UI.

The following still happens

Code:
[709] Sonofa Beach
Preference lastEncounter changed from The Walking-Stick Rebellion to Zerg Rush
Encounter: Zerg Rush
You lose 107 hit points
Stack trace:

(had to copy that out of the session log as the CLI had scrolled past it by the time I thought to report this as I'd restarted autoscend and the session log doesn't log the "Insufficient health to continue message" that the CLI showed at that point when it aborted).

Basically, ending up on 0 HP during a call to adv1() causes a hard stop to automation such that the afterAdventureScript doesn't run. Which is an issue when you're relying on your afterAdventureScript to do things like heal you after combat.
 

Veracity

Developer
Staff member
Well... the "betweenBattleScript" is the "beforeAdventureScript". That is intended to be called when you are about to run an adventure. It looks at the "nextAdventure" property and does whatever is needed to prepare to go to that location. I suppose that can include recovering HP and MP, if you have built-in recovery disabled, as you do.

If you automating multiple adventures, the sequence is like this:

loop (KoLmafia.executeRequest):
--> do full recovery
----> call betweenBattleScript
----> execute mood
----> recover HP (recovery script & built-in methods)
----> mana burning
----> recover MP (built-in methods)
--> adventure once
--> call afterAdventureScript

As you can see, the betweenBattleScript is not intended to be executed after each adventure. It is intended to be executed before.

Given that, it should be acceptable to enter that loop with 0 HP, since it will heal before adventuring, and it should be acceptable to leave the loop with 0 HP, since it will heal up before it adventures again - possibly at a new location.

Now, the issue is that that loop itself is wrapped in additional processing (KoLmafia.makeRequest). That is called from adventure() and adv1().

As coded, for an adventure request:

if current HP == 0 and the location has combats
--> recover HP (recovery script & built-in methods)
executeRequest (the above loop)
--> do HP only recovery
----> recover HP (recovery script & built-in methods)
----> this is where it aborts if it fails to recover HP.

Some observations:

1) It should not be necessary to recover HP before calling the executeRequest loop, since that does a full recovery - including the betweenBattle check itself.
2) It really shouldn't be necessary to recover HP after the request sequence is done, since we'll heal up next time you try to adventure.
3) Perhaps that is psychological: people will be uncomfortable if they see they are at zero HP after adventuring.
4) Given that, perhaps we should simply "recover HP" rather than doing the "HP only recovery" which includes the HP.

In any case, failing to call the "betweenBattleScript" (aka the "beforeAdventureScript") AFTER you are done with an adventure sequence is not a bug.

Perhaps the solution is to simply "recover HP" (with no abort) after the adventure sequence. This will be a no-op for your script, but will provide the psychological comfort for people adventuring through the GUI.
 

Veracity

Developer
Staff member
I now notice you were talking about the afterAdventureScript.

I am confused, because I believe the afterAdventureScript always runs in that loop I described and the only thing which causes the abort you mentioned is called after that loop. Looking at the code, that is the case: after adventuring in the location, it calls the afterAdventureScript and then tries to do a "HP only recovery", which will abort as you described.

I'll modify it to not abort - but are you sure your afterAdventureScript was not called? Or did it fail to recover HP? Or what?
 

Malibu Stacey

Active member
afterAdventureScript was definitely not called. It aborts right after the adventure is finished handling. I have a print statement as the first line in the main function to check this as I was hoping setting those properties to the values the UI does to disable them would fix this issue (we were previously using -1 for them all).

I can try getting another log from the CLI this time so you can see the "Insufficent health to continue" message but it'll be 2-3 days before I get another Ed run started and to the level 12 quest.
 
Last edited:

Malibu Stacey

Active member
I'd close this, was likely user error caused by not setting autoAbortThreshold to -0.05.
Seems all good now and apologies for wasting your time with yet another wild goose chase Veracity.
 
Top