Bug - Fixed outfit aaaa doesn't acquire enough components when aaaa has multiples of an item

xKiv

Active member
Equipping an entire outfit doesn't work as well as it could, in the case when said outfit contains multiples of an item:
(my outfit has two bugged old school mafia knicher!@#%^%s, because pvp verbosity mini; xdisp is my script for displaying where I have how many of what - used this because a) it shows zeroes b) it also matches with mafia's fuzzy to_item() matching, unlike "inv" which only matches substrings)
Code:
> xdisp bugged old school mafia

Updating display case...
Requesting store inventory...
Store inventory request complete.
old school Mafia knicke½æ
#### NOTE: shows 0 in inventory, 7 in closet, 1 in DC, 0 equipped, 0 in store
DONE

> equip

Hat: insulting hat
Weapon: plexiglass pikestaff
Off-hand: (none)
Shirt: Corporal Fennel's Lonely Clubs Club Jacket
Pants: Vicar's Tutu
Container: auxiliary backbone

Acc. 1: offensive moustache
Acc. 2: Uncle Hobo's fingerless tinsel gloves
Acc. 3: Zombo's skull ring

Pet: Hobo Monkey (50 lbs)
Item: sugar shield

Sticker 1: scratch 'n' sniff unicorn sticker (0)
Sticker 2: scratch 'n' sniff unicorn sticker (0)
Sticker 3: scratch 'n' sniff unicorn sticker (0)

> outfit pvp

Removing items from closet...
You acquire an item: old school Mafia knicke½æ         ###### note how mafia only uncloseted one, even though there are two in the outfit (also can happen with accessories)
Removing items from closet...
You acquire an item: giant gym membership card
Removing items from closet...
You acquire an item: tiny plastic Hank North, Photojournalist
Putting on outfit: pvp
You only put on part of that outfit.

> equip

Hat: hardened slime hat
Weapon: old school Mafia knicke½æ
Off-hand: (none)
Shirt: Hodgman's disgusting technicolor overcoat
Pants: hardened slime pants
Container: giant gym membership card

Acc. 1: tiny plastic Hank North, Photojournalist
Acc. 2: hardened slime belt
Acc. 3: plexiglass pinky ring

Pet: Hobo Monkey (50 lbs)
Item: sugar shield

Sticker 1: scratch 'n' sniff unicorn sticker (0)
Sticker 2: scratch 'n' sniff unicorn sticker (0)
Sticker 3: scratch 'n' sniff unicorn sticker (0)

> xdisp bugged old school mafia

##### shows 1 (bogus) in inventory, 6 in closet (correct), 1 in DC, 1 equipped (correct), 0 in store
DONE

#### correct amount in inventory is zero:
> /count old school

Sorry, I can't figure out what "old school" means. Perhaps you have 0.

#### verification that mafia thinks it's 1:
> inv old school

old school Mafia knicke½æ

> refresh inv

Updating inventory...
Requests complete.

#### verification that mafia can be refreshed to correct knowledge:
> inv old school

So that's actually *two* entangled problems:
1) mafia didn't acquire enough components to equip the entire outfit, even though it was easily possible
2) partial equip of the outfit left mafia thinking that it has a bogus something in inventory, that's not in fact there

I kind of assume that fixing 1) will make 2) non-reproducible, but I might be wrong. It has happened before [1].
[1] frequently.
 

Rinn

Developer
Here's the offending code in EquipmentManager.java line 1661:

Code:
public static final boolean retrieveOutfit( final SpecialOutfit outfit )
    {
        AdventureResult[] pieces = outfit.getPieces();
        for ( int i = 0; i < pieces.length; ++i )
        {
            AdventureResult piece = pieces[ i ];
            if ( !KoLCharacter.hasEquipped( piece ) && !InventoryManager.retrieveItem( piece ) )
            {
                return false;
            }
        }


        return true
    }

It loops through the array of equipment and attempts to retrieve each one. If an item is in the array multiple times, the second attempt will succeed because the earlier iteration already acquired the item or because it is equipped once already.

