Bug - Not A Bug Putting back the Macguffin in Actually Ed the Undying doesn't run kingLiberatedScript

Malibu Stacey

Active member
As title. I made a script with literally just a print statement in the main(), set it to kingLiberatedScript and it never fires when you finish an Ed run.

Yes technically you're not freeing the king but once you pick a class after replacing the macguffin, there's an astral gash sitting next to the NS tower so it's either equivalent or we need an Ed specific macguffinReplacedScript automation preference.

Thanks.
 

Veracity

Developer
Staff member
ChoiceManager.postChoice2:

Code:
		case 1054:
			// Returning the MacGuffin
			QuestDatabase.setQuestProgress( Quest.WAREHOUSE, QuestDatabase.FINISHED );
			if ( ChoiceManager.lastDecision == 1 )
			{
				ResultProcessor.processItem( ItemPool.ED_HOLY_MACGUFFIN, -1 );
			}
			break;

		case 1055:
			// Returning the MacGuffin
			KoLCharacter.liberateKing();
			ChoiceManager.handleAfterAvatar();
			break;
This is called after you have taken a choice.

Choice 1054 is where you are placing the Macguffin on the altar (or not; you do have a choice).
Choice 1055 is where you have selected a class. That calls KoLCharacter.liberateKing. This is, literally, the last action of that script:

Code:
		// Run a user-supplied script
		KoLmafiaCLI.DEFAULT_SHELL.executeLine( Preferences.getString( "kingLiberatedScript" ) );
However, before we get there, I see this:

Code:
		// If leaving a path with a unique class, finish when player picks a new class.
		// We can't interrupt choice.php with (most) requests.
		if ( oldPath.equals( AVATAR_OF_BORIS ) ||
		     oldPath.equals( ZOMBIE_SLAYER ) ||
		     oldPath.equals( AVATAR_OF_JARLSBERG ) ||
		     oldPath.equals( AVATAR_OF_SNEAKY_PETE ) ||
		     oldPath.equals( ACTUALLY_ED_THE_UNDYING ) ||
		     oldPath.equals( GELATINOUS_NOOB ) ||
		     oldPath.equals( DARK_GYFFTE ) )
		{
			return;
		}
In Ed the Undying, by the time this is called, you have already taken the choice to select your new class.
Could be as simple as removing the one line that checks if you were Ed.
Are you going to be doing another Ed run to be able to test that?
 

Malibu Stacey

Active member
Thanks Veracity. Might be a while before I get to test this as I'm running KoE on my autoscend test account now to work on it's support of the current challenge path (taking a break from Ed runs after about 40 and a lot of changes pushed to the script now it can just about do 3 day runs with no IotMs again).
 

Veracity

Developer
Staff member
Well, I am not sure of this any more.

ChoiceManager.handleAfterAvatar calls KoLmafia.resetAfterAvatar which is supposed to call the kingLiberated script.

In theory, when you returned the MacGuffin and chose a new class, we should see in your session log:

Now walking on the Accordion Thief road.

(or whatever) and then it would call your script.

Code:
		// Run a user-supplied script
		KoLmafiaCLI.DEFAULT_SHELL.executeLine( Preferences.getString( "kingLiberatedScript" ) );

Looking at my last Ed run:

Code:
place.php?whichplace=edbase&action=edbase_altar
Encounter: Returning the MacGuffin
Took choice 1054/1: unknown
choice.php?pwd&whichchoice=1054&option=1
Encounter: Returning the MacGuffin
Took choice 1055/6: unknown
choice.php?pwd&whichchoice=1055&option=6
Now walking on the Accordion Thief road.
followed by all sorts of stuff from my kingLiberated script.

Which is to say, it sure looks like it worked.

I am going to undo my last submit and think some more about this, since it still looks like it should have worked.

Pondering.

(What does your session log say?)
 
Last edited:

Malibu Stacey

Active member
Yep I got the following

Code:
place.php?whichplace=edbase&action=edbase_altar
Preference lastEncounter changed from You Found It! to Returning the MacGuffin
Encounter: Returning the MacGuffin
Took choice 1054/1: Yep
choice.php?pwd&whichchoice=1054&option=1
Encounter: Returning the MacGuffin
Preference questL13Warehouse changed from started to finished
Took choice 1055/2: or a jerk Turtle Tamer
choice.php?pwd&whichchoice=1055&option=2
Preference kingLiberated changed from false to true
Preference edPoints changed from 77 to 79
Preference breakfastCompleted changed from true to false
Now walking on the Turtle Tamer road.

Close this as not a bug for now. If I can replicate it I'll post something in here.
 

Veracity

Developer
Staff member
OK, thanks. I don't see how it could have failed to run your script.

Code:
	private static void handleAfterAvatar()
	{
...
		StringBuilder buffer = new StringBuilder();
		buffer.append( "Now walking on the " );
		buffer.append( newClass );
		buffer.append( " road." );

		String message = buffer.toString();

		KoLmafia.updateDisplay( message );
		RequestLogger.updateSessionLog( message );

		KoLmafia.resetAfterAvatar();
	}
and that last method:

Code:
	public static final void resetAfterAvatar()
	{
...
		// Run a user-supplied script
		KoLmafiaCLI.DEFAULT_SHELL.executeLine( Preferences.getString( "kingLiberatedScript" ) );
	}
If you had the preference "kingLiberatedScript" misspelled, it would not find it.
But you are an experienced scripter, so I'm assuming it was not that. :)

I'll look again if you can reproduce it.
 
Top