chore(Scripts/Spells): Reduce the amount of player checks (#16719)

merge some player checks
This commit is contained in:
Synful-Syn
2023-07-17 07:24:18 -04:00
committed by GitHub
parent 8dba430d82
commit f84d786df0
+23 -45
View File
@@ -4933,21 +4933,19 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
if (!unitTarget) if (!unitTarget)
return; 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; ObjectGuid targetGUID = ObjectGuid::Empty;
if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !m_spellInfo->IsPositive() && m_caster->GetTypeId() == TYPEID_PLAYER && Player* player = m_caster->ToPlayer();
m_caster->GetTarget() == unitTarget->GetGUID()) if (player)
{
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(); targetGUID = unitTarget->GetGUID();
} }
}
float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE; float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE;
// Spell is not using explicit target - no generated path // Spell is not using explicit target - no generated path
@@ -4955,20 +4953,15 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
{ {
Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetCombatReach(), unitTarget->GetRelativeAngle(m_caster)); 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); 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 else
{ {
m_caster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed, targetGUID); 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,14 +5137,11 @@ void Spell::EffectSendTaxi(SpellEffIndex effIndex)
if (!unitTarget) if (!unitTarget)
return; return;
Player* player = unitTarget->ToPlayer(); if (Player* player = unitTarget->ToPlayer())
if (!player)
{ {
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) void Spell::EffectPullTowards(SpellEffIndex effIndex)
{ {
@@ -5732,14 +5722,11 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex)
if (!unitTarget) if (!unitTarget)
return; return;
Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself(); if (Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
if (!player)
{ {
return;
}
player->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue); player->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue);
} }
}
void Spell::EffectKillCredit(SpellEffIndex effIndex) void Spell::EffectKillCredit(SpellEffIndex effIndex)
{ {
@@ -5774,14 +5761,11 @@ void Spell::EffectQuestFail(SpellEffIndex effIndex)
if (!unitTarget) if (!unitTarget)
return; return;
Player* player = unitTarget->ToPlayer(); if (Player* player = unitTarget->ToPlayer())
if (!player)
{ {
return;
}
player->FailQuest(m_spellInfo->Effects[effIndex].MiscValue); player->FailQuest(m_spellInfo->Effects[effIndex].MiscValue);
} }
}
void Spell::EffectQuestStart(SpellEffIndex effIndex) void Spell::EffectQuestStart(SpellEffIndex effIndex)
{ {
@@ -6190,14 +6174,11 @@ void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/)
if (!unitTarget) if (!unitTarget)
return; return;
Player* player = unitTarget->ToPlayer(); if (Player* player = unitTarget->ToPlayer())
if (!player)
{ {
return;
}
player->UpdateSpecCount(damage); player->UpdateSpecCount(damage);
} }
}
void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/) void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/)
{ {
@@ -6207,14 +6188,11 @@ void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/)
if (!unitTarget) if (!unitTarget)
return; return;
Player* player = unitTarget->ToPlayer(); if (Player* player = unitTarget->ToPlayer())
if (!player)
{ {
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) void Spell::EffectPlaySound(SpellEffIndex effIndex)
{ {