SmartStasis -- a complex script for a simple CCS


Well-known member

What is it?

SmartStasis handles basically everything you might want to do in combat other than actually kill the monster (although in some special cases it will also do that). Once it's done with all that, it will hand the combat off to the next stage of your CCS in time for you to finish off the monster.

The script assumes two categories for all actions available to you in combat:

Custom actions. These are special actions, not necessarily profitable according to the script's logic, which should be done sometime before the end of combat, usually due to something situational or user-specified.
Regular actions such as attacking, jiggling, spellcasting, itemslinging, etc.

This script is designed to execute the first category smartly, and to prolong combat using actions from either category if it decides that prolonging the combat would be profitable (note the overlap).

So, below is the nitty-gritty. All of the user-configurable script settings (mentioned in this teletype font) can be adjusted by typing "zlib settingname = value" in the CLI. Type "zlib vars" in the CLI to see the current values or to grab a convenient copypasta. These values will not change when updating the script (handy!), nor by editing it.

Custom Actions Handled by SS

  • Pickpocketing if you're in the clear and/or if you could acquire a goal (twice if possible).
  • Stealing accordions where applicable.
  • Mug for the Audience: SS will generally try to keep you in Love rather than Hate, unless you still need to Incite a Riot for the day (and you've already Thrown a Party, if applicable). That means that although it will still pickpocket for goals, for other monsters it will Mug unless you are at full Love already.
  • Using Olfaction (or analogous skills) on the monsters you specify in BatMan_attract, as well as bounty monsters when you are on a bounty hunt, or New-You monsters if you have set the correct properties! In the event of multiple targets in the same zone, SS will not attract any targets until the number of targets goes back down to 1, though monsters specified in mafia's autoOlfact property will always be attracted. Certain monsters specified in BatMan_attract which are quest-specific may not be considered targets if the relevant quest step is complete. Puttying will also take place against bounty monsters for bounties requiring up to BatMan_puttybountiesupto items (default is 19). For puttying to be effective, you also need something that will fight your spooky putty monster after creating it. I recommend the Best Between Battle Script Ever!
  • Puttying bounty monsters (for bounties requiring at most BatMan_puttybountiesupto items). Also, both Olfaction and puttying are sensitive to mafia's one-time olfaction/putty combat settings, so including "special action" in your CCS is unnecessary. Note: any action that copies a monster (i.e. 4-d cameras) is considered when looking to putty.
  • Using Yellow Ray type actions against any monster specified in BatMan_yellow. Certain ascension-specific monsters will only trigger if they are in the setting and the ascension-relevant conditions are met.
  • Using Duplicate on any monster specified in BatMan_duplicate. Gaudy pirates and lobsterfrogmen (the default configuration) will only trigger if the duplication will help you ascend faster.
  • Using a banishing action (like Batter Up!, Creepy Grin, a tennis ball, etc.) on the monsters you specify in BatMan_banish.
  • Casting Summon Mayfly Swarm if the script determines it's desirable.
  • Casting Siphon Spirits if the resultant drink provides you with some mainstat and is an appropriate level.
  • Salving yourself for some safe HP gain if you need it or it's better than your out-of-combat restore options.
  • Using the Big Book of Pirate Insults (or Manual of Marauder Mockery) on pirates if you still need insults.
  • Using spooky putty (or analogue) on lobsterfrogmen if you haven't completed that sidequest yet.
  • Using specific items against the mini-bosses in the Cyrpt.
  • Throwing clumsiness bark at The Thorax and The Bat in the Spats.
  • Throwing jars full of wind at Thug 1 and Thug 2.
  • Throwing dangerous jerkcicles at Mammon the Elephant and The Large-Bellied Snitch.
  • Throwing flyers at everything you can if you have flyers (if BatMan_flyereverything is true).
  • Throwing a disposable instant camera at Bob Racecar (or Racecar Bob) to get your photograph of a dog.
  • Always throwing flyers and/or hand mirrors against the Guy Made of Bees.
  • Always throwing flyers and/or yet-unthrown base pairs at Cyrus the Virus.
  • Throwing meat vortices at thieving brigands.
  • Throwing opium grenades at pairs of burnouts.
  • Throwing skate decoys at groupers/urchins to get goal familiars.
  • Throwing cocktail napkins to drive away clingy pirates if clingfilm items are not goals.
  • Throwing the beehive and electric boning knife at the appropriate tower monsters.
  • Throwing useful punchcard combinations at monsters in the El Vibrato portal. It should be possible now to automate this zone.
  • Identifying unknown bang potions (transparent with the mafia setting).
  • Learning unknown Rave Combos.
  • Releasing the Boots! to get paste whenever your stomping boots are at full charge (and the monster doesn't give boring gooey paste).
  • Throwing quantum nanopolymer spider webs at bugbear scientists.
  • Throwing drone self-destruct chips at liquid metal bugbears.
  • Appropriately throw utensils in A Kitchen Drawer to gain the effect specified in BatMan_pretentioustarget (default is My Breakfast with Andrea).
  • Tunnel Upward or Downward in the case that your goal is a climate colada or digital underground potion.
  • Disco combos! SS will cast disco combos where profitable. It will also always cast Rave Steal if you're Outside the Club.
  • Using lassos in the Sea to improve your lasso skill.
  • Throwing killscrolls and healscrolls to get dreadscroll clues when appropriate.
  • Throwing sea cowbells and a lasso at the wild seahorse.
  • Throwing complimentary refreshments to feed tourists in Dinseylandfill.
  • Using fingernail clippers on Weirdeaux creations.
  • Using tin snips to collect blood for Walford.

Stasis Situations

Under normal conditions, SS will stasis (make combat take longer by using your most profitable low-damage action) if each round's expected profit meets or exceeds BatMan_profitforstasis (default 15.0). This profit is expressed as a meat value, but is really cumulative, including HP, MP, items gained, and other factors. Due to changes in your HP/MP, or familiars losing their ability to generate further meat/MP, the expected profit changes from round to round, and once it drops below the set value, the stasis loop is done. Unlike the pre-BatBrain version, SS does not check if you are in the clear before entering the stasis loop -- it simply considers your probable HP loss as a negative value.

Some generally profitable situations which usually make SS decide to stasis:

  • Using a meat-producing familiar like the hobo monkey or NPZR.
  • Using an HP-restoring familiar such as the Cocoabo when you're low on HP.
  • Using an an MP-restoring familiar like the starfish.
  • Putting a familiar in your Crown of Thrones which restores HP/MP, produces meat, or drops an item.

Additionally, there are some situations which will cause SS to attempt stasis regardless of profit:

  • If you have a molybdenum magnet and you are fighting gremlins, it will stasis until encountering the tool, then use the magnet (it will also exit stasis when encountering the "no tool" message).
  • If you have a Ruby Rod equipped and are fighting in the Seaside Megalopolis, it will stasis until the monster's elemental attack, then attack using the Ruby Rod, but only if you don't already have that particular disc.
  • If you have not learned the DB Nemesis dance skills, it will stasis the relevant monsters until they do their special move, then cast Gothy Handwave.
  • If you are fighting a hellseal pup and lack a seal tooth, it will stasis the pup until it cries out.
  • If you are fighting The Server, it will stasis until the panel falls off, then throw the strange goggles.
  • If you are fighting The Thorax, it will stasis until you defeat the monster.
  • If you are adventuring with a He-Boulder vs. a specified yellow ray target, it will stasis until the yellow eye is showing, then use your major yellow ray.

Additional Features

  • For all custom actions, if preceding that action with a stunning action would be more profitable, SS will do so, accounting for the fact that it's possible to funksling a single-round stunner with that action.
  • SS uses macros where possible to save server hits. Presently, this looks like a strange hybrid of consult/macro play, with chunks of actions being executed at once.
  • SS will automatically convert consecutive single item uses into a single funkslinging action where possible.
  • SS treats any unknown monster stat as being unknown_ml, rather than 0, for tweakable and more realistic results.


  • You can simply install this script by copying
    svn checkout
    into your CLI. This script depends on BatBrain and ZLib, which will also be automatically installed if you don't already have them. Once these three scripts are installed, you may relocate them to a subfolder of your scripts directory if you like.
  • Since SS bases its decisions on overall profit, the value of HP and MP for your character is particularly important information. For this reason, I strongly recommend also configuring mafia to use Bale's Universal Recovery, since besides being the superior option for automatic HP/MP restoration, that script also calculates the value of HP and MP with far greater accuracy than this one. Bale and I have designed these scripts to play nicely together -- Bale's script outputs settings which are read by BatBrain to allow for much greater accuracy when calculating profit.
  • SS also needs to know accurate values for items, and since it can't search the mall in combat, it relies on the ASH function historical_price(). For best results, I also strongly recommend that you enable the "Share recent Mall price data with other users" option in mafia preferences. Leaving this unchecked may mean that you are using nonexistent (0) or very outdated prices for some items. Additionally, the aforementioned Best Between Battle Script will make sure your prices are up-to-date for all combat items in your possession before entering combat.
  • Include something like this in your custom combat script:

    [ default ]
    consult SmartStasis.ash
  • Make sure you have selected "custom combat script" for your battleAction.
  • ...
  • Profit!


SmartStasis is on SourceForge and the changelog can be found here, though I will continue to post more detailed release notes in this thread. The pre-SourceForge changelog is in the following post.
Last edited:


Well-known member
Pre-SourceForge Changelog

2.08.09 - ver. 1.0 posted, followed shortly by a couple fixes to the COMMENTS.
3.12.09 - 1.1 changes: detect hobo monkey theft in FTF, not SmartStasis. This will ensure theft is always detected. Do not stasis Naughty Sorority Nurses. Only stasis gremlins if a tool is needed. For NPZR's and Cocoabos you can start attacking on the 9th round.
4.07.09 - 1.2 changes: fix issue vs. gremlins where using combat healing skills caused endless loop.
4.26.09 - 1.3 changes: added initial support for ghosts/hobos. FTF now has putty separate from use_special_item().
4.30.09 - 1.4 changes: fix gremlins not being properly stasis'd when you are not in the clear.
5.06.09 - 1.5 changes: works with latest FTF to provide proper support for hobo spirits, and poison removal that follows your combat setting. Detecting a used-up ghost still needs help -- so as of this version ghosts are permanently on for stasis. If you are weilding any haiku katana, cast Spring Raindrop Attack as part of stasis before trying restore skills.
5.20.09 - 1.6 changes: works with the latest FTF to provide proper support for GGG's.
6.09.09 - 1.7 changes: only stasis gremlins that may actually drop tools (untested). Keep up with changes to FTF.
6.11.09 - 1.8 changes: handle stasising Seaside Megalopolis monsters. Added Consume Burrowgrub to restore skills used, but only if you will make full use of it.
6.14.09 - 1.9 changes: moved a few things out -- now requires ZLib. Now has once-daily version checking. Improved stasis loop logic (no more loop-in-loop), removing several possible bug situations. Reorganized a bit to hopefully be independent from FTF changes, at least for a while.
8.25.09 - 1.9.1 changes: added midget clownfish to MP-producing familiars.
9.01.09 - 1.9.2 changes: added rock lobster to MP-producing familiars. Fixed bug with detecting 7-foot Dwarf Replicant's elemental attack/miss (after fighting about 10 of them without getting the dang essence disc).
11.28.09 - 2.0 changes: fix a bug detecting stasis cutoff for MP. Move detection of gremlins/megalopolis monsters to FTF so they will be handled without fail. Add support for Disco Concentration, and fix formula for Disco Nirvana. Prefer dictionaries as they do 0 damage.
12.06.09 - 2.1 changes: improved familiar support: added support for Stocking Mimic. Consider monster element for rock lobster and midget clownfish.
12.30.09 - 2.2 changes: completely refactored familiar calculation to use formulas, thus improving speed and greatly improving accuracy AND reducing memory use! Add Snow Angels. Uses values of HP/MP set by Bale's Universal Recovery script to further increase accuracy, especially when calculating whether to cast disco combos. This also allowed me to add a "profitforstasis" variable. Use ZLib's new vprint().
1.08.10 - 2.3 changes: adjust combo calculations based on refactored familiar calculations. Olfact if FTF determined you were supposed to but you didn't have enough MP. Include Static Shock as a restore option. Consider possible Bandersnatch bonus damage when calculating whether to cast disco combos.
4.01.10 - 2.4 changes: add Rave combos. In fact, rework disco combos significantly.
4.19.10 - 2.5 changes: slightly refactor DB combos to avoid an evil foreach error. Better DB combo profit calculations using item_drops_array(). Add support for more stasis familiars: Slimelings, Animated Macaroni Ducks, Adorable Seal Larvae, and Autonomous Disco Balls.
4.25.10 - 2.6 changes: has_goal() now returns a float. Use better guestimates for Nemesis familiar weight.
4.07.11 - 3.0 changes: the new BatBrain-powered SS goes online, to much fanfare and holladoodlin'. This version absorbs and thus obsoletes FTF. Far too many changes to list here (or remember, for that matter). It's a completely different kind of combat script altogether.
4.17.11 - 3.1 changes: add familiar spentness detections to the repeat conditions of the stasis macro. Move all jump actions to custom actions -- stealing is now part of the custom actions macro. Initial support for post-SS noodling.
4.24.11 - 3.2 changes: abort stasis properly for life-threatening huckleberries. Avoid Teleportitis. Use m rather than last_monster().
5.02.11 - 3.3 changes: completely refactor DB combos to use BB's features. Additional combos besides the farming/stasis ones will be easy to add now as well. Yet again, BB drastically reduces the amount of code needed. Realized I hadn't gotten around to normalizing the ZLib settings which are lists of monsters, even though that functionality has been in ZLib for a long time.
6.02.11 - 3.4 changes: don't stasis yourself to death. Prefer Marauder Manuals over Big Books. Solve annoying and seemingly inexplicable automation-stopping error (and added a few more high-verbosity debug statements in the process). Initial support for Summon Mayfly Swarm.
6.15.11 - 3.5 changes: adjust to BatBrain round number changes.
7.02.11 - 3.6 changes: don't try to Olfact in birdform. Be more permissive about HP/MP gain during the stasis macro (far fewer server hits for high-level farmers). Only try to Entangle if it will actually stun. Use BatBrain's new happenings tracking.
10.21.11 - 3.7 changes: Haunted House changes! Use ghost trap vs. sexy sorority ghosts. Use mayfly bait and always try to steal in the Haunted House. Don't use bounty.txt anymore -- proxy records supply all our funky needs.
11.30.11 - 3.8 changes: use BB's new attack_action() to determine your survivability rather than simply your attack, which should help in huckleberry situations where your regular attack is insufficient. The page variable is now global -- remove from parameters where necessary.
12.01.11 - 3.9 changes: Fix to the last update: moved detection of unknown bang potions/spheres from BB into SS.
12.09.11 - 3.10 changes: always try to steal in Lollipop Forest.
1.15.12 - 3.11 changes: Re-add the check for the Unstoppable Banjo before trying Rave combos off-volcano. Make use of Release the Boots. Add stasis macro repeat conditions for Crown of Thrones. Speed: recognize when combat has ended and stop thinking.
3.12.12 - 3.12 changes: Adapt to BatBrain's new format for advevents. Improved stomping logic. Avoid ID-ing bubbly potions in Beecore.
3.31.12 - 3.14 changes: Where applicable, don't include custom actions that have already happened. Don't ID more than ceil(die_rounds/10) bang potions per fight. Properly add base pair event when fighting Cyrus. Refactor gremlin huckleberry detection a bit. Split the try_events() functions into enqueue_events() and try_events() functions. Use this to cast custom actions and combos in one server hit when not pickpocketing. Fix residual error detecting Gothy Handwave.
4.29.12 - 3.15 changes: Important fixes to the server-hit-saving parts to fix a bug and keep you out of trouble. Move stasis loop conditions into separate function to allow access to other macro-building scripts. After calling sort functions, use the new global caches rather than declaring local variables.
12.07.12 - 3.16 changes: Add tower monsters to custom actions. Throw some auto-killers at certain bugbears during Bugbear runs. Cast any preparatory stunning action rather than just Noodles. Adjust to monster name changes. Improve stomping logic.
1.27.13 - 3.17 changes: Finally, support for black boxes and 4-d cameras as putty. Throw seal teeth at hellseal pups and treat them as huckleberries until they wail.
1.31.13 - 3.18 changes: Monster damage is now a spread. Initial support for Siphon Spirits.
5.8.13 - 3.19 changes: Names for phyla have changed (but names for pastes have not). More thoroughly flesh out Summon Mayfly logic. Bump required flyer amount to 100.5% to avoid possible shortage as per Bale's request. Set endscombat flag for custom actions in to_event() where possible. Don't stun before endscombat actions. Skip +items combos if you're going to yellow ray.
5.29.13 - 3.20 changes: Optimize pirate insult logic using questM12Pirate setting (fixes a problem with insults in BIG! path).
6.05.13 - 3.21 Contact! Treat BIG! like aftercore for siphoning spirits. Flyer the GMoB/Cyrus even if it kills you. Don't stun before a custom action if the stunner is the custom action.
7.01.13 - 3.22 changes: SmartStasis is how hosted on SourceForge. Changes for this migratory update are detailed here.
Last edited:


Well-known member
Haha! Well, that link links to the main page now... so in a way it kind of links here. :)

Okay, I changed it. There was also another bad wording in one of the comments which I changed. But I didn't change the version number. If you find any more bugs in the comments, please continue to report them. ;)
Last edited by a moderator:


New member
It doesn't appear to work if my hobo monkey steals the first round of combat. If this happens, it turtle-totems for 26 rounds, then starts attacking, instead of just attacking right away.


Well-known member
@fuzzyevil: Good catch. The problem was that if the monkey stole while FTF was doing its thing, SmartStasis would have no idea about that. The fix involved editing both FTF and SmartStasis, so you'll have to download both of them again.

A few other minor tweaks as well.


New member
@fuzzyevil: Good catch. The problem was that if the monkey stole while FTF was doing its thing, SmartStasis would have no idea about that. The fix involved editing both FTF and SmartStasis, so you'll have to download both of them again.

A few other minor tweaks as well.

Ah, thank you. That works now.


Well-known member
2.1 Update

Fought gremlins today on a character with Lasagna Bandages, and discovered that it would enter into a loop of healing as long as I had MP, without checking to see if the gremlin had or lacked the desired tool. Fixed that.


New member
I'm not sure if this is SmartStasis's doing, but I'm having a problem with lasagna bandages as well, and the new version of the script didn't fix it. When I win initiative, I'm automatically summoning a ghost (is that kolmafia or Smartstasis or FTF?). That isn't the problem though. After summoning the ghost, it automatically tries to use Lasagna Bandages, and it fails. The CLI says that it is redirected to a fight page, tells me I'm on my own, and puts up a Request Synch window.

I think the problem is that some script or another is trying to use the "out-of-combat" version of Lasagna Bandages, but then can't, as I'm still fighting.

EDIT: Another bit of relevant information: the error did not happen when my hobomonkey stole on the first round of combat.

Scripts I am running:
Bale's Universal Recovery


Well-known member
You are running an older version of First Things First. Re-download and your problem should be fixed.


I posted this in the FirstThingsFirst thread, but I might as well put it here too since this thread is looked at more often. The FirstThingFirst script is not maintaining my moods when I set up my automation. The mood is still saved, but it will not activate if I have FTF running. I have the most up to date version of all my scripts.

Current Scripts = UniversalRecovery

Also running the latest .exe version of mafia, always.


Well-known member
I'm not sure what you mean. Moods and custom combat scripts are two entirely separate things. CCS's happen during combat, whereas moods happen between combat. I'm sure that FTF could not possibly interfere with your mood, since FTF has nothing to do with moods.


I know it doesn't make sense, but I'll try and explain this... slightly... differently.

When I run mafia normally, just attack with weapon, I am having no problems (besides an occasional freeze). If I set mafia to run a ccs, it runs just fine, everything works the way it is supposed to.

For some reason though, if I set my FTF ccs to run, mafia quits auto-buffing me. The only permanent mood I have set during my runs is Leash and Butt-Rock Hair. But if I set my CCS to the FTF script, mafia quits buffing me. I only noticed it happened when I went in the castle, with barely enough moxie to make it through, thanks to butt-rock hair. The effect ran out, mafia never attempted to use hairspray, it just kept adventuring. Thus, I started getting my rear handed to me.

I know it doesn't make sense for a CCS to mess with moods... but somehow it is. I would say it was a bug in mafia itself, but that doesn't explain why it only triggers when I use the FTF CCS.


Well-known member
I have no idea what to tell you. I am unable to duplicate this behavior. I use FTF and SmartStasis, and they do not interfere with my moods.

Are you sure you didn't just run out of hairspray? :)


I never actually buy the hairspray myself... I just let Mafia's self automation do it. I know, I'm lazy... but hey, if mafia will buy it and use it for me, why buy it beforehand? :p

It's possible I ran out of hairspray, and for some reason mafia quit buying it automatically. But that would not explain why Mafia quit casting Leash as well. (Yes, I had plenty of Meat)

Oh well, I'll try it again soon. New ascension, new moon, another mafia update, who knows, maybe it will correct itself.


Well-known member
I suppose because I don't know of a way to know whether your ghost/hobo is properly sated. Would you rather the script assume ghosts and hobos are fed and able to restore? That's very simple to add -- 1 line each under the mpfams category.


I suppose because I don't know of a way to know whether your ghost/hobo is properly sated. Would you rather the script assume ghosts and hobos are fed and able to restore? That's very simple to add -- 1 line each under the mpfams category.

The simplest way to find out if a ghost or hobo is lacking nourishment is to parse the combat results. If a hobo or ghost could possibly give another blast, there will be some sort of message about it doing something random that round. If the ghost/hobo isn't mentioned at all, then it will not have any chance of firing off a blast in the next round.
Last edited:


Well-known member
I meant besides that. I want hobofullness(), not (contains_text(page,"blah blah") || contains_text(page,"chogochochogo") || contains_text(page,"nantoko kantoko"))...

So do sated ghosts and hobos act every round (i.e. we can simply test for absence), or do we need to detect inability by looking for hunger/sobriety messages? The wiki has all the strings but doesn't give me frequency.

I don't have a hobo and never use my ghost so I completely lack motivation to figure this out. I would be glad to incorporate this functionality if someone else can fill me in on ghost/hobo behavior (or just writes the detection coding), however.

By the way, those bits all mean "blah blah" but in different languages. Fun!


Sated ghosts and hobos will do something every round, even if it is only a text about hunting through garbage cans. I rely on that cue to know when my hobo/ghost has run out of charges. No comment about the vagrant = no more charges. Also, the stat gaining message after the fight will change based on the hobo/ghost being charged, but that isn't helpful for a consult script.

PS. What languages are chogochochogo and nantoko kantoko?