Feature - Implemented choiceAdventureScript

zarqon

Well-known member
I've wished for quite some time for a choiceAdventureScript option. We have hooks for almost everything when adventuring -- moods, before and after adventures, during adventures (combat), but not during adventures (noncombat). Aside from setting properties in advance (such as Mercenary Mood does), we can't automate choiceAdventures while auto-adventuring, of which there are more and more special cases:

  • Insult Pong (insult selection logic)
  • Unlocking the Hidden City (first, you need to make different choices on the same number; then there's dvorak)
  • Wumpus hunting
  • Hyboria quest
  • ...

Presently, if you wish to script these choices, you have to abandon adventure() and attempt to duplicate mafia's svelte automation in ASH -- which is possible but definitely nontrivial.

Now that mafia has been improving its handling (particularly in ASH) of choices, I'd like to be able to specify a choiceAdventureScript so that we can script noncombat adventures just as we can currently use consult scripts for combat adventures. I'd imagine something like this:

Code:
void main(int whichchoice, string page) {
   // code to handle the choice, using available_choice_options(), run_choice(), etc.
}

The first variable is not necessary there (we could look at last_choice()) but it will almost certainly be needed. If the script exits and you're still in a choice, mafia resumes its regular automation -- so the script can simply handle special cases by switching on whichchoice and leave the rest alone. This would make a lot more automation possible without having to attempt to duplicate KoLmafia's well-developed automation framework.

Thanks!
 
Presently, if you wish to script these choices, you have to abandon adventure() and attempt to duplicate mafia's svelte automation in ASH -- which is possible but definitely nontrivial.

This is how autoscend/cc_ascend has handled these things in the past and it is horrible. I wholeheartedly second this request.
 
This script:

Code:
void main( int choice, string page )
{
    // code to handle the choice, using available_choice_options(), run_choice(), etc.
    print( "In choice adventure " + choice );
    if ( choice != 786 ) {
	print( "not handling" );
	return;
    }

    // Options:
    // 1 => get boring binder clip or random items
    // 2 => Get random item
    // 3 => Fight pygmy witch accountant
    // 6 => Skip adventure

    run_choice( 3 );
    print( "Done!" );
}
when set as a choiceAdventureScript, after automating 5 adventures in the Hidden Office Building:

Code:
Request 5 of 5 (HiddenCity: The Hidden Office Building) in progress...

[847613] The Hidden Office Building
Encounter: Working Holiday
In choice adventure 786
Submitting option 3 for choice 786
Encounter: pygmy witch accountant
Round 0: Tebryn wins initiative!
Round 1: Tebryn executes a macro!
Round 1: Tebryn attacks!
Round 2: pygmy witch accountant takes 6463 damage.
Round 2: Tebryn wins the fight!
After Battle: Stubert sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 524 Meat
After Battle: Wingwang whirls around picking up items, like a little couscous tornado.
You acquire an item: adder
After Battle: You notice some extra Meat hidden next to a red stapler.
You gain 17 Meat.
After Battle: You gain 15 Strengthliness
After Battle: You gain 21 Magicalness
After Battle: You gain 9 Cheek
Done!
Note that run_choice() automates the fight, since I did not use the version that said "don't automate fights".

Revision 19899.
 
Get revision 19900. That should handle chained choices the way it used to - with the choiceAdventureScript being invoked each time through.
 
Issues with scripting Ed Fights and the Underworld

Getting some issues with this in Actually Ed when UNDYING.

Code:
In choice adventure 1023
Submitting option 1 for choice 1023
Unhandled redirect to place.php?whichplace=edunder
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
Countdown: 1 second...
Waiting completed.
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
No choice adventure in response text.
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.

My choiceAdventureScript looks like this:

Code:
void main(int choice, string page)
{
	print( "In choice adventure " + choice );
	switch (choice) {
		case 1023: // Actually Ed - Like a Bat Into Hell
			run_choice(1);
			if (get_property("_edDefeats").to_int() <= get_property("edDefeatAbort").to_int()) {
				// edDefeatAbort defaults to 2 so we should stop when _edDefeats = 3 (or greater)
				set_property("choiceAdventure1024", "1");
				auto_log_info("Ed died in combat " + get_property("_edDefeats").to_int() + " time(s)", "blue");
				ed_shopping(); // "free" trip to the Underworld, may as well go shopping!
				visit_url("place.php?whichplace=edunder&action=edunder_leave");
			} else {
				set_property("auto_disableAdventureHandling", false);
				abort("Manually forcing edDefeatAborts. We can't handle the battle.");
			}
		break;
		default:
			auto_log_info("In choice adventure " + choice.to_string() + " and not handling it.");
			abort();
		break;
	}
}

That visit_url call goes to -> https://kol.coldfront.net/thekolwiki/index.php/Like_a_Bat_out_of_Hell

Any assistance would be greatly appreciated.


EDIT: so I got it working by adding a run_choice(1) after the visit_url but I still think this isn't being handled properly as that choice adventure has the preference set. It also doesn't work if I add a case for 1024 in that switch statement.

Also this happens occasionally

Code:
Round 1: Player Two uses the holy spring water!
Round 2: You gain 25 Mana Points
You acquire an effect: Spiritually Awake (10)
Round 2: You lose 36 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2

Preference lastEncounter changed from filthy hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 21 hit points
[WARNING] - Unrecognized unhandled choice after combat 1023
You are currently in a choice.
Pretty sure choice 1023 should be handled by both mafia and the code I pasted above. The line that says "You are currently in a choice." is because it tried to invoke the afterAdventureScript because it thought it was done with combat for some reason.

and now

Code:
[82] Hippy Camp
Preference lastEncounter changed from filthy hippy jewelry maker to dirty hippy Vegan chef
Encounter: dirty hippy Vegan chef
Preference _lastCombatStarted changed from 20200329074518 to 20200329074532
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 48 hit points
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1
Preference lastEncounter changed from dirty hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 24 hit points
In choice adventure 1023
Submitting option 1 for choice 1023
Unhandled redirect to place.php?whichplace=edunder
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to dirty hippy Vegan chef
Encounter: dirty hippy Vegan chef
Preference _lastCombatStarted changed from 20200329074532 to 20200329074538
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 48 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2
Unsupported choice adventure #1024
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
 
Last edited:
Having thought about this some more overnight, the first part in my reply above (the section including and prior to the EDIT line) I completely understand as being expected behaviour. We have adventured as Ed somewhere, died and hit a choiceAdventure post-combat which is (mostly, see the rest of the post) being handled. Anything after that point such as the visit_url call to leave the Underworld is on me as a the script author as it's not adventuring (there's no call to adventure() or adv1()), it's explicitly subverting the normal adventure handling in mafia.

