Universal Recovery Script

StormCrow42

Member
Current HP: 11, current MP: 2... restoring HP! Target = 25
Internal error: Unary minus can only be applied to numbers (Universal_recovery.ash, line 270)
Autorecovery failed.

Current HP: 11, current MP: 2... restoring MP! Target = 10
Internal error: Unary minus can only be applied to numbers (Universal_recovery.ash, line 270)
Autorecovery failed.
 

Bale

Minion
I'm assuming you mean -maxval[value] in this particular case :p Also, you could potential do away with the maxval map altogether and just sort with 'sort options by -heal[value].maxhp;' and 'sort options by -heal[value].maxmp;' in the two separate sections.

Are you sure about that? I admit I don't entirely understand the syntax for sort.

some stuff in quotes, so I can't just quote it.
Ug. I guess he's right. Do as he suggested. I'll churn out 2.43
 

Bale

Minion
Universal recovery v 2.43 released!

Thanks for that juyes. A little bit of testing shows that it works best exactly as you suggested. A couple of lines and a map reference are removed. I now understand a lot more about how to use sort. The script is now faster.
 

juyes

New member
Are you sure about that? I admit I don't entirely understand the syntax for sort.

Yes, I'm sure, and I'll explain how I think about sort.

Firts, the syntax for sort is:
sort map by expression

map: is any map that associates keys (indices) with returned values
expression: is an expression evaluated for each item in map

To do the sort, mafia considers each item in the map one at a time and computes the expression for that item. Then the result of the expression for that item determines where it gets sorted to. To build the expression you have access to two 'special' variables.

index: refers to the key of the item under consideration
value: refers to the value of the item under consideration

In this case, map is:
item [int] options
so index refers to the int key and value refers to the returned item.

and the proper expression is:
-maxval[value]
which looks the item up in the maxheal map to get the integer maxhp/mp, and then takes the negative so big values become small ones.

If you instead did the sort inside the hp section, you could directly get away with this:
sort options by -heal[value].maxhp;
without needing the second maxval map. It just looks up the item directly in the heal map, grabs the maxhp field, and then reverses the order.

Does that make more sense?

Cheers, juyes

Edit: ninja'd, because it looks like you figured it all out before my message, but it may help other people
 
Last edited:

Braska

Member
I've found a small problem... though it might not be with the program, yet to figure it out. I just ascended as a sauceror under a myst sign, (for the hobocode and a HC perm skill), and mafia is no longer automating my adventures. I've had to do everything manually, because Universal Recovery is trying to use MMJ, which I don't have access to yet. This is causing an error which makes all automation abort. While this is solved by leaving Universal Recovery off while adventuring until the MMJ is available, I'd still like to think there is a way to fix this.
 

Bale

Minion
You're right. That is an issue I should definitely deal with. I'm aware of that, but with Mojomuscular melody I can open the store early on and it ceases to be a problem, but not everyone can deal with that.

I've ignored it all this time since mafia does not track if your guild store is open and it didn't bother me. I should probably just detect it myself with a visit_url() and then do away with mmj if it isn't open. I'll do that for you right now:



Universal recovery v 2.44 released!

Changelog:
version 2.44 April 9, 2009
  • Will check to see if you can purchase mmj before buying any.

The down-side is that it will hit the server once each time it is run. I'll have to make a feature request in hopes that the devs will give me boolean store_open().
 

zarqon

Well-known member
I would LOVE a guild_store_available() function. It would be consistent with the equivalent functions for the white citadel and black market, and allow scripters to save server hits. Countless server hits in the case of this particular script, given its usefulness and popularity.
 

Bale

Minion
I would LOVE a guild_store_available() function. It would be consistent with the equivalent functions for the white citadel and black market, and allow scripters to save server hits. Countless server hits in the case of this particular script, given its usefulness and popularity.

I was sure I couldn't be the only one. :) Well I made the feature request so go and back me up. So far we have a 100% success rate when we're united. ;)
 

Braska

Member
Thank you very much. Like I said, it was easy enough to disable it until the guild was open, but convenience is always appreciated. :)
 

slyz

Developer
Hi, i just wanted to post a rather strange behavior i was having since getting v2.43:


Current HP: 120, current MP: 66... restoring HP! Target = 173
Current HP: 120, current MP: 66... restoring MP! Target = 136
Purchasing black cherry soda (8 @ 80)...
You acquire black cherry soda (8)
Purchases complete.
Using 8 black cherry soda...
You gain 81 Mojo Points
Finished using 8 black cherry soda.
Casting Disco Nap 3 times...
You gain 60 hit points
Disco Nap was successfully cast.

Wouldn't Disco Power Nap be more MP efficient than 2 Disco Naps ? I hadn't realised the script was doing this until today (I got the Power Nap a few days ago).

It also seemed to ignore that i had "Do not auto recover mana"

In this other example, it did cast Disco Power Nap (the setting for MP was "Auto recover at 10%" but it stilled recovered MP)


> Current HP: 95, current MP: 127... restoring HP! Target = 133
> Current HP: 95, current MP: 127... restoring MP! Target = 132

buy 1 black cherry soda at market price from Black Market
You acquire an item: black cherry soda

use 1 black cherry soda
You gain 11 Mojo Points

cast 1 Disco Power Nap
You gain 40 hit points


Maybe i didn't pay enough attention to this thread, and the script tries to end the healing process with as many MP as when it started.

I'm not sure this will be very helpful, since i didn't try to understand the script yet, but let me know if you think this actually isn't the expected behavior, and if there is any other information you want (i'm in HC by the way).

Many thanks to your hard work !
 

Bale

