Universal Recovery Script

muczachan

Member
> call scripts/Universal_recovery.ash

Undefined reference to function 'max' (Universal_recovery.ash, line 422)

Are you using some outside library for this function, possibly? (Today's version: 3.41)
 

Bale

Minion
I'm glad. Most of those improvements don't fix any problems. They just make the code a little bit cleaner and faster. I feel that fewer lines to do the same thing is an improvement.
 

shoptroll

Member
I'm glad. Most of those improvements don't fix any problems. They just make the code a little bit cleaner and faster. I feel that fewer lines to do the same thing is an improvement.

Cleaner and faster is always a good thing. Downloading :)
 

Spiny

Member
The change that Jason did recently allowed the script to purchase some of the desired quantity of items needed if I had insufficient meat to purchase the complete quantity. The loop I was encountering has, in effect, been dealt with. The problem now is that the purchased quantity of restoratives is not actually being used.

Example:

I need 8 MMJs.. I have 200 meat, script seeks to buy 8, buys 2, tries to use 8, says I don't have enough meat, ends.

Rerunning the script with those 2 MMJs on hand and no more meat on hand, it tries to use 8, tells me I don't have enough meat, ends.

Manually using those 2 MMJs restored enough to allow me to auto-adventure again.

Code:
_BalesUniversalRecovery => 3.41
86 prices updated from http://zachbardon.com/mafiatools/updateprices.php?action=getmap
0 prices updated from http://nixietube.info/mallprices.txt
Pricelist updated.
Restoring MP! Currently at 806 of 806 HP, 1092 of 1491 MP... Target MP = 1491, current meat: 0.
In mallmode, best MP restorative is: magical mystery juice @ 752.8302 meat total.
Trying to use 8 magical mystery juice
Searching for magical mystery juice...
Desired purchase quantity not reached (wanted 8, got 0)
Failed to use an item from the mall.
Current HP: 806, MP: 1092
In mallmode, best MP restorative is: magical mystery juice @ 752.8302 meat total.
Trying to use 8 magical mystery juice
Running out of meat! Time to take some out of the closet...

Requests complete.

> closet take 200 meat

Removing meat from closet...
Requests complete.

Restoring MP! Currently at 806 of 806 HP, 1092 of 1491 MP... Target MP = 1491, current meat: 200.
In mallmode, best MP restorative is: magical mystery juice @ 752.8302 meat total.
Trying to use 8 magical mystery juice
Purchasing magical mystery juice (2 @ 100)...
You acquire magical mystery juice (2)
Desired purchase quantity not reached (wanted 8, got 2)
You need 6 more magical mystery juice to continue.
Failed to use an item from the mall.
Current HP: 806, MP: 1092
In mallmode, best MP restorative is: magical mystery juice @ 752.8302 meat total.
Trying to use 8 magical mystery juice
Running out of meat! Time to take some out of the closet...

Requests complete.

Restoring MP! Currently at 806 of 806 HP, 1092 of 1491 MP... Target MP = 1491, current meat: 0.
In mallmode, best MP restorative is: magical mystery juice @ 752.8302 meat total.
Trying to use 8 magical mystery juice
Running out of meat! Time to take some out of the closet...

Requests complete.

> use 2 MMJ

Using 2 magical mystery juice...
You gain 106 Mana Points
Finished using 2 magical mystery juice.
Validating adventure sequence...
Condition set: broken petri dish (40)
broken petri dish (40)
Requests complete.

Visit to Lab: Knob Goblin Laboratory in progress...
Changing auto-attack: attack with weapon

[27084] Knob Goblin Laboratory
Encounter: Knob Goblin Mad Scientist
Strategy: attack with weapon
Round 0: Genevieve Alfredo loses initiative!
Round 1: Genevieve Alfredo attacks!
Round 2: Genevieve Alfredo attacks!
Round 3: Genevieve Alfredo attacks!
Round 3: Got spits on your opponent. Yech.
Round 4: Genevieve Alfredo attacks!
Round 5: Genevieve Alfredo attacks!
Round 5: Got spits on your opponent. Yech.
Round 5: A smile crosses Got's serene countenance.
Round 5: knob goblin mad scientist takes 566 damage.
You gain 80 Meat
You acquire an item: Knob Goblin steroids
You acquire an item: broken petri dish
You gain 4 Muscleboundness
You gain 8 Mysteriousness
You gain 3 Sarcasm
 

Bale

Minion
I never realized that use() would work that way. I believed that if told to use 8 items and it only had 2, it would use those 2 rather than fail without using any. The simplest solution would probably be cli_execute("use "+q+" "+it) although it annoys me to insert a cli equivalent of an ash command. I'm going to think about the best way to do that. Probably run some tests to verify to my satisfaction that use() really works like that.