Hence I would ignore that unless it's pertinent to the other two issues after the EDIT.
 
Been a long time since I did Ed. I'm wondering about this:

Code:
Unhandled redirect to place.php?whichplace=edunder
That is almost certainly just informing us that KoLmafia itself did not process that location.
I can fix that.

So let's consider the sequencing:

Ed is defeated in a fight.
Redirected to "Like a Bat Into Hell" (choice 1023)
Option 1 sends you to The Underworld (place.php?whichplace=edunder)
Option 2 (?) sends you back to the fight, healed but un-upgraded.
In the Underworld:
You can shop for supplies (shop.php?whichshop=edunder_shopshop)
You can upgrade your body (Underworld Body Shop - choice 1052)
You can Enter the Astral Portal back to the fight (place.php?whichplace=edunder&action=edunder_leave)
Redirects to "Like a Bat Out of Hell" (choice 1024)
option 1 = Go back to the Fight
option 2 = Go to Your Tomb (costs an adventure. The in-progress adventure did not cost a tuern - yet. I assume this is the equivalent of losing the fight?)
option 3 (?) - go back to The Underworld

In your initial report, when you did this:

visit_url( "place.php?whichplace=edunder&action=edunder_leave" )
It followed the redirect - leaving you in a choice - but we logged:

Code:
No choice adventure in response text.
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.
So we saw we were in choice.php but were unable to extract the choice #.
We did find the choice options.

