diff --git a/Source/Game/DataStorage/AreaTriggerDataStorage.cs b/Source/Game/DataStorage/AreaTriggerDataStorage.cs index 0596ca834..f0eec3fed 100644 --- a/Source/Game/DataStorage/AreaTriggerDataStorage.cs +++ b/Source/Game/DataStorage/AreaTriggerDataStorage.cs @@ -122,9 +122,9 @@ namespace Game.DataStorage // 0 1 2 3 4 SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " + - //5 6 7 8 9 10 11 12 13 + - "MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale, " + - //14 15 16 17 18 19 20 21 22 23 + //5 6 7 8 9 10 11 12 13 14 + "MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTarget, TimeToTargetScale, " + + //15 16 17 18 19 20 21 22 23 24 "Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`"); if (!areatriggerCreateProperties.IsEmpty()) { @@ -139,7 +139,7 @@ namespace Game.DataStorage createProperties.Flags = (AreaTriggerCreatePropertiesFlag)areatriggerCreateProperties.Read(4); - AreaTriggerShapeType shape = (AreaTriggerShapeType)areatriggerCreateProperties.Read(14); + AreaTriggerShapeType shape = (AreaTriggerShapeType)areatriggerCreateProperties.Read(15); if (areaTriggerId.Id != 0 && createProperties.Template == null) { @@ -173,17 +173,27 @@ namespace Game.DataStorage createProperties.AnimKitId = areatriggerCreateProperties.Read(10); createProperties.DecalPropertiesId = areatriggerCreateProperties.Read(11); - createProperties.TimeToTarget = areatriggerCreateProperties.Read(12); - createProperties.TimeToTargetScale = areatriggerCreateProperties.Read(13); + if (!areatriggerCreateProperties.IsNull(12)) + { + createProperties.SpellForVisuals = areatriggerCreateProperties.Read(12); + if (!Global.SpellMgr.HasSpellInfo(createProperties.SpellForVisuals.Value, Difficulty.None)) + { + Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid SpellForVisual {createProperties.SpellForVisuals.Value}, set to none."); + createProperties.SpellForVisuals = null; + } + } + + createProperties.TimeToTarget = areatriggerCreateProperties.Read(13); + createProperties.TimeToTargetScale = areatriggerCreateProperties.Read(14); createProperties.Shape.TriggerType = shape; unsafe { for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i) - createProperties.Shape.DefaultDatas.Data[i] = areatriggerCreateProperties.Read(15 + i); + createProperties.Shape.DefaultDatas.Data[i] = areatriggerCreateProperties.Read(16 + i); } - createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read(23)); + createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read(24)); if (shape == AreaTriggerShapeType.Polygon) { @@ -274,8 +284,8 @@ namespace Game.DataStorage uint oldMSTime = Time.GetMSTime(); // Load area trigger positions (to put them on the server) - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - SQLResult result = DB.World.Query("SELECT SpawnId, AreaTriggerCreatePropertiesId, IsCustom, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, SpellForVisuals, ScriptName FROM `areatrigger`"); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + SQLResult result = DB.World.Query("SELECT SpawnId, AreaTriggerCreatePropertiesId, IsCustom, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, ScriptName FROM `areatrigger`"); if (!result.IsEmpty()) { do @@ -344,17 +354,7 @@ namespace Game.DataStorage spawn.PhaseId = result.Read(10); spawn.PhaseGroup = result.Read(11); - if (!result.IsNull(12)) - { - spawn.SpellForVisuals = result.Read(12); - if (!Global.SpellMgr.HasSpellInfo(spawn.SpellForVisuals.Value, Difficulty.None)) - { - Log.outError(LogFilter.Sql, $"Table `areatrigger` has areatrigger (GUID: {spawnId}) with invalid SpellForVisual {spawn.SpellForVisuals}, set to none."); - spawn.SpellForVisuals = null; - } - } - - spawn.ScriptId = Global.ObjectMgr.GetScriptId(result.Read(13)); + spawn.ScriptId = Global.ObjectMgr.GetScriptId(result.Read(12)); spawn.spawnGroupData = Global.ObjectMgr.GetLegacySpawnGroup(); // Add the trigger to a map::cell map, which is later used by GridLoader to query diff --git a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs index c04ec474c..f3fe0128c 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs @@ -128,8 +128,17 @@ namespace Game.Entities if (spellInfo != null && !IsStaticSpawn()) SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellID), spellInfo.Id); - if (spellInfo != null) - SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellForVisuals), spellInfo.Id); + + SpellInfo spellForVisuals = spellInfo; + if (GetCreateProperties().SpellForVisuals.HasValue) + { + spellForVisuals = Global.SpellMgr.GetSpellInfo(GetCreateProperties().SpellForVisuals.Value, Difficulty.None); + + if (spellForVisuals != null) + spellVisual.SpellXSpellVisualID = spellForVisuals.GetSpellXSpellVisualId(); + } + if (spellForVisuals != null) + SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellForVisuals), spellForVisuals.Id); SpellCastVisualField spellCastVisual = areaTriggerData.ModifyValue(m_areaTriggerData.SpellVisual); SetUpdateFieldValue(ref spellCastVisual.SpellXSpellVisualID, spellVisual.SpellXSpellVisualID); @@ -268,15 +277,7 @@ namespace Game.Entities if (createProperties == null) return false; - SpellInfo spellInfo = null; - SpellCastVisual spellVisual = default; - if (spawnData.SpellForVisuals.HasValue) - { - spellInfo = Global.SpellMgr.GetSpellInfo(spawnData.SpellForVisuals.Value, Difficulty.None); - if (spellInfo != null) - spellVisual.SpellXSpellVisualID = spellInfo.GetSpellXSpellVisualId(); - } - return Create(spawnData.Id, map, spawnData.SpawnPoint, -1, spawnData, null, null, spellVisual, spellInfo); + return Create(spawnData.Id, map, spawnData.SpawnPoint, -1, spawnData); } public override void Update(uint diff) diff --git a/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs b/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs index cca9d9f2f..55523e941 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs @@ -262,6 +262,8 @@ namespace Game.Entities public uint DecalPropertiesId; + public uint? SpellForVisuals; + public uint TimeToTarget; public uint TimeToTargetScale; @@ -286,7 +288,6 @@ namespace Game.Entities public class AreaTriggerSpawn : SpawnData { public new AreaTriggerId Id; - public uint? SpellForVisuals; public AreaTriggerSpawn() : base(SpawnObjectType.AreaTrigger) { } }