Bug - Fixed retrieve_item() returns false for multiples of an equipped weapon

AlbinoRhino

Active member
It appears that retrieve_item() will unequip gear that is currently in use as part of its retrieval process.

If multiples of the same accessory are equipped, retrieve_item() will unequip the correct amount and return true. However, if two of the same weapon are equipped, retrieve_item() will unequip them both and return false. Tested the accessories with 2 natty blue ascots equipped (of which I have 2 available) and also with 2 Stick-Knife of Loathing equipped (which I also have 2).

This can be re-produced by equipping 2 Stick-Knives and using the cli command:

ash retrieve_item(available_amount($item[Stick-Knife of Loathing]), $item[Stick-Knife of Loathing]);

(assuming only 2 Stick-Knives are available, of course.)

This gives (in the cli) :

> ash retrieve_item(available_amount($item[Stick-Knife of Loathing]), $item[Stick-Knife of Loathing]);

Taking off Stick-Knife of Loathing...
Equipment changed.
You need 1 more Stick-Knife of Loathing to continue.
Returned: false

Both knives will be unequipped and put into inventory, as expected, however.
 

Veracity

Developer
Staff member
If you are dual-wielding and ask for 1, does it take it from the main hand or the offhand? 'cause if the former, that will drop the second one, too, which might be the issue there.

Not sure what the issue would be for two accessories.
 

heeheehee

Developer
Staff member
I don't think there's an issue with multiple accessories. Your assessment sounds spot-on for the weapons, though.

If multiples of the same accessory are equipped, retrieve_item() will unequip the correct amount and return true.

However, if two of the same weapon are equipped, retrieve_item() will unequip them both and return false.
 

Veracity

Developer
Staff member
The only character I have who can dual wield is in Nuclear Autumn and cannot, therefore, dual wield.

Replacing the conditional in InventoryManager.doRetrieveItem @ line 603 with the following seems like it might do the job, if somebody is interested in trying it:

Code:
		if ( !isRestricted && ItemDatabase.isEquipment( itemId ) && useEquipped )
		{
			for ( int i = EquipmentManager.HAT; i <= EquipmentManager.FAMILIAR; ++i )
			{
				// If you are dual-wielding the target item,
				// remove the one in the offhand slot first
				// since taking from the weapon slot will drop
				// the offhand weapon.
				int slot =
					i == EquipmentManager.WEAPON ? EquipmentManager.OFFHAND :
					i == EquipmentManager.OFFHAND ? EquipmentManager.WEAPON :
					i;

				if ( EquipmentManager.getEquipment( slot ).equals( item ) )
				{
					if ( sim )
					{
						return "remove";
					}

					SpecialOutfit.replaceEquipmentInSlot( EquipmentRequest.UNEQUIP, slot );

					RequestThread.postRequest( new EquipmentRequest( EquipmentRequest.UNEQUIP, slot ) );

					if ( --missingCount <= 0 )
					{
						return "";
					}
				}
			}
		}
 
Top