Minion
Wouldn't Disco Power Nap be more MP efficient than 2 Disco Naps ? I hadn't realised the script was doing this until today (I got the Power Nap a few days ago).
That's truly interesting! 3*8 = 2* 24, so to heal 60 HP, it settled on the first one in the list. Obviously a bad choice and I'm going to have to take care of that, but this is a really intersting bug.

It also seemed to ignore that i had "Do not auto recover mana"
That's troubling. I found a round off bug that would cause it to restore if you had very low HP/MP, but I fixed that bug in 2.4. Can you please verify that it insists on restoring your mana when restoration is turned off? If so, please tell me your current MaxHP and MaxMP.

In this other example, it did cast Disco Power Nap (the setting for MP was "Auto recover at 10%" but it stilled recovered MP)


> Current HP: 95, current MP: 127... restoring HP! Target = 133
> Current HP: 95, current MP: 127... restoring MP! Target = 132

buy 1 black cherry soda at market price from Black Market
You acquire an item: black cherry soda

use 1 black cherry soda
You gain 11 Mojo Points

cast 1 Disco Power Nap
You gain 40 hit points


Maybe i didn't pay enough attention to this thread, and the script tries to end the healing process with as many MP as when it started.

I'm not sure this will be very helpful, since i didn't try to understand the script yet, but let me know if you think this actually isn't the expected behavior, and if there is any other information you want (i'm in HC by the way).

Many thanks to your hard work !
This is honestly very weird to me. It is things like that which make me regretful I turned off the extra gCLI output. I'm going to have to think about why it would possibly do that. Once again, what are your maxHP and MaxMP? What are your auto-restore values set at?
 

pioupiou

New member
That's troubling. I found a round off bug that would cause it to restore if you had very low HP/MP, but I fixed that bug in 2.4. Can you please verify that it insists on restoring your mana when restoration is turned off? If so, please tell me your current MaxHP and MaxMP.

This is honestly very weird to me. It is things like that which make me regretful I turned off the extra gCLI output. I'm going to have to think about why it would possibly do that. Once again, what are your maxHP and MaxMP? What are your auto-restore values set at?

I have the same exact problem on all my accounts (4 different ones, with very different maxHP and maxMP : for example a lvl 20 pastamancer (around 30 Hp I guess and something like 750 Mp) and a lvl 7 disco bandit in bad moon (hp around 50 and mp around 35).

The script insists on almost maxing MP after healing, even if Mp is set to not auto-recover. It happens if it auto-recovers and if I manually click on the HP link to heal. It was only annoying in bad moon where it costed me all my early meat....

Don't hesitate to ask if you need some precise facts.

Pioupiou
 

Bale

Minion
Universal recovery v 2.45 released!

Changelog:
version 2.45 April 9, 2009
  • Thanks to palipitations I found a bug that appears if you have no healing skills. It's fixed now!

Still looking into problems reported by pioupiou and slyz.
 

pioupiou

New member
Another anomaly : it keeps pretending it can't heal beaten up
You've had the crap beaten out of you... attempting to find some more crap.
Unable to cure beaten up! Go sewer or adventure someplace wussier.
Insufficient health to continue (auto-abort triggered).
I have tongue of the walrus HP perm and enough MP to cast it....
It has happened several times with the new script...
 

Muhandes

Member
No idea if this is something with the script or with mafia. From some reason even though I had 20 goblin seltzers, it went and bought more instead of using what I have.

Code:
Current HP: 121, current MP: 1... restoring MP! Target = 58
Using 5 Knob Goblin seltzer...
You gain 47 Muscularity Points
Finished using 5 Knob Goblin seltzer.
Saving outfit Backup...
Outfit saved
Putting on Knob Goblin Elite Guard Uniform...
Equipment changed.
Purchasing Knob Goblin seltzer (3 @ 80)...
You acquire Knob Goblin seltzer (3)
Purchases complete.
Putting on Backup...
Equipment changed.
Using 1 Knob Goblin seltzer...
You gain 11 Muscularity Points
Finished using 1 Knob Goblin seltzer.

> inv goblin sel

Knob Goblin seltzer (21)
 

tOaDeR

Member
for some reason i keep getting this
Code:
Current HP: 145, current MP: 327... restoring HP! Target = 404
Division by zero (Universal_recovery.ash, line 684)
Autorecovery failed.

it has no problem recovering MP, just HP. any idea why?
 
Last edited:

Bale

Minion
for some reason i keep getting this
Code:
Current HP: 145, current MP: 327... restoring HP! Target = 404
Division by zero (Universal_recovery.ash, line 684)
Autorecovery failed.

it has no problem recovering MP, just HP. any idea why?
I believe that is the bug I fixed in 2.45 that only crops up if you have no healing skills. Are you using version 2.45? Do you have healing skills?

OK, once again, I am asking a dolt question. What are the recommended settings for the integers?
I'm sorry, but I don't understand your question. What integers are being set?
 

palpitations

New member
From some reason even though I had 20 goblin seltzers, it went and bought more instead of using what I have.

I just came here to report this.

Code:
Current HP: 33, current MP: 24... restoring HP! Target = 66
Current HP: 33, current MP: 24... restoring MP! Target = 56
Using 2 Knob Goblin seltzer...
You gain 19 Mojo Points
Finished using 2 Knob Goblin seltzer.
Saving outfit Backup...
Outfit saved
Putting on Knob Goblin Elite Guard Uniform...
Equipment changed.
Purchasing Knob Goblin seltzer (6 @ 80)...
You acquire Knob Goblin seltzer (6)
Purchases complete.
Putting on Backup...
Equipment changed.
Using 2 Knob Goblin seltzer...
You gain 22 Mojo Points
Finished using 2 Knob Goblin seltzer.
Casting Disco Nap 2 times...
You gain 40 hit points
Disco Nap was successfully cast.

I had 19 in inventory at the end of everything.

Thanks again for all your work on this, Bale!
 
Top