diff options
| author | QAston <none@none> | 2010-12-05 21:38:52 +0100 |
|---|---|---|
| committer | QAston <none@none> | 2010-12-05 21:38:52 +0100 |
| commit | 59c1a238f5f4ba3888bb588958015a245ac83c45 (patch) | |
| tree | 5fca9cb35068f8635b542dc0dd4358749dd905ed /src/server/scripts | |
| parent | e2c9453442d0bf5497d048305e0ff9c993c74ab5 (diff) | |
Scripts/AuraScript: Make AuraApplication in OnEffectPeriodic never be NULL.
Scripts: remove some unnecessary NULL checks from scripts.
--HG--
branch : trunk
Diffstat (limited to 'src/server/scripts')
10 files changed, 62 insertions, 80 deletions
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 65254996eca..ce63835641b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1508,9 +1508,8 @@ class spell_blood_council_shadow_prison : public SpellScriptLoader void HandleDummyTick(AuraEffect const* aurEff, AuraApplication const* aurApp) { - if (aurApp) - if (aurApp->GetTarget()->isMoving()) - aurApp->GetTarget()->CastSpell(aurApp->GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, true, NULL, aurEff); + if (aurApp->GetTarget()->isMoving()) + aurApp->GetTarget()->CastSpell(aurApp->GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, true, NULL, aurEff); } void Register() diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 2f5451e3f22..b8929ebbe06 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -473,9 +473,6 @@ class spell_blood_queen_frenzied_bloodthirst : public SpellScriptLoader void OnRemove(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp, AuraEffectHandleModes /*mode*/) { - if (!aurApp) - return; - Unit* target = aurApp->GetTarget(); if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) if (InstanceScript* instance = target->GetInstanceScript()) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index bf079cfc757..3c7b349c6b4 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -760,8 +760,7 @@ class spell_putricide_gaseous_bloat : public SpellScriptLoader void HandleExtraEffect(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp) { - if (aurApp->GetTarget()) - aurApp->GetTarget()->RemoveAuraFromStack(GetSpellProto()->Id, aurApp->GetBase()->GetCasterGUID()); + aurApp->GetTarget()->RemoveAuraFromStack(GetSpellProto()->Id, aurApp->GetBase()->GetCasterGUID()); } void Register() diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index ed253dd4eda..b316424987b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -712,7 +712,7 @@ class spell_rotface_unstable_ooze_explosion_suicide : public SpellScriptLoader { PreventDefaultAction(); Unit* target = aurApp->GetTarget(); - if (!target || target->GetTypeId() != TYPEID_UNIT) + if (target->GetTypeId() != TYPEID_UNIT) return; target->ToCreature()->AI()->DoAction(EVENT_UNSTABLE_DESPAWN); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 188a859422f..8e943d13b1f 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -106,13 +106,13 @@ public: void HandleEffectPeriodic(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp) { - if (Unit* pTarget = aurApp->GetTarget()) - if (Player* pPlayerTarget = pTarget->ToPlayer()) - if (pPlayerTarget->IsFalling()) - { - pPlayerTarget->RemoveAurasDueToSpell(SPELL_PARACHUTE); - pPlayerTarget->CastSpell(pPlayerTarget, SPELL_PARACHUTE_BUFF, true); - } + Unit* pTarget = aurApp->GetTarget(); + if (Player* pPlayerTarget = pTarget->ToPlayer()) + if (pPlayerTarget->IsFalling()) + { + pPlayerTarget->RemoveAurasDueToSpell(SPELL_PARACHUTE); + pPlayerTarget->CastSpell(pPlayerTarget, SPELL_PARACHUTE_BUFF, true); + } } void Register() @@ -246,17 +246,17 @@ public: void HandleEffectPeriodic(AuraEffect const * aurEff, AuraApplication const * aurApp) { - if (Unit* pTarget = aurApp->GetTarget()) - if (Unit* pCaster = GetCaster()) - { - int32 lifeLeeched = pTarget->CountPctFromMaxHealth(aurEff->GetAmount()); - if (lifeLeeched < 250) - lifeLeeched = 250; - // Damage - pCaster->CastCustomSpell(pTarget, SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false); - // Heal - pCaster->CastCustomSpell(pCaster, SPELL_LEECHING_SWARM_HEAL, &lifeLeeched, 0, 0, false); - } + Unit* pTarget = aurApp->GetTarget(); + if (Unit* pCaster = GetCaster()) + { + int32 lifeLeeched = pTarget->CountPctFromMaxHealth(aurEff->GetAmount()); + if (lifeLeeched < 250) + lifeLeeched = 250; + // Damage + pCaster->CastCustomSpell(pTarget, SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false); + // Heal + pCaster->CastCustomSpell(pCaster, SPELL_LEECHING_SWARM_HEAL, &lifeLeeched, 0, 0, false); + } } void Register() @@ -408,8 +408,6 @@ class spell_creature_permanent_feign_death : public SpellScriptLoader void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/) { Unit* pTarget = aurApp->GetTarget(); - if (!pTarget) - return; pTarget->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); pTarget->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); @@ -528,20 +526,16 @@ class spell_gen_shroud_of_death : public SpellScriptLoader void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/) { - if (Unit* target = aurApp->GetTarget()) - { - target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); - target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); - } + Unit* target = aurApp->GetTarget(); + target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); + target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); } void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/) { - if (Unit* target = aurApp->GetTarget()) - { - target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); - target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); - } + Unit* target = aurApp->GetTarget(); + target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); + target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); } void Register() diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 5fa440c3633..906bc87ef69 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -361,29 +361,27 @@ public: if (aurEff->GetAmount() > 0) return; - if (Unit* pTarget = aurApp->GetTarget()) + uint32 spellId = SPELL_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_SNIPER_TRAINING_R1; + Unit * pTarget = aurApp->GetTarget(); + if (!pTarget->HasAura(spellId)) { - uint32 spellId = SPELL_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_SNIPER_TRAINING_R1; - if (!pTarget->HasAura(spellId)) - { - const SpellEntry* triggeredSpellInfo = sSpellStore.LookupEntry(spellId); - Unit* triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, GetCaster(), pTarget); - triggerCaster->CastSpell(pTarget, triggeredSpellInfo, true, 0, aurEff); - } + SpellEntry const * triggeredSpellInfo = sSpellStore.LookupEntry(spellId); + Unit* triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, GetCaster(), pTarget); + triggerCaster->CastSpell(pTarget, triggeredSpellInfo, true, 0, aurEff); } } void HandleUpdatePeriodic(AuraEffect * aurEff) { - if (Unit* pTarget = GetUnitOwner()) - if (Player* pPlayerTarget = pTarget->ToPlayer()) - { - int32 baseAmount = aurEff->GetBaseAmount(); - int32 amount = pPlayerTarget->isMoving() ? - pTarget->CalculateSpellDamage(pTarget, GetSpellProto(), aurEff->GetEffIndex(), &baseAmount) : - aurEff->GetAmount() - 1; - aurEff->SetAmount(amount); - } + Unit * pTarget = GetUnitOwner(); + if (Player* pPlayerTarget = pTarget->ToPlayer()) + { + int32 baseAmount = aurEff->GetBaseAmount(); + int32 amount = pPlayerTarget->isMoving() ? + pTarget->CalculateSpellDamage(pTarget, GetSpellProto(), aurEff->GetEffIndex(), &baseAmount) : + aurEff->GetAmount() - 1; + aurEff->SetAmount(amount); + } } void Register() diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index f543a2baaa0..2092735d2f8 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -701,8 +701,7 @@ public: void OnStackChange(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp, AuraEffectHandleModes /*mode*/) { Unit* target = aurApp->GetTarget(); - if (!target) - return; + switch (GetStackAmount()) { case 1: @@ -722,8 +721,7 @@ public: void OnRemove(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp, AuraEffectHandleModes /*mode*/) { Unit* target = aurApp->GetTarget(); - if (!target) - return; + if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_STACK) return; target->RemoveAurasDueToSpell(SPELL_SHADOWMOURNE_VISUAL_LOW); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index f0ccb58d2f5..c63a699fed0 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -110,16 +110,15 @@ public: void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/) { + Unit* pTarget = aurApp->GetTarget(); if (Unit* pCaster = GetCaster()) - if (Unit* pTarget = aurApp->GetTarget()) - pCaster->CastSpell(pTarget, PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, true); + pCaster->CastSpell(pTarget, PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, true); } void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/) { - if (GetCaster()) - if (Unit* pTarget = aurApp->GetTarget()) - pTarget->RemoveAura(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); + Unit* pTarget = aurApp->GetTarget(); + pTarget->RemoveAura(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); } void Register() diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 7a0d6204aa8..ed31db2d264 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -111,20 +111,18 @@ public: void HandleEffectPeriodic(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp) { - if (Unit* pTarget = aurApp->GetTarget()) + Unit* pTarget = aurApp->GetTarget(); + Unit* pVictim = pTarget->getVictim(); + if (pVictim && (pTarget->GetHealthPct() > pVictim->GetHealthPct())) { - Unit* pVictim = pTarget->getVictim(); - if (pVictim && (pTarget->GetHealthPct() > pVictim->GetHealthPct())) + if (!pTarget->HasAura(ROGUE_SPELL_PREY_ON_THE_WEAK)) { - if (!pTarget->HasAura(ROGUE_SPELL_PREY_ON_THE_WEAK)) - { - int32 bp = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), 0); - pTarget->CastCustomSpell(pTarget, ROGUE_SPELL_PREY_ON_THE_WEAK, &bp, 0, 0, true); - } + int32 bp = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), 0); + pTarget->CastCustomSpell(pTarget, ROGUE_SPELL_PREY_ON_THE_WEAK, &bp, 0, 0, true); } - else - pTarget->RemoveAurasDueToSpell(ROGUE_SPELL_PREY_ON_THE_WEAK); } + else + pTarget->RemoveAurasDueToSpell(ROGUE_SPELL_PREY_ON_THE_WEAK); } void Register() diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 1d88e3f68b5..f39cd2b064c 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -156,11 +156,11 @@ public: void HandleEffectPeriodic(AuraEffect const * aurEff, AuraApplication const * aurApp) { - if (Unit* target = aurApp->GetTarget()) - if (Unit *caster = aurEff->GetBase()->GetCaster()) - if (AuraEffect* aur = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0)) - if (roll_chance_i(aur->GetBaseAmount())) - target->CastSpell(target, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true, NULL, aurEff); + Unit* target = aurApp->GetTarget(); + if (Unit *caster = aurEff->GetBase()->GetCaster()) + if (AuraEffect* aur = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0)) + if (roll_chance_i(aur->GetBaseAmount())) + target->CastSpell(target, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true, NULL, aurEff); } void Register() |
