Universal Recovery Script

Bale

Minion
[size=+1]Universal Recovery 3.13[/size]
Universal Recovery Configuration 1.3

This script will change kolMafia's default healing functions to make the most of your available items in hardcore/ronin or make the most of your meat if you have access to the mall. That makes this a great restoration improvement for both ascenders and farmers.

Once installed, mafia will use this script to restore with. It does not require the user to ever call it explicitly. Just install it and forget it, assuming it will be there to take care of you. After installation, configuration only requires you to set the healing targets in mafia's HP/MP usage tab just as when you set up mafia's restoration settings.

  1. Distribution has migrated over to SVN. To install this script, with a current daily build, please copy/paste the following line into KoLmafia's CLI and press enter:
    Code:
    svn checkout https://svn.code.sf.net/p/kolmafiascripts/mafiarecovery/code/
  2. Then in the gCLI type:
    set recoveryScript = Universal_recovery
    This is character specific so you'll have to set recoveryScript for every character who uses the script. If you ever want to turn the script off again, use the gCLI command: set recoveryScript =

  3. To configure options from the relay browser, you are able to call up a user interface from a drop-down menu from the relay browser's top menu.

Options: This script will allow you to customize its healing in hardcore or ronin by making use of the user interface options from the relay browser's top menu or the equivalent options in KolMafia's HP/MP usage. When the mall is available it will anything and everything to heal. Anything not listed in the relay browser's user interface will be used whenever the script decides. The user can feel free to use either the relay browser's interface for recovery options or the mafia interface. They both work. However there are also several options for this script that are only accessible through the relay browser.
recovery_options.png

The script has two different healing modes, based on the character's access to the mall.
  • Hardcore Mode: For hardcore before freeing the king or in normal core before breaking Ronin. This mode will treat inventory as if it was precious, always attempting to heal with the minimal items, never wasting any inventory since it is hard to replace.
  • Mallcore Mode: For Casual Ascension, after breaking Ronin or in hardcore after freeing the King and gaining mall access. In this mode, Universal Recovery will do whatever is most profitable. It will use the method of recovery that costs the least meat. It will check current mall prices (once per session) and purchase the items that have the best healing for their value. It will even balance the cost of restoring 20MP to cast Cannelloni Cocoon vs the cost of a scroll of drastic healing (and other HP healing items) and use the cheapest method. It will not use any more expensive restoratives in your inventory, as it assumes they would be sold in your store since you can make more meat that way.
The script will obey mafia's preferences, so if you have it set to not purchase from the mall or NPC stores, then it will avoid that. Alternately, using the optional relay browser user interface, you can instruct the script to refrain from using the mall or NPC stores.

If this script cannot purchase from the mall, it will stay in hardcore mode.


Changelog in following post.
 
Last edited by a moderator:
Changelog

version 3.9.4 March 31, 2011
- Need to recover at the hidden temple now.

version 3.9.1 August 29, 2011
- extra checks to prevent purchase in Way of the Surprising Fist

version 3.9 August 19, 2011
- Will only use medicinal herbs to fill up the extra 3 spleen if you have a spleen familiar and are in ronin/hardcore. If you have mall access it will still use your entire spleen as before
- Turn off all purchases during "Way of the Surprising Fist"
- add option to script controlled by relay_Universal_recovery v1.2
-- Enable purchasing during "Way of the Surprising Fist"

version 3.891 July 23, 2011
- Fixed small bug.
- Medicinal Herbs given greater precedence if you approve of using them.

version 3.89 July 5, 2011
- Fixed critical restoration bugs that sometimes affects people with a healing skill, but not cannelloni cocoon or other full heal. Why did nobody ever report this problem clearly!?

version 3.883 May 22, 2011
- Bees Hate medicinal herbs.

version 3.882 May 18, 2011
- Bees Hate plump juicy grubs.

version 3.881 May 18, 2011
- Bugfixes for both of the previous releases!

version 3.88 May 18, 2011
- Bees Hate You, but Universal Recovery loves you!

version 3.87 May 18, 2011
- Add invisible setting set baleUr_ignoreStatus = true to keep from recovering any status effects including Beaten Up.

version 3.86 April 19, 2011
- Fix for un-ascended, low-level characters

version 3.85 April 13, 2011
- Added support for beer-scented teddy bear and comfy pillow
- Hippy side nuns now cooperate with Cannelloni Cocoon
- Temporary Amnesia is Hot Tub worthy
- Use April Shower if enabled using relay script v1.14
-- added options to script controlled by relay_Universal_recovery v1.14
-- - Option to use April Shower
-- - No longer shows VIP options unless you have a VIP Key

