From 68891cc6361dfa0e6d689305117e5c6e863f380d Mon Sep 17 00:00:00 2001 From: Gabriel Radzki Date: Fri, 15 Mar 2024 19:15:30 -0300 Subject: [PATCH 1/2] Adds conditions to avoid equipping 2handed when occupied --- src/GameLogic/PlayerActions/Items/MoveItemAction.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/GameLogic/PlayerActions/Items/MoveItemAction.cs b/src/GameLogic/PlayerActions/Items/MoveItemAction.cs index 87c050b1a..558049d84 100644 --- a/src/GameLogic/PlayerActions/Items/MoveItemAction.cs +++ b/src/GameLogic/PlayerActions/Items/MoveItemAction.cs @@ -238,9 +238,16 @@ private async ValueTask CanMoveAsync(Player player, Item item, byte to static bool IsOneHandedOrShield(ItemDefinition definition) => (definition.ItemSlot!.ItemSlots.Contains(RightHandSlot) && definition.ItemSlot.ItemSlots.Contains(LeftHandSlot)) || definition.Group == 6; + static bool RightHandOccupied(ItemDefinition definition) => definition != null; + + // Bolts = 7, Arrows = 15 + static bool IsArrowOrBolt(ItemDefinition definition) => + definition.Group == 4 && (definition.Number == 7 || definition.Number == 15); + if ((toSlot == LeftHandSlot && itemDefinition.Width >= 2 - && storage.GetItem(RightHandSlot)?.Definition!.Group == 6) + && RightHandOccupied(storage.GetItem(RightHandSlot)?.Definition!) + && !IsArrowOrBolt(storage.GetItem(RightHandSlot)?.Definition!)) || (toSlot == RightHandSlot && IsOneHandedOrShield(itemDefinition) && storage.GetItem(LeftHandSlot)?.Definition!.Width >= 2)) From c23b6b8bcdce2a3c81c96005d163929c286dec34 Mon Sep 17 00:00:00 2001 From: Gabriel Radzki Date: Fri, 22 Mar 2024 00:34:57 -0300 Subject: [PATCH 2/2] Use existing IsAmmunition property --- src/GameLogic/PlayerActions/Items/MoveItemAction.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/GameLogic/PlayerActions/Items/MoveItemAction.cs b/src/GameLogic/PlayerActions/Items/MoveItemAction.cs index 558049d84..cf9b94a1f 100644 --- a/src/GameLogic/PlayerActions/Items/MoveItemAction.cs +++ b/src/GameLogic/PlayerActions/Items/MoveItemAction.cs @@ -238,16 +238,12 @@ private async ValueTask CanMoveAsync(Player player, Item item, byte to static bool IsOneHandedOrShield(ItemDefinition definition) => (definition.ItemSlot!.ItemSlots.Contains(RightHandSlot) && definition.ItemSlot.ItemSlots.Contains(LeftHandSlot)) || definition.Group == 6; - static bool RightHandOccupied(ItemDefinition definition) => definition != null; - - // Bolts = 7, Arrows = 15 - static bool IsArrowOrBolt(ItemDefinition definition) => - definition.Group == 4 && (definition.Number == 7 || definition.Number == 15); + var rightHandItemDefinition = storage.GetItem(RightHandSlot)?.Definition!; if ((toSlot == LeftHandSlot && itemDefinition.Width >= 2 - && RightHandOccupied(storage.GetItem(RightHandSlot)?.Definition!) - && !IsArrowOrBolt(storage.GetItem(RightHandSlot)?.Definition!)) + && rightHandItemDefinition != null + && !rightHandItemDefinition.IsAmmunition) || (toSlot == RightHandSlot && IsOneHandedOrShield(itemDefinition) && storage.GetItem(LeftHandSlot)?.Definition!.Width >= 2))