Skip to content

Commit

Permalink
allow auto-equipping two-handed weapons with both hands occupied
Browse files Browse the repository at this point in the history
specifically where the larger item is in the right hand, this would fail previously in certain circumstances.
  • Loading branch information
ephphatha authored and AJenbo committed Oct 21, 2024
1 parent 1b32872 commit 5758e56
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,20 +837,25 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool
// the left hand), invloc isn't used there.
invloc = INVLOC_HAND_RIGHT;
} else {
// Both hands are holding items, we must unequip the right hand item and check that there's
// space for the left before trying to auto-equip
if (!AutoPlaceItemInInventory(player, player.InvBody[INVLOC_HAND_RIGHT])) {
// No space to move right hand item to inventory, abort.
break;
// Both hands are holding items, we must unequip one of the items and check that there's
// space for the other before trying to auto-equip
inv_body_loc mainHand = INVLOC_HAND_LEFT;
inv_body_loc offHand = INVLOC_HAND_RIGHT;
if (!AutoPlaceItemInInventory(player, player.InvBody[offHand])) {
// No space to move right hand item to inventory, can we move the left instead?
std::swap(mainHand, offHand);
if (!AutoPlaceItemInInventory(player, player.InvBody[offHand])) {
break;
}
}
if (!CouldFitItemInInventory(player, player.InvBody[INVLOC_HAND_LEFT], iv)) {
// No space for left item. Move back right item to right hand and abort.
player.InvBody[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1];
if (!CouldFitItemInInventory(player, player.InvBody[mainHand], iv)) {
// No space for the main hand item. Move the other item back to the off hand and abort.
player.InvBody[offHand] = player.InvList[player._pNumInv - 1];
player.RemoveInvItem(player._pNumInv - 1, false);
break;
}
RemoveEquipment(player, INVLOC_HAND_RIGHT, false);
invloc = INVLOC_HAND_LEFT;
RemoveEquipment(player, offHand, false);
invloc = mainHand;
}
break;
default:
Expand Down

0 comments on commit 5758e56

Please sign in to comment.