diff --git a/modules/mod-Forge/src/ForgeCache.cpp b/modules/mod-Forge/src/ForgeCache.cpp index 65159684ab8d11..e78a4dcb7156fb 100644 --- a/modules/mod-Forge/src/ForgeCache.cpp +++ b/modules/mod-Forge/src/ForgeCache.cpp @@ -2,6 +2,7 @@ #define OUT #include +#include "AreaTriggerDataStore.h" #include "ScriptMgr.h" #include "Player.h" #include "Config.h" @@ -1040,6 +1041,8 @@ class ForgeCache : public DatabaseScript LOG_INFO("server.load", "Loading npc sounds..."); sObjectMgr->LoadNpcSounds(); + + sAreaTriggerDataStore->LoadAreaTriggerTemplates(); } catch (std::exception & ex) { std::string error = ex.what(); diff --git a/src/server/game/Globals/AreaTriggerDataStore.cpp b/src/server/game/Globals/AreaTriggerDataStore.cpp index 3fa123d4ccc079..bcb1188ecb468e 100644 --- a/src/server/game/Globals/AreaTriggerDataStore.cpp +++ b/src/server/game/Globals/AreaTriggerDataStore.cpp @@ -59,58 +59,6 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates() LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates actions. DB table `areatrigger_template_actions` is empty."); } - // 0 1 2 3 4 5 - if (QueryResult vertices = WorldDatabase.Query("SELECT AreaTriggerId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `areatrigger_template_polygon_vertices` ORDER BY `AreaTriggerId`, `Idx`")) - { - do - { - Field* verticeFields = vertices->Fetch(); - uint32 areaTriggerId = verticeFields[0].Get(); - - verticesByAreaTrigger[areaTriggerId].emplace_back(verticeFields[2].Get(), verticeFields[3].Get()); - - if (!verticeFields[4].IsNull() && !verticeFields[5].IsNull()) - verticesTargetByAreaTrigger[areaTriggerId].emplace_back(verticeFields[4].Get(), verticeFields[5].Get()); - else if (verticeFields[4].IsNull() != verticeFields[5].IsNull()) - LOG_ERROR("sql.sql", "Table `areatrigger_template_polygon_vertices` has listed invalid target vertices (AreaTrigger: %u, Index: %u).", areaTriggerId, verticeFields[1].Get()); - } while (vertices->NextRow()); - } - else - { - LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates polygon vertices. DB table `areatrigger_template_polygon_vertices` is empty."); - } - - // 0 1 2 3 - if (QueryResult splines = WorldDatabase.Query("SELECT SpellMiscId, X, Y, Z FROM `spell_areatrigger_splines` ORDER BY `SpellMiscId`, `Idx`")) - { - do - { - Field* splineFields = splines->Fetch(); - uint32 spellMiscId = splineFields[0].Get(); - splinesBySpellMisc[spellMiscId].emplace_back(splineFields[1].Get(), splineFields[2].Get(), splineFields[3].Get()); - } while (splines->NextRow()); - } - else - { - LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates splines. DB table `spell_areatrigger_splines` is empty."); - } - - // 0 1 2 3 4 5 6 - if (QueryResult rollpitchyaws = WorldDatabase.Query("SELECT SpellMiscId, X, Y, Z, TargetX, TargetY, TargetZ FROM `spell_areatrigger_rollpitchyaw` ORDER BY `SpellMiscId`")) - { - do - { - Field* rollpitchyawFields = rollpitchyaws->Fetch(); - uint32 spellMiscId = rollpitchyawFields[0].Get(); - rollpitchyawBySpellMisc[spellMiscId].emplace_back(rollpitchyawFields[1].Get(), rollpitchyawFields[2].Get(), rollpitchyawFields[3].Get()); - rollpitchyawBySpellMisc[spellMiscId].emplace_back(rollpitchyawFields[4].Get(), rollpitchyawFields[5].Get(), rollpitchyawFields[6].Get()); - } while (rollpitchyaws->NextRow()); - } - else - { - LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates Roll Pitch Yaw. DB table `spell_areatrigger_rollpitchyaw` is empty."); - } - // 0 1 2 3 4 5 6 7 8 9 if (QueryResult templates = WorldDatabase.Query("SELECT Id, Type, Flags, Data0, Data1, Data2, Data3, Data4, Data5, ScriptName FROM `areatrigger_template`")) { @@ -145,7 +93,7 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates() } // 0 1 2 3 4 5 6 7 8 9 10 - if (QueryResult areatriggerSpellMiscs = WorldDatabase.Query("SELECT SpellMiscId, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale FROM `spell_areatrigger`")) + if (QueryResult areatriggerSpellMiscs = WorldDatabase.Query("SELECT SpellMiscId, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale FROM `areatrigger_create_properties`")) { do { @@ -203,50 +151,6 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates() LOG_INFO("server.loading", ">> Loaded 0 Spell AreaTrigger templates. DB table `spell_areatrigger` is empty."); } - // 0 1 2 3 4 5 6 7 - if (QueryResult circularMovementInfos = WorldDatabase.Query("SELECT SpellMiscId, StartDelay, CircleRadius, BlendFromRadius, InitialAngle, ZOffset, CounterClockwise, CanLoop FROM `spell_areatrigger_circular` ORDER BY `SpellMiscId`")) - { - do - { - Field* circularMovementInfoFields = circularMovementInfos->Fetch(); - uint32 spellMiscId = circularMovementInfoFields[0].Get(); - - auto atSpellMiscItr = _areaTriggerTemplateSpellMisc.find(spellMiscId); - if (atSpellMiscItr == _areaTriggerTemplateSpellMisc.end()) - { - LOG_ERROR("sql.sql", "Table `spell_areatrigger_circular` reference invalid SpellMiscId %u", spellMiscId); - continue; - } - - AreaTriggerOrbitInfo& orbitInfo = atSpellMiscItr->second.OrbitInfo; - - orbitInfo.StartDelay = circularMovementInfoFields[1].Get(); - -#define VALIDATE_AND_SET_FLOAT(Float, Value) \ - orbitInfo.Float = Value; \ - if (!std::isfinite(orbitInfo.Float)) \ - { \ - LOG_ERROR("sql.sql", "Table `spell_areatrigger_circular` has listed areatrigger (MiscId: %u) with invalid " #Float " (%f), set to 0!", \ - spellMiscId, orbitInfo.Float); \ - orbitInfo.Float = 0.0f; \ - } - - VALIDATE_AND_SET_FLOAT(Radius, circularMovementInfoFields[2].Get()); - VALIDATE_AND_SET_FLOAT(BlendFromRadius, circularMovementInfoFields[3].Get()); - VALIDATE_AND_SET_FLOAT(InitialAngle, circularMovementInfoFields[4].Get()); - VALIDATE_AND_SET_FLOAT(ZOffset, circularMovementInfoFields[5].Get()); - -#undef VALIDATE_AND_SET_FLOAT - - orbitInfo.CounterClockwise = circularMovementInfoFields[6].Get(); - orbitInfo.CanLoop = circularMovementInfoFields[7].Get(); - } while (circularMovementInfos->NextRow()); - } - else - { - LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates circular movement infos. DB table `spell_areatrigger_circular` is empty."); - } - LOG_INFO("server.loading", ">> Loaded {} spell areatrigger templates in %u ms.", _areaTriggerTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime)); } diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index 4101043da508d5..c53ad7f262db20 100644 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -393,6 +393,7 @@ enum AuraType SPELL_AURA_MOD_SPELL_POWER_OF_STAT_PERCENT = 330, SPELL_AURA_MOD_SPELL_POWER_OF_RATING_PERCENT = 331, SPELL_AURA_MOD_TRIGGER_SPELL_ON_POWER_PCT = 332, + SPELL_AURA_AREA_TRIGGER = 333, TOTAL_AURAS }; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 33a03a0b42fdd2..cb008126f33727 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -393,6 +393,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS] = &AuraEffect::HandleAuraModSpellPowerOfStatPercent, //330 SPELL_AURA_MOD_SPELL_POWER_OF_STAT_PERCENT &AuraEffect::HandleAuraModSpellPowerOfCombatRatingPercent, //331 SPELL_AURA_MOD_SPELL_POWER_OF_RATING_PERCENT &AuraEffect::HandleAuraModTriggerSpellPowerPercent, //332 SPELL_AURA_MOD_TRIGGER_SPELL_ON_POWER_PCT + &AuraEffect::HandleCreateAreaTrigger, //333 SPELL_AURA_AREA_TRIGGER }; AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32* baseAmount, Unit* caster): @@ -7246,3 +7247,19 @@ void AuraEffect::HandleAuraAddCharges(AuraApplication const* aurApp, uint8 mode, } } } + +void AuraEffect::HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mode, bool apply) const +{ + if (!(mode & AURA_EFFECT_HANDLE_REAL)) + return; + + Unit* target = aurApp->GetTarget(); + + if (Unit* caster = GetCaster()) + { + if (apply) + AreaTrigger::CreateAreaTrigger(GetMiscValue(), caster, target, GetSpellInfo(), *target, GetBase()->GetDuration(), m_spellInfo->SpellVisual, ObjectGuid::Empty, this); + //else + // caster->RemoveAreaTrigger(this); + } +} diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 84482dc03ce1fc..bf5eb6cfb49ab8 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -339,6 +339,7 @@ class AuraEffect void HandleModTriggerSpellOnStacksSelf(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleModTriggerSpellOnStacksTarget(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleModToggleAuraCombatState(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mode, bool apply) const; // aura effect periodic tick handlers void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const;