aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-06-24 20:10:14 +0200
committerShauren <shauren.trinity@gmail.com>2023-06-24 20:10:14 +0200
commita03455acbbbb6b070c9592a9c5c24c8f109dccc8 (patch)
treed3f854c756b707a9b6caad19ca34b1d3379260f6 /src
parent76d2f29e4e4c0e14a014676aafff2f8836f96ea0 (diff)
Core/AreaTriggers: Add Spell* argument to AreaTriggerAI::OnCreate script
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/AreaTriggerAI.h11
-rw-r--r--src/server/game/Entities/AreaTrigger/AreaTrigger.cpp17
-rw-r--r--src/server/game/Entities/AreaTrigger/AreaTrigger.h4
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp2
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp2
8 files changed, 22 insertions, 20 deletions
diff --git a/src/server/game/AI/CoreAI/AreaTriggerAI.h b/src/server/game/AI/CoreAI/AreaTriggerAI.h
index 2153d577107..77924dae86c 100644
--- a/src/server/game/AI/CoreAI/AreaTriggerAI.h
+++ b/src/server/game/AI/CoreAI/AreaTriggerAI.h
@@ -21,6 +21,7 @@
#include "Define.h"
class AreaTrigger;
+class Spell;
class Unit;
class TC_GAME_API AreaTriggerAI
@@ -37,22 +38,22 @@ class TC_GAME_API AreaTriggerAI
virtual void OnInitialize() { }
// Called when the AreaTrigger has just been created
- virtual void OnCreate() { }
+ virtual void OnCreate([[maybe_unused]] Spell const* creatingSpell) { }
// Called on each AreaTrigger update
- virtual void OnUpdate(uint32 /*diff*/) { }
+ virtual void OnUpdate([[maybe_unused]] uint32 diff) { }
// Called when the AreaTrigger reach splineIndex
- virtual void OnSplineIndexReached(int /*splineIndex*/) { }
+ virtual void OnSplineIndexReached([[maybe_unused]] int32 splineIndex) { }
// Called when the AreaTrigger reach its destination
virtual void OnDestinationReached() { }
// Called when an unit enter the AreaTrigger
- virtual void OnUnitEnter(Unit* /*unit*/) { }
+ virtual void OnUnitEnter([[maybe_unused]] Unit* unit) { }
// Called when an unit exit the AreaTrigger, or when the AreaTrigger is removed
- virtual void OnUnitExit(Unit* /*unit*/) { }
+ virtual void OnUnitExit([[maybe_unused]] Unit* unit) { }
// Called when the AreaTrigger is removed
virtual void OnRemove() { }
diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
index 5c4dc985146..dac8444f667 100644
--- a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
+++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
@@ -92,7 +92,7 @@ void AreaTrigger::RemoveFromWorld()
}
}
-bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff)
+bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spellInfo, Position const& pos, int32 duration, SpellCastVisual spellVisual, Spell const* spell, AuraEffect const* aurEff)
{
_targetGuid = target ? target->GetGUID() : ObjectGuid::Empty;
_aurEff = aurEff;
@@ -128,10 +128,11 @@ bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Uni
auto areaTriggerData = m_values.ModifyValue(&AreaTrigger::m_areaTriggerData);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::Caster), caster->GetGUID());
- SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::CreatingEffectGUID), castId);
+ if (spell)
+ SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::CreatingEffectGUID), spell->m_castId);
- SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellID), spell->Id);
- SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spell->Id);
+ SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellID), spellInfo->Id);
+ SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spellInfo->Id);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::SpellXSpellVisualID), spellVisual.SpellXSpellVisualID);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::ScriptVisualID), spellVisual.ScriptVisualID);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::TimeToTargetScale), GetCreateProperties()->TimeToTargetScale != 0 ? GetCreateProperties()->TimeToTargetScale : *m_areaTriggerData->Duration);
@@ -218,15 +219,15 @@ bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Uni
caster->_RegisterAreaTrigger(this);
- _ai->OnCreate();
+ _ai->OnCreate(spell);
return true;
}
-AreaTrigger* AreaTrigger::CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId /*= ObjectGuid::Empty*/, AuraEffect const* aurEff /*= nullptr*/)
+AreaTrigger* AreaTrigger::CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spellInfo, Position const& pos, int32 duration, SpellCastVisual spellVisual, Spell const* spell /*= nullptr*/, AuraEffect const* aurEff /*= nullptr*/)
{
AreaTrigger* at = new AreaTrigger();
- if (!at->Create(areaTriggerCreatePropertiesId, caster, target, spell, pos, duration, spellVisual, castId, aurEff))
+ if (!at->Create(areaTriggerCreatePropertiesId, caster, target, spellInfo, pos, duration, spellVisual, spell, aurEff))
{
delete at;
return nullptr;
@@ -295,7 +296,7 @@ bool AreaTrigger::CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerT
AI_Initialize();
- _ai->OnCreate();
+ _ai->OnCreate(nullptr);
return true;
}
diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.h b/src/server/game/Entities/AreaTrigger/AreaTrigger.h
index 84d8de4d0d3..a461a11a173 100644
--- a/src/server/game/Entities/AreaTrigger/AreaTrigger.h
+++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.h
@@ -78,11 +78,11 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
bool IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects = false) const override;
private:
- bool Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff);
+ bool Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spellInfo, Position const& pos, int32 duration, SpellCastVisual spellVisual, Spell const* spell, AuraEffect const* aurEff);
bool CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerTemplate, AreaTriggerSpawn const& position);
public:
- static AreaTrigger* CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId = ObjectGuid::Empty, AuraEffect const* aurEff = nullptr);
+ static AreaTrigger* CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spellInfo, Position const& pos, int32 duration, SpellCastVisual spellVisual, Spell const* spell = nullptr, AuraEffect const* aurEff = nullptr);
static ObjectGuid CreateNewMovementForceId(Map* map, uint32 areaTriggerId);
bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool allowDuplicate);
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 7a544bb9f41..78bd542fc1f 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -536,7 +536,7 @@ class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks
static void LoadResetScript(AreaTrigger* at)
{
- at->AI()->OnCreate();
+ at->AI()->OnCreate(nullptr);
}
static Creature* GetEntityFromMap(std::common_type<Creature>, Map* map, ObjectGuid const& guid)
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 73dc1ee087a..198f2626d28 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -6089,7 +6089,7 @@ void AuraEffect::HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mo
if (apply)
{
- AreaTrigger::CreateAreaTrigger(GetMiscValue(), GetCaster(), target, GetSpellInfo(), *target, GetBase()->GetDuration(), GetBase()->GetSpellVisual(), ObjectGuid::Empty, this);
+ AreaTrigger::CreateAreaTrigger(GetMiscValue(), GetCaster(), target, GetSpellInfo(), *target, GetBase()->GetDuration(), GetBase()->GetSpellVisual(), nullptr, this);
}
else
{
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 3ac7951aa29..27867438eda 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -5253,7 +5253,7 @@ void Spell::EffectCreateAreaTrigger()
int32 duration = GetSpellInfo()->CalcDuration(GetCaster());
- AreaTrigger::CreateAreaTrigger(effectInfo->MiscValue, unitCaster, nullptr, GetSpellInfo(), destTarget->GetPosition(), duration, m_SpellVisual, m_castId);
+ AreaTrigger::CreateAreaTrigger(effectInfo->MiscValue, unitCaster, nullptr, GetSpellInfo(), destTarget->GetPosition(), duration, m_SpellVisual, this);
}
void Spell::EffectRemoveTalent()
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp
index e0636a0f272..1fbe326b4be 100644
--- a/src/server/scripts/Spells/spell_paladin.cpp
+++ b/src/server/scripts/Spells/spell_paladin.cpp
@@ -165,7 +165,7 @@ struct areatrigger_pal_ashen_hallow : AreaTriggerAI
}
}
- void OnCreate() override
+ void OnCreate(Spell const* /*creatingSpell*/) override
{
RefreshPeriod();
_refreshTimer = _period;
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index 6d5872f7437..80711dd25ad 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -436,7 +436,7 @@ struct areatrigger_sha_earthquake : AreaTriggerAI
{
areatrigger_sha_earthquake(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger), _refreshTimer(0s), _period(1s) { }
- void OnCreate() override
+ void OnCreate(Spell const* /*creatingSpell*/) override
{
if (Unit* caster = at->GetCaster())
if (AuraEffect const* earthquake = caster->GetAuraEffect(SPELL_SHAMAN_EARTHQUAKE, EFFECT_1))