diff options
author | ariel- <ariel-@users.noreply.github.com> | 2016-10-02 02:34:23 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2016-10-02 02:34:23 -0300 |
commit | a4baef19dd5d1fd42f20557d34219d9d14181545 (patch) | |
tree | 494399f0b92af157adc7182e172f2345cde6501e | |
parent | 03e21d2fad3b174f6e813f114f2828d9d9b510bb (diff) |
Core/Player: Implemented Titan's Grip damage reduction
Closes #6375
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 54 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 5 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 4 |
3 files changed, 60 insertions, 3 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 7824587a7bc..e91807aa5f9 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -401,6 +401,7 @@ Player::Player(WorldSession* session): Unit(true) m_canParry = false; m_canBlock = false; m_canTitanGrip = false; + m_titanGripPenaltySpellId = 0; m_ammoDPS = 0.0f; m_temporaryUnsummonedPetNumber = 0; @@ -3817,6 +3818,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) if (spell_id == 46917 && m_canTitanGrip) SetCanTitanGrip(false); + if (spell_id == 674 && m_canDualWield) SetCanDualWield(false); @@ -12074,6 +12076,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 UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot); @@ -12097,6 +12102,9 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem) pItem->SendUpdateToPlayer(this); } + if (slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND) + CheckTitanGripPenalty(); + UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot); } @@ -12217,7 +12225,11 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 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); @@ -13299,12 +13311,54 @@ 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; + + if (!value) + CheckTitanGripPenalty(); + + 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); return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); } +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 f9acbe22c10..56e0ed70496 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1268,6 +1268,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 count, bool received, bool created, bool broadcast = false); bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); @@ -1938,7 +1939,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(); @@ -2480,6 +2482,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; float m_ammoDPS; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 0ca5aea9ded..630236f05ac 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -5531,13 +5531,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, m_spellInfo->Effects[effIndex].MiscValue); } void Spell::EffectRedirectThreat(SpellEffIndex /*effIndex*/) |