diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index ce45a5589..c580e69f1 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -4933,20 +4933,18 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/) if (!unitTarget) return; - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - sScriptMgr->AnticheatSetSkipOnePacketForASH(m_caster->ToPlayer(), true); - } - - // charge changes fall time - if( m_caster->GetTypeId() == TYPEID_PLAYER ) - m_caster->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), m_caster->GetPositionZ()); - ObjectGuid targetGUID = ObjectGuid::Empty; - if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !m_spellInfo->IsPositive() && m_caster->GetTypeId() == TYPEID_PLAYER && - m_caster->GetTarget() == unitTarget->GetGUID()) + Player* player = m_caster->ToPlayer(); + if (player) { - targetGUID = unitTarget->GetGUID(); + sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true); + // charge changes fall time + player->SetFallInformation(GameTime::GetGameTime().count(), m_caster->GetPositionZ()); + + if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !m_spellInfo->IsPositive() && m_caster->GetTarget() == unitTarget->GetGUID()) + { + targetGUID = unitTarget->GetGUID(); + } } float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE; @@ -4955,20 +4953,15 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/) { Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetCombatReach(), unitTarget->GetRelativeAngle(m_caster)); m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speed, EVENT_CHARGE, nullptr, false, 0.0f, targetGUID); - - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer()); - } } else { m_caster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed, targetGUID); + } - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer()); - } + if (player) + { + sScriptMgr->AnticheatSetUnderACKmount(player); } } @@ -5144,13 +5137,10 @@ void Spell::EffectSendTaxi(SpellEffIndex effIndex) if (!unitTarget) return; - Player* player = unitTarget->ToPlayer(); - if (!player) + if (Player* player = unitTarget->ToPlayer()) { - return; + player->ActivateTaxiPathTo(m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id); } - - player->ActivateTaxiPathTo(m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id); } void Spell::EffectPullTowards(SpellEffIndex effIndex) @@ -5732,13 +5722,10 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex) if (!unitTarget) return; - Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself(); - if (!player) + if (Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) { - return; + player->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue); } - - player->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue); } void Spell::EffectKillCredit(SpellEffIndex effIndex) @@ -5774,13 +5761,10 @@ void Spell::EffectQuestFail(SpellEffIndex effIndex) if (!unitTarget) return; - Player* player = unitTarget->ToPlayer(); - if (!player) + if (Player* player = unitTarget->ToPlayer()) { - return; + player->FailQuest(m_spellInfo->Effects[effIndex].MiscValue); } - - player->FailQuest(m_spellInfo->Effects[effIndex].MiscValue); } void Spell::EffectQuestStart(SpellEffIndex effIndex) @@ -6190,13 +6174,10 @@ void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/) if (!unitTarget) return; - Player* player = unitTarget->ToPlayer(); - if (!player) + if (Player* player = unitTarget->ToPlayer()) { - return; + player->UpdateSpecCount(damage); } - - player->UpdateSpecCount(damage); } void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/) @@ -6207,13 +6188,10 @@ void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/) if (!unitTarget) return; - Player* player = unitTarget->ToPlayer(); - if (!player) + if (Player* player = unitTarget->ToPlayer()) { - return; + player->ActivateSpec(damage - 1); // damage is 1 or 2, spec is 0 or 1 } - - player->ActivateSpec(damage - 1); // damage is 1 or 2, spec is 0 or 1 } void Spell::EffectPlaySound(SpellEffIndex effIndex)