This probably causes a bunch of those AutoBasement outfit issues. Good catch.
 
Last edited:

fronobulax

Developer
Staff member
Here's the offending code in EquipmentManager.java line 1661:

Code:
public static final boolean retrieveOutfit( final SpecialOutfit outfit )
    {
        AdventureResult[] pieces = outfit.getPieces();
        for ( int i = 0; i < pieces.length; ++i )
        {
            AdventureResult piece = pieces[ i ];
            if ( !KoLCharacter.hasEquipped( piece ) && !InventoryManager.retrieveItem( piece ) )
            {
                return false;
            }
        }


        return true
    }

It loops through the array of equipment and attempts to retrieve each one. If an item is in the array multiple times, the second attempt will succeed because the earlier iteration already acquired the item or because it is equipped once already.

This probably causes a bunch of those AutoBasement outfit issues. Good catch.

Thank you. If I am reading things right, this may cause problems if an item is in one slot but the outfit expects it in another.
 

xKiv

Active member
I don't understand how you reach that conclusion, since nothing in that code cares about what slot an item is in.

Does kol itself care?
If so, then you could have a situation where the outfit specifies weapon A and offhand B, but you started with weapon B and empty offhand. Then mafia will keep B in mainhand (it *is* equipped, just not in the right slot) and tell kol to put on the outfit ... and that could fail, because there's no B in inventory which could be put in offhand.
But I think kol doesn't really care which of the weapons will end up in which hand, except those that can be equipped only in mainhand (chefstaves, ...) - and you can't have those in the wrong slot in the first place.
 

Fluxxdog

Active member
I believe that's frono's point. Each piece of the outfit is checked for whether you have it or have it equipped, but only for that single piece with no consideration to other pieces of the outfit.

Say that you need two asparagus knives for your outfit. It'll check for the first one, see the knife in your closet, grab it and put it in your inventory, then it'll check for the second one, see it in your inventory, and think it's already met the requirement. In other words, false positive. If you don't have that second knife, it should be returning false.
 

fronobulax

Developer
Staff member
My thinking, admittedly while under the influence of an adult beverage, was that there are places where KoLmafia seems to care about what slot something is in. If the statement made elsewhere that when the maximizer suggests "Remove & equip" it means it wants to change the slot of an already equipped item is correct then that is at least one of them. Since the scratch n' sniff autoBasement problem is definitely tied to running the maximizer and saving and changing, outfits my intuition is that the referenced code may be a factor.
 

Rinn

Developer
This should be fixed with r13518.

I've updated the outfit code to have some idea of what slot an item should be equipped in. I also account for kol not caring what slot an accessory is in, or what slot a weapon is in if you're dual-fisting.

I also added output for what pieces of an outfit are missing if you try to wear an outfit and mafia is unable to retrieve those items, which will happen more often after the recent change that made the outfit command not buy missing pieces.
 
Last edited:

Theraze

Active member
Question - since some dual-wield items do matter in terms of their slot, such as having the antique machete in your primary hand rather than in the offhand to skip the combats, is that the direction you account for KoL not caring about slots, or do you account for KoL not (generally) caring by putting the weapons into whichever hand KoL feels like?
 

Rinn

Developer
The code treats outfits like kol does, as in if you have items in the wrong slots they will not be moved. This could be fixed by bypassing the kol outfit process entirely and equipping each piece individually, but that's more server hits so probably not going to happen. You could do this manually if you wanted using the outfit_pieces() function, all you need to do is check if multiple weapons are in the list and equip them in the correct order.

At the end mafia is still just calling the kol outfit equip process after it retrieves all the necessary items, so your equipment is at the whims of whatever kol decides. From my testing it does seem like kol will equip items in the exact order they are listed in the custom outfits page if you don't have those items equipped beforehand.
 
Last edited:

Theraze

Active member
So if you want to guarantee same slot, the birthday suit is your friend. But if there's weirdness, it's KoL's weirdness, not mafia weirdness. Got it. :) Thanks!
 
Top