That was choice #1024, but we didn't know it was 1024.

I think that is the core issue.

Could you get me a DEBUG log for when you go through the portal and arrive in Like a Bat Out of Hell?
I'll need to look at that page to diagnose and fix the issue.

Thanks.
 
Thanks Veracity. Will do. It'll have to be after the next rollover though as my test account is all done and overdrunk for the day.
 
As requested.
View attachment DEBUG_20200331.txt
this is running on r19934 if that makes a difference.

Thanks.

Another issue I'm noticing with Ed (or possibly all related to the same issue). Dying in combat more than once (which is still free to resurrect the second time, it only costs Ka from the third time onwards) causes mafia to think we're on a new adventure when we encounter Like a Bat Into Hell. The flow is:

Start combat as normal anywhere.
Lose combat, encounter Like a Bat Into Hell - handled by choiceAdventureScript.
Go back through the portal to the combat again via Like a Bat out of Hell (visit_url and run_choice).
Lose combat a second time, encounter Like a Bat Into Hell again - not handled by anything. As far as mafia is concerned the previous adventure is all done.
 
Last edited:
Thanks.

Code:
[color=green]> test load edunder.html[/color]

Read 9,909 bytes into a 9,909 character string

[color=green]> test visit-choice[/color]

choice = 1024
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
I'm going to have to think abut this more.
That is exactly as expected.
 
I think this is happening:

adv1 -> initiates adventure
redirect to fight.php
(fight is automated)
(Ed dies)
redirected to choice.php (forceoption=0)
(we follow that and get the choice page)
-> choiceAdventureScript (choice = 1023)
script does run_choice( 1 )
redirects to place.php?place=edunder
script goes shopping
script enters Portal
redirected to choice.php (forceoption=0)
(we follow that and get the choice page)

At this point, the script should return. It has finished the processing for choice 1023
We happen to be in a new choice - 1024 - but automation should continue.

So, this is a case that I anticipated - a choice finishing but leaving you in a different choice.

What are the options for a choiceAdventureScript?

1) Looks at choice and decides to do nothing with it.
-> KoLmafia's built-in automation takes over

2) Looks at choice and handles it, but you end up in the same choice.
-> This could happen with Gnasir, as you turn in items, one by one, and the exit
We can't distinguish this from case 1, so will will continue with the built-in automation.
I think if the choiceAdventureScript wants to handle choice XXX, it should handle chains of choice XXX until you exit from that choice.

3) Looks at choice and handles it, but you end up in a different choice
-> We should treat this as a brand-new choice. This is not happening. This is the bug.
Note that if I fix this, after your choiceAdvetureScript goes through the portal, it should return, rather than submitting visit_choice(1) in an attempt to also handle choice 1024

Working on it.
 
OK, I think I have it. Here's a ChoiceAdentureScript:

Code:
void main( int choice, string page )
{
    // code to handle the choice, using available_choice_options(), run_choice(), etc.
    print( "In choice adventure " + choice );

    int option = 0;
    switch ( choice ) {
	// The Spooky Forest
    case 26:	// A Three-Tined Fork
	// 1 => 27, 2 => 28, 3 => 29
	option = 2;
	break;
    case 27:	// Footprints
	// 1 => Seal Clubber, 2 => Turtle Tamer
	option = 2;
	break;
    case 28:	// A Pair of Craters
	// 1 => Pastamancer, 2 => Sauceror
	option = 2;
	break;
    case 29:	// The Road Less Visible
	// 1 => Disco Bandit, 2 => Accordion Thief
	option = 2;
	break;
    case 46:	// An Interesting Choice
	// 1 => mysticality, 2 => Muscle, 3 => fight
	option = 3;
	break;
    case 47:	// Have a Heart
	// 1 => give hearts, 2 => exit choice
	option = 1;
	break;
    case 502:	// Arboreal Respite
	// 1 => 503, 2 => 505, 3 => 506
	option = 2;
	break;
    case 503:	// The Road Less Traveled
	// 1 => Meat, 2 => wooden stakes or 47, 3 => 504
	option = 1;
	break;
    case 504:	// Tree's Last Stand
	// 1, 2, 3 => (buy or sell) and stay in 504, 4 => exit choice
	option = 4;
	break;
    case 505:	// Consciousness of a Stream
	// 1 => mosquito larva or 3 spooky mushrooms, 2 => tree-holed coin or nothing, 3 => 46
	option = 2;
	break;
    case 506:	// Through Thicket and Thinnet
	// 1 => 26, 2 => Spooky-Gro fertilizer, 3 => 507
	option = 1;
	break;
    case 507:	// O Lith, Mon
	// 1 => Spooy Temple map, 2 => exit choice, 3 => exit choice
	option = 1;
	break;

	// The Gourd!
    case 619:	// To Meet a Gourd
    case 620:	// A Blow is Struck!
    case 621:	// Hold the Line!
    case 622:	// The Moment of Truth
    case 634:	// Goodbye Fnord
	// The following occur if you leave the battle and return
    case 623:	// Return To the Fray!
    case 624:	// Returning to Action
	option = 1;
	break;

	// The Haunted Bedroom
    case 876:	// One Simple Nightstand
    case 877:	// One Mahogany Nightstand
    case 878:	// One Ornate Nightstand
    case 879:	// One Rustic Nightstand
	option = 1;
	break;
    case 880:	// One Elegant Nightstand
	option = 2;
	break;

    default:
	print( "not handling " + choice );
	return;
    }

    run_choice( option );
    print( "Done!" );
}
It handles the Spooky Forest, which is a chained series of (different) choice adventures
It handles The Gourd!, which is a chain of choice => 6 fights => choice => 6 fights => choice => 6 fights => choice => 1 fight => choice
It handles the Haunted Bedroom which is a fight => choice

1) I selected The Spooky Forest, set a goal of 1 choice, and told KoLmafia to adventure for 10 turns. On turn 5:

Code:
[1081734] The Spooky Forest
Encounter: Arboreal Respite
> In choice adventure 502
Took choice 502/2: gain mosquito larva or spooky mushrooms, skip adventure, get stats or fight a vampire
choice.php?whichchoice=502&option=2&pwd
Encounter: Consciousness of a Stream
> Done!
> In choice adventure 505
Took choice 505/2: gain 300 meat & tree-holed coin then nothing
choice.php?whichchoice=505&option=2&pwd
> Done!

2) I used a jar of psychoses (The Captain of the Gourd), selected The Gourd!, and told KoLmafia to adventure for 1 turn.

Code:
[1081710] The Gourd!
Encounter: To Meet a Gourd
> In choice adventure 619
Took choice 619/1: Let me at 'em! (6 adventures)
choice.php?whichchoice=619&option=1&pwd
Encounter: tin can conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: tin can conspirator takes 3252 damage.
Round 2: Chondara wins the fight!
You gain 40 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: razor-sharp can lid
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 2 Beefiness
After Battle: You gain 6 Enchantedness
> Done!

[1081711] The Gourd!
Encounter: goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: goblin conspirator takes 3221 damage.
Round 2: Chondara wins the fight!
You gain 107 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: Knob Goblin firecracker
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 2 Strengthliness
After Battle: You gain 6 Magicalness
After Battle: You gain 2 Chutzpah

[1081712] The Gourd!
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3220 damage.
Round 2: Chondara wins the fight!
You gain 91 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
You acquire an item: spider web
After Battle: You see a weird thing out of the corner of your eye, and you grab it. Far out, man!
You acquire an item: sleaze powder
After Battle: You gain 1 Strongness
After Battle: You gain 12 Wizardliness

[1081713] The Gourd!
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3218 damage.
Round 2: Chondara wins the fight!
You gain 86 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 2 Strongness
After Battle: You gain 6 Wizardliness
After Battle: You gain 2 Cheek

[1081714] The Gourd!
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3224 damage.
Round 2: Chondara wins the fight!
You gain 76 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 3 Fortitude
After Battle: You gain 6 Wizardliness
After Battle: You gain 1 Chutzpah

[1081715] The Gourd!
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3245 damage.
Round 2: Chondara wins the fight!
You gain 66 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
You acquire an item: spider web
After Battle: You gain 1 Beefiness
After Battle: You gain 6 Wizardliness
After Battle: You gain 3 Cheek

[1081716] The Gourd!
Encounter: A Blow Is Struck!
> In choice adventure 620
Took choice 620/1: Let's do this!  (6 adventures)
choice.php?whichchoice=620&option=1&pwd
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3217 damage.
Round 2: Chondara wins the fight!
You gain 66 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
After Battle: You gain 2 Beefiness
After Battle: You gain 8 Enchantedness
After Battle: You gain 1 Smarm
> Done!

[1081717] The Gourd!
Encounter: tin can conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: tin can conspirator takes 3215 damage.
Round 2: Chondara wins the fight!
You gain 51 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: razor-sharp can lid
After Battle: You see a weird thing out of the corner of your eye, and you grab it. Far out, man!
You acquire an item: Sugar Cog
After Battle: You gain 1 Beefiness
After Battle: You gain 4 Wizardliness
After Battle: You gain 2 Smarm

[1081718] The Gourd!
Encounter: spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider conspirator takes 3222 damage.
Round 2: Chondara wins the fight!
You gain 61 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
You acquire an item: spider web
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 1 Strongness
After Battle: You gain 10 Wizardliness

[1081719] The Gourd!
Encounter: canned goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: canned goblin conspirator takes 3256 damage.
You acquire an item: Xiblaxian polymer
Round 2: Chondara wins the fight!
You gain 107 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: Knob Goblin firecracker
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 1 Beefiness
After Battle: You gain 10 Wizardliness
After Battle: You gain 2 Roguishness

[1081720] The Gourd!
Encounter: spider-goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider-goblin conspirator takes 3260 damage.
Round 2: Chondara wins the fight!
You gain 132 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: Knob Goblin firecracker
You acquire an item: spider web
After Battle: You gain 4 Muscleboundness
After Battle: You gain 4 Enchantedness
After Battle: You gain 3 Cheek

[1081721] The Gourd!
Encounter: canned goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: canned goblin conspirator takes 3256 damage.
Round 2: Chondara wins the fight!
You gain 112 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: Knob Goblin firecracker
After Battle: You gain 2 Strengthliness
After Battle: You gain 6 Magicalness
After Battle: You gain 2 Sarcasm

[1081722] The Gourd!
Encounter: Hold the Line!
> In choice adventure 621
Took choice 621/1: I'm so ready!  (6 adventures)
choice.php?whichchoice=621&option=1&pwd
Encounter: canned goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: canned goblin conspirator takes 3212 damage.
Round 2: Chondara wins the fight!
You gain 112 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: Knob Goblin firecracker
After Battle: You gain 2 Beefiness
After Battle: You gain 8 Wizardliness
After Battle: You gain 1 Roguishness
> Done!

[1081723] The Gourd!
Encounter: tin spider conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: tin spider conspirator takes 3219 damage.
Round 2: Chondara wins the fight!
You gain 107 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
You acquire an item: razor-sharp can lid
After Battle: You gain 1 Strengthliness
After Battle: You gain 10 Wizardliness
After Battle: You gain 2 Chutzpah

[1081724] The Gourd!
Encounter: spider-goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider-goblin conspirator takes 3219 damage.
Round 2: Chondara wins the fight!
You gain 56 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: Knob Goblin firecracker
You acquire an item: spider web
After Battle: You see a weird thing out of the corner of your eye, and you grab it. Far out, man!
You acquire an item: stench powder
After Battle: You gain 2 Fortitude
After Battle: You gain 10 Wizardliness
After Battle: You gain 2 Sarcasm

[1081725] The Gourd!
Encounter: spider-goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider-goblin conspirator takes 3220 damage.
Round 2: Chondara wins the fight!
You gain 58 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: Knob Goblin firecracker
You acquire an item: spider web
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 3 Fortitude
After Battle: You gain 10 Magicalness
After Battle: You gain 1 Roguishness

