Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 42

Thread: choiceAdventureScript

  1. #1
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,776

    Lightbulb choiceAdventureScript

    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!
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Woss | Om****est (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  2. #2

    Default

    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.
    Originally Posted by zarqon View Post
    This is how autoscend/cc_ascend has handled these things in the past and it is horrible. I wholeheartedly second this request.

  3. #3
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,177

    Default

    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.

  4. #4
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,776

    Default

    I must have two birthdays this year. I'll get started on my choiceAdventureScript!
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Woss | Om****est (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  5. #5
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,177

    Default

    Get revision 19900. That should handle chained choices the way it used to - with the choiceAdventureScript being invoked each time through.

  6. #6

    Lightbulb 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...at_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 by Malibu Stacey; 03-29-2020 at 07:51 AM.

  7. #7
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,177

    Default

    Thanks for the lengthy report. I'll reopen this and study it this afternoon.

  8. #8

    Default

    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.

  9. #9
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,177

    Default

    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.

  10. #10

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •