Bug - Fixed Bug: Doctor Bag quest NC isnt being handled as part of combat

xerxes431

New member
Version r19136

If your script does something like the following, mafia will abort once it gets the doctor bag quest start NC. Instead of eating, it will print "you are currently in a choice." This happens even if you have the choice set. It doesn't matter if mafia is set it to accept the quest, reject the quest, or turn off the phone.

adv1($location[someplace], -1, "");
eat(1, $item[thing]);

Just run the above until the phone rings, it will abort instead of eating.
 

ckb

Minion
Staff member
I don't think this is a bug - this is expected behavior.
If you want Mafia to handle all choices and such to completion before moving on, use adventure()
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
Nonetheless, it would be nice to be able to recover from a doctor NC if you have initiated the adventure with adv1().
 

ckb

Minion
Staff member
Nonetheless, it would be nice to be able to recover from a doctor NC if you have initiated the adventure with adv1().

You can, you just have to understand what adv1() does, and script around it. It does not do what adventure() does.

Why are you using adv1() by itself, without any other handling? What are you trying to accomplish?

This would be a workaround (though probably not a good one):
Code:
adv1($location[someplace], -1, "");
if (get_property("lastEncounter")=="Is There A Doctor In The House?") run_choice(-1);
eat(1, $item[thing]);

