diff options
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 60 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 5 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 4 |
3 files changed, 64 insertions, 5 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d17d9d97e98..0e4a569b834 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -224,6 +224,7 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this) m_canParry = false; m_canBlock = false; m_canTitanGrip = false; + m_titanGripPenaltySpellId = 0; m_temporaryUnsummonedPetNumber = 0; //cache for UNIT_CREATED_BY_SPELL to allow @@ -3403,8 +3404,14 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) m_overrideSpells.erase(spell_id); - if (spell_id == 46917 && m_canTitanGrip) - SetCanTitanGrip(false); + if (m_canTitanGrip) + { + if (spellInfo && spellInfo->IsPassive() && spellInfo->HasEffect(SPELL_EFFECT_TITAN_GRIP)) + { + RemoveAurasDueToSpell(m_titanGripPenaltySpellId); + SetCanTitanGrip(false); + } + } if (m_canDualWield) { @@ -11833,6 +11840,9 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) return pItem2; } + if (slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND) + CheckTitanGripPenalty(); + // only for full equip instead adding to stack UpdateCriteria(CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); UpdateCriteria(CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot); @@ -11955,6 +11965,9 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem) pItem->SendUpdateToPlayer(this); } + if (slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND) + CheckTitanGripPenalty(); + UpdateCriteria(CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); UpdateCriteria(CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot); } @@ -12075,7 +12088,11 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty); if (slot < EQUIPMENT_SLOT_END) + { SetVisibleItemSlot(slot, nullptr); + if (slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND) + CheckTitanGripPenalty(); + } } else if (Bag* pBag = GetBagByPos(bag)) pBag->RemoveItem(slot, update); @@ -13256,6 +13273,30 @@ bool Player::IsUseEquipedWeapon(bool mainhand) const return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)); } +void Player::SetCanTitanGrip(bool value, uint32 penaltySpellId /*= 0*/) +{ + if (value == m_canTitanGrip) + return; + + m_canTitanGrip = value; + m_titanGripPenaltySpellId = penaltySpellId; +} + +void Player::CheckTitanGripPenalty() +{ + if (!CanTitanGrip()) + return; + + bool apply = IsUsingTwoHandedWeaponInOneHand(); + if (apply) + { + if (!HasAura(m_titanGripPenaltySpellId)) + CastSpell((Unit*)nullptr, m_titanGripPenaltySpellId, true); + } + else + RemoveAurasDueToSpell(m_titanGripPenaltySpellId); +} + bool Player::IsTwoHandUsed() const { Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); @@ -13268,6 +13309,21 @@ bool Player::IsTwoHandUsed() const (itemTemplate->GetInventoryType() == INVTYPE_RANGEDRIGHT && itemTemplate->GetClass() == ITEM_CLASS_WEAPON && itemTemplate->GetSubClass() != ITEM_SUBCLASS_WEAPON_WAND); } +bool Player::IsUsingTwoHandedWeaponInOneHand() const +{ + Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + + if (!mainItem || !offItem) + return false; + + if (mainItem->GetTemplate()->InventoryType != INVTYPE_2HWEAPON && + offItem->GetTemplate()->InventoryType != INVTYPE_2HWEAPON) + return false; + + return true; +} + void Player::TradeCancel(bool sendback) { if (m_trade) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 5de298686ea..dcfd2674057 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1473,6 +1473,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> uint32 GetArmorProficiency() const { return m_ArmorProficiency; } bool IsUseEquipedWeapon(bool mainhand) const; bool IsTwoHandUsed() const; + bool IsUsingTwoHandedWeaponInOneHand() const; void SendNewItem(Item* item, uint32 quantity, bool received, bool created, bool broadcast = false); bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); bool BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot, uint32 currency, uint32 count); @@ -2161,7 +2162,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> bool CanBlock() const { return m_canBlock; } void SetCanBlock(bool value); bool CanTitanGrip() const { return m_canTitanGrip; } - void SetCanTitanGrip(bool value) { m_canTitanGrip = value; } + void SetCanTitanGrip(bool value, uint32 penaltySpellId = 0); + void CheckTitanGripPenalty(); bool CanTameExoticPets() const { return IsGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); } void SetRegularAttackTime(); @@ -2744,6 +2746,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> bool m_canParry; bool m_canBlock; bool m_canTitanGrip; + uint32 m_titanGripPenaltySpellId; uint8 m_swingErrorMsg; ////////////////////Rest System///////////////////// diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index db59ed14f10..bab9bc02570 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -5219,13 +5219,13 @@ void Spell::EffectDiscoverTaxi(SpellEffIndex /*effIndex*/) unitTarget->ToPlayer()->GetSession()->SendDiscoverNewTaxiNode(nodeid); } -void Spell::EffectTitanGrip(SpellEffIndex /*effIndex*/) +void Spell::EffectTitanGrip(SpellEffIndex effIndex) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->SetCanTitanGrip(true); + m_caster->ToPlayer()->SetCanTitanGrip(true, uint32(effectInfo->MiscValue)); } void Spell::EffectRedirectThreat(SpellEffIndex /*effIndex*/) |