Skip to content

Commit

Permalink
Prevent unequipping main hand weapon while disarmed.
Browse files Browse the repository at this point in the history
Thanks to Chero.
  • Loading branch information
ratkosrb committed Aug 28, 2024
1 parent 707c9c9 commit 2f500b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/game/Handlers/ItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recv_data)
msg = _player->CanUnequipItem(dest, !pSrcItem->IsBag());
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, pDstItem, nullptr);
_player->SendEquipError(msg, pDstItem, pSrcItem);
return;
}

Expand Down
7 changes: 5 additions & 2 deletions src/game/Objects/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10330,8 +10330,11 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const
if (pItem->HasTemporaryLoot())
return EQUIP_ERR_ALREADY_LOOTED;

// do not allow unequipping gear except weapons, offhands, projectiles, relics in
// - combat
// you cannot unequip main hand weapon while disarmed
if (IsMainHandPos(pos) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED))
return EQUIP_ERR_NOT_WHILE_DISARMED;

// do not allow unequipping gear except weapons, offhands, projectiles, relics in combat
if (!pProto->CanChangeEquipStateInCombat())
{
if (IsInCombat())
Expand Down
1 change: 1 addition & 0 deletions src/game/Objects/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ class Player final: public Unit
static uint32 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot
uint32 GetHighestKnownArmorProficiency() const;
std::vector<Item*>& GetItemUpdateQueue() { return m_itemUpdateQueue; }
static bool IsMainHandPos(uint16 pos) { return uint8(pos >> 8) == INVENTORY_SLOT_BAG_0 && uint8(pos & 255) == EQUIPMENT_SLOT_MAINHAND; }
static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); }
static bool IsInventoryPos(uint8 bag, uint8 slot);
static bool IsEquipmentPos(uint16 pos) { return IsEquipmentPos(pos >> 8, pos & 255); }
Expand Down

0 comments on commit 2f500b9

Please sign in to comment.