How to circumvent max_mp being reduced when shopping for restoration items

ereinion

Member
Using "restore_mp(to_int(my_maxmp()*0.9));" in an ash-script the following happened to me:
Code:
[COLOR=blue]Restoring mp to 3315[/COLOR]
Searching for "black      cherry soda"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing black cherry soda (326 @      76)...
You acquire black cherry soda (326)
You spent 24,776 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      326 black cherry soda...
You gain 3,247 Muscularity Points
Finished      using 326 black cherry soda.
Searching for "black cherry soda"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      black cherry soda (1 @ 76)...
You acquire an item: black cherry soda
You      spent 76 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 1 black cherry soda...
You gain 10 Muscularity Points
Finished      using 1 black cherry soda.
Searching for "Knob Goblin seltzer"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      Knob Goblin seltzer (12 @ 76)...
You acquire Knob Goblin seltzer (12)
You      spent 912 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 12 Knob Goblin seltzer...
You gain 111 Muscularity      Points
Finished using 12 Knob Goblin seltzer.
Searching for "Knob      Goblin seltzer"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing Knob Goblin seltzer (2 @      76)...
You acquire Knob Goblin seltzer (2)
You spent 152 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      2 Knob Goblin seltzer...
You gain 22 Muscularity Points
Finished      using 2 Knob Goblin seltzer.
Searching for "black cherry soda"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      black cherry soda (11 @ 76)...
You acquire black cherry soda (11)
You      spent 836 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 11 black cherry soda...
You gain 111 Muscularity      Points
Finished using 11 black cherry soda.
Searching for "black      cherry soda"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing black cherry soda (2 @      76)...
You acquire black cherry soda (2)
You spent 152 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      2 black cherry soda...
You gain 20 Muscularity Points
Finished using      2 black cherry soda.
Searching for "Knob Goblin seltzer"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      Knob Goblin seltzer (11 @ 76)...
You acquire Knob Goblin seltzer (11)
You      spent 836 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 11 Knob Goblin seltzer...
You gain 110 Muscularity      Points
Finished using 11 Knob Goblin seltzer.
Searching for "Knob      Goblin seltzer"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing Knob Goblin seltzer (2 @      76)...
You acquire Knob Goblin seltzer (2)
You spent 152 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      2 Knob Goblin seltzer...
You gain 21 Muscularity Points
Finished      using 2 Knob Goblin seltzer.
Searching for "black cherry soda"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      black cherry soda (11 @ 76)...
You acquire black cherry soda (11)
You      spent 836 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 11 black cherry soda...
You gain 110 Muscularity      Points
Finished using 11 black cherry soda.
Searching for "black      cherry soda"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing black cherry soda (2 @      76)...
You acquire black cherry soda (2)
You spent 152 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      2 black cherry soda...
You gain 19 Muscularity Points
Finished using      2 black cherry soda.
Searching for "Knob Goblin seltzer"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      Knob Goblin seltzer (11 @ 76)...
You acquire Knob Goblin seltzer (11)
You      spent 836 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 11 Knob Goblin seltzer...
You gain 105 Muscularity      Points
Finished using 11 Knob Goblin seltzer.
Searching for "Knob      Goblin seltzer"...
Search complete.
Putting on Travoltan      trousers...
Equipment changed.
Purchasing Knob Goblin seltzer (3 @      76)...
You acquire Knob Goblin seltzer (3)
You spent 228 Meat
Purchases      complete.
Putting on Jeans of Loathing...
Equipment changed.
Using      3 Knob Goblin seltzer...
You gain 29 Muscularity Points
Finished      using 3 Knob Goblin seltzer.
Searching for "black cherry soda"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      black cherry soda (10 @ 76)...
You acquire black cherry soda (10)
You      spent 760 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 10 black cherry soda...
You gain 97 Muscularity Points
Finished      using 10 black cherry soda.
Searching for "black cherry soda"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      black cherry soda (3 @ 76)...
You acquire black cherry soda (3)
You      spent 228 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 3 black cherry soda...
You gain 28 Muscularity Points
Finished      using 3 black cherry soda.
Searching for "Knob Goblin seltzer"...
Search      complete.
Putting on Travoltan trousers...
Equipment changed.
Purchasing      Knob Goblin seltzer (10 @ 76)...
You acquire Knob Goblin seltzer (10)
You      spent 760 Meat
Purchases complete.
Putting on Jeans of Loathing...
Equipment      changed.
Using 10 Knob Goblin seltzer...
You gain 96 Muscularity      Points
Finished using 10 Knob Goblin seltzer.
Searching for "Knob      Goblin seltzer"...
Search complete.
Putting on Travoltan      trousers...
[COLOR=red]KoLmafia declares world peace.[/COLOR]
You      acquire Knob Goblin seltzer (4)
You spent 304 Meat
The reason this happened was that my max mp wearing the Travoltan Trousers is 3184 < 3315 which is my 90% of max mp when wearing the jeans of loathing. Is there any easy way to circumvent this problem, and does the same thing happen if the mafia's restorer function is called from outside a script too (I assume not, or there would probably be a few more people complaining :))?
 

Veracity

Developer
Staff member
Easy solution: put your Travoltan Trousers in the closet. Used to be, hola had it coded to not bother using them outside of Ronin. I removed that, since the only time I CAN use them is outside of Ronin. I've save thousands - maybe even hundreds - of Meat since I made that change. :)

The bigger issue is that for restores with a variable yield, KoLmafia didn't buy enough to guarantee it'd be able to reach its target without having to go back and buy more. I suppose it could buy enough to reach its target assuming minimum yield - but I guarantee that we'd get bug reports from people complaining that it had bought extras.
 

ereinion

Member
So, you're adding on to this bug report then?
I suppose. I wouldn't exactly call it a bug though, since each part of what happens is what's intended. I just wondered if anyone else had come across this in their script-writing, and if there was any obvious way to circumvent it (other than just closeting the trousers :)). I guess I could have been more explicit in my orginal post.
 

Bale

Minion
if there was any obvious way to circumvent it (other than just closeting the trousers :)).

Yup! Use the whatif command!

Code:
int maxhp = my_maxhp();
int maxmp = my_maxmp();
if(available_amount($item[Travoltan trousers]) > 0) {
	cli_execute("whatif equip Travoltan trousers; quiet");
	maxhp = numeric_modifier("_spec", "Buffed HP Maximum");
	maxmp = numeric_modifier("_spec", "Buffed MP Maximum");
}
restore_mp(to_int(maxmp*0.9));
 

ereinion

Member
Thanks - I didn't know of that command, but if I'd read a bit further in the bug-report thread (or thought a bit harder in the first place) I think I might have come up with something :) Anyway, I went with this small modification of the code you posted:
Code:
int mp_to_restore_to;
// Figure out what mp to restore to
        if(available_amount($item[Travoltan trousers]) > 0) {
            cli_execute("whatif unequip pants");
            mp_to_restore_to = min(to_int(numeric_modifier("_spec", "Buffed MP Maximum")), to_int(0.9*my_maxmp()));
        } else {
            mp_to_restore_to = 0.9*my_maxmp();
        }
I haven't tested it yet, but I think it should work unless I've overlooked something obvious :)
 
Top