Bug Maximizer trying to equip 2 scratch 'n' sniff swords

digitrev

Member
Code:
> ash maximize("mysticality", 0, 0, true, true)

Maximizing...
17712 combinations checked, best score 1,181.00
Returned: aggregate {string display; string command; float score; effect effect; item item; skill skill;} [119]
1 => record {string display; string command; float score; effect effect; item item; skill skill;}
**display => equip weapon scratch 'n' sniff sword
**command => equip weapon ¶3508
**score => 87.0
**effect => none
**item => scratch 'n' sniff sword
**skill => none
2 => record {string display; string command; float score; effect effect; item item; skill skill;}
**display => equip off-hand scratch 'n' sniff sword
**command => equip off-hand ¶3508
**score => 87.0
**effect => none
**item => scratch 'n' sniff sword
**skill => none

You can only have one, so this keeps giving me grief.
 

digitrev

Member
Added: somehow, occasionally, the game thinks I have 2 swords. No idea how this keeps happening, but "refresh all" seems to fix it, more or less. Not sure if it still qualifies as a bug, then.
 

Theraze

Active member
Could have been related to the issue Veracity recently fixed with removal order to fix offhand issues when you're dualwielding and try to retrieve from your equipped set.
Could be related, if when you remove mainhand weapon and offhand drops into inventory, the inventory gets out of sync... sometimes... or something like that.
 

xKiv

Active member
I believe it is (or was) also an issue with switching outfits, but I don't really remember. Something with mafia parsing kol's result text (list of newly equipped items, then list of newly unequipped items) not being ready for the case when a 1-handed weapon has not been reported by kol at all (because outfit says it should be equipped and it is), desyncing mafia's idea of which weapon is in which hand? Maybe it needed something else to manifest too?

The code in EquipmentRequest (from roughly line 1876 on) looks like if
1) a custom outfit is saved with weapon X in mainhand and a different weapon Y in offhand
2) I equip a duplicate of the weapon Y in my mainhand (so I am wielding two copies of the weapon)
3) the custom oufit is restored

kol will say it unequips weapon Y (but it won't say it's being unequipped from mainhand)
mafia will see that I have weapon Y in offhand and deduce that it is therefore being unequipped from offhand:
Code:
if ( newEquipment[ EquipmentManager.OFFHAND ].equals( item ) )
					{
						slot = EquipmentManager.OFFHAND;
					}

(I just checked this in vanilla kol, and KoL *did* equip X into mainhand; so it at least *can* happen, even if it doesn't happen always)

mafia started (before step 3, correctly) at "1 X in inventory, 1 Y in mainhand, 1 Y in offhand"
then it saw "equip X, unequip Y - both incorrectly in offhand"

kol knows I have 1 Y in inventory, 1 X in mainhand, 1 Y in offhand
mafia thinks I have 1 Y in inventory, 1 Y in mainhand, 1 X in offhand

if I now unequip offhand, mafia will see from kol's response that 1 Y entered inventory (and it will forget about the X that was in the offhand)

Result: extra copy of Y in mafia's inventory model (and a missing X)


Conversely, if
1) save the same custom outfit (mainhand X, offhand Y)
2) equip a second X in offhand
3) restore the outfit

kol will say it unequips X and equips Y (Y ended up in offhand this time in kol)
mafia will see that I did *not* already have Y in offhand, so it will think it's being put into mainhand

mafia goes from "1 Y in inventory, 1 X in mainhand, 1 X in offhand"
then sees "equip Y, unequip X - incorrectly in mainhand"

kol knows I have 1 X in inventory, 1 X in mainhand, 1 Y in offhand
mafia thinks I have 1 X in inventory, 1 Y in mainhand, 1 Y in offhand

if I know unequip mainhand, mafia will see from kol's response that 1 X and 1 Y entered inventory

Result: extra Y in mafia's inventory model (and a missing X)

(the difference is, in the first case I needed to start with 2 of the "duplicated" items; in the second case I only need to start with 2 of the other item, which means that it can "duplicate" even a quest item like a s'n's sword)


Does this work? I can check later in mafia, now I am only conjecturing from vanilla kol and mafia sources.
 

xKiv

Active member
It doesn't seem to work like a thought. However ...
outfit test was saved with skeleton bone in mainhand and cardboard wakizashi in offhand.
I start with that equipped.
Code:
> refresh inv

Updating inventory...
Requests complete.

> refresh equipment

Retrieving equipment...

Hat: beer helmet
Weapon: skeleton bone
Off-hand: cardboard wakizashi
Shirt: Knob Goblin elite shirt
Pants: (none)
Container: protonic accelerator pack

