Bug - Fixed Preadventure checkpoint clear no longer works.

soolar

Member
Usually when you change equipment in a preadventure script, mafia will helpfully (well, it's often helpful) switch it back to what it was before the adventure after the adventure. You used to be able to avoid this if you so desired by calling checkpoint clear within the preadventure script, but that no longer works, meaning if you are running a script that uses a preadventure script to change equipment, you will constantly have your equipment swapped back after every adventure, resulting in a lot of needless server hits.

I'm pretty sure the cause is r19776 of mafia.

It'd be nice if either checkpoint clear could be made to work with the new changes, or some other approach could be provided to prevent swapping equipment back after adventure.
 

Veracity

Developer
Staff member
The preadventure script is the "betweenBattle" script. It is invoked in exactly one method in KoLmafia: RecoveryManager.runBetweenBattleChecks.

Code:
		if ( isScriptCheck )
		{
			KoLmafia.executeScript( Preferences.getString( "betweenBattleScript" ) );
		}

		// Now, run the built-in behavior to take care of
		// any loose ends.

		Checkpoint checkpoint = new Checkpoint();
		try
		{
			if ( isMoodCheck )
			{
				MoodManager.execute();
			}

			if ( isHealthCheck )
			{
				RecoveryManager.recoverHP();
			}

			if ( isMoodCheck )
			{
				ManaBurnManager.burnExtraMana( false );
			}

			if ( isManaCheck )
			{
				RecoveryManager.recoverMP();
			}
		}
		finally
		{
			checkpoint.restore();
		}
The betweenBattleScript is not run within an outfit chackpoint.
Subsequent checks - HP & MP restoration, moods, mana burning - are.
Which is to say, I see nothing in the code to confirm you bug.
So, I decided to test it.

I created a betweenBattle script and named it "bb.ash".
I set my Pre-Adventure script to bb.ash
I set "run between battle checks in the relay browser"
I manually adventured in the relay browser.

Script:

Code:
print( "starting betweenBattle script" );
item hat = equipped_item( $slot[ hat ] );
print( "current hat = " + hat );
equip( $slot[ hat ], $item[ none ] );
hat = equipped_item( $slot[ hat ] );
print( "new hat = " + hat );
print( "done with  betweenBattle script" );
gCLI output:

Code:
starting betweenBattle script
current hat = ratty knitted cap
Taking off ratty knitted cap...
Equipment changed.
new hat = none
done with betweenBattle script

[155] The Haunted Bedroom
Encounter: animated rustic nightstand
...
[color=green]> ash equipped_item( $slot[ hat ] ).to_string()[/color]

Returned: none
I was unable to reproduce your described behavior. What, exactly, are you doing that shows equipment being set in a betweenBattleScript and being restored before the actual adventure is run?
 

Veracity

Developer
Staff member
OK, I can reproduce it via automated adventuring.

Code:
Validating adventure sequence...

starting betweenBattle script
current hat = fuzzy busby
Taking off fuzzy busby...
Equipment changed.
new hat = none
done with betweenBattle script

Visit to Beanstalk: The Castle in the Clouds in the Sky (Ground Floor) in progress...

[294] The Castle in the Clouds in the Sky (Ground Floor)
Encounter: Possibility Giant
Round 0: Veracity wins initiative!
Round 1: Veracity executes a macro!
Round 1: Veracity casts SPIN JUMP!
Round 2: Hobo Grrl climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 84 Meat.
Round 2: Veracity casts MULTI-BOUNCE!
Round 3: Possibility Giant takes 57 damage.
Round 3: Possibility Giant takes 57 damage.
Round 3: Possibility Giant takes 57 damage.
Round 3: Possibility Giant takes 57 damage.
Round 3: Possibility Giant takes 57 damage.
You acquire an item: coin (4)
Round 3: Veracity wins the fight!
You acquire an item: coin (7)
After Battle: You gain 5 hit points
After Battle: Hobo Grrl sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 416 Meat
After Battle: Private Peridot suddenly appears next to you and drops some meat in your sack.
You gain 10 Meat.
You acquire an item: chaos butterfly
After Battle: You gain 2 Strengthliness
After Battle: You gain 7 Enchantedness
You gain a Mysticality point!

Putting on fuzzy busby...
Equipment changed.
 

Veracity

Developer
Staff member
Revision 19810 restores use of "checkpoint clear" to no longer rrstore any active checkpoints.
 

zarqon

Well-known member
Thank you! This also fixed an issue with familiar equipment that I was experiencing with BBB, without my even having to dig into it!
 

zarqon

Well-known member
Yep, my main usually VeracityMeatFarms in aftercore with MM and BBB on to maintain buffs and swap familiars for drops (less profitable but more satisfying, somehow). Until this revision I was getting 3 or 4 aborts a day about familiars being unable to equip the previous familiar's equipment. Didn't have time to fix it so just restarted the script each time and it eventually got to the end. Today I'm 300 turns in and no aborts, so it seems fixed to me!
 

Crowther

Active member
My aborts were more like 3 or 4 a week and I never could figure out what conditions caused it beyond familiar drop swapping and it was mostly an aftercore problem on my ascender. I'm still very happy it is gone. Thanks.
 
Top