Bug betweenBattleScript and afterAdventureScript can fail to be run

Malibu Stacey

Active member
running the following:

Code:
print("adventuring using adv1 at " + loc.to_string(), "fuchsia");
retval = adv1(loc, 0, option);

betweenBattleScript contains:

Code:
void main()
{
	print("in auto_pre_adv", "fuchsia");
	handlePreAdventure();
}

afterAdventureScript contains

Code:
void main()
{
	print("in auto_post_adv", "fuchsia");
	handlePostAdventure();
}

results in:

Code:
> adventuring using adv1 at Mist-Shrouded Peak

This area is not available

Seems that because the character is missing the required 5 resistance to adventure in the Mist-Shrouded Peak, betweenBattleScript and afterAdventureScript are never called which causes issues when you're relying on betweenBattleScript to fix issues like needing resistances to adventure in certain locations.

In my opinion, at the very worst betweenBattleScript should be still running even if we fail to adventure subsequently (thus calling afterAdventureScript would be moot since there was no adventure).
 
Last edited:

Veracity

Developer
Staff member
KoLAdventure.validate() attempts to make sure that the destination is valid for you to go to.
Almost all of the checking has to do with areas that only open up after a particular level or a particular quest step has been reached.
A couple of them require conditions which can be met by using items - and that method will try to use them.
Astral Trip? If you are not Half-Astral, use an astral mushroom.
Bat Hole zones? Use enough sonars to get there.
Goblin King? Wear an outfit, perhaps spray on perfume.

And so on.

Literally the only zone which is either legitimately unavailable or we can't/don't make a best effort to equip for is the Mist-Shrouded Peak.

Code:
			this.isValidAdventure = KoLCharacter.getElementalResistanceLevels( Element.COLD ) > 4;
For the 50 or more adventures that you can really be locked out of because of level/equipment/effect requirements you don't meet, running your pre-adventure script before doing the validation is a big waste of time and server hits.

Perhaps we could split validate into two parts:

- Physical availability of the zone based on level and quest progression that you cannot fix without adventuring somewhere first.
- Things that can be fixed by a pre-adventure script: using astral mushrooms, sonars, day passes, equipping outfits or items, buffing resistances, etc.

The first part of validation runs early.
(other checks - adventures left, enough Meat for a shore vacation, acquistion of an antidote if autoAntidote, etc.)
betweenBattle checks (healing, MP recovery, script)
Second part of validation. We can fix keep auto-outfit, use Astral mushroom, etc stuff. If your betweenBattleScript did those, the built in code will not activate.
 

Veracity

Developer
Staff member
I have a commit ready to test that does that. It's a pretty major whackage of the adventure validation code.

validate1 looks at quest progress and needed quest items to eliminate a lot of areas that you can't get to without adventuring somewhere.
We then check adventures available, certain battle strategies, etc.
We do clover protection, if configured.
We then do between battle actions - healing, mp recovery, betweenBattleScript.
validate2 then checks if everything is really set up to adventure in the location. It will wear outfits, put on equipment, use items to get effects, and so on.
(Those are all things that the betweenBattleScript could have done, but, we know how to do some of them ourself.)
It will also check areas that can be permanently or per-day unlocked with a day pass. We do not use day passes, but the betweenBettleScript can, if it wants.
Finally, it submits the request to adventure.

It does clover protection before the betweenBattleScript and second stage of validation because it is, potentially, up to the script to decide if it wants to use a clover.

This was mostly moving code around, but there was a fair bit of clean up as well. I'll test a lot of it tomorrow before releasing it into the wild.
If there are bugs, I expect I'll hear about them over the next month and squash them long before I make a new point release. :)
 

Veracity

Developer
Staff member
I did remove some previous functionality in order to make sure that it doesn't adventure.

We will do things like plant an enchanted bean (if you have one), use sonars (if you have them and need them to get to a zone), use an astral muhroom, visit the mystic to get a continuum transfunctioner, and so on. Those items are all things that a betweenBattleScript could get, were it inclined.

We will NOT offer to adventure to get an enchanted bean.
We will NOT automatically unlock your guild to get the White Citadel quest to go to Whitey's Grive. (Sheesh. That is OLD code. You now need to go there as part of (Hardcore, at least) ascension, guild or not.)
 

Veracity

Developer
Staff member
Huh. Well, I accidentally submitted my code in 19935 - which was the choiceAdventureScript fix.
Time to go test THIS code with a variety of adventure zones. :)
 

Veracity

Developer
Staff member
Seems to be working well with revision 19937. Both validate1 and validate2 can emit custom error messages, if adventuring is invalid. If they choose not to do that, you get a generic "That area is not available."
 

Malibu Stacey

Active member
"That area is not available."

Getting this when trying to do adv1($location[The Batrat and Ratbat Burrow], -1, "");

I have 2 Stench resistance (Ed with 1st upgrade and Hide of Sobek buff). Zone was unlocked by clovering Guano Junction and using the 2 sonar-in-a-biscuit. questL04Bat = step2
I can manually adventure there in the relay browser without any issues.

Code:
> version

KoLmafia v20.3 r19947
 
Last edited:

Veracity

Developer
Staff member
That is all fixed now.

I think that validate1 and validate2 are in good shape.

validate2 contains all the checks that COULD be fixed by your pre-adventure script and runs after your script.

I think that completes the fix for your issue.

Edit: By the way - you only need Stench resistance for Guano Junction. We haven't ever enforced that. That actually seems like a good thing to add to validate2 for Guano Junction - just like we check cold resistance in the Misty and Icy Peaks in validate2.

I think I'll do that.
 

Malibu Stacey

Active member
Excellent, I'll have to wait until next run to test it as my current Ed run is done with both the level 4 and level 8 quests (will be on day 3 after rollover so I may be starting a new test run if it gets the level 11 and 12 quests done).

Thanks again Veracity.
 

Veracity

Developer
Staff member
This is weird.

I changed KoLAdventure.validate2 for the Airship to simply return (true) if QuestL10Garbage is better than "started", since it goes to "step1" if you have planted the beanstalk.
If it's not that far, if you have an enchanted bean, it will plant it.
And then it is supposed to proceed with adventuring in the Airship.

I was in the Beanbat Chamber and got an enchanted bean.
I went to the GUI and told it to adventure for 1 turn in the Penultimate Fantasy Airship.

Code:
...
You acquire an item: enchanted bean
...

Validating adventure sequence...

Visit to Beanstalk: The Penultimate Fantasy Airship in progress...

Inspecting the Giant Pile of Coffee Grounds
You have planted a beanstalk.
And that was it; validate2 planted the beanstalk, but we did do one adventure in the Airship?

I went to the GUI and told it to spend one turn in the airship:

Code:
Validating adventure sequence...

Visit to Beanstalk: The Penultimate Fantasy Airship in progress...

[231] The Penultimate Fantasy Airship
Encounter: The Beginning of the End of the Penultimate Fantasy

Visit to Beanstalk: The Penultimate Fantasy Airship in progress...

[231] The Penultimate Fantasy Airship
Encounter: Spunky Princess
...
Which is what I expected to see the previous time: visit the Airship, get the NC which does not take a turn, and then visit again and spend a turn.

Code:
[color=green]> get questL10Garbage[/color]

step2
That is correct. We are now seeking the immateria.

I don't understand this.
 
Top