Results 1 to 3 of 3

Thread: InterStasis v1.4 - A between-battle script to complement NeoStasis

  1. #1

    Default InterStasis v1.4 - A between-battle script to complement NeoStasis

    This is my first attempt at ASH coding, so any and all suggestions and comments -- including "are you taking new medication or something?" -- are most welcome

    This script is designed to complement Illarion's NeoStasis script by providing some between-round adjustments to help keep you at the stasis "sweet spot" for the area you just adventured at, and to help you burn off the excess mana that you'll inevitably collect if you're running stasis for a while without a PBS.

    To get the most out of the script, I recommend that you don't run it until you've adventured at least once in the area you want to burn turns in. All of the MCD management is set to trigger from my_location() -- the last area you adventured in -- and you'll get a turn of poor results if you just start running the script before that datum is set properly.

    v1.4 - Update 5-4-07

    * Complete overhaul of stat adjustment functions to provide better accuracy

    v1.3 - Update 4-13-07

    * Added functions to guide user on how to adjust defense stat using skills, items, and gear (all WIP)
    * Fixed more infinite-loop condition errors
    * Created library of functions for converting items to effects and vice versa

    v1.2 - Update 4-10-07

    * Changed user prompt logic to be less intrusive
    * Started work on defense stat balancer
    * Fixed infinite-loop bug on buff failure

    v1.1 - Update 4-9-07

    * Improved buff-casting logic
    * Added user input to help manage extreme MCD cases

    v1.0 - Initial release

    Current features include:

    * If you have MCD access, adjusts MCD to the best setting for the area
    * Allows you to choose whether "best setting" means average monster power for the area, or low monster power for the area
    * Manages a maximum and minimum threshhold for your MP ... if you go over the maximum %, the script will cast a user-defined group of buffs for you, while keeping your MP over the minimum %


    I'm currently reusing a few functions from NeoStasis and from Tyvek's "Between Violence" script, and I'm truly grateful for both of those scripts. See "References" below for links to the latest versions of both.

    To-do list:

    * Make gear adjustments to keep muscle/moxie at the sweet spots for your skillset
    * Figure out a workaround to stop the script from making MCD adjustments when you switch areas


    Illarion's NeoStasis script
    Tyken's Between Violence script[hr]Sorry for the double-post, but this script has undergone enough serious revisions that I wanted to call attention to the new stuff. The biggest change is that the script is starting to develop some intelligence around how you might keep your defense stat at the perfect "sweet spot" for a given area. I'm expecting that in the next release, I'll have enough confidence in those functions to allow the script to actually take action to fix your stat in between battles -- i.e., by casting skills, using items on hand, and/or changing your gear.

    The code has gotten pretty unwieldy, so any suggestions on how to make things more elegant would be very much appreciated. This ASH stuff is still new to me, and I'm sure there are control structures that I don't know about yet. Comments would be much appreciated!
    Attached Files

  2. #2
    Join Date
    Mar 2006

    Default Re: InterStasis v1.3 - A between-battle script to complement NeoStasis


    Since you seem to use a lot of key comparisons and maps, I'd recommend trying file_to_map(filename, map). This lets you store data in a tab-delimited file to load/reload whenever you need to instead of hardcoding all the values into a script. There is a slight performance hit in doing so, but it makes scripts slightly more readable. It also makes it so that updating your script is modifying a single data file, rather than modifying multiple lines of code.

    There's a bug in the public version of v10.9 where KoLmafia doesn't release the read locks on files accessed in this fashion, so you can't really write to them in the current release, but reading should never be a problem. Here's an example of how you might use it:

    int [item] muscgear;
    file_to_map( "fmuscgear.txt", muscgear );

    int [item] pmuscgear;
    file_to_map( "pmuscgear.txt", pmuscgear );

    foreach pitem in pmuscgear
    muscgear[pitem] = pmuscgear[pitem] * $stat[muscle].my_basestat() / 100;

    It simplifies a lot of maintenance problems by turning everything you would update into a simple data file. Your effect to item and item to effect functions could be similarly converted. Or, if you wanted to go all the way (and modify half the number of files), you could just use records as well. I *believe* this will work.

    record modifier
    int muscle;
    int moxie;

    modifier [item] adjusters;
    file_to_map( "f_adjusters.txt", adjusters );

    modifier [item] p_adjusters;
    file_to_map( "p_adjusters.txt", adjusters );

    foreach pitem in p_adjusters
    adjusters[pitem].muscle = p_adjusters[pitem].muscle * $stat[muscle].my_basestat() / 100;
    adjusters[pitem].moxie = p_adjusters[pitem].moxie * $stat[moxie].my_basestat() / 100;



    Probably using the same methodology as other programming languages would help ... like, not being afraid of imports. For example, I'd put each of the if ( xxxAdjustment ) code blocks into its own function to make things easier to track down, and to reduce the nesting level of your code by one. That'll make things 'feel' a bit less complicated and it lets you modularize scripts and have different scripts for each type of adjustment.

    I see if (debug) print(""); in a lot in scripts and it makes me wonder why people don't just write a function in order to reduce the amount of typing, put it into a script called 'debug.ash' and just import it. I don't do it with mafia because I found that there was a lot of overhead with mafia constantly reconstructing really long strings, but none of your tests involve printing huge strings, and I (personally) think it's a good practice.

    [color=indigo]boolean SHOULD_PRINT_DEBUG = false;

    void debug( string message )
    print( message );

    if ( level == 0 )
    debug( "We are in serious trouble, I think." );

  3. #3

    Default Re: InterStasis v1.3 - A between-battle script to complement NeoStasis

    Major overhaul, ahoy:

    // v1.4: Complete overhaul of stat guide functions to provide better accuracy. WIP: Function
    // is way slow with 15+ items in the list; it totally fails if you have 20 or more items to
    // check. WIP: Need to actually apply the changes if config set.

    This is very much a WIP, and has not been tested exhaustively yet due to the weird intermittent problems I'm having with count(). But I wanted to get this new version out there since I think it's a big step in the right direction.

    The core functionality of the script is still basically the same ... it will adjust the MCD to the optimal setting for you, burn MP between turns, etc. However, I've added two new functions -- evalStat() and adjustStat() -- that are designed to help you keep your defense stat (moxie or muscle) at the optimal setting for the area you're adventuring in. It's important to note that these functions are NOT enabled yet in the script; I expect to do that shortly (once time permits).

    Near the top of the script, you'll find some new configuration settings:

    // Choose to use skills, items, or gear adjustments to adjust defense stat when necessary
    boolean skillAdjustments = false;
    boolean itemAdjustments = false;
    boolean gearAdjustments = true;

    These settings tell the script the ways in which you want it to evaluate ways to change your stats. It's worth noting that you should almost never run the script with all three of these set to "true" ... I'll explain why in a second.

    When you call adjustStat(), you specify which stat you want to modify, and by how much. For example:


    When the function is called, it looks through all your skills, usable items, and/or gear (depending on how you've set the configuration) and tries to find the simplest way to achieve the specified stat gain. For example, if you're wearing the frilly skirt, and you have filthy courdoroys in inventory, the script will tell you to put on the dirty hippy pants. Or if you're wearing the shiny ring, it'll tell you to take it off.

    So: the reason you don't usually want to allow the script to look at skills, items, AND gear is that it takes forever and a day to evaluate. A rule of thumb is that you don't want the script to have to evaluate a list of more than 13 items or so at once ... if you try to look at a list of 14+ items, the script will appear to hang, it's actually trying to run through all the possible permutations of those items, a process that lengthens exponentially as the list grows. Caveat emptor.

    Note that the script doesn't actually change your gear, use your items, or use your skills ... yet. That should be coming in v1.5, assuming testing goes well on this version. My goal is to get the script to a point where you can stasis for 25+ turns at MCD 11 without worrying that your moxie is going to carry you out of range for the area you're playing in.

    I haven't changed the adjustments library to a map yet ... the suggestion totally makes sense, though, so I'll try to get that done soon. Meanwhile, any questions or comments are welcome.
    Attached Files

Similar Threads

  1. Best Between Battle Script Ever -- formerly AutoMCD
    By zarqon in forum Buff Upkeep Scripts
    Replies: 692
    Last Post: 02-22-2019, 06:58 PM
  2. Replies: 0
    Last Post: 12-11-2013, 10:50 PM
  3. Bug - Fixed adventure() from a between battle script changes combat filter
    By picklish in forum Bug Reports
    Replies: 0
    Last Post: 03-13-2011, 06:14 AM
  4. Illarion's NeoStasis script v1.4
    By illarion in forum Custom Combat Settings
    Replies: 70
    Last Post: 07-25-2007, 03:55 PM
  5. Changing equipment in a between battle script. Is this possible?
    By Darkness in forum Item Handling Scripts
    Replies: 1
    Last Post: 02-15-2007, 04:07 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