Results 1 to 5 of 5

Thread: abort does not work in combat

  1. #1
    Senior Member
    Join Date
    Oct 2017
    Posts
    606

    Default abort does not work in combat

    Code:
    string test_combatHandler(int round, monster enemy, string text)
    {
        abort("test");
        return "attack with weapon";
    }
    
    
    run_combat("test_combatHandler");
    this results in:
    1. test_combatHandler will hit abort("test") and print a stack trace. it will stop running and will not do attack with weapon... mafia background changes from grey to red
    2. however at that point it will not abort the script which called run_combat(), instead it will fallback on using CCS and then continuing as if nothing happened
    Last edited by taltamir; 06-17-2020 at 04:45 AM.
    ttpack = a collection of scripts by taltamir

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

    Default

    How's this?

    Code:
    string test_combatHandler(int round, monster enemy, string text)
    {
        abort("test");
        return "attack with weapon";
    }
    
    visit_url( $location[ The Hippy Camp (Bombed Back to the Stone Age)].to_url() );
    run_combat("test_combatHandler");
    print( "Here I am" );
    yields:

    Code:
    > cfa.ash
    
    [14312] The Hippy Camp (Bombed Back to the Stone Age)
    Encounter: cavewomyn hippy
    Round 0: Veracity wins initiative!
    test
    You're on your own, partner.
    Click here to continue in the relay browser.
    
    Combat filter function aborted execution
    
    > ashq run_combat()
    
    Round 1: Veracity executes a macro!
    Round 1: Veracity tries to steal an item!
    Round 2: Psychic Grrl says, I sense an unexpected windfall in your near future! and hands you some meat.
    You gain 10 Meat.
    Round 2: Veracity tries to steal an item!
    Round 3: Veracity casts GALLAPAGOSIAN MATING CALL!
    Round 4: Psychic Grrl says, I sense an unexpected windfall in your near future! and hands you some meat.
    You gain 14 Meat.
    Round 4: Veracity attacks!
    Round 5: cavewomyn hippy takes 566 damage.
    Round 5: Psychic Grrl says, I sense an unexpected windfall in your near future! and hands you some meat.
    You gain 8 Meat.
    Round 5: Veracity wins the fight!
    After Battle: You pause and think about KoL Con IV, when you armwrestled SleazyBoozeFighter. You lost, but it was a good workout!
    After Battle: You gain 6 Fortitude
    After Battle: Psychic Grrl surveys the scene from atop the throne and sighs.
    After Battle: With the grinding of stone on stone, Grave Hematite points at some items you hadn't spotted.
    You acquire an item: handful of nuts and berries
    You acquire an item: handful of pine needles
    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 notice some extra Meat hidden in the pile of communal berries.
    You gain 29 Meat.
    After Battle: You gain 20 Strengthliness
    After Battle: You gain 12 Enchantedness
    After Battle: You gain 42 Chutzpah
    You acquire an item: Gathered Meat-Clip
    You acquire an item: stick of firewood
    Revision 20210

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

    Default

    Here's where those messages came from:

    Code:
    run_combat( "filter" )
       FightRequest.nextRound
         Macrofier.macrofy
           execute "filter" function
             abort("test") -> ABORT state
             --> prints "test"
             aborts script
           return "abort"
         prints "You're on your own partner"
         aborts automation
       prints "combat filter aborted"
       aborts script
    Since the combat filter is in the same script interpreter as the out script, I probably didn't need to print "Combat filter function aborted" message.
    But I don't think it hirts to do that.
    What do you think?

  4. #4
    Senior Member
    Join Date
    Oct 2017
    Posts
    606

    Default

    Thank you. I think it looks great.
    I am fine with it printing that combat script is what caused the abort.

    I tested the new version and it works. even when embedded in subfunctions called by the filter function like so
    Code:
    string test2(int round, monster enemy, string text)
    {
        abort("test abort embedded 3 functions deep");
        return "I need a return value after abort";
    }
    
    
    string test1(int round, monster enemy, string text)
    {
        return test2(round, enemy, text);
    }
    
    
    string auto_combatHandler(int round, monster enemy, string text)
    {
        return test1(round, enemy, text);
    and it aborted just fine.
    I think this can be marked as fixed
    Last edited by taltamir; 06-24-2020 at 07:12 AM.

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

    Default

    I tweaked this such that run_combat() does not itself abort. It simply checks if the interpreter state is STATE_EXIT (which it will be with either an abort() an "exit") and returns. This will propagate all the way up and the script will exit.

Posting Permissions

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