[1081726] The Gourd!
Encounter: canned goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: You lose 8 hit points
Round 2: Chondara attacks!
Round 3: canned goblin conspirator takes 3210 damage.
Round 3: Chondara wins the fight!
You gain 39 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: razor-sharp can lid
You acquire an item: Knob Goblin firecracker
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 1 Muscleboundness
After Battle: You gain 8 Enchantedness
After Battle: You gain 2 Smarm

[1081727] The Gourd!
Encounter: spider-goblin conspirator
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spider-goblin conspirator takes 3218 damage.
Round 2: Chondara wins the fight!
You gain 48 Meat
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: Knob Goblin firecracker
You acquire an item: spider web
After Battle: You see a weird thing out of the corner of your eye, and you grab it. Far out, man!
You acquire an item: gilt perfume bottle
After Battle: You gain 1 Fortitude
After Battle: You gain 10 Magicalness
After Battle: You gain 3 Chutzpah

[1081728] The Gourd!
Encounter: The Moment of Truth
> In choice adventure 622
Took choice 622/1: He is going down!  (1 adventure)
choice.php?whichchoice=622&option=1&pwd
Encounter: Fnord the Unspeakable
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: Fnord the Unspeakable takes 3245 damage.
Round 2: Chondara wins the fight!
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: spider web
You acquire an item: spider web
You acquire an item: razor-sharp can lid
You acquire an item: razor-sharp can lid
You acquire an item: Knob Goblin firecracker
You acquire an item: Knob Goblin firecracker
After Battle: You think you see a weird thing out of the corner of your eye, but it turns out to be nothing. Which is actually pretty weird, if you think about it, man.
After Battle: You gain 1 Muscleboundness
After Battle: You gain 10 Mysteriousness
After Battle: You gain 5 Roguishness
> Done!

[1081729] The Gourd!
Encounter: Goodbye Fnord
> In choice adventure 634
Took choice 634/1: Take It
choice.php?whichchoice=634&option=1&pwd
You acquire an item: fancy gourd potion
> Done!
Whoa.

3) I selected Haunted Bedroom and told KoLmafia to adventure once:

Code:
[1081709] The Haunted Bedroom
Encounter: animated ornate nightstand
Round 0: Chondara wins initiative!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: animated ornate nightstand takes 3198 damage.
Round 2: Chondara wins the fight!
After Battle: Tog does a couple of karate moves, then swivels his hips and gyrates his pelvis.
After Battle: You see a weird thing out of the corner of your eye, and you grab it. Far out, man!
You acquire an item: Take Eleven Bar
After Battle: You gain 2 Muscleboundness
After Battle: You gain 23 Enchantedness
After Battle: You gain 2 Roguishness
Encounter: One Ornate Nightstand
> In choice adventure 878
Took choice 878/1: small meat boost
choice.php?whichchoice=878&option=1&pwd
You gain 492 Meat
> Done!
In all cases, my choiceAdventureScript was called for every choice adventure.

Revision 19935.

Take out the run_choice(1) after
visit_url("place.php?whichplace=edunder&action=edunder_leave");
and tell me how your script works now.
 
Hmm. Not quite right.

Code:
[1089957] The Penultimate Fantasy Airship
Encounter: Random Lack of an Encounter
In choice adventure 182
not handling 182
Encounter: Spunky Princess
Round 0: Brianna wins initiative!
Round 1: Brianna executes a macro!
Round 1: Brianna tries to steal an item!
You acquire an item: tiny house
You gain 18 Meat.
Round 2: Brianna attacks!
Round 3: Spunky Princess takes 4628 damage.
Round 3: Brianna wins the fight!
You gain 528 Meat
After Battle: Tort does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: titanium assault umbrella
You acquire an item: cocoa eggshell fragment
After Battle: You gain 5 Strongness
After Battle: You gain 10 Enchantedness
After Battle: You gain 15 Cheek
In choice adventure 182
not handling 182
A choice led to a fight, but we called the choiceAdventureScript both before and after it.
 
And with revision 19937, automating adventuring for 5 turns in An Incredibly Strange Place (Great Trip) works as it always has and got me a munchies pill, which required a multi-stage choice path through the Violet Fog.
 
