Bug - Fixed Equipping Outfits That Swap An Item Between Main and Off Hands Confuses Mafia

So this one's hard to word properly, so I'll start out with the specific example. I have an outfit called Regular that has the Sledgehammer of the Valkyr in my main hand and an Icy Shield in my offhand. My Underwater outfit has a Mer-Kin Hookspear in my main hand and the Sledgehammer of the Valkyr in the off hand, for reasons that probably made sense at the time. If I have Regular equipped, and use Mafia to put on Underwater, it does so without complaint. Here's the problem: the KoL inventory will show me having the Sledgehammer of the Valkyr in the main hand and the Mer-Kin Hookspear in the off hand, while Mafia is under the impression that I am holding the Mer-Kin Hookspear in my main hand and nothing in the off hand. Furthermore, trying to use Mafia to equip the Sledgehammer of the Valkyr in the off hand results in it telling me I don't have that item (because it is in fact equipped). Refreshing my character status in Mafia corrects the inconsistency.

I'm guessing this is in part due to how KoL interprets the outfit request: Using KoL itself to make the swap has the same result in that I end up with the Hookspear in the offhand, while equipping Underwater with empty hands puts the Hookspear in the main hand.

Steps to reproduce:
  • Have only 1 of 1-handed weapon A, have 1-handed weapon B, have off-hand item x, have Double Fisted Skull Smashing.
  • Create outfit with weapon A in main hand and item x in off hand.
  • Create outfit with weapon B in main hand and weapon A in off hand.
  • Unequip everything.
  • Equip outfit A, note resulting equipped gear in Mafia and KoL corroborate.
  • Equip outfit B, note that Mafia reports (main/off) B/(nothing) while KoL reports A/B, despite outfit being B/A.

I'll add some more here like what I'd like to see and reasons it's important but have run out of time, I'll be back in a few hours. Just want to get this out first so you can see it.

EDIT: Since this is primarily a bug with KoL, I understand if you want to follow your policy of not correcting for those. However, here is what I would like to see:
When equipping an outfit, have Mafia check against its cached version of what the player is wearing. If the desired main or off hand is already equipped in the opposite slot, before sending the outfit request simply unequip both slots. I believe this would suffice to solve the issue because the only other slots that items can go in any of are the accessories, where slot number doesn't matter. If I understand correctly, there are a few instances where it is important that a weapon be in the main hand over the off hand.

So my idea for the fix would work like this:
  • User/script requests outfit change
  • Mafia compares Main Hand slot and Off Hand slot in requested outfit to what it has cached as currently equipped
  • If the requested Main Hand is currently in the cached Off Hand, or the requested Off Hand is currently in the cached Main Hand, send KoL a request to unequip Main Hand and Off Hand
  • Send KoL outfit change request

I hope that makes it clear? Let me know if it's not.
 
Last edited:

Bale

Minion
This hit me multiple times in my last few runs. Thanks for working out exactly when it happens, since it's really troublesome.

Apparently it wasn't an issue before since I almost always had Smithsness in my off-hand while now a second weapon is often a useful item.
 
Last edited:

xKiv

Active member
IIRC: kol doesn't store outfits as "item1 in slot1, item2 in slot2, ...", it just stores the items in some order. Using kol to change outfit then tries to equip them all, with a bunch of rules about what goes where depending on which slots are full/empty. It's a mess, but can't be cleaned up, because then someone's outfit would stop being equipped like they are used to.
Mafia already mimics kol's rules for accessories - everybody has 3 accessory slots.
 
I noticed I made a mistake in my explanation: when the process is over, Mafia thinks the offhand is empty entirely, not item x.

Also, I'd like to object to fixing this making people's outfits stop equipping like they're used to. The only thing it would change is outfits with 2 weapons, and specifically outfits with 2 weapons where the offhand is currently equipped in the main hand. There are 2 scenarios here when people make an outfit with 2 weapons: 1) they want a specific weapon in their main hand and also a weapon in their off hand, or 2) they want 2 weapons equipped and don't care which is in the main hand. People in situation 2 have likely not even noticed this happening as it doesn't affect them. People in situation 1 have either not been noticing this happening and therefore not having things work like they thought they told it, or have been noticing this happening and have been manually fixing it every time it happens.

If you're saying that there's not actually anything Mafia can do to mitigate this, though, I can take it up with TPTB and see if they can fix what's behind it.
 

xKiv

Active member
I noticed I made a mistake in my explanation: when the process is over, Mafia thinks the offhand is empty entirely, not item x.
Because, starting with "A in mainhand, B in offhand", equipping an outfit with "..., B, A, ..." in kol doesn't change anything. Mafia looks at kol's response text and puts the first weapon in mainhand, second weapon in offhand, in order. In this case ... I can't really tell why mafia does what it does, because I don't see kol's result text. But it looks like either a) kol said you equipped B, then didn't say anything about A.
or b) something with the order of the operations left mafia thinking that it has no A to hold in offhand after "equipping" B into mainhand
or c) something with the order of the operations made mafia first "equip" A into offhand, and then move B from offhand to mainhand (leaving offhand unequipped).
How many A and B did you have (in inventory) before equipping outfit B? How many did mafia report after?

1) they want a specific weapon in their main hand and also a weapon in their off hand,

As you already observed, this won't work. Kol itself makes sure that it won't (except chefstaves, which have been kludged to always go to mainhand, because they can't be held in offhand).
 
How many A and B did you have (in inventory) before equipping outfit B? How many did mafia report after?
1 of A, as it's the epic something something weapon. Only 1 of B, but I doubt that is important in this case since B does not begin the process already equipped. I don't know how many Mafia reports afterwards; I can check.

As you already observed, this won't work. Kol itself makes sure that it won't .
Unless I misunderstand, this is incorrect. If I take everything off, then equip the Underwater outfit, it appropriately equips in the form of B/A because that's how it is stored. It is only because I normally wield A in my main hand(and possibly because A is a quest item that I therefore have only 1 of) that anything is going wrong.

EDIT: While Wearing Outfit 1, Mafia reports 0 of A and 1 of B. This is expected, as A is equipped and B is not. When equipping Outfit 2 from Outfit 1, Mafia now reports 1 of A and 0 of B, despite both being equipped in KoL (In A/B format, while Outfit 2 is supposed to be B/A).

Just to test it out, I equipped Outfit 3 which is wielding 2 entirely different items, we'll call them C and D. Equipping Outfit 2 from that state properly ends in KoL and Mafia in agreement about having B/A equipped.

For some additional information, If I have Outfit 2 equipped properly (B/A) and equip Outfit 1 (A/x), Kol manages to end up correct at A/x while Mafia now thinks I am <nothing>/x. This and the previous point should confirm that the issue takes place only when the only A you have is already equipped.
 
Last edited:

xKiv

Active member
1 of A, as it's the epic something something weapon. Only 1 of B, but I doubt that is important in this case since B does not begin the process already equipped. I don't know how many Mafia reports afterwards; I can check.

So that's presumably 0 of A and 1 of B in inventory "before equipping outfit B"?
(until now, I didn't notice that your outfit A had a completely different item in offhand, which helps explain mafia's behavior: kol probably didn't say anything about weapon A because it was already equipped, and then it said it's equipping weapon B ... so mafia only saw the instruction to equip B, and since it was the first instruction to equip a weapon, it interpretted it as "equip into mainhand" ... which can't easily be fixed, since, iirc, mafia doesn't currently know what items are supposed to be in each custom outfit. So at this point it can't tell the difference between "equip an outfit that has only weapon B but no offhand" and "equip an outfit that has the weapon you already have in your mainhand + weapon B", because kol doesn't say what goes in which slot and also doesn't mention which items are already equipped)

Unless I misunderstand, this is incorrect.

I would say you misunderstand.

1) What happens is, to my knowledge, kol has the outfit stored, somehow, as a (fundamentally) unordered set of items. This normally happens to load in a stable order, but can change at any point without warning (and sometimes does, even if it's rare).

but that's irrelevant, because

2) the listed order doesn't really matter anyway. If you already have some items equipped, kol won't switch them around (evidence is in your first post), unless it absolutely has to (i.e. making room for a newly equipped item that is restricted to a particular slot, like an offhand, or chefstaff).

while Outfit 2 is supposed to be B/A.
Please just stop expecting this to be a thing. You can't rely on it, and shouldn't rely on it even if you /unequip all in between.

For some additional information, If I have Outfit 2 equipped properly (B/A) and equip Outfit 1 (A/x), Kol manages to end up correct at A/x while Mafia now thinks I am <nothing>/x. This and the previous point should confirm that the issue takes place only when the only A you have is already equipped.

Kol's response here would look somithing like "you already had some parts of outfit2 equipped; you equipped x; you unequipped B". I am assuming x is not a weapon (" have off-hand item x" is ambigous between "x is of the type off-hand" and "x is in the slot off-hand"), so mafia only saw "put weapon from mainhand to inventory (leaving mainhand empty) and equip x, which is offhand and therefore can only go to offhand".


In all cases, the issue is that mafia doesn't know which items are the "you already had some parts of outfit equipped", and so can't compensate.
 
Last edited:

xKiv

Active member
I am afraid (even if not 100% confident) that the only reliable fix will be to refresh equipment after putting on an outfit with ambiguous items.
 

Veracity

Developer
Staff member
Rebump.

I note that if you put on an outfit via the GUI or scripting, we follow up up with an api.php call, which will put the items into the correct slots, but if you do it in the Relay Browser, the browser follows up with a charpane.php refresh, which doesn't help.

So, these look like the choices:

1) Convince CDM to add something (HTML comment?) to the ajax response to the inv_equip request to show exactly which slot each item is unequipped or equipped from.
2) Figure out, somehow, KoL's algorithm for replacing items during an outfit switch.
3) Force an api.php call after every outfit switch, even a Relay Request from the browser.

I would vastly prefer #1 - and will happily adjust the code where we parse ajax outfit switches to to use it - but CDM no longer responds when I write him. I will try, but, expect nothing.

I also think I will implement #3 and will remove it if/when #1 becomes possible.
 

Veracity

Developer
Staff member
And revision 17742 always does an api.php?what=status to follow up outfit swaps, even if initiated in the Relay Browser.

I sent CDM kmail explaining why it would be Real Helpful if he could make the outfit swap ajax results include slot names for each item. If he ever does it, I will rewrite EquipmentRequest.donOutfit() to handle it and we can eliminate the api.php request.
 

Bale

Minion
I am hopeful that the knowledge that mafia users are now doing two server hits for every outfit change will convince him that it is a worthwhile use of time to fix that.
 

lostcalpolydude

Developer
Staff member
I am hopeful that the knowledge that mafia users are now doing two server hits for every outfit change will convince him that it is a worthwhile use of time to fix that.

I don't think CDMoyer is very concerned about server hits. He told me a while back that KoLmafia should load the login page to check for special events (after I mentioned that we don't bother any more, since it's a wasted server hit).
 
Top