Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Importing SmartStasis main() function to your script, to modify combat queue?

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    257

    Default Importing SmartStasis main() function to your script, to modify combat queue?

    I've been using a custom script of mine for a few years now, but strange bugs pop up and I've always wondered if I was using script imports incorrectly or something. Below is the main() function that I copy-pasted from SmartStasis into my script fxer.ash, with two blocks of modifications as commented in the code: Actions that have to fire before SmartStasis takes an action, and Actions that can fire whenever SmartStasis chooses.

    1st change: To use a nanorhino you have to use a muscle skill as your first skill (like Toss, if you cast entangling noodles that is Myst class and you can't Nanobrawny effect). So my mod is just to fire a macro directly to the server and not enqueue anything with smartstasis/batbrain.

    Then you see build_custom(), which SS/Batbrain use to create the actions.

    2nd change: Then I add a few more skills, if necessary, to the custom[] combat queue array. Such as Creepy Grin if it hasn't been used yet.

    Those are my only additions but strange bugs pop up for me such as:

    1) On firing the Romantic Arrow, mafia halts and says you're on your own, I've posted about it before here: http://kolmafia.us/showthread.php?17...ll=1#post98824

    2) Recently a macro has started getting built that tries to use the Indigo Cup repeatedly in a combat, even though it's a once-per-combat item and is marked as such in BatFactors.txt, I've posted about it here: http://kolmafia.us/showthread.php?64...l=1#post117925

    Hopefully this is just me being a bad scripter, so perhaps this code shows what obvious error I'm making and how to correct it. Anyone else had trouble firing romantic arrows from their scripts?


    PHP Code:
    // SmartStasish.ash Consult Script for your CCS, with additions
    void main(int initroundmonster foestring pg) {
       
    act(pg);
       
    vprint_html("Profit per round: "+to_html(baseround()),5);

           
    // *** MODIFICATIONS TO FIRE BEFORE SmartStasis ***

        // Attempt to get Nanobrawny buff from nanorhino
        
    if( my_fam() == $familiar[nanorhino] && $familiar[nanorhino].image == "nanorhinoc.gif"){
            
    // Track the number of nanorhino uses today
            
    set_property("_nanorhinoUses"get_property("_nanorhinoUses").to_int() + 1);
            
    //custom[count(custom)] = to_event("skill " + get_combat_skill("muscle").to_int(),"",1);
            
    abort("ready for nanorino combat skill!");
            
    macro("skill " get_combat_skill("muscle").to_int()); // Need to fire this to server before SS tries entangling noodles or some such
        
    }

        
    // *** END BEFORE SmartStasis MODS ***

      // custom actions
       
    build_custom();

           
    // *** MODIFICATIONS TO FIRE WHENEVER SmartStasis WANTS ***

        // Attempt to unleash the nanites if it will banish a monster
        
    if( have_effect($effect[nanobrawny]) >= 40 && get_banish_monsters("perm"contains foe){
            
    custom[count(custom)] = to_event("skill " $skill[Unleash Nanites].to_int(),"",1);
            
    //macro("skill " + $skill[Unleash Nanites].to_int());
        
    }

        
    // Attempt to temporarily banish monsters if you have skills available
        
    if( get_banish_monsters("temp"contains foe ){
            
    // Pantsgiving (30 advs, 5 daily)
            
    if( have_skill($skill[Talk About Politics]) && get_property("_pantsgivingBanish").to_int() < 5){
                
    custom[count(custom)] = to_event("skill " $skill[Talk About Politics].to_int(),"",1);
            }
            
    // Vivala mask (10 advs, 1 daily)
            
    else if( have_skill($skill[Creepy Grin]) && !get_property("_vmaskBanisherUsed").to_boolean() ){
                
    custom[count(custom)] = to_event("skill " $skill[creepy grin].to_int(),"",1);
            }
            
    // Stinky cheese eye (10 advs, 1 daily)
            
    else if( have_skill($skill[Give Your Opponent the Stinkeye]) && !get_property("_stinkyCheeseBanisherUsed").to_boolean() ){
                
    custom[count(custom)] = to_event("skill " $skill[Give Your Opponent the Stinkeye].to_int(),"",1);
            }
        }

        
    // Use the romantic arrow if we've got our Obtuse Angel with us
        
    if( my_fam() == $familiar[Obtuse Angel] && get_putty_monster() == foe){
            
    custom[count(custom)] = to_event("skill " $skill[Fire a badly romantic arrow].to_int(),"",1);
        }

        
    // *** END WHENEVER SmartStasis MODS ***

       
    switch (m) {    // add boss monster items here since BatMan is not being consulted
          
    case $monster[conjoined zmombie]: for i from 1 upto item_amount($item[half-rotten brain])
             
    custom[count(custom)] = get_action("use 2562"); break;
          case 
    $monster[giant skeelton]: for i from 1 upto item_amount($item[rusty bonesaw])
             
    custom[count(custom)] = get_action("use 2563"); break;
          case 
    $monster[huge ghuol]: for i from 1 upto item_amount($item[can of Ghuol-B-Gone&trade;])
             
    custom[count(custom)] = get_action("use 2565"); break;
       }
       if (
    count(queue) > && queue[0].id == "pickpocket" && my_class() == $class[disco bandit]) try_custom();
        else 
    enqueue_custom();
      
    // combos
       
    build_combos();
       if ((
    $familiars[hobo monkeygluttonous green ghostslimelingcontains my_fam() && !happened("famspent")) || have_equipped($item[crown of thrones])) try_combos();
        else 
    enqueue_combos();
      
    // stasis loop
       
    stasis();
       if (
    round maxround && !is_our_huckleberry() && adj.stun && stun_action(false).stun to_int(dmg_dealt(buytime.dmg) == 0) &&
           
    kill_rounds(smack) > && min(buytime.stun-1kill_rounds(smack)-1)*m_dpr(0,0)*meatperhp buytime.profitenqueue(buytime);
       
    macro();
       
    vprint("SmartStasis complete.",9);


  2. #2
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,741

    Default

    Well, keeping the fact that you're running custom actions tied into your 'intelligent' scripts that cause them to potentially choke because it's already built the page and created the 'status' before you send custom actions to change the status and make it no longer in the state it was when it built the page...

    From what you said, you're running SS twice. In your custom script, as well as through WHAM - which calls SS itself through its own wrapper. From your description of your CCS, it would probably be much easier to just import WHAM rather than SS and modify the WHAM main instead...

  3. #3
    Senior Member
    Join Date
    Dec 2008
    Posts
    257

    Default

    Well, keeping the fact that you're running custom actions tied into your 'intelligent' scripts that cause them to potentially choke because it's already built the page and created the 'status' before you send custom actions to change the status and make it no longer in the state it was when it built the page...

    From what you said, you're running SS twice. In your custom script, as well as through WHAM - which calls SS itself through its own wrapper. From your description of your CCS, it would probably be much easier to just import WHAM rather than SS and modify the WHAM main instead...
    Originally Posted by Theraze View Post
    Thanks Theraze, my CCS reads:
    1: call fxer.ash
    2: call wham.ash

    So would that cause SS to run twice in the same loop? I thought my script would be complete then pass processing off to WHAM (and SS)

  4. #4
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,741

    Default

    Hmm... call, or consult? Do those do the same thing? I know all of mine use consult.

    But very simply, yes. Your fxer.ash script above does the stasis with lines like:
    Code:
      // stasis loop 
       stasis();
    WHAM.ash does this:
    Code:
    		vprint("WHAM: Running SmartStasis", "purple", 3);
    		SmartStasis();
    which does this:
    Code:
    	// stasis loop
    	stasis_WHAM();
    	macro();
    	vprint("WHAM: SmartStasis complete.", "purple", 7);
    So yes... you're doubling up the stasis. While 'once' items SHOULD only trigger one time, there had been some fun confusion regarding getting the jump on rounds and it marking as different fights a while in the past. I believe that bug got fixed, but still... the duplication of executions might be causing issues for you.

    Or maybe it's as simple as the different between call and consult. Maybe.

  5. #5
    Senior Member
    Join Date
    Dec 2008
    Posts
    257

    Default

    Hmm... call, or consult? Do those do the same thing? I know all of mine use consult.
    Originally Posted by Theraze View Post
    Sorry you're right, it's consult not call. Even then though I thought the stasis() in my script would be complete, so when WHAM calls SmartStasis() it would see there is nothing to do and simply move on?

    In either case, do you think trying to modify the WHAM main() function would be the easiest/only way to achieve what I'm trying to do? Trigger buffs from the nanorhino and use banishing items at the beginning of combats etc?

  6. #6
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    I am not sure how persistent the BatBrain "have done this"-map is so it may be that having it show up in different scripts called after eachother may lead to unwanted issues.
    If you want to add specific stasising and whatnot things I'd suggest looking if it would be possible to add them to build_custom_WHAM() which is where I put in things I think should be done as part of that but that SS may not do.

  7. #7
    Senior Member
    Join Date
    Dec 2008
    Posts
    257

    Default

    Thanks Winterbay I'll check that option. Would I need to cut and paste any changes I make back into wham.ash whenever it was updated via svn if I go this route?

  8. #8
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    If you make the changes in the "\svn\winterbay-mafia-wham"-folder they should be merged whenever an updated is pushed out.

  9. #9
    Senior Member
    Join Date
    Dec 2008
    Posts
    257

    Default

    I'd suggest looking if it would be possible to add them to build_custom_WHAM() which is where I put in things I think should be done as part of that but that SS may not do.
    Originally Posted by Winterbay View Post
    This has been working well Winterbay, thanks for the tip. I can get things like temporary banishers to work (ex: pantsgiving, creepy grin, stinkeye), but one that isn't working is setting up the Nanorhino's permanent banish.

    Inside your method I've added the code:
    PHP Code:
        // Attempt to get Nanobrawny buff from nanorhino
        
    if( my_fam() == $familiar[nanorhino] && get_property("_nanorhinoCharge").to_int() == 100){
            
    encustom(get_action($skill[Toss]));
        } 
    But when I enter combat a bunch of other things happen before Toss and then the combat is over (pickpocket, pocket crumbs, zombo's eye and done). Is there a way to prioritize Toss so the buff happens immediately before the combat could possibly end?

  10. #10
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    There is a function "pre_brain()" which is called before BatBrain has had any chance to do anything. I would assume that if you were to add a
    Code:
    macro("skill " + to_string(to_int($skill[toss])));
    in there it should run before anything batbrain/smartstasis/WHAM does and trigger what you want it to trigger.

Similar Threads

  1. SmartStasis -- a complex script for a simple CCS
    By zarqon in forum Custom Combat Settings
    Replies: 1871
    Last Post: 08-01-2018, 01:30 PM
  2. Bug Round 0 ends each combat, lands on main map
    By Haroldine in forum Bug Reports
    Replies: 20
    Last Post: 06-05-2014, 12:53 AM
  3. Replies: 0
    Last Post: 04-08-2013, 05:32 PM
  4. Replies: 8
    Last Post: 12-24-2012, 07:38 PM
  5. Replies: 1
    Last Post: 01-27-2010, 11:57 PM

Posting Permissions

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