From 691412d05c9a81322dc86f0efe9cf7c5c75ae8fc Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 21 Oct 2010 14:08:00 +0400 Subject: [PATCH] [10636] Implement server side check combo points req. for spell cast. Thanks to nos4r2zod for problem research. --- src/game/Player.cpp | 25 ++++++++++++------------- src/game/Player.h | 4 ++-- src/game/SharedDefines.h | 4 ++-- src/game/Spell.cpp | 21 ++++++++++++++------- src/game/SpellAuras.cpp | 4 ++-- src/game/SpellMgr.h | 2 +- src/game/Unit.cpp | 4 ++-- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 623406d18..df01f78da 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -430,7 +430,6 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m if(GetSession()->GetSecurity() == SEC_PLAYER) SetAcceptWhispers(true); - m_comboTarget = 0; m_comboPoints = 0; m_usedTalentCount = 0; @@ -6900,14 +6899,14 @@ void Player::DuelComplete(DuelCompleteType type) RemoveAurasDueToSpell(auras2remove[i]); // cleanup combo points - if(GetComboTarget()==duel->opponent->GetGUID()) + if (GetComboTargetGuid() == duel->opponent->GetObjectGuid()) ClearComboPoints(); - else if(GetComboTarget()==duel->opponent->GetPetGUID()) + else if (GetComboTargetGuid().GetRawValue() == duel->opponent->GetPetGUID()) ClearComboPoints(); - if(duel->opponent->GetComboTarget()==GetGUID()) + if (duel->opponent->GetComboTargetGuid() == GetObjectGuid()) duel->opponent->ClearComboPoints(); - else if(duel->opponent->GetComboTarget()==GetPetGUID()) + else if (duel->opponent->GetComboTargetGuid().GetRawValue() == GetPetGUID()) duel->opponent->ClearComboPoints(); //cleanups @@ -19448,7 +19447,7 @@ void Player::InitPrimaryProfessions() void Player::SendComboPoints() { - Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget); + Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTargetGuid); if (combotarget) { WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); @@ -19466,17 +19465,17 @@ void Player::AddComboPoints(Unit* target, int8 count) // without combo points lost (duration checked in aura) RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); - if(target->GetGUID() == m_comboTarget) + if(target->GetObjectGuid() == m_comboTargetGuid) { m_comboPoints += count; } else { - if(m_comboTarget) - if(Unit* target2 = ObjectAccessor::GetUnit(*this,m_comboTarget)) + if (!m_comboTargetGuid.IsEmpty()) + if(Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTargetGuid)) target2->RemoveComboPointHolder(GetGUIDLow()); - m_comboTarget = target->GetGUID(); + m_comboTargetGuid = target->GetObjectGuid(); m_comboPoints = count; target->AddComboPointHolder(GetGUIDLow()); @@ -19490,7 +19489,7 @@ void Player::AddComboPoints(Unit* target, int8 count) void Player::ClearComboPoints() { - if(!m_comboTarget) + if (m_comboTargetGuid.IsEmpty()) return; // without combopoints lost (duration checked in aura) @@ -19500,10 +19499,10 @@ void Player::ClearComboPoints() SendComboPoints(); - if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) + if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTargetGuid)) target->RemoveComboPointHolder(GetGUIDLow()); - m_comboTarget = 0; + m_comboTargetGuid.Clear(); } void Player::SetGroup(Group *group, int8 subgroup) diff --git a/src/game/Player.h b/src/game/Player.h index 297d905be..7d705b6db 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1583,7 +1583,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SetSelectionGuid(ObjectGuid guid) { m_curSelectionGuid = guid; SetTargetGuid(guid); } uint8 GetComboPoints() { return m_comboPoints; } - const uint64& GetComboTarget() const { return m_comboTarget; } + ObjectGuid const& GetComboTargetGuid() const { return m_comboTargetGuid; } void AddComboPoints(Unit* target, int8 count); void ClearComboPoints(); @@ -2512,7 +2512,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 m_ExtraFlags; ObjectGuid m_curSelectionGuid; - uint64 m_comboTarget; + ObjectGuid m_comboTargetGuid; int8 m_comboPoints; QuestStatusMap mQuestStatus; diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index f51ddeb72..13abe2ff0 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -275,9 +275,9 @@ const uint32 ItemQualityColors[MAX_ITEM_QUALITY] = { #define SPELL_ATTR_EX_UNK17 0x00020000 // 17 for auras SPELL_AURA_TRACK_CREATURES, SPELL_AURA_TRACK_RESOURCES and SPELL_AURA_TRACK_STEALTHED select non-stacking tracking spells #define SPELL_ATTR_EX_UNK18 0x00040000 // 18 #define SPELL_ATTR_EX_UNK19 0x00080000 // 19 -#define SPELL_ATTR_EX_REQ_COMBO_POINTS1 0x00100000 // 20 Req combo points on target +#define SPELL_ATTR_EX_REQ_TARGET_COMBO_POINTS 0x00100000 // 20 Req combo points on target #define SPELL_ATTR_EX_UNK21 0x00200000 // 21 -#define SPELL_ATTR_EX_REQ_COMBO_POINTS2 0x00400000 // 22 Req combo points on target +#define SPELL_ATTR_EX_REQ_COMBO_POINTS 0x00400000 // 22 Use combo points (in 4.x not required combo point target selected) #define SPELL_ATTR_EX_UNK23 0x00800000 // 23 #define SPELL_ATTR_EX_UNK24 0x01000000 // 24 Req fishing pole?? #define SPELL_ATTR_EX_UNK25 0x02000000 // 25 diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index c46115780..c59658ec2 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4297,14 +4297,21 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_CASTER_AURASTATE; } - // cancel autorepeat spells if cast start when moving - // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code) - if( m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->isMoving() ) + if (m_caster->GetTypeId() == TYPEID_PLAYER) { - // skip stuck spell to allow use it in falling case and apply spell limitations at movement - if( (!((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR) || m_spellInfo->Effect[EFFECT_INDEX_0] != SPELL_EFFECT_STUCK) && - (IsAutoRepeat() || (m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) != 0) ) - return SPELL_FAILED_MOVING; + // cancel autorepeat spells if cast start when moving + // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code) + if (((Player*)m_caster)->isMoving() ) + { + // skip stuck spell to allow use it in falling case and apply spell limitations at movement + if ((!((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR) || m_spellInfo->Effect[EFFECT_INDEX_0] != SPELL_EFFECT_STUCK) && + (IsAutoRepeat() || (m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) != 0)) + return SPELL_FAILED_MOVING; + } + + if (!m_IsTriggeredSpell && NeedsComboPoints(m_spellInfo) && + (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetObjectGuid() != ((Player*)m_caster)->GetComboTargetGuid())) + return SPELL_FAILED_NO_COMBO_POINTS; } if(Unit *target = m_targets.getUnitTarget()) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 3f2fa28b9..cac3f9eb6 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -6261,8 +6261,8 @@ void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) - if( !apply && m_removeMode == AURA_REMOVE_BY_EXPIRE && target->GetComboTarget()) - if(Unit* unit = ObjectAccessor::GetUnit(*GetTarget(),target->GetComboTarget())) + if (!apply && m_removeMode == AURA_REMOVE_BY_EXPIRE && !target->GetComboTargetGuid().IsEmpty()) + if (Unit* unit = ObjectAccessor::GetUnit(*GetTarget(),target->GetComboTargetGuid())) target->AddComboPoints(unit, -m_modifier.m_amount); } diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 8b0eb4b9c..a5ccb70da 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -462,7 +462,7 @@ inline bool IsChanneledSpell(SpellEntry const* spellInfo) inline bool NeedsComboPoints(SpellEntry const* spellInfo) { - return (spellInfo->AttributesEx & (SPELL_ATTR_EX_REQ_COMBO_POINTS1 | SPELL_ATTR_EX_REQ_COMBO_POINTS2)); + return (spellInfo->AttributesEx & (SPELL_ATTR_EX_REQ_TARGET_COMBO_POINTS | SPELL_ATTR_EX_REQ_COMBO_POINTS)); } inline SpellSchoolMask GetSpellSchoolMask(SpellEntry const* spellInfo) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 75375dd63..261412365 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8628,7 +8628,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt int32 value = basePoints; // random damage - if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget())) + if (comboDamage != 0 && unitPlayer && target && (target->GetObjectGuid() == unitPlayer->GetComboTargetGuid())) value += (int32)(comboDamage * comboPoints); if(Player* modOwner = GetSpellModOwner()) @@ -10021,7 +10021,7 @@ void Unit::ClearComboPointHolders() uint32 lowguid = *m_ComboPointHolders.begin(); Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, lowguid)); - if(plr && plr->GetComboTarget()==GetGUID()) // recheck for safe + if (plr && plr->GetComboTargetGuid() == GetObjectGuid())// recheck for safe plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders; else m_ComboPointHolders.erase(lowguid); // or remove manually