Bug Mafia sometimes loses track of liver capacity modifiers when changing equipment

VeeArr

New member
I've once again come across an issue I've seen mentioned a few times before and had some time to do some investigation. I found that occasionally when changing equipment, mafia would lose track of my Liver Capacity modifiers and would then think I was overdrunk when I wasn't. Curiously, it doesn't seem to happen 100% consistently, but after attaching a debugger I think I narrowed down the issue to mafia sometimes incorrectly recalculating the player's current modifiers when equipping a weapon if previously unarmed.

While updating the character's status after equipping the weapon, it appears that mafia rebuilds the modifiers and accounts for passive skills by layering on a cached copy of modifiers representing the effects of those skills. For whatever reason, this set of modifiers includes the "Unarmed" boolean modifier. (I didn't check for why this is the case, though I could hypothesize that it's due to previously being unarmed and having a passive that cares about being unarmed like Master of the Surprising Fist.)

Then, when mafia tries to add the modifiers representing the passive skills to the character state, it sees that the cached skills modifiers are marked "unarmed", but the player isn't unarmed, and they get skipped. Stack for when this check occurs is listed below.


Code:
Modifiers.add(Modifiers) line: 664  
Modifiers.applyPassiveModifiers(boolean) line: 979  
KoLCharacter.recalculateAdjustments(boolean, int, Map<Slot,AdventureResult>, List<AdventureResult>, FamiliarData, FamiliarData, FamiliarData, String, String, String, Map<Modeable,String>, boolean) line: 5210  
KoLCharacter.recalculateAdjustments(boolean) line: 5004  
KoLCharacter.recalculateAdjustments() line: 4999  
CharPaneRequest.refreshEffects(JSONObject) line: 1920  
CharPaneRequest.parseStatus(JSONObject) line: 1700
 
Amazing find!

I think the fix is to move "Unarmed" into expressions and out of modifiers. It's more like a restriction than a modifier -- yes, it's like "single equip", but we have a lot of boolean modifiers which aren't really like the others (e.g. "Attacks Can't Miss" is an enchantment that changes what your character can do, "Softcore only" is a restriction that changes when you can equip an item).
 
Back
Top