diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-09-27 00:05:33 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-09-27 00:06:08 +0200 |
| commit | 3bc3b67a8fae059e1019446b09882dfa7fcd11a0 (patch) | |
| tree | 5ab7ad7036448ae3c4763196c76ce4453cd280cb /src/server/game/Entities | |
| parent | e51b6601779050837fcc87f27579b86c50446fc3 (diff) | |
Core/Player: Changed ranged weapons to be equipped in main hand slot instead of no longer used ranged slot
Closes #14675
Closes #15296
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Item/ItemTemplate.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 132 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 6 |
4 files changed, 50 insertions, 92 deletions
diff --git a/src/server/game/Entities/Item/ItemTemplate.h b/src/server/game/Entities/Item/ItemTemplate.h index c578b641ad2..cdcf7b558b8 100644 --- a/src/server/game/Entities/Item/ItemTemplate.h +++ b/src/server/game/Entities/Item/ItemTemplate.h @@ -444,7 +444,7 @@ enum ItemSubclassWeapon #define ITEM_SUBCLASS_MASK_WEAPON_RANGED (\ (1 << ITEM_SUBCLASS_WEAPON_BOW) | (1 << ITEM_SUBCLASS_WEAPON_GUN) |\ - (1 << ITEM_SUBCLASS_WEAPON_CROSSBOW) | (1 << ITEM_SUBCLASS_WEAPON_THROWN)) + (1 << ITEM_SUBCLASS_WEAPON_CROSSBOW)) #define MAX_ITEM_SUBCLASS_WEAPON 21 diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a2f74202883..b52172afcc8 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7503,7 +7503,7 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply) TC_LOG_DEBUG("entities.player.items", "applying mods for item %s", item->GetGUID().ToString().c_str()); - uint8 attacktype = Player::GetAttackBySlot(slot); + uint8 attacktype = Player::GetAttackBySlot(slot, item->GetTemplate()->GetInventoryType()); if (item->GetSocketColor(0)) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items CorrectMetaGemEnchants(slot, apply); @@ -7750,9 +7750,7 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply) WeaponAttackType attType = BASE_ATTACK; - if (slot == EQUIPMENT_SLOT_RANGED && ( - proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || - proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) + if (slot == EQUIPMENT_SLOT_MAINHAND && (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) { attType = RANGED_ATTACK; } @@ -7771,16 +7769,10 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply) WeaponAttackType attType = BASE_ATTACK; float damage = 0.0f; - if (slot == EQUIPMENT_SLOT_RANGED && ( - proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || - proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) - { + if (slot == EQUIPMENT_SLOT_MAINHAND && (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) attType = RANGED_ATTACK; - } else if (slot == EQUIPMENT_SLOT_OFFHAND) - { attType = OFF_ATTACK; - } float minDamage, maxDamage; item->GetDamage(this, minDamage, maxDamage); @@ -7798,14 +7790,7 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply) } if (proto->GetDelay() && !IsInFeralForm()) - { - if (slot == EQUIPMENT_SLOT_RANGED) - SetAttackTime(RANGED_ATTACK, apply ? proto->GetDelay() : BASE_ATTACK_TIME); - else if (slot == EQUIPMENT_SLOT_MAINHAND) - SetAttackTime(BASE_ATTACK, apply ? proto->GetDelay() : BASE_ATTACK_TIME); - else if (slot == EQUIPMENT_SLOT_OFFHAND) - SetAttackTime(OFF_ATTACK, apply ? proto->GetDelay() : BASE_ATTACK_TIME); - } + SetAttackTime(attType, apply ? proto->GetDelay() : BASE_ATTACK_TIME); if (CanModifyStats() && (damage || proto->GetDelay())) UpdateDamagePhysical(attType); @@ -7959,7 +7944,7 @@ void Player::UpdateEquipSpellsAtFormChange() { for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if (m_items[i] && !m_items[i]->IsBroken() && CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i] && !m_items[i]->IsBroken() && CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) { ApplyItemEquipSpell(m_items[i], false, true); // remove spells that not fit to form ApplyItemEquipSpell(m_items[i], true, true); // add spells that fit form but not active @@ -8014,7 +7999,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 { case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; - case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; + case RANGED_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; default: slot = EQUIPMENT_SLOT_END; break; } if (slot != i) @@ -8233,7 +8218,7 @@ void Player::_RemoveAllItemMods() if (proto->GetItemSet()) RemoveItemsSetItem(this, proto); - if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) continue; ApplyItemEquipSpell(m_items[i], false); @@ -8245,10 +8230,10 @@ void Player::_RemoveAllItemMods() { if (m_items[i]) { - if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) continue; - uint32 attacktype = Player::GetAttackBySlot(i); + uint32 attacktype = Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()); if (attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false); @@ -8267,10 +8252,10 @@ void Player::_ApplyAllItemMods() { if (m_items[i]) { - if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) continue; - uint32 attacktype = Player::GetAttackBySlot(i); + uint32 attacktype = Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()); if (attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), true); @@ -8290,7 +8275,7 @@ void Player::_ApplyAllItemMods() if (proto->GetItemSet()) AddItemsSetItem(this, m_items[i]); - if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) continue; ApplyItemEquipSpell(m_items[i], true); @@ -8307,7 +8292,7 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply) { if (m_items[i]) { - if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) + if (m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) continue; _ApplyItemBonuses(m_items[i], i, apply); @@ -9469,8 +9454,6 @@ void Player::SetSheath(SheathState sheathed) uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const { - uint8 playerClass = getClass(); - uint8 slots[4]; slots[0] = NULL_SLOT; slots[1] = NULL_SLOT; @@ -9536,31 +9519,11 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c slots[0] = EQUIPMENT_SLOT_OFFHAND; break; case INVTYPE_RANGED: - slots[0] = EQUIPMENT_SLOT_RANGED; + slots[0] = EQUIPMENT_SLOT_MAINHAND; break; case INVTYPE_2HWEAPON: slots[0] = EQUIPMENT_SLOT_MAINHAND; - if (Item* mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) - { - if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) - { - if (mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_STAFF) - { - const_cast<Player*>(this)->AutoUnequipOffhandIfNeed(true); - break; - } - } - } - - if (GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - { - if (proto->GetSubClass() == ITEM_SUBCLASS_WEAPON_POLEARM || proto->GetSubClass() == ITEM_SUBCLASS_WEAPON_STAFF) - { - const_cast<Player*>(this)->AutoUnequipOffhandIfNeed(true); - break; - } - } - if (CanDualWield() && CanTitanGrip() && proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_POLEARM && proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_STAFF) + if (CanDualWield() && CanTitanGrip()) slots[1] = EQUIPMENT_SLOT_OFFHAND; break; case INVTYPE_TABARD: @@ -9575,11 +9538,8 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c case INVTYPE_HOLDABLE: slots[0] = EQUIPMENT_SLOT_OFFHAND; break; - case INVTYPE_THROWN: - slots[0] = EQUIPMENT_SLOT_RANGED; - break; case INVTYPE_RANGEDRIGHT: - slots[0] = EQUIPMENT_SLOT_RANGED; + slots[0] = EQUIPMENT_SLOT_MAINHAND; break; case INVTYPE_BAG: slots[0] = INVENTORY_SLOT_BAG_START + 0; @@ -9587,13 +9547,6 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c slots[2] = INVENTORY_SLOT_BAG_START + 2; slots[3] = INVENTORY_SLOT_BAG_START + 3; break; - case INVTYPE_RELIC: - { - if (playerClass == CLASS_PALADIN || playerClass == CLASS_DRUID || - playerClass == CLASS_SHAMAN || playerClass == CLASS_DEATH_KNIGHT) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - } default: return NULL_SLOT; } @@ -9786,9 +9739,14 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const //Does additional check for disarmed weapons Item* Player::GetUseableItemByPos(uint8 bag, uint8 slot) const { - if (!CanUseAttackType(GetAttackBySlot(slot))) - return NULL; - return GetItemByPos(bag, slot); + Item* item = GetItemByPos(bag, slot); + if (!item) + return nullptr; + + if (!CanUseAttackType(GetAttackBySlot(slot, item->GetTemplate()->GetInventoryType()))) + return nullptr; + + return item; } Bag* Player::GetBagByPos(uint8 bag) const @@ -9807,7 +9765,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f { case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; - case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; + case RANGED_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; default: return NULL; } @@ -9847,13 +9805,12 @@ Item* Player::GetShield(bool useable) const return item; } -uint8 Player::GetAttackBySlot(uint8 slot) +uint8 Player::GetAttackBySlot(uint8 slot, InventoryType inventoryType) { switch (slot) { - case EQUIPMENT_SLOT_MAINHAND: return BASE_ATTACK; + case EQUIPMENT_SLOT_MAINHAND: return inventoryType != INVTYPE_RANGED && inventoryType != INVTYPE_RANGEDRIGHT ? BASE_ATTACK : RANGED_ATTACK; case EQUIPMENT_SLOT_OFFHAND: return OFF_ATTACK; - case EQUIPMENT_SLOT_RANGED: return RANGED_ATTACK; default: return MAX_ATTACK; } } @@ -11675,7 +11632,6 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) { case EQUIPMENT_SLOT_MAINHAND: case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: RecalculateRating(CR_ARMOR_PENETRATION); default: break; @@ -11838,7 +11794,6 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { case EQUIPMENT_SLOT_MAINHAND: case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: RecalculateRating(CR_ARMOR_PENETRATION); default: break; @@ -11968,7 +11923,6 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) { case EQUIPMENT_SLOT_MAINHAND: case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: RecalculateRating(CR_ARMOR_PENETRATION); default: break; @@ -12891,7 +12845,13 @@ bool Player::IsUseEquipedWeapon(bool mainhand) const bool Player::IsTwoHandUsed() const { Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - return mainItem && mainItem->GetTemplate()->GetInventoryType() == INVTYPE_2HWEAPON && !CanTitanGrip(); + if (!mainItem) + return false; + + ItemTemplate const* itemTemplate = mainItem->GetTemplate(); + return (itemTemplate->GetInventoryType() == INVTYPE_2HWEAPON && !CanTitanGrip()) || + itemTemplate->GetInventoryType() == INVTYPE_RANGED || + (itemTemplate->GetInventoryType() == INVTYPE_RANGEDRIGHT && itemTemplate->GetClass() == ITEM_CLASS_WEAPON && itemTemplate->GetSubClass() != ITEM_SUBCLASS_WEAPON_WAND); } void Player::TradeCancel(bool sendback) @@ -13151,11 +13111,14 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool break; case ITEM_ENCHANTMENT_TYPE_DAMAGE: if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) - HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(enchant_amount), apply); + { + if (item->GetTemplate()->GetInventoryType() != INVTYPE_RANGED && item->GetTemplate()->GetInventoryType() != INVTYPE_RANGEDRIGHT) + HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(enchant_amount), apply); + else + HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); + } else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(enchant_amount), apply); - else if (item->GetSlot() == EQUIPMENT_SLOT_RANGED) - HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: if (enchant_spell_id) @@ -23421,10 +23384,12 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons { case ITEM_CLASS_WEAPON: { - for (uint8 i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; break; } case ITEM_CLASS_ARMOR: @@ -23440,11 +23405,6 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; - // ranged slot can have some armor subclasses - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - break; } default: diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0f481741369..05aa3d5bbf4 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1408,7 +1408,7 @@ class Player : public Unit, public GridObject<Player> Bag* GetBagByPos(uint8 slot) const; Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; Item* GetShield(bool useable = false) const; - static uint8 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot + static uint8 GetAttackBySlot(uint8 slot, InventoryType inventoryType); // MAX_ATTACK if not weapon slot std::vector<Item*> &GetItemUpdateQueue() { return m_itemUpdateQueue; } static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); } static bool IsInventoryPos(uint8 bag, uint8 slot); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c8db3a07573..44b078028bb 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5917,7 +5917,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID()) return false; - WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot())); + WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot(), castItem->GetTemplate()->GetInventoryType())); if ((attType != BASE_ATTACK && attType != OFF_ATTACK) || (attType == BASE_ATTACK && procFlag & PROC_FLAG_DONE_OFFHAND_ATTACK) || (attType == OFF_ATTACK && procFlag & PROC_FLAG_DONE_MAINHAND_ATTACK)) @@ -13286,12 +13286,10 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const if (spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) { Item* item = NULL; - if (attType == BASE_ATTACK) + if (attType == BASE_ATTACK || attType == RANGED_ATTACK) item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); else if (attType == OFF_ATTACK) item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - else - item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); if (player->IsInFeralForm()) return false; |
