Bug - Waiting for Info MP Restoration and Equipment Changing (Travoltan Trousers mostly)

Here's an example of how this can happen:

Imagine a level [insert level] [insert class], with at least 200 in all stats. Now imagine this character wearing Hodgman's lobsterskin pants, and having Travoltan trousers. Try to restore MP, with recover MP to 100% set, and less than 100% MP. Watch what happens.

A summary of the bug:
A combination of a recent change to KoLmafia to permit it to use Travoltan trousers in aftercore, combined with its tendency to underestimate how many restoratives are required to fully restore MP, causes it to get into a loop:
1. Switch equipment
2. Buy restoratives
3. Use restoratives
4. Check - is MP full?
5. No, go back to step 1

... which of course wastes valuable Meat, and the only way to break out of it is to tell KoLmafia to abort what it's doing and manually restore via the relay browser.
 

Theraze

Active member
Or... y'know... don't require it to get to 100% restoration. Or disable equipment changing. It's your own fault for doing mutually exclusive settings. :)
 

fronobulax

Developer
Staff member
In fairness to the OP, it requires a certain amount of analysis to realize that they are mutually exclusive.
 

Fluxxdog

Active member
Honestly, I think the OP proved they aren't exclusive. I have a script that attempts to reduce mana cost without wasting MP by losing MP just from switching gear. It uses a series of checks against cli_execute("speculate") to make sure the new max MP isn't less than the current MP I have. For example, if I have 1000 MP and swapping out an item would drop me to 400 MP, then it doesn't change it.

From what the OP is describing, step 3.5 is "switch equipment back" which causes a changes in max MP values, which can lower MP below max MP. Shouldn't 3.5 be at 2.5 or does mafia do it differently? wrldwzrd89! Can you post a snippet of your log that shows this happening?
 

Theraze

Active member
The issue, Fluxxdog, is that most restoratives have a range of restoring. This was actually one of the first feature requests I made a patch for... Since Seltzers restore 8-12 MP, if you purchase enough for what mafia expects (10), you have a ~40% chance that it will fail and need to go buy more. Every time. The patch just turned Seltzers to officially restore 8 instead, so you'll definitely buy enough...
 
Honestly, I think the OP proved they aren't exclusive. I have a script that attempts to reduce mana cost without wasting MP by losing MP just from switching gear. It uses a series of checks against cli_execute("speculate") to make sure the new max MP isn't less than the current MP I have. For example, if I have 1000 MP and swapping out an item would drop me to 400 MP, then it doesn't change it.

From what the OP is describing, step 3.5 is "switch equipment back" which causes a changes in max MP values, which can lower MP below max MP. Shouldn't 3.5 be at 2.5 or does mafia do it differently? wrldwzrd89! Can you post a snippet of your log that shows this happening?
equip pants Travoltan trousers

buy 22 magical mystery juice at market price from Gouda's Grimoire and Grocery
You acquire magical mystery juice (22)
You spent 2,090 Meat

equip pants Hodgman's lobsterskin pants

use 22 magical mystery juice
You gain 796 Mana Points

equip pants Travoltan trousers

buy 1 magical mystery juice at market price from Gouda's Grimoire and Grocery
You acquire an item: magical mystery juice
You spent 95 Meat

equip pants Hodgman's lobsterskin pants

use 1 magical mystery juice
You gain 35 Mana Points

equip pants Travoltan trousers

buy 16 black cherry soda at market price from Black Market
You acquire black cherry soda (16)
You spent 1,216 Meat

equip pants Hodgman's lobsterskin pants

use 16 black cherry soda
You gain 161 Mana Points

equip pants Travoltan trousers

buy 4 black cherry soda at market price from Black Market
You acquire black cherry soda (4)
You spent 304 Meat

equip pants Hodgman's lobsterskin pants

use 4 black cherry soda
You gain 41 Mana Points
outfit Knob Goblin Elite Guard Uniform

buy 16 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (16)
You spent 1,280 Meat
custom outfit Backup

use 16 Knob Goblin seltzer
You gain 166 Mana Points
outfit Knob Goblin Elite Guard Uniform

buy 3 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (3)
You spent 240 Meat
custom outfit Backup

use 3 Knob Goblin seltzer
You gain 33 Mana Points

equip pants Travoltan trousers

buy 42 soda water at market price from Market Demon
You acquire soda water (42)
You spent 2,772 Meat

equip pants Hodgman's lobsterskin pants

use 42 soda water
You gain 178 Mana Points

equip pants Travoltan trousers

buy 6 soda water at market price from Market Demon
You acquire soda water (6)
You spent 396 Meat

equip pants Hodgman's lobsterskin pants

use 6 soda water
You gain 26 Mana Points

equip pants Travoltan trousers

buy 5 magical mystery juice at market price from Gouda's Grimoire and Grocery
You acquire magical mystery juice (5)
You spent 475 Meat

equip pants Hodgman's lobsterskin pants

use 5 magical mystery juice
You gain 180 Mana Points

equip pants Travoltan trousers

