Core/AreaTriggers: Add Spell* argument to AreaTriggerAI::OnCreate script

This commit is contained in:
Shauren
2023-06-24 20:10:14 +02:00
parent 76d2f29e4e
commit a03455acbb
8 changed files with 22 additions and 20 deletions

View File

@@ -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() { }

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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)

View File

@@ -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
{

View File

@@ -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()

View File

@@ -165,7 +165,7 @@ struct areatrigger_pal_ashen_hallow : AreaTriggerAI
}
}
void OnCreate() override
void OnCreate(Spell const* /*creatingSpell*/) override
{
RefreshPeriod();
_refreshTimer = _period;

View File

@@ -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))