In the meantime I'd recommend making the change to the function use_mall(int q, item it). Replace use_inv(q, it) with cli_execute("use "+q+" "+it).
 

Bale

Minion
I see. Then you've already had to deal with that foolishness. I think my cli_execute() solution seems simpler than your...

Code:
   if (item_amount(doodad) >= n || (purchase && retrieve_item(n, doodad))) return use(n, doodad);
   if (item_amount(doodad) == 0) return false;
   return use(item_amount(doodad), doodad);

Do you see any obvious problems with cli_execute("use "+q+" "+it)?
 

jasonharper

Developer
Any attempt to use a specific number of an item will involve retrieving that many of the item, and will fail if the retrieval fails. This works EXACTLY the same for both the ASH and CLI versions of commands, so I have no idea why you'd expect your cli_execute() to solve the problem.

Since this is apparently happening in the context of a function that buys the items to be used, why not pass the return value of buy() as the first parameter to use()?
 

zarqon

Well-known member
Sorry, I was under the mistaken impression that you were importing ZLib, so I wanted to let you know use_upto() was available. But after looking at the script just now I saw that you just pasted some ZLib functions in there rather than import it.
 

Bale

Minion
Having just freed the king I did a little bit of testing which revealed exactly what Jason wrote. I did my testing before reading. I've just never seen this behavior before since I've never had no meat in aftercore. Somehow I was under the impression that if I typed a use command in the CLI, it would use as many as it could.

Sorry, I was under the mistaken impression that you were importing ZLib, so I wanted to let you know use_upto() was available. But after looking at the script just now I saw that you just pasted some ZLib functions in there rather than import it.
Yep. I did that to ensure minimal execution time. I only use 1 of zlib's functions, so I don't use it. I just give you credit in the comments.

I figured you just pointed out zlib to offer an example of how you handled the problem. It was good to see.
 
Last edited:

Bale

Minion
Universal recovery v 3.411 released!


Changelog:
version 3.411 October 26, 2009
  • very minor bug fixed
  • minor efficiency improvements


Spiny, thanks for tracking down yet another obscure bug that only occurs when someone has no meat on hand in aftercore. Since this bug is fairly obscure I set the new version number such that automatic update won't interrupt anyone's restoration with a pop-up.
 
Last edited:

Spiny

Member
Thanks Bale! This might have done the trick :D I ascended my myst account earlier today, but I did a quick little test with Spiny and I think it might be ok... as always, I'll keep you posted ;)
 

zarqon

Well-known member
I see. In that case, you could minimize runtime by a few more ms by hardcoding the filename in update_heal_map()!

use_upto() still isn't ideal since it returns the nearly worthless result of use(). I suppose I could note the number in inventory beforehand and then return whether the amount had decreased appropriately, but that still wouldn't work for items that are not consumed upon use. Meh.

This bit made me chuckle:

Code:
	// That's enough of zarqon. Now update current price list
	cli_execute("update prices http://zachbardon.com/mafiatools/updateprices.php?action=getmap");

That's enough of zarqon... now, let's load some information from his server using a script that he wrote. :)
 

Bale

Minion
Lol! Yeah, there was originally some other stuff there and the marker between stuff zarqon wrote and stuff you didn't write was more meaningful. I just didn't properly update the comment. ;)

I see. In that case, you could minimize runtime by a few more ms by hardcoding the filename in update_heal_map()!
Probably. I figure though that there is a much more noticable difference of having to verify zlib.ash every time my script is called. And I don't want my users to have to download more than 1 file if it isn't necessary. Serious question: Does it bother you?

use_upto() still isn't ideal since it returns the nearly worthless result of use(). I suppose I could note the number in inventory beforehand and then return whether the amount had decreased appropriately, but that still wouldn't work for items that are not consumed upon use. Meh.
It would be more meaningful to return an integer. That way the user could make use of the exact number that had been used.
 

zarqon

Well-known member
I share my scripts so that others may find them useful, not to inflate my ego or to get lots of meat. (I have received one Mr. A for all my scripting work, and it was a pleasant surprise!) So no, it doesn't bother me. Rather, I'm glad you found the functions useful.

I may just make that change to use_upto(), but that might screw up some dependent scripts. I'll ask in the ZLib thread.
 

Heffed

Member
The latest version is failing on my DB.

Bad item value: "medicinal herbs" (Universal_recovery.ash, line 603)
Bad item value: "medicinal herbs" (Universal_recovery.ash, line 603)
Autorecovery failed.
 

Bale

Minion
I cannot imagine why that would fail. I haven't even changed that part of the program. Are you sure you aren't having a problem with mafia?

Checking this in the CLI, ash item_amount($item[medicinal herbs]) does not yield a bad item value error.
 
Top