buy 1 magical mystery juice at market price from Gouda's Grimoire and Grocery
You acquire an item: magical mystery juice
You spent 95 Meat

equip pants Hodgman's lobsterskin pants

use 1 magical mystery juice
You gain 37 Mana Points

equip pants Travoltan trousers

buy 16 black cherry soda at market price from Black Market
You acquire black cherry soda (16)
You spent 1,216 Meat

equip pants Hodgman's lobsterskin pants

use 16 black cherry soda
You gain 160 Mana Points

equip pants Travoltan trousers

buy 4 black cherry soda at market price from Black Market
You acquire black cherry soda (4)
You spent 304 Meat

equip pants Hodgman's lobsterskin pants

use 4 black cherry soda

... (more logs omitted)
 
Last edited:

Fluxxdog

Active member
Wow.

The problem seems mafia doesn't check to see if it'll lose MP if it changes outfits, which is causing the cycle of wasted meat. It keeps trying to replace MP that it's losing from removing the lobsterskin pants (which give +20% mys).

The question is then does wrldwzrd have the patch? Is this an outdated version issue?
 

Fluxxdog

Active member
Then that means it's not buying enough restorers to 100% MP if all the items gave minimal value. Was that patch just Seltzers or every MP item?
 

Theraze

Active member
The patch I made was just Seltzers. The person was getting annoyed by switching back and forth to buy seltzers 2-3 times, and I agreed (and left the patch in my personal copy).

The issue that wrldwzrd89 is having is that changing gear to do his healing drops his max... he fills up, then changes back to adventuring gear, which has a higher cap, and isn't full. The fix is either turning off equipment for buffs, or dropping the request for 100% healing down to 80% or 90% unless there's a HUGE reason why you need that extra bit of mana. With health, lobstermen, Lord Spookyraven, and other such mobs may be a valid reason for wanting to be fully healed up... but for mana? If you have enough to finish off your fight regardless of if it'll take 1 round or 10, what does it really matter if it's full or not? *shrugs*
 
The patch I made was just Seltzers. The person was getting annoyed by switching back and forth to buy seltzers 2-3 times, and I agreed (and left the patch in my personal copy).

The issue that wrldwzrd89 is having is that changing gear to do his healing drops his max... he fills up, then changes back to adventuring gear, which has a higher cap, and isn't full. The fix is either turning off equipment for buffs, or dropping the request for 100% healing down to 80% or 90% unless there's a HUGE reason why you need that extra bit of mana. With health, lobstermen, Lord Spookyraven, and other such mobs may be a valid reason for wanting to be fully healed up... but for mana? If you have enough to finish off your fight regardless of if it'll take 1 round or 10, what does it really matter if it's full or not? *shrugs*
Two issues:
1: I cannot find any setting to turn off equipment changing when restoring. There's a setting for equipment changing when casting buffs, but this doesn't affect restoring behavior.
2: Normally, KoLmafia's between-adventure processor handles healing needs perfectly well, and I can easily override it for HP, as you said. For Mana though... I do need it at 100% for buffing purposes, AFTER adventuring is completed.
 

Fluxxdog

Active member
Which means it's a bug as you expect mafia to fill you to full MP :/ Not a bug in the "typo in the code" sense, but "it's doing something that it shouldn't" sense. the CLI command speculate can predict buffed max HP/MP after equipment change, couldn't that framework be used to ensure you're not losing HP/MP when swapping equipment to buy restorers?
 

Fluxxdog