version 3.84 March 22, 2011
- Fixed meat per mp calculation

version 3.83 March 10, 2011
- Fixed bug with purchasing combat reserve restoration

version 3.82 March 5, 2011
- Fixed very unpleasant bug.

version 3.81 March 1, 2011
- Fixed bug with using MMJ when you can't buy any and are running out.

version 3.8 February 24, 2011
- Include Nemesis final battle as a multi-state battle to avoid healing in the middle of.
- Handle bad status effects to encourage players to turn off mafia's "auto-remove malignant status effects."
- Refuse to use Hot Tub when you're in the Slime Tube. (You probably want to ration that.)

version 3.79 February 17, 2011
- KoL changed the dispensary. This update requres r9054 or better.
- Will not try to heal between stages of Ed the Undying or the Naughty Sorceress.

version 3.78 January 13, 2011
- fixed stupid idiot error with last release.

version 3.77 January 12, 2011
- Checks for presence of spleen familiar before assuming spleen consumption (for some people's improved Hot Tub usage).
- Executive Narcolepsy allows a free rest.
- Fixes healing in "no heal zones" such as the hidden temple when it is a fighting holiday like FoB or you have a hipster equipped.

version 3.76 August 12, 2010
- Fixed bugs with using the sofa to rest.

version 3.75 August 7, 2010
- Fix a bug for restoring HP with resting costing an adventure, when you don't have an adventure.

version 3.74 July 24, 2010
- Fix a bug in mallmode that caused mis-evaluation of multiple casting of heal skills past MaxMP.
Okay, it's hard to explain, but slyz fixed it.

version 3.73 July 21, 2010
- allow level 9 Accordion Thief to use Medicinal Herbs.
- added "Never abort automation, even if restoration fails" option for automating fiends.
- added "Never abort automation, even if restoration fails" option to relay_Universal_recovery v1.13

version 3.72 July 7, 2010
- fix bug that prevented use of Doc Galaktik to heal HP if verbosity was turned up.

version 3.71 June 30, 2010
- improved logic to save meat on Doc Galaktik by skimping on healing if unnecessary.
- fixed possible infinite loop for Palm fronds and mummy wrappings.
- small tweaks to relay_Universal_recovery v1.12

version 3.7 May 11, 2010
- added options to script controlled by relay_Universal_recovery v1.1
-- Option to use inventory in mallmode (not recommended!)
-- Option to use disco rests even when Hp or Mp are not fully restored
-- Added buttons to restore HP or MP
- less complaint about not opening guild store for mmj if character is a level 9 AT
- fixed bugs where plump juicy grubs might not be used as a priority
- fixed bug where it restored mp to cast a healing skill, even when the player has no healing skill
- fixed bug which caused items to be used even though it would be followed by a full heal
- small error in CLI feedback

version 3.61 April 14, 2010
- fixed problem with using stockpile of mmj
- fix verbosity default
- fix compatibility with r8382

version 3.6 April 13, 2010
- Adds UI for preferences in relay browser: relay_Universal_recovery v1.0
- Makes use of new price sharing list at kolmafia.us
- Improved checks for meat per mp to update when access to lab or mmj is achieved
- Fixed cases where cost of restoring MP for a healing spell could be higher than cost of purchasing HP with meat

version 3.532 March 8, 2010
- Fixed version update bug

version 3.532 March 4, 2010
- Fixed seltzer bug

version 3.53 March 1, 2010
- Lots of bugfixes
- Several recovery logic improvements
- Moved all logic out of main so that it can be used as an included function in other recovery scripts
- If auto Olfacting, it will ensure you have enough MP for the job, regardless of restoration settings

version 3.52 January 4, 2010
- Fixed meat per mp bug on first run

version 3.5 December 23, 2009
- Calculates meat per mp and hp for assistance to other scripts such as zarqon's SmartStasis
- Refrains from stockpiling antidotes until level 5
- If mafia set to "do not recover hp", then it won't recover from Beaten Up
- Refrains from using Nun healing for HP if it would need to use Cannelloni Cocoon or a scroll of drastic healing afterwards
v3.51 bugfix

version 3.43 December 3, 2009
- small improvements to healing logic
- bugfixes related to healing MP for casting recovery spells
- additional configuration option
v3.431 bugfixed the bugfix
v3.432 another bugfix

version 3.42 November 11, 2009
- efficiency improvements
- several bug fixes

version 3.411 October 26, 2009
- very minor bug fixed
- minor efficiency improvement

version 3.41 October 19, 2009
- removed special location handling because it is unreleased to recovery
- fixed for compatibility with daily build r7751+
- bug with nun recovery fixed
- tiny program improvements that make me happy

version 3.4 October 4, 2009
- Added a few more location specific controls to aid adventuring
- Stopped attempted purchase of antidotes if user doesn't want to purchase from NPC stores
- Adjusted dynamic changes to current mall prices thanks to jason's fix in r7590
- Miscellaneous potential bugs fixed

version 3.334 August 31, 2009
- Improved verbose mode again. Probably only one person in the universe cares, but she's verbose about it.
- Fixed a single bug.

version 3.33 August 26, 2009
- Improved clarity of verbose mode
- Improvement to Hot Tub usage
- Improvement to using Nuns for HP restoration
- Bugfix for using Nuns to restore after the putty trick
- fix for r7570's mall_price() change
- Can remove need for user confirmation if version increases low decimals
v3.333 (August 26) - Stupid Typo!

version 3.3 August 18, 2009
- Enough little bugfixes that at least one of them was probably bothering someone
- Optional verbose mode

version 3.2 August 12, 2009
- Improved equipment switching for reduced mana cost
- Some mallcore improvements and bugfixes
- Improved restoration logic for Hidden Temple and mining cave-ins
- Reduced server hits determining status of guild store using new feature from revision 7509
- Reduced loadtimes and server hits for price checking using new price history from revision 7531
- Better calculate Max HP/MP when changing equipment and accounts for Slimy Skills
- Fixed accounting of skill mp cost in certain circumstances
- Added version checking
- Added automatic updating for data files (and user no longer needs to manually download a data file)
- Added counter for steel organ
- Added counter for shore item if you have a full telescope
v3.21 (Aug 14) - Bug fix and price sharing upgrades using r7544

version 3.1 July 23, 2009
- Fixed a few bugs
- Only restores 1 HP (and doesn't heal beaten up) if you're in the Hidden Temple or mining for ore.

version 3.0 June 24, 2009
- Bugfix
- Upgrade version to 3.0 to reflect condition of relative perfection

version 2.94 June 16, 2009
- Corrected misuse of items after skills.
- Predictive MP recovery during HP recovery phase

version 2.9 June 3, 2009
- Uses a free pull to get the VIP Lounge Key from Hangks for you.
- Fixes mmj use for Accordion Thieves
- Will allow you to designate characters using up stock of MMJ in aftercore, even if it cannot be purchased.
v2.91 (June 10) - Price protection
v2.92 (June 10) - More improvements to price protection and dynamic repricing
v2.93 (June 10) - Bug fixes and recovery logic improvements

version 2.8 May 25, 2009
- Hot Tub support for healing, curing poison and recovering from beaten up
- A few bugfixes and improvements
- Requires build 7310 or higher
v2.81 - Checks for Bad Moon before trying to use the Hot Tub
v2.82 - Fixed bug
v2.83 - Bug fix and recovery logic improvements

version 2.7 April 27, 2009
- Scroll of drastic healing is re-used 1/3 of the time, so now mallcore mode acounts for that in the price
- Drastically increased ability to control script functions in hardcore mode
- Will make really thick bandages from mummy wrappings if you select them in preferences
- Added ability to use Clan Sofa in case you really want to waste turns resting there
- Bug fixing
v2.71 - (May 2) Lots of Bugfixes
v2.72 - (May 4) More Bugfixes

version 2.6 April 23, 2009
- Mallcore Mode improvements
- Improved handling of mummy wrapping, Palm frond and six-pack of New Cloaca-Cola
- Faster
- Bugfixes involving skill use

version 2.5 April 21, 2009
- Fixed compatibility with KolMafia revision 7185
- Lots of bugfixes
- Removed vestigial maps left from before switch was implemented, to increase speed
- Updated mapfile to speed up processing speed by pre-calculating average healing
- Some improvements to recovery logic
- Allow a small amount of wastage to save meat costs
v2.51 - Bugfix

version 2.4 April 7, 2009
- Considers effect of automatic equipment switching on MP cost of skills.
- Will prevent automatic equipment switching into Brimstone Bracelet if it will lower max HP too much.
- Fixed recovery logic for cases when HP target is 100% of max HP, to allow for wasted restoration.
- Fixed round up error causing script to recover at low HP/MP, when set to not recover.
- Knows when to purchase extra seltzer for next time, to save time from excessive outfit switching.
- Less stubborn about HP restoration to save meat.
- More options are configurable.
v2.41 - bugfixes and faster mp cost computation
v2.42 - one more annoying bugfix
v2.43 - bugfix/logic and speed improvement
v2.44 - (April 9) Will check to see if you can purchase mmj before buying any
v2.45 - (April 12) "No healing skills" bug found by palpitations and fixed.

Version 2.3 - March 31, 2009
- Some routines rewritten for greater efficiency under KolMafia revision 7098 and 7114
- CLI output reduced. It runs much cleaner now.
- Use of birdform restoration is now user configurable.
- Will check user's preference for "Buy items from the mall whenever needed" and stay in hardcore mode if the preference is unchecked.
- Fixed unseemly preference for palm fronds and mummy wrappings when healing relatively few MP/HP.
- Configurable variables moved to the top of the script.
- A few miscellaneous improvements to restoration logic.

Version 2.2 - March 20, 2009
- Made scented massage oil use configurable by user
- Improved logic for comparison of otter to walrus for healing "beaten up"
- More improvements to mallcore mode
- Made some algorithms tidier: improving clarity AND reducing script length.
- (March 22) Bugfix
- (March 23) Won't use last SGEEA for "beaten up" if you haven't identified the potion of teleportitis.

Version 2.1 - March 13, 2009
- Improvements for mallcore mode.
- Eliminated mallcore's "Did not fully restore MP for some reason" false alarm bug.

Version 2.0 - March 3, 2009
- Hardcore_recoveryScript is now Universal_recovery.
- Much of the code has been rewritten.
v2.01 - Fixed Medicinal Herb's medicinal herbs use in mallcore mode.
v2.02 - Fixed usage of palm fronds, mummy wrappings and six-packs of New Cloaca-Cola.
v2.03 - A couple of small, but very important fixes
v2.04 - Minor parenthesis issue.


Formerly known as the Hardcore Recovery Script, the name has been changed since it is no longer optimized exclusively for hardcore. You'll find the changelog for version 1.0 to 1.99 in that thread.

Early discussion of this script's development was in this thread. For a long time after that it was developed in another thread as a Recovery Script for Hardcore. While I am extremely happy with its current abilities, I am always eager to hear comments and suggestions for improvement. I'd love to hear what feature you think it needs next.
 
Last edited:
put restore_map.txt in the /data directory.

Do you mean recoveryScript_map.txt? I don't see a file called restore_map.txt.

Once again, HUGE thanks for this script! I have been using the Hardcore Recovery script since you started it and it has been truly invaluable. I can't wait to try this one out.
 
I'm very happy it's helping you. I'm going to continue to make it better any time I can figure out how.

Do you mean recoveryScript_map.txt? I don't see a file called restore_map.txt.
Oh. Thanks! Yes, the name got changed at an earlier point but I didn't update the instructions. I'll edit that. :D
 
Ok, first bug. The script (at least in mall mode) fails if it decided Medicinal Herbs are cheapest and then can't use them because your spleen is full.

Great work otherwise, interesting to watch it try to decide what to get :)
 
Facepalm!

Oh. Yeah. I'm going to have to make it check for spleen if you're in mallcore mode. Unfortunately I never use them so I forgot to make it check that in mallcore mode, like it already does in hardcore mode. You're really good at spotting my bugs. I like that.

That's such an easy fix I've already uploaded v2.01 right now! If any of the 8 previous downloaders want to heal with Medicinal Herb's medicinal herbs then download the update, otherwise ignore it.

Great work otherwise, interesting to watch it try to decide what to get :)
I think that's fun to watch also. I wonder if widespread use of my script amongst farmers would make a notable difference at keeping restorative prices proportional to how much they heal.
 
By the way, since my script now tries to make use of the Platinum Yendorian Express Card, if anyone actually has one of these, please let me know if the script uses it.

The heuristic it uses, is that it will try to heal with the Express Card if your mp is below autoheal levels and also below 1/9 of your maximum mp. So, get your MP down that low and please tell me if it works. I doubt I'll ever own one so I can't test this myself. Also, if that heuristic doesn't match your own preferences, please tell me so I can make it better suit someone who actually owns one.
 
AutoHeal if below 82HP, up to -> 207HP with Bale's Universal Recovery.
Current HP: 81, Current MP: 73... restoring HP! Target = 207
Searching for "mummy wrapping"...
Purchasing mummy wrapping (2 @ 190)...
You acquire mummy wrapping (2)
Purchases complete.
Using 2 mummy wrapping...
You acquire an item: really thick bandage
Finished using 2 mummy wrapping.
Using 1 really thick bandage...
You gain 107 hit points
Finished using 1 really thick bandage.
Did not fully restore HP for some reason.
 
Attempting to heal up to 162MP with Bale's Universal Recovery.
Current HP: 202, Current MP: 110... restoring MP! Target = 162
Searching for "palm frond"...
Purchasing palm frond (1 @ 100)...
You acquire an item: palm frond
Purchases complete.
Using 2 palm frond...
You acquire an item: palm-frond fan
Finished using 2 palm frond.
Using 1 palm-frond fan...
You gain 36 hit points
You gain 39 Mojo Points
Finished using 1 palm-frond fan.
Using cached search results for palm frond...
Purchasing palm frond (1 @ 100)...
You acquire an item: palm frond
Purchases complete.

Looks like perhaps a failure to purchase the proper number of palm fronds/mummy wrappings.

I'm not certain, but it might also be valuing them at only half of what the combined set costs.
 
I hadn't run into that problem during my testing. Dang. It is an interesting bug actually. I caused it by getting too clever and then forgetting how clever I had gotten.

I think I've gotten it fixed so v2.02 is now uploaded. Please download and continue testing. :o
 
That seems to have fixed that issue. At least it's successfully making palm frond fans and using them.

However, it's even doing this in preference to using moths when in bird form. This seems off to me, since the palm fronds are costing 100 each, leaving the fans at 200 for ~40 MP. Moths are 100 meat in the mall for ~30 MP (not to mention that I'm accumulating them by farming them out of ronin on the battlefield).

This character also has access to MMJ, so I'm not certain that the fans are the best deal even normally, unless you factor in their HP restoring ability.
 
Please tell me the level of the character, so I can figure out the value of MMJ. Also, just in case, please tell me what class they are.

I'm going to have to look into the moth issue. I can't think of any reason why it wouldn't use them for recovering MP if their cost is 100 meat if you are currently in Form of...Bird. I specifically check to make sure that is right... I'm going to have to run some tests for this one.

In the meantime you can tell it to stick to hardcore mode so that it will use items in your inventory by setting mall to false. (That option is the documentation at the beginning of my script, under options.)
 
The particular character I'm testing on is currently a level 12 Accordion Thief (well he just hit level 13 and it's still happening).
 
Then mmj should restore from 22-24 MP. Palm frond fans restore 35-45, so mmj should have the margin. Barely. I'll definitely have to examine the issue. Perhaps this script wasn't as ready as I thought.

One last question. You have opened the moxie guild store, right? I figure that the answer to this is almost certainly yes, but I like to be certain.
 
Thank you very much for all the help StormCrow42, I've fixed the last of the problems.

To track down these issues I changed the script into a recovery simulator that enabled me to see how it would perform under various conditions without actually restoring anything. I even found a couple of minor issues that you didn't find yet. :o Thank goodness I thought to do that.

I'm quite certain that it will work properly now. I'm embarrassed that it was released in such a buggy condition, but pleased that it will now use magical mystery juice and plump juicy grubs if it can do so.

V2.03 is now released.
 
Last edited:
Thank you very much for all the help StormCrow42, I've fixed the last of the problems.

To track down these issues I changed the script into a recovery simulator that enabled me to see how it would perform under various conditions without actually restoring anything. I even found a couple of minor issues that you didn't find yet. :o Thank goodness I thought to do that.

I'm quite certain that it will work properly now. I'm embarrassed that it was released in such a buggy condition, but pleased that it will now use magical mystery juice and plump juicy grubs if it can do so.

V2.03 is now released.

Quite certain, you say?
KoLmafia said:
Expected }, found && (universal_recovery.ash, line 647)
Beyond that little hiccup, this is a pretty impressive script. Thanks for all your hard work!
 
After fixing the missed parens on that line, it seems to be working better. At least it used cheap Nards and anti-magi wipes, I'll have to wait until after rollover to test it with grubs and moths again.

Thanks for all your hard work on this. I understand how difficult complex stuff like this is to get right.
 
Gik. v2.04 uploaded to fix that parenthesis issue. I'm honestly not sure how I did that to it since I remember verifying it before uploading... there must have been one last thing that I wanted to do and I was getting tired?

Incidently I tested a post-ascension character in Birdform and it did eat a moth so I'm comfortable about that.

Thank you for your patience. Yes, the code and heuristics are getting rather complex.
 
Back
Top