Thanks Veracity. My current Ed test run just finished but I think I will wait until after the next rollover to test this otherwise salad salad salad salad salad salad salad salad salad salad salad salad salad salad salad salad salad salad (isn't this hilarious?)
 
Code:
[21] Hippy Camp
Preference lastEncounter changed from dirty hippy to dirty hippy Vegan chef
Encounter: dirty hippy Vegan chef
Preference _lastCombatStarted changed from 20200402183024 to 20200402183034
Round 0: Player Two wins initiative!
Round 1: You lose 1 hit point
[INFO] - auto_combatHandler: 0
Preference auto_edCombatCount changed from 6 to 7
Preference auto_edStatus changed from dying to UNDYING!
Preference auto_edCombatRoundCount changed from 7 to 8
Round 1: Player Two casts MILD CURSE!
Round 2: dirty hippy Vegan chef takes 2 damage.
Preference auto_combatHP changed from 119 to 3
Preference auto_edCombatRoundCount changed from 8 to 9
Preference auto_diag_round changed from 0 to 1
Round 2: Player Two casts MILD CURSE!
Round 3: dirty hippy Vegan chef takes 3 damage.
Preference auto_edCombatRoundCount changed from 9 to 10
Preference auto_diag_round changed from 1 to 2
Round 3: Player Two casts MILD CURSE!
Round 4: dirty hippy Vegan chef takes 3 damage.
Round 4: You lose 45 hit points
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1
Preference lastEncounter changed from dirty hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 8 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
[INFO] - Buying Holy Spring Water
You acquire an item: holy spring water
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to dirty hippy Vegan chef
Encounter: dirty hippy Vegan chef
Preference _lastCombatStarted changed from 20200402183034 to 20200402183045
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 46 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2
Unsupported choice adventure #1024
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.

Code:
> version

KoLmafia v20.3 r19947

my choiceAdventureScript looks like

Code:
	switch (choice) {
		case 1023: // Like a Bat Into Hell (Actually Ed the Undying)
			run_choice(1); // Enter the Underworld
			auto_log_info("Ed died in combat " + get_property("_edDefeats").to_int() + " time(s)", "blue");
			ed_shopping(); // "free" trip to the Underworld, may as well go shopping!
			visit_url("place.php?whichplace=edunder&action=edunder_leave");
			break;
		case 1024:  // Like a Bat out of Hell (Actually Ed the Undying)
			if (get_property("_edDefeats").to_int() < get_property("edDefeatAbort").to_int()) {
				// resurrecting is still free.
				run_choice(1); // UNDYING!
				run_combat("auto_edCombatHandler");
			} else {
				// resurrecting will cost Ka.
				run_choice(2); // Go back to the Pyramid (costs an adventure)
				auto_log_info("Ed died and spent an adventure resurrecting!");
				set_property("auto_beatenUpCount", get_property("auto_beatenUpCount").to_int() + 1);
			}
			break;
		default:
			auto_log_warning("Unrecognized unhandled choice after combat " + choice, "red");
			break;
	}

I had to add the run_combat() call under the handling for 1024 as otherwise it would treat it as the adventure being over & start running the afterAdventureScript (which would fail because we're still in a combat).

The crux of the problem I think is that Ed can be in a combat <-> choice cycle for 3 cycles for "free" and potentially as many as you have Ka to keep resurrecting for before the adventure is done. And the adventure can be over either by winning the combat (losing always sends you to the Like a Bat Into Hell choice) or exiting the Underworld via the second option in Like a Bat out of Hell.
 
[I had to add the run_combat() call under the handling for 1024 as otherwise it would treat it as the adventure being over & start running the afterAdventureScript (which would fail because we're still in a combat).[/code]
That is (part of) the problem: the intended use for this is that the choiceAdventureScript will do whatever you want up to the run_choice() and then return.
KoLmafia will take over at that point.

That worked in choice 1023: run_choice() redirected to 1024, and KoLmafia called your choiceAdventureScript with 1024.
Your script should have called run_choice() and returned.
KoLmafia should have detected that you were back in combat.

In other words, it SHOULD have been a "choice redirects to a fight".
Pondering.
 
Back
Top