Active member
Which would defeat the purpose of having them, sad to say. (I mean, yeah, 5% from an NPC store isn't much, but the long term can always have a case made for it.) Come to think of it, Theraze's patch only addressed one aspect of the bug, since the lobsterskin pants aren't the only thing that increases MP. ...Here's a test run @ 100% MP. First stripped to Birthday suit and then set MP restoring to only use seltzers...
Code:
equip pants bullet-proof corduroys <===+40 max MP

take from closet: 12 Knob Goblin seltzer

use 12 Knob Goblin seltzer
You gain 119 Mojo Points <===I am now at 445 MP

cast 1 Disco Aerobics
You acquire an effect: Disco State of Mind (duration: 5 Adventures) <===444 MP, less than 100%
outfit Knob Goblin Elite Guard Uniform <===MP drops to 405

buy 1 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire an item: Knob Goblin seltzer
You spent 80 Meat
custom outfit Backup <===now at 405/445

use 1 Knob Goblin seltzer
You gain 8 Mojo Points <===now at 413/445
outfit Knob Goblin Elite Guard Uniform <===MP drops to 405

buy 3 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (3)
You spent 240 Meat
custom outfit Backup

use 3 Knob Goblin seltzer
You gain 31 Mojo Points
outfit Knob Goblin Elite Guard Uniform

buy 1 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire an item: Knob Goblin seltzer
You spent 80 Meat
custom outfit Backup

use 1 Knob Goblin seltzer
You gain 10 Mojo Points
outfit Knob Goblin Elite Guard Uniform

buy 3 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (3)
You spent 240 Meat
custom outfit Backup

use 3 Knob Goblin seltzer
You gain 29 Mojo Points
outfit Knob Goblin Elite Guard Uniform

buy 1 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire an item: Knob Goblin seltzer
You spent 80 Meat
custom outfit Backup

use 1 Knob Goblin seltzer
You gain 12 Mojo Points
outfit Knob Goblin Elite Guard Uniform

buy 2 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (2)
You spent 160 Meat
custom outfit Backup

use 2 Knob Goblin seltzer
You gain 20 Mojo Points
outfit Knob Goblin Elite Guard Uniform

buy 2 Knob Goblin seltzer at market price from Knob Goblin Laboratory
You acquire Knob Goblin seltzer (2)
You spent 160 Meat
custom outfit Backup
Yeah, it's not the Travoltan trousers causing the problem. If your MP (and HP should be affected the same way) is above the max MP that an equipment change would drop you down to, it'll cycle repeatedly attempting to get you back to max since you keep losing MP. HP may not be that large an issue because it can simply bust a scroll of drastic healing, but the only items similar to that for MP are the PYEC (an ultra-rare, once per day) and a jumbo Dr. Lucifer (which costs HP and a fullness and isn't guaranteed to get you to max MP). Mafia shouldn't be costing us HP or MP to restore HP/MP.
 

lostcalpolydude

Developer
Staff member
The logic needed for mafia to do what people want without unintended side effects is probably fairly complicated, so it may not get changed very soon. I guess the best workaround is to manually buy a whole bunch of whatever restorative you are using so you don't have to switch gear to buy more.
 

Darzil

Developer
I guess the logic you would need would go:

1. What is the total MP you want to restore to ?
2. Swap to outfit to purchase in.
3. What is the current MP you now have ?
4. Buy amount of restorers to restore the difference between 1 and 3.
5. Swap back to starting outfit.
6. Consume restorers.

Perhaps there should be an 'are you sure' on restoring to 100% MP option, at least if restoring using NPC store items, pointing out the hazard ?
 

xKiv

Active member
Also, possibly expanding 2 to
2.1 what is my MP now?
2.2 what would my max MP be if I swapped into the outfit to purchase in?
2.3 if MP from 2.2 is less than MP from 2.1, burn mana down to 2.2 (but not lower?)
2.4 *now* switch outfit
 

fronobulax

Developer
Staff member
I guess the logic you would need would go:

1. What is the total MP you want to restore to ?
2. Swap to outfit to purchase in.
3. What is the current MP you now have ?
4. Buy amount of restorers to restore the difference between 1 and 3.
5. Swap back to starting outfit.
6. Consume restorers.

Perhaps there should be an 'are you sure' on restoring to 100% MP option, at least if restoring using NPC store items, pointing out the hazard ?

Why not:

1) How much mp is needed?
2) Switch outfit and buy enough restore to guarantee 1).
3) Switch back to original outfit.
4) Use restores bought in 2) one at a time until desired mp reached.

I'm sure there is a reason why the above won't work but I don't see it. Too many server hits compared to alternatives? User resistance to purchasing, and perhaps using, more restoration items than necessary? Going for an optimal restoration strategy rather than a guaranteed strategy? Thanks.
 

xKiv

Active member
I'm sure there is a reason why the above won't work but I don't see it.

set reason := step 2 can reduce your current MP

ETA: If you are already accounting for that in the "to guarantee 1)" part, then you are basically doing exactly the same, but explaining it worse.
 

Veracity

Developer
Staff member
I guess the logic you would need would go:

1. What is the total MP you want to restore to ?
2. Swap to outfit to purchase in.
3. What is the current MP you now have ?
4. Buy amount of restorers to restore the difference between 1 and 3.
5. Swap back to starting outfit.
6. Consume restorers.
I would do this:

1. Calculate the total MP you want to restore to
2. Calculate total - current MP
3. Swap to outfit to purchase in.
4. Buy amount of restorers to restore the amount calculated in 2.
5. Swap back to starting outfit.
6. Consume restorers.

Currently, I believe we consume restorers BEFORE swapping back the outfit (I may be wrong on that...) and, once we swap back, we check again to see if we have reached our target, and if not, try again. That is because restorers have a range and our table has the AVERAGE amount restored, not the range - or even the minimum.

Theraze's personal patch changes one table entry to the minimum.

I would suggest a few changes:

- Actually store the minimum and maximum restoration range, giving us the option to do more intelligent logic
- When purchasing restorers to add X HP or MP, figure out how many would be needed given minimum yield and average yield. Give the user a choice:
-- Assume minimum yield and buy extras. Consume enough assuming average yield (or even max yield), but if you don't hit your target, you have the extras on hand already. If restoring to a specific MP target to cast a specific spell, this is probably sensible.
-- Assume average yield and be satisfied with whatever you get, even if it doesn't reach target. If restoring to X%, this is probably sensible.
- Swap to original outfit before consuming (if it doesn't already).
- Do NOT iterate and try again if you fail to meet a X% target.

This would end some of the "annoying" (to me ;)) repeat trips to the Lab to get that one last seltzer. Although, such trips are much much faster, now that we do Ajax outfit saving and outfit swapping.
 
Top