There are a lot of choiceadventure things that pop up that adv1() will not handle... including doctor bag (also, Halloweener, and probably other stuff I can't think of now)
 

xerxes431

New member
CKB, that's just an easy way to reproduce it. What is happening is that I'm using a photocopied monster, YRing it, then trying to drink.

The bag is triggering on the photocopied monster, and preventing me from drinking.
 

Malibu Stacey

Active member
You can, you just have to understand what adv1() does, and script around it. It does not do what adventure() does.

Why are you using adv1() by itself, without any other handling? What are you trying to accomplish?

This would be a workaround (though probably not a good one):
Code:
adv1($location[someplace], -1, "");
if (get_property("lastEncounter")=="Is There A Doctor In The House?") run_choice(-1);
eat(1, $item[thing]);

There are a lot of choiceadventure things that pop up that adv1() will not handle... including doctor bag (also, Halloweener, and probably other stuff I can't think of now)

adv1 said:
This will adventure exactly once in the specified place (even if it took no turns), although it will follow chained choice adventures for as long as you have preset options.
From https://wiki.kolmafia.us/index.php?title=Adv1

I raised this in the Doc bag thread over 2 weeks ago but it appears to have gone unanswered. With choiceAdventure1340 set to anything other than 0, it should not abort according to the documentation above but it does. So either the documentation is wrong or it's a bug in the handling of this.

Also the main difference I can see between adv1() and adventure() is

adventure said:
Note that adventures is the number of adventures to spend in the specified location place. Any "free" turns (choiceadventures that don't consume an adventure, usually) or adventures spend in other locations (by a counterScript or a betweenBattleScript for example) will not count towards this total.

so if you want to automate free fight wanderers you either use adv1() or unnecessarily burn an adventure every time by using adventure(). If that's not the case then we have unearthed yet another documentation discrepancy.
 
Last edited:

Ryo_Sangnoir

Developer
Staff member
If you're using adv1 and it hits the doctor bag in the middle of adventures, it carries it out (presumably by the next adv1). It's only when you hit the doctor bag at the end that you need the extra handling.

I also found that the choice didn't trigger until I hit another URL, so my workaround goes
Code:
while (to_int(get_property("_snojoFreeFights")) < 10) {
  heal_if_necessary();
  adv1($location[The X-32-F Combat Training Snowman], -1, "");
}
visit_url("main.php", false);
run_choice(-1);
where the last two statements do nothing in the case that a choice adventure wasn't hit.
 
adv1() doesn't play nice with fights that are followed by other fights or choice adventures, but in_multi_fight() and choice_follows_fight() can be used to test for this.
My free fight script has a lot of "while ( in_multi_fight() ) run_combat();", to get those eldritch tentacles out of the way (and as a bonus, stuff didn't break when I had some clingy going from OCRS modifiers).
 
Yeah, I don't even think it's a problem with adv1() specifically, even using mafia's built-in automated adventuring stalls out when I try to automate turns in the haunted bedroom (with all the nightstand noncombats).
 
Last edited:

Malibu Stacey

Active member
Code:
adv1(to_location("VYKEA"), -1, "");
if (choice_follows_fight())
{
  run_choice(-1);
}

still results in

[70857] VYKEA
Preference lastEncounter changed from angry tourist to Witchess Knight
Encounter: Witchess Knight
Preference _lastCombatStarted changed from 20190320073053 to 20190320073103
Preference _sourceTerminalDigitizeMonsterCount changed from 2 to 3
Preference relayCounters changed from 70856:Digitize Monster loc=* type=wander:watch.gif to
Preference relayCounters changed from to 70896:Digitize Monster loc=* type=wander:watch.gif
Preference _stinkyCheeseCount changed from 25 to 26
Round 0: Malibu Stacey wins initiative!
WHAM: Running SmartStasis
Round 1: Malibu Stacey executes a macro!
Round 1: Malibu Stacey casts SUMMON LOVE GNATS!
Round 2: Light-Fingered Haroun chomps your foe on the arm and refuses to let go. That's that famous Saint Patrick tenacity at work.
Round 2: Malibu Stacey casts EXTRACT!
You acquire an item: Source essence
Round 3: Malibu Stacey casts SING ALONG!
WHAM: Starting evaluation and performing of attack
WHAM: We are going to 1-shot with attack with your weapon.
Round 4: Malibu Stacey executes a macro!
Round 4: Malibu Stacey attacks!
Round 5: Witchess Knight takes 3156 damage.
Round 5: Malibu Stacey wins the fight!
You gain 224 Meat
After Battle: Light-Fingered Haroun shoots you a wink and does a little dance to disabuse onlookers of his nefarious intentions.
You acquire an item: jumping horseradish
You gain 41 Meat.
After Battle: Saint Light-Fingered Haroun barks or howls or makes whatever sort of excited animal noise is appropriate for a thing like Light-Fingered Haroun, and this gets you pumped up. (+4 Muscle Stats)
After Battle: You gain 30 Muscleboundness
After Battle: You gain 30 Magicalness
After Battle: You gain 58 Sarcasm
After Battle: Light-Fingered Haroun takes advantage of the downtime to grab a few z's.
After Battle: Light-Fingered Haroun takes note of any security cameras in the area.
Preference testudinalTeachings changed from 150:5|211:2|203:5|267:0|266:1|198:1|213:0|207:2|206:4|214:5|210:5|197:2|269:3|209:3 to 150:5|211:2|203:5|267:1|266:1|198:1|213:0|207:2|206:4|214:5|210:5|197:2|269:3|209:3
Preference _catBurglarCharge changed from 37 to 38
Preference _catBurglarCharge changed from 38 to 39
This combat did not cost a turn
Preference walfordBucketProgress changed from 59 to 60
Preference walfordBucketProgress changed from 60 to 61

A choice follows this fight immediately.

A choice follows this fight immediately.

even though choiceAdventure1340=1
 

ckb

Minion
Staff member
FWIW, running adv1() inside a while loop correctly handles the doctor bag adventure, choosing to ignore/dismiss it when choiceAdventure1340=3
 

Malibu Stacey

Active member
FWIW, running adv1() inside a while loop correctly handles the doctor bag adventure, choosing to ignore/dismiss it when choiceAdventure1340=3

Sounds like the core of the problem is mafia not handing a refresh of adventure.php when a choice follows an adventure (see Dictator's earlier post about Haunted Bedroom combats also not being handled similarly).
Using a while loop as a workaround is the proverbial bandaid on a bullet hole.
 

Malibu Stacey

Active member
Is this fixed by 19204? It'll be a couple of days before I can test it as I have a doctor bag quest at present & I don't get through them too quickly.
 

Malibu Stacey

Active member
Bumping from page 12.

I think my issue in this thread is fixed by the recent changes to run_choice() but I was working around it using the following

Code:
  adv1(to_location("VYKEA"), -1, "");
  if (choice_follows_fight()) {
    visit_url("choice.php");
    run_choice(-1);
  }

thanks to discussion on that issue highlighting the need to manually call visit_url("choice.php"); (which I think may no longer be needed?)
 

Veracity

Developer
Staff member
Yeah, I made run_choice do the visit_url itself if choice_follows_fight.

I bumped this because the Doctor's Bag can interrupt adventuring anywhere, including places you are not expecting a choice, so, perhaps if you have set a default for that choice, we should automaically handle it for you? I need to think more about this and probably do some experimentation.
 

Veracity

Developer
Staff member
I haven't tried the doctor's bag yet, since I've been testing stuff on characters that have no IOTMs, but I noticed this when automating a single adventure in the Haunted Bedroom.

Code:
Visit to Manor2: The Haunted Bedroom in progress...

[847624] The Haunted Bedroom
Encounter: Wardröb nightstand
Round 0: Tebryn wins initiative!
Round 1: Tebryn executes a macro!
Round 1: Tebryn attacks!
Round 2: Wardröb nightstand takes 5269 damage.
Round 2: Wingwang shakes loose a considerable quantity of spice. You conjure up a canister and collect it.
You acquire an item: spices
Round 2: Tebryn wins the fight!
After Battle: Wingwang demonstrates a dance of celebration from his native land. Translated into couscous, it's basically incomprehensible.
After Battle: You gain 1 Fortitude
After Battle: You gain 15 Mysteriousness
After Battle: You gain 7 Smarm

Requests complete.

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]

[color=green]> ash choice_follows_fight()[/color]

Returned: true
This is the same issue as the Doctor's Bag, and is easily reproducible for any of my test characters.
 

Veracity

Developer
Staff member
Revision 19901 fixes KoLmafia.executeAdventureOnce to detect that choice_follows_fight and, if so, request choice.php and then automate the choice.

The new code:

Code:
		RequestThread.postRequest( adventure );
		if ( FightRequest.choiceFollowsFight )
		{
			RequestThread.postRequest( new GenericRequest( "choice.php" ) );
			ChoiceManager.gotoGoal();
		}
Looks suspiciously like your:

Code:
  adv1(to_location("VYKEA"), -1, "");
  if (choice_follows_fight()) {
    visit_url("choice.php");
    run_choice(-1);
  }
 
Top