Universal Recovery Script

heeheehee

Developer
Staff member
The weirdest part is that line 1446 isn't even in a foreach loop. And it doesn't modify any maps (or variables, for that matter) -- it's an if statement!

Edit: Ninja'd somehow.
 

Bale

Minion
heeheehee, I'm reverse stalking you again!

There is a foreach loop that ends just before 1446, but it doesn't modify the map there. Completely implausible.
 

Spiny

Member
WTF? Please confirm for me that your line 1446 is this:

Code:
		if(reserve_purch == reserve || heal[reserve].minmp < heal[reserve_purch].minmp)

Even if that's wrong, there isn't any line anywheres near that line that modifies the map within a foreach. That error seems completely implausible

Yep that's the line, so I don't know what happened. I just copied and pasted as it appeared from CLI and then I got into the cage for coat run, so hard to say. The person that usually runs that account doesn't use UR and I probably won't be on that account again in the near future, but I thought I'd mention what happened just in case some fluke occurred. It was mafia r8440 too if that matters :)
 

Bale

Minion
That character was in the cage? Honestly I still don't understand the error, but that situation creates so many strange problems that it must be the cause.
 

Spiny

Member
Nono, not in the cage yet. I logged in, set up UR, pasted stuff, then when about my business to get into the cage :) Cage has nothing to do with what I posted at all. Sorry for the confusion. Just saying I can't get back to the account to try to duplicate the situation anytime soon :)
 

xKiv

Active member
FWIW, I think accessing heal[X] might modify the heal map even if it's not an assignment - if the X key is not in the map yet, it will try to autovivify (i.e. put a new record under that key).
But that still doesn't explain why it throws that error *outside* of the loop.
 
WTF? Please confirm for me that your line 1446 is this:

Code:
		if(reserve_purch == reserve || heal[reserve].minmp < heal[reserve_purch].minmp)

Even if that's wrong, there isn't any line anywheres near that line that modifies the map within a foreach. That error seems completely implausible.

I don't think any of that are things that I want to have a script making decisions about. I don't think any of those are applicable for a recovery script either.

Well... maybe I'd consider the aftercore slimeling since I can tell when it's running out of charges if it is a simple as feeding it antiques from the mall. Is it really that simple?

the collections on the wiki suggest that it is, and since every comparable item smashes to 3 wads
It's pretty complicated. You could check the pulverize results in the mall and go backwards. You'll get hot, twinkly, and useless powders and twinkly nuggets at autosell, and go through those. 2-4 powder stuff is complicated. I don't see anything being better than antiques, though

the alternatives are lihc face, spiked femur, flaming crutch, skeleton bone, some others, and the pulverize results, which is the whole point, decrease faster than the slimeling charges, and then there's below mall prices...
 
Last edited:

slyz

Developer
If Bale is considering it for aftercore (with a false option by default, please, and only when the slimeling is equipped and after checking slimelingFullness), it's pretty straightforward.

I don't really know how the MP that will be generated by the slimeling would be counted towards UR's goal MP (I guess it just won't), so you might want to just fix a slimelingFullness that you want your slimeling to be fed all the time.

I do feel this would be more appropriate as a separate mood or BetweenBattle script though.
 

Bale

Minion
I do feel this would be more appropriate as a separate mood or BetweenBattle script though.

I think that is best. I think I'll write that script -- it shouldn't be hard if it only works in aftercore and only feeds antiques. Expect me to present the first draft of the Slimeling.ash mood next week.
 

philmasterplus

Active member
Feature request

Could you please add a debug mode so that instead of healing right away, the script shows which HP/MP restorers it is going to use? Just hoping :)

Also, is it possible to force the mafia to heal using the script in the CLI? Would the restore mp command automatically use this script after registering it as instructed in the first post?
 

slyz

Developer
Could you please add a debug mode so that instead of healing right away, the script shows which HP/MP restorers it is going to use? Just hoping :)

You can change the verbosity of the script, but unless you modify the script yourself, there isn't any debug mode you can switch to.

Also, is it possible to force the mafia to heal using the script in the CLI? Would the restore mp command automatically use this script after registering it as instructed in the first post?

This script is called every time Mafia needs to restore HP and/or MP, including when the CLI command is used.
 

Bale

Minion
Could you please add a debug mode so that instead of healing right away, the script shows which HP/MP restorers it is going to use? Just hoping :)
I'm puzzled. You want it to explain what it would do, but leave you unhealed? Anyway, that would be extremely difficult since it often takes place in steps that change your HP and/or MP. I'd need to keep track of a running total of what your HP/MP would be if I did something. Normally I just use my_hp() and my_mp() to track those changes which is MUCH easier, but requires me to actually use the restoratives.