Acc. 1: dead guy's watch
Acc. 2: your cowboy boots
Acc. 3: gold detective badge

Pet: Trick-or-Treating Tot (26 lbs)
Item: li'l unicorn costume
Requests complete.

> inv skeleton bone

skeleton bone (7)

> inv cardboard waki

cardboard wakizashi

> hold skeleton bone

Holding skeleton bone...
Equipment changed.

> outfit test

Putting on outfit: test
Equipment changed.

> inv skeleton bone

skeleton bone (8)

> inv cardboard waki

cardboard wakizashi

At this point, mafia's idea of what's in my mainhand and offhand is correct, but there's an extra skeleton bone in my inventory.

Code:
> unequip weapon

Taking off skeleton bone...
Equipment changed.

> inv skeleton bone

skeleton bone (9)

> inv cardboard waki

cardboard wakizashi (2)

> refresh inv

Updating inventory...
Requests complete.

> inv skeleton bone

skeleton bone (8)

> inv cardboard wakizashi

cardboard wakizashi (2)

(and the first case seems to work entirely correctly)
 

Veracity

Developer
Staff member
Well, let's see.

I save outfit test with a skeleton bone in main hand and a non-weapon in offhand.

Code:
[color=green]> inv skeleton bone[/color]

skeleton bone (8)

[color=green]> hold skeleton bone[/color]

Holding skeleton bone...
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (7)

[color=green]> outfit test[/color]

Putting on outfit: Test
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (8)
That is correct.

I made a new outfit with skeleton bone in main hand and a cardboard wakizashi in offhand, as you did.

Code:
[color=green]> inv skeleton bone[/color]

skeleton bone (8)

[color=green]> hold skeleton bone[/color]

Holding skeleton bone...
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (7)

[color=green]> outfit test2[/color]

Putting on outfit: Test2
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (9)
I love reproducible test cases.
 

Veracity

Developer
Staff member
Here is the response text to the outfit request, with images removed.

Code:
<center>
  <table  width=95%  cellspacing=0 cellpadding=0>
    <tr><td style="color: white;" align=center bgcolor=blue><b>Results:</b></td></tr>
    <tr><td style="padding: 5px; border: 1px solid blue;">
        <center>
          <table>
            <tr><td><br />You put on an Outfit: <b>Test2</b><center>
                  <table>
                    <tr>
                      <td align=right>Item equipped:</td>
                      <td><b>cardboard wakizashi</b></td>
                    </tr>
                    <tr>
                      <td colspan=2 height=2 bgcolor=black></td>
                    </tr>
                    <tr>
                      <td align=right>Item unequipped:</td>
                      <td><b>skeleton bone</b></td>
                    </tr>
                  </table>
                </center>
              </td>
            </tr>
          </table>
        </center>
      </td>
    </tr>
    <tr><td height=4></td></tr>
  </table>
</center>
Since this is an ajax=1 request, we parse it in EquipmentRequest.parseEquipmentChange.

First we look at unequipped items.
There is one. It is a weapon. In particular, a skeleton bone.
We had two of those equipped: in in the weapon slot and one in the offhand slot.
We look first in the offhand slot and set that to unequipped.

Next we look at equipped items.
There is one. It is a weapon. In particular, a cardboard wakizashi.
Even though we decided to unequip the weapon from the offhand slot, we decide this new one goes in the weapon slot.

I suppose that if we unequipped a weapon from the offhand slot, we could go there first.
Or, perhaps, we should equip weapons into the first available slot of {weapon, offhand}.
Or something.

In any case, given that KoL does not tell us which slots it is unequipping or equipping, it will be a heuristic.

(Back when CDM was willing to consider doing things for him, I asked if he could annotate the slot number via an HTML comment. Unfortunately, he did not.}

Pondering.
 

Veracity

Developer
Staff member
Code:
[color=green]> outfit test2[/color]

Putting on outfit: Test2
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (8)

[color=green]> hold skeleton bone[/color]

Holding skeleton bone...
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (7)

[color=green]> outfit test2[/color]

Putting on outfit: Test2
Equipment changed.

[color=green]> inv skeleton bone[/color]

skeleton bone (8)
Lets see how revision 17582 works.
 

Veracity

Developer
Staff member
Bumping to consider whether this specific thing is fixed or not. We still have issues with outfits & dual wielding, as seen by this:

Code:
Putting on outfit: BackupLast
*** slot weapon: KoL has garbage sticker but KoLmafia has scratch 'n' sniff sword
*** slot off-hand: KoL has scratch 'n' sniff sword but KoLmafia has garbage sticker
Equipment changed.
 
Top