Scripts/AuraScript: Make AuraApplication in OnEffectPeriodic never be NULL.

Scripts: remove some unnecessary NULL checks from scripts.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-12-05 21:38:52 +01:00
parent e2c9453442
commit 59c1a238f5
13 changed files with 84 additions and 88 deletions
@@ -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()
@@ -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())
@@ -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()
@@ -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);
+24 -30
View File
@@ -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()
+15 -17
View File
@@ -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()
+2 -4
View File
@@ -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);
+4 -5
View File
@@ -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()
+8 -10
View File
@@ -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()
+5 -5
View File
@@ -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()