Universal Recovery Script

natnit

Member
Edit: Redacted.

Misinformed jumping to conclusions on my part based on misreading of update times and my own particular experiences. Sorry, Stannius and Veracity!
 
Last edited:

Veracity

Developer
Staff member
Is it "likely" that Universal Recovery buying black cherry soda has to do with making a TPS drink with a cherry?
 
Hoping someone can explain to me what I should look for to fix this:

gCLI said:
Restoring HP! Currently at 340 of 3795 HP, 35 of 7597 MP, current meat: 3086077 ... Target HP = 3795.
Using 16 magical mystery juice...
You gain 670 Mana Points
Finished using 16 magical mystery juice.
Casting Tongue of the Walrus 98 times...
You gain 3,431 hit points
Tongue of the Walrus was successfully cast.
Casting Tongue of the Walrus 1 times...
You gain 36 hit points
Tongue of the Walrus was successfully cast.
Restoring MP! Currently at 3795 of 3795 HP, 12 of 7597 MP, current meat: 3086077 ... Target MP = 250.
Using 6 magical mystery juice...
You gain 253 Mana Points
Finished using 6 magical mystery juice.

as you can see it's choosing to use a bunch of MMJ to restore mana so it can cast a ton of tongue of the walrus. I do not have cocoon on this character, so tongue is my best healing spell, however i don't understand why it isn't using scroll of drastic healing (aside from being cheaper in the mall than 16 MMJs would be, I have some on hand so it's not a mall vs on-hand preference. Any help would be greatly appreciated, or if I can provide more details please let me know what you'd like to see.
 

Bale

Minion
Judging by your maximum HP and MP you are in aftercore at approximately level 25.

In aftercore it does not care what items you have on hand. It only care if selling them in the mall will produce enough meat to purchase MMJ. Since the scroll is more expensive than 600 meat (current mall = 795), it will prefer to use the MMJ and hope you make more meat by selling your scrolls.


Anyway, I've been making small improvements to the script and now seems like a good time to release.



Universal recovery v 3.891 released!


Changelog:
version 3.891 July 23, 2011
  • Small bug fixed.
  • Medicinal Herbs given greater precedence if you approve of using them.
    (Because I've discovered that low skill characters really need to save the meat and aren't doing anything else with their spleens. I only wish they could be used when Bees hate me.)
 
Last edited:

lostcalpolydude

Developer
Staff member
The script used 22 MMJs total for max, and 16 to begin with. I'm guessing that since historical_price() returns 0 for MMJ and he already has them, they were considered free.
 
I guess I don't understand. The MMJ are "worth" 100 each, so it spent the equivalent of 1600 meat to heal me instead of the ~700 meat value of a scroll. That seems wrong. Good call on level by the way, mid level 25 doing basement. Perhaps the thing lostcalpolydude mentions, ie: that MMJ are considered free because I already have them is coming into play, but it seems like there should be a way to consider the value of the MMJ. Also, as i mentioned above, I also have scrolls on hand. Also, when you said:

bale said:
Since the scroll is more expensive than 600 meat (current mall = 795), it will prefer to use the MMJ and hope you make more meat by selling your scrolls.

did you miss that it used 16, not 6? or am i misunderstanding?
 
I don't. The only option i have selected in the bottom panel of the relay script is "Use MMJ in stock, even if it cannot be purchased this ascension" which I take to mean "don't worry about using something that I can't refill" - a sort of safety setting. that said, i have both mmj and scrolls in my inventory so i don't think it's a mall vs. inventory thing unless i dont understand how it's working.
 

igue

New member
Anyone else getting Division by zero error with version 3.891?

Division by zero (Universal_recovery.ash, line 726)
 

Allucaneet

New member
In aftercore the script will use whatever it believes to be cheapest. Such limitations only exist for ronin/hardcore use. The script compares the cost of purchasing all possible restoratives and then uses whatever gives the best ratio of meat per mp. It assumes that if you have more expensive restoratives in your inventory you'll want to sell them in the mall for enough meat to purchase a better value.

Even if I still have my free rests per day, the script still buys the black cherry sodas. Are they cheaper than the free rests? The sodas are unchecked in the hp/mp restore checklist, if that will be helpful.
 

Theraze

Active member
Believe it will only use the free rests if it will heal both hp and mp, and if you'll be able to make full use of both restorations...
 

slyz

Developer
First of all, do you have "Free disco rest" checked in the Mafia HP/MP Usage tab, or in relay_Universal_Recovery.ash, and what is "Use free disco rests for" set to in relay_Universal_Recovery.ash?

Here is the code that control whether UR will use free rests for HP and MP:
PHP:
if(contains_text(hpAutoRecoveryItems, "free disco rest") 
	  && (numeric_modifier("Base Resting MP") >= 10 || my_path() == "Bees Hate You"))
		while(to_int(get_property("timesRested")) < disco  && my_hp()<target
		  && my_maxhp() - my_hp() >=rest_hp && (DiscoResting == "hp" || my_maxmp() - my_mp() >= rest_mp))
			cli_execute("rest");
PHP:
if(contains_text(mpAutoRecoveryItems, "free disco rest") 
  && (numeric_modifier("Base Resting MP") >= 10 || my_path() == "Bees Hate You"))
	while(to_int(get_property("timesRested")) < disco  && my_mp()<target
	  && my_maxmp() - my_mp() >=rest_mp && (DiscoResting == "mp" || (my_maxhp() - my_hp())/2 >= rest_hp))
		cli_execute("rest");
This means that UR will use a free rest when restoring HP/MP if:
  • You authorized Mafia to use free rests for HP and/or MP
  • You have a dwelling OR you are in a BHY run
  • You have free rests left
  • You HP/MP is lower than the target HP/MP
  • You will not waste HP/MP by getting more than your max from resting
  • "Use free disco rests for" is set to HP/MP OR you won't waste MP when resting to gain HP OR you won't gain more than half your missing HP when resting to gain MP
From looking at the last condition, maybe
PHP:
(my_maxhp() - my_hp())/2 >= rest_hp)
was meant to be
PHP:
(my_maxhp() - my_hp())*2 >= rest_hp)
?
 

Theraze

Active member
Ran into an infinite loop bug with UR today... came in to this:
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Restoring MP! Currently at 132 of 357 HP, 3 of 136 MP, current meat: 1 ... Target MP = 12.
Insufficient meat to fully restore MP without wasting restoratives!
Unexpected error, debug log printed.
Unexpected error, debug log printed.
Script execution aborted
Autorecovery failed.
Could not restore enough mana to cast Disco Power Nap.
KoLmafia declares world peace.
That abort/failed is when I hit escape to stop it. The debug log was a stack overflow from it trying to cast DPN several hundred/thousand times.

After adventuring once in the treasury (and getting a 500 meat NC):
Restore 9 MP at Doc Galaktik's
You gain 9 Muscularity Points
You spent 108 Meat
Cure purchased.
Casting Disco Power Nap 1 times...
You gain 40 hit points
You lose an effect: Tenuous Grip on Reality
Disco Power Nap was successfully cast.
Restoring HP! Currently at 172 of 357 HP, 0 of 136 MP, current meat: 393 ... Target HP = 340.
Restoring MP! Currently at 172 of 357 HP, 0 of 136 MP, current meat: 393 ... Target MP = 37.
Visiting Doc Galaktik...

Restore 32 MP at Doc Galaktik's
You gain 32 Muscularity Points
You spent 384 Meat
Cure purchased.
Insufficient meat to fully restore MP without wasting restoratives!
_meatperhp => 3.4285715
Casting Tongue of the Walrus 1 times...
You gain 34 hit points
Tongue of the Walrus was successfully cast.
So... apparently it will loop if trying to remove bad effects and there isn't enough meat to do it?
 
Last edited:

Allucaneet

New member
First of all, do you have "Free disco rest" checked in the Mafia HP/MP Usage tab, or in relay_Universal_Recovery.ash, and what is "Use free disco rests for" set to in relay_Universal_Recovery.ash?
  • You authorized Mafia to use free rests for HP and/or MP
  • You have a dwelling OR you are in a BHY run
  • You have free rests left
  • You HP/MP is lower than the target HP/MP
  • You will not waste HP/MP by getting more than your max from resting
  • "Use free disco rests for" is set to HP/MP OR you won't waste MP when resting to gain HP OR you won't gain more than half your missing HP when resting to gain MP

The first four are okay. Perhaps the problem is in the fifth and sixth. I'll waste HP when resting to gain MP. I'll lower my target HP then.
 
Last edited:

Bale

Minion
I'm not going to have much time to take a look at either of these issues until Monday. Sorry, but I've got a very long very fun weekend planned. Probably slyz will have everything figured out before then. (He's amazing!)
 
I wont be able to supply any more debugging for the deal where it consumes MMJ and casts tongue instead of using a scroll of healing as that char has ascended (into a pasta run so i can get cocoon)
 
I seem to be getting this error a lot today:

Invalid line in data file: "banana spritzer 0 0 40 100 0.0 70.0" (Universal_recovery.ash, line 137)

and this:

Invalid line in data file: "carbonated soy milk 0 0 70 80 0.0 75.0" (Universal_recovery.ash, line 137)
 
Top