Also, is it possible to force the mafia to heal using the script in the CLI? Would the restore mp command automatically use this script after registering it as instructed in the first post?
restore mp and restore hp don't do exactly what you think. If you want to force the script to heal, I recommend that you make an alias:

Code:
alias restoration => ash restore_hp(0); restore_mp(0)
 

philmasterplus

Active member
I'm puzzled. You want it to explain what it would do, but leave you unhealed?

I was trying to determine the cheapest MP restorer in the mall. It looks like I'll have to write a script myself then. Does anyone know a script that does exactly that?

restore mp and restore hp don't do exactly what you think. If you want to force the script to heal, I recommend that you make an alias:

Code:
alias restoration => ash restore_hp(0); restore_mp(0)

Thank you.
 

heeheehee

Developer
Staff member
Doesn't this script create a map for efficiency of restorers?

Edit: Yeah, it's... recoveryScript_map_v2.txt?

It looks like it's a record keyed by string. More specifically, this record:
PHP:
record restorative_info {
	int minhp;
	int maxhp;
	int minmp;
	int maxmp;
	float avehp;
	float avemp;
	boolean combat;
};
(Record taken from the script.)
 
Last edited:

Winterbay

Active member
Hmm... I just fought Ed and as you can see I ended up with 3 HP (actually that was after the first turn since I forgot to use Noodles) and every round afterwards UR tries to restore my HP and fails (redirected to a fight page). After the battle is over it casts Lasagna 1 time gaining me 30HP and then stops. I then type "restore hp" in the CLI and it first manages to divide by 0 and then goes to Doc Galactic to heal up instead. Possibly not the most efficient way...

Code:
Restoring HP! Currently at 3 of 130 HP, 52 of 213 MP, current meat: 6787 ... Target HP = 124.
Casting Lasagna Bandages 1 times...
Redirected to a fight page.
Monster value: 0
Encounter: Ed the Undying
Round 0: winterbay wins initiative!
Monster value: 0
Round 1: winterbay jiggles the Staff of the Black Kettle
You gain 15 Strongness
You gain 43 Magicalness
You gain 22 Cheek
You gain a Moxie point!
You acquire an item: Holy MacGuffin
Restoring HP! Currently at 3 of 130 HP, 57 of 213 MP, current meat: 6787 ... Target HP = 124.
Casting Lasagna Bandages 1 times...
You gain 30 hit points
Lasagna Bandages was successfully cast.
You acquire an item: handful of confetti

> restore hp

Division by zero (Universal_recovery.ash, line 397)
Visiting Doc Galaktik...
Restoring HP! Currently at 33 of 130 HP, 51 of 213 MP, current meat: 6787 ... Target HP = 124.
Casting Lasagna Bandages 1 times...

Restore 90 HP at Doc Galaktik's
You gain 90 hit points
You spent 900 Meat
You gain 26 hit points
Lasagna Bandages was successfully cast.
Cure purchased.
 

Bale

Minion
Well this is just a whole hodgepodge of problems!

First of all, mafia does not know that the fight with Ed is continuing and erroneously calls UR. Blame mafia since mafia decided to call UR. (My script does nothing unless called by mafia.) Mafia does the same thing for the first and second forms of the NS. There's nothing I can do to correct that error since a script cannot tell if you are still in fight with Ed or it is over.

Then, my script is in the middle of an automated heal when you type "restore hp". It fails with a division by zero error and stops. That seems impossible since I already checked to see if heal[it].maxhp == 0 two lines earlier! WTF?!

Finally, the script attempts to execute your "restore hp" command and I'm totally flummoxed about what happens at that point since it starts casting lasagna bandages then goes to Doc Galaktik and then finishes casting lasagna bandages. WTF?!

A couple of days ago I actually added some code to limit unexpected amounts of Doc Galaktik restoration, but I'm seriously WTF about this whole chain of errors, especially the division by zero right after checking to see if it would be dividing by zero. I can only blame mafia, but it seems way too unlikely!
 

Winterbay

Active member
Yes, I went and looked at the code around the line quoted and could not find a reason for why it would divide by zero. I'll just hope it doesn't happen again :)
(which it shouldn't until the NS then I guess... :))
 

Spiny

Member
Ok... I'm finally trying to fire off UR with my BM account. I'm lv 8 and I haven't had reason to fire it off til now or I may have noticed this sooner. Anyhow, it's a sauce run and I have no hp restoratives on hand. I had restore hp from set to 40% til 100%. I did:

Code:
> restore both

Searching for "anti-anti-antidote"...
Purchasing anti-anti-antidote (4 @ 30)...
You acquire anti-anti-antidote (4)
You spent 120 Meat
Purchases complete.
0 prices updated from http://nixietube.info/mallprices.txt
Pricelist updated.
_meatpermp => 5.882353
_meatperhp => 6.6666665
_version_BalesUniversalRecovery => 3.7
Purchasing some magical mystery juices for use as a combat restorative.
Searching for "magical mystery juice"...
Purchasing magical mystery juice (4 @ 100)...
You acquire magical mystery juice (4)
You spent 400 Meat
Purchases complete.
Restoring HP! Currently at 24 of 66 HP, 43 of 124 MP, current meat: 17497 ... Target HP = 66.
Try to heal HP from inventory.
Try to heal HP with skills.
Last attempt to purchase HP with meat.
Restoring MP! Currently at 24 of 66 HP, 43 of 124 MP, current meat: 17497 ... Target MP = 124.
Try to heal MP from inventory.
Using 9 Mountain Stream soda...
You gain 68 Mana Points
Finished using 9 Mountain Stream soda.
Using 1 Mountain Stream soda...
You gain 9 Mana Points
Finished using 1 Mountain Stream soda.
Last attempt to purchase MP with meat.
Searching for "magical mystery juice"...
Purchasing magical mystery juice (1 @ 100)...
You acquire an item: magical mystery juice
You spent 100 Meat
Purchases complete.
Using 1 magical mystery juice...
You gain 18 Mana Points
Finished using 1 magical mystery juice.

I noticed it didn't heal me, so I tried restore hp after changing to max verbosity thru the relay interface with update and heal:

Code:
baleUr_Verbosity => 3
Calling Universal Recovery for type=HP, amount=0
Restoring HP! Currently at 24 of 66 HP, 124 of 124 MP, current meat: 17397 ... Target HP = 66.
Trying to fullheal
Try to heal HP from inventory.
Trying to fullheal
Try to heal HP with skills.
Last attempt to purchase HP with meat.

So I tried it your way:
Code:
> ash restore_hp(0);

Calling Universal Recovery for type=HP, amount=0
Restoring HP! Currently at 24 of 66 HP, 124 of 124 MP, current meat: 17397 ... Target HP = 66.
Trying to fullheal
Try to heal HP from inventory.
Trying to fullheal
Try to heal HP with skills.
Last attempt to purchase HP with meat.
Returned: true

And in the end I'm left scratching my head and still not healed. I have galaktik's nostrum and ailment ointments enabled. Is UR just saying I have no full heal spell, no full heal item and the other options aren't worth it? :)

Unrelated note to self: If I'd remembered I was a sauceror I would have had a potion running and not been in this situation to begin with lmao.

Edit2:

With only 1 hp missing and an explicit call:

Code:
> restore both

Calling Universal Recovery for type=HP, amount=71
Restoring HP! Currently at 70 of 71 HP, 10 of 115 MP, current meat: 16604 ... Target HP = 71.
Trying to fullheal
Visiting Doc Galaktik...

Restore 1 HP at Doc Galaktik's
You gain 1 hit point
You spent 10 Meat
Cure purchased.
Calling Universal Recovery for type=MP, amount=115
Restoring MP! Currently at 71 of 71 HP, 10 of 115 MP, current meat: 16594 ... Target MP = 115.
Try to heal MP from inventory.
Using 1 magical mystery juice...
You gain 18 Mana Points
Finished using 1 magical mystery juice.
Using 1 Mountain Stream soda...
You gain 8 Mana Points
Finished using 1 Mountain Stream soda.
Last attempt to purchase MP with meat.
Searching for "magical mystery juice"...
Purchasing magical mystery juice (5 @ 100)...
You acquire magical mystery juice (5)
You spent 500 Meat
Purchases complete.
Using 5 magical mystery juice...
You gain 89 Mana Points
Finished using 5 magical mystery juice.
_meatpermp => 5.4054055

Wonder why it would heal me this time, but not the prior time.
 
Last edited:

Aankhen

Member
Experiencing a strange problem with 3.7 in Mafia r8461, and I think it’s probably a Mafia bug but I wanted to confirm with you first.

I’m an HCNP DB with three palm fronds in my inventory. When the script is called, it decides to heal using a palm-frond fan. However, the call to use() doesn’t seem to work; adding a print() shows that there are still three palm fronds in my inventory afterwards, and zero palm-frond fans. As such, the script gets stuck in an infinite loop where it keeps trying to create a palm-frond fan and failing.

From what I can see, the call to use() is correct, and I’ve never experienced this problem before over the course of five ascensions, hence my pointing the finger at Mafia. All that’s changed is that I updated to r8461 yesterday (before which I didn’t have any palm fronds in my inventory).
 
Last edited:
Top