aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <none@none>2010-12-05 21:38:52 +0100
committerQAston <none@none>2010-12-05 21:38:52 +0100
commit59c1a238f5f4ba3888bb588958015a245ac83c45 (patch)
tree5fca9cb35068f8635b542dc0dd4358749dd905ed /src
parente2c9453442d0bf5497d048305e0ff9c993c74ab5 (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')
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp25
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h3
-rwxr-xr-xsrc/server/game/Spells/SpellScript.h2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp5
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp3
-rwxr-xr-xsrc/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp3
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp54
-rw-r--r--src/server/scripts/Spells/spell_hunter.cpp32
-rw-r--r--src/server/scripts/Spells/spell_item.cpp6
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp9
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp18
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp10
13 files changed, 84 insertions, 88 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index bcc00a0c1e4..9704ff48a45 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -400,6 +400,17 @@ void AuraEffect::GetTargetList(std::list<Unit *> & targetList) const
}
}
+void AuraEffect::GetApplicationList(std::list<AuraApplication *> & applicationList) const
+{
+ Aura::ApplicationMap const & targetMap = GetBase()->GetApplicationMap();
+ // remove all targets which were not added to new list - they no longer deserve area aura
+ for (Aura::ApplicationMap::const_iterator appIter = targetMap.begin(); appIter != targetMap.end(); ++appIter)
+ {
+ if (appIter->second->HasEffect(GetEffIndex()))
+ applicationList.push_back(appIter->second);
+ }
+}
+
int32 AuraEffect::CalculateAmount(Unit * caster)
{
int32 amount;
@@ -1057,13 +1068,13 @@ void AuraEffect::Update(uint32 diff, Unit * caster)
m_periodicTimer += m_amplitude - diff;
UpdatePeriodic(caster);
- UnitList effectTargets;
- GetTargetList(effectTargets);
+ std::list<AuraApplication*> effectApplications;
+ GetApplicationList(effectApplications);
// tick on targets of effects
if (!caster || !caster->hasUnitState(UNIT_STAT_ISOLATED))
{
- for (UnitList::iterator targetItr = effectTargets.begin(); targetItr != effectTargets.end(); ++targetItr)
- PeriodicTick(*targetItr, caster);
+ for (std::list<AuraApplication*>::iterator apptItr = effectApplications.begin(); apptItr != effectApplications.end(); ++apptItr)
+ PeriodicTick(*apptItr, caster);
}
}
}
@@ -1224,12 +1235,14 @@ void AuraEffect::SendTickImmune(Unit * target, Unit *caster) const
caster->SendSpellDamageImmune(target, m_spellProto->Id);
}
-void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
+void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
{
- bool prevented = GetBase()->CallScriptEffectPeriodicHandlers(const_cast<AuraEffect const *>(this), GetBase()->GetApplicationOfTarget(target->GetGUID()));
+ bool prevented = GetBase()->CallScriptEffectPeriodicHandlers(const_cast<AuraEffect const *>(this), aurApp);
if (prevented)
return;
+ Unit * target = aurApp->GetTarget();
+
switch(GetAuraType())
{
case SPELL_AURA_PERIODIC_DAMAGE:
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 2807e621673..0e07fb5ff3d 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -23,6 +23,7 @@ class AuraEffect
uint64 GetCasterGUID() const { return GetBase()->GetCasterGUID(); }
Aura * GetBase() const { return m_base; }
void GetTargetList(std::list<Unit*> & targetList) const;
+ void GetApplicationList(std::list<AuraApplication*> & applicationList) const;
SpellEntry const * GetSpellProto() const { return m_spellProto; }
uint32 GetId() const { return m_spellProto->Id; }
@@ -63,7 +64,7 @@ class AuraEffect
void SendTickImmune(Unit * target, Unit *caster) const;
- void PeriodicTick(Unit * target, Unit * caster) const;
+ void PeriodicTick(AuraApplication * aurApp, Unit * caster) const;
void PeriodicDummyTick(Unit * target, Unit * caster) const;
Unit* GetTriggerTarget(Unit * target) const;
void TriggerSpell(Unit * target, Unit * caster) const;
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 09ef73c37c0..0a06d5ab091 100755
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -444,7 +444,7 @@ class AuraScript : public _SpellScript
Unit* GetCaster() const;
// returns object on which aura was casted, target for non-area auras, area aura source for area auras
WorldObject * GetOwner() const;
- // returns owner if it's unit, NULL otherwise
+ // returns owner if it's unit or unit derived object, NULL otherwise (only for persistent area auras NULL is returned)
Unit * GetUnitOwner() const;
// returns owner if it's dynobj, NULL otherwise
DynamicObject * GetDynobjOwner() const;
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()