diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 4c6963c75..80e0aaaff 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -131,17 +131,6 @@ namespace Framework.Constants NosaveRespawn = 0x04, } - public enum SmartAITemplate - { - Basic = 0, //nothing is preset - Caster = 1, //spellid, repeatMin, repeatMax, range, manaPCT +JOIN: target_param1 as castFlag - Turret = 2, //spellid, repeatMin, repeatMax +JOIN: target_param1 as castFlag - Passive = 3, - CagedGOPart = 4, //creatureID, give credit at point end?, - CagedNPCPart = 5, //gameObjectID, despawntime, run?, dist, TextGroupID - End = 6 - } - [Flags] public enum SmartCastFlags { @@ -312,7 +301,7 @@ namespace Framework.Constants WpStop = 55, // Despawntime, Quest, Fail? AddItem = 56, // Itemid, Count RemoveItem = 57, // Itemid, Count - InstallAiTemplate = 58, // Aitemplateid + //Unused58 = 58, // do not reuse SetRun = 59, // 0/1 SetDisableGravity = 60, // 0/1 SetSwim = 61, // 0/1 diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 51829cec6..f3b388e00 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -448,9 +448,6 @@ namespace Game.AI if (Math.Abs(e.Target.o) > 2 * MathFunctions.PI) Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} has abs(`target.o` = {e.Target.o}) > 2*PI (orientation is expressed in radians)"); - if (e.GetActionType() == SmartActions.InstallAiTemplate) - return true; // AI template has special handling - switch (e.GetTargetType()) { case SmartTargets.CreatureDistance: @@ -747,7 +744,6 @@ namespace Game.AI SmartActions.WpStop => Marshal.SizeOf(typeof(SmartAction.WpStop)), SmartActions.AddItem => Marshal.SizeOf(typeof(SmartAction.Item)), SmartActions.RemoveItem => Marshal.SizeOf(typeof(SmartAction.Item)), - SmartActions.InstallAiTemplate => Marshal.SizeOf(typeof(SmartAction.InstallTtemplate)), SmartActions.SetRun => Marshal.SizeOf(typeof(SmartAction.SetRun)), SmartActions.SetDisableGravity => Marshal.SizeOf(typeof(SmartAction.SetDisableGravity)), SmartActions.SetSwim => Marshal.SizeOf(typeof(SmartAction.SetSwim)), @@ -1677,13 +1673,6 @@ namespace Game.AI return false; } break; - case SmartActions.InstallAiTemplate: - if (e.Action.installTtemplate.id >= (uint)SmartAITemplate.End) - { - Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Creature {0} Event {1} Action {2} uses non-existent AI template id {3}, skipped.", e.EntryOrGuid, e.EventId, e.GetActionType(), e.Action.installTtemplate.id); - return false; - } - break; case SmartActions.WpStop: if (e.Action.wpStop.quest != 0 && !IsQuestValid(e, e.Action.wpStop.quest)) return false; @@ -3040,9 +3029,6 @@ namespace Game.AI [FieldOffset(4)] public Item item; - [FieldOffset(4)] - public InstallTtemplate installTtemplate; - [FieldOffset(4)] public SetRun setRun; @@ -3471,15 +3457,6 @@ namespace Game.AI public uint entry; public uint count; } - public struct InstallTtemplate - { - public uint id; - public uint param1; - public uint param2; - public uint param3; - public uint param4; - public uint param5; - } public struct SetRun { public uint run; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 05fcff099..2fdcf757f 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -71,8 +71,6 @@ namespace Game.AI Dictionary _storedTargets = new(); - SmartAITemplate _template; - public SmartScript() { _go = null; @@ -85,7 +83,6 @@ namespace Game.AI _textGUID = ObjectGuid.Empty; _useTextTimer = false; _talkerEntry = 0; - _template = SmartAITemplate.Basic; _meOrigGUID = ObjectGuid.Empty; _goOrigGUID = ObjectGuid.Empty; LastInvoker = ObjectGuid.Empty; @@ -1262,11 +1259,6 @@ namespace Game.AI } break; } - case SmartActions.InstallAiTemplate: - { - InstallTemplate(e); - break; - } case SmartActions.AddItem: { foreach (var target in targets) @@ -2573,88 +2565,6 @@ namespace Game.AI RecalcTimer(e, Math.Min(min, 5000), Math.Min(min, 5000)); } - void InstallTemplate(SmartScriptHolder e) - { - if (GetBaseObject() == null) - return; - - if (_template != SmartAITemplate.Basic) - { - Log.outError(LogFilter.Sql, "SmartScript.InstallTemplate: Entry {0} SourceType {1} AI Template can not be set more then once, skipped.", e.EntryOrGuid, e.GetScriptType()); - return; - } - - _template = (SmartAITemplate)e.Action.installTtemplate.id; - switch ((SmartAITemplate)e.Action.installTtemplate.id) - { - case SmartAITemplate.Caster: - { - AddEvent(SmartEvents.UpdateIc, 0, 0, 0, e.Action.installTtemplate.param2, e.Action.installTtemplate.param3, 0, SmartActions.Cast, e.Action.installTtemplate.param1, e.Target.raw.param1, 0, 0, 0, 0, SmartTargets.Victim, 0, 0, 0, 0, 1); - AddEvent(SmartEvents.Range, 0, e.Action.installTtemplate.param4, 300, 0, 0, 0, SmartActions.AllowCombatMovement, 1, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 1); - AddEvent(SmartEvents.Range, 0, 0, e.Action.installTtemplate.param4 > 10 ? e.Action.installTtemplate.param4 - 10 : 0, 0, 0, 0, SmartActions.AllowCombatMovement, 0, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 1); - AddEvent(SmartEvents.ManaPct, 0, e.Action.installTtemplate.param5 - 15 > 100 ? 100 : e.Action.installTtemplate.param5 + 15, 100, 1000, 1000, 0, SmartActions.SetEventPhase, 1, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - AddEvent(SmartEvents.ManaPct, 0, 0, e.Action.installTtemplate.param5, 1000, 1000, 0, SmartActions.SetEventPhase, 0, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - AddEvent(SmartEvents.ManaPct, 0, 0, e.Action.installTtemplate.param5, 1000, 1000, 0, SmartActions.AllowCombatMovement, 1, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - break; - } - case SmartAITemplate.Turret: - { - AddEvent(SmartEvents.UpdateIc, 0, 0, 0, e.Action.installTtemplate.param2, e.Action.installTtemplate.param3, 0, SmartActions.Cast, e.Action.installTtemplate.param1, e.Target.raw.param1, 0, 0, 0, 0, SmartTargets.Victim, 0, 0, 0, 0, 0); - AddEvent(SmartEvents.JustCreated, 0, 0, 0, 0, 0, 0, SmartActions.AllowCombatMovement, 0, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - break; - } - case SmartAITemplate.CagedNPCPart: - { - if (_me == null) - return; - //store cage as id1 - AddEvent(SmartEvents.DataSet, 0, 0, 0, 0, 0, 0, SmartActions.StoreTargetList, 1, 0, 0, 0, 0, 0, SmartTargets.ClosestGameobject, e.Action.installTtemplate.param1, 10, 0, 0, 0); - - //reset(close) cage on hostage(me) respawn - AddEvent(SmartEvents.Update, SmartEventFlags.NotRepeatable, 0, 0, 0, 0, 0, SmartActions.ResetGobject, 0, 0, 0, 0, 0, 0, SmartTargets.GameobjectDistance, e.Action.installTtemplate.param1, 5, 0, 0, 0); - - AddEvent(SmartEvents.DataSet, 0, 0, 0, 0, 0, 0, SmartActions.SetRun, e.Action.installTtemplate.param3, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - AddEvent(SmartEvents.DataSet, 0, 0, 0, 0, 0, 0, SmartActions.SetEventPhase, 1, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - - AddEvent(SmartEvents.Update, SmartEventFlags.NotRepeatable, 1000, 1000, 0, 0, 0, SmartActions.MoveOffset, 0, 0, 0, 0, 0, 0, SmartTargets.Self, 0, e.Action.installTtemplate.param4, 0, 0, 1); - //phase 1: give quest credit on movepoint reached - AddEvent(SmartEvents.Movementinform, 0, (uint)MovementGeneratorType.Point, EventId.SmartRandomPoint, 0, 0, 0, SmartActions.SetData, 0, 0, 0, 0, 0, 0, SmartTargets.Stored, 1, 0, 0, 0, 1); - //phase 1: despawn after time on movepoint reached - AddEvent(SmartEvents.Movementinform, 0, (uint)MovementGeneratorType.Point, EventId.SmartRandomPoint, 0, 0, 0, SmartActions.ForceDespawn, e.Action.installTtemplate.param2, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 1); - - if (Global.CreatureTextMgr.TextExist(_me.GetEntry(), (byte)e.Action.installTtemplate.param5)) - AddEvent(SmartEvents.Movementinform, 0, (uint)MovementGeneratorType.Point, EventId.SmartRandomPoint, 0, 0, 0, SmartActions.Talk, e.Action.installTtemplate.param5, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 1); - break; - } - case SmartAITemplate.CagedGOPart: - { - if (_go == null) - return; - //store hostage as id1 - AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 1, 0, 0, 0, 0, 0, SmartTargets.ClosestCreature, e.Action.installTtemplate.param1, 10, 0, 0, 0); - //store invoker as id2 - AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 2, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0, 0); - //signal hostage - AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.SetData, 0, 0, 0, 0, 0, 0, SmartTargets.Stored, 1, 0, 0, 0, 0); - //when hostage raeched end point, give credit to invoker - if (e.Action.installTtemplate.param2 != 0) - AddEvent(SmartEvents.DataSet, 0, 0, 0, 0, 0, 0, SmartActions.CallKilledmonster, e.Action.installTtemplate.param1, 0, 0, 0, 0, 0, SmartTargets.Stored, 2, 0, 0, 0, 0); - else - AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.CallKilledmonster, e.Action.installTtemplate.param1, 0, 0, 0, 0, 0, SmartTargets.Stored, 2, 0, 0, 0, 0); - break; - } - default: - return; - } - } - - void AddEvent(SmartEvents e, SmartEventFlags event_flags, uint event_param1, uint event_param2, uint event_param3, uint event_param4, uint event_param5, - SmartActions action, uint action_param1, uint action_param2, uint action_param3, uint action_param4, uint action_param5, uint action_param6, - SmartTargets t, uint target_param1, uint target_param2, uint target_param3, uint target_param4, uint phaseMask) - { - _installEvents.Add(CreateSmartEvent(e, event_flags, event_param1, event_param2, event_param3, event_param4, event_param5, action, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, t, target_param1, target_param2, target_param3, target_param4, phaseMask)); - } - SmartScriptHolder CreateSmartEvent(SmartEvents e, SmartEventFlags event_flags, uint event_param1, uint event_param2, uint event_param3, uint event_param4, uint event_param5, SmartActions action, uint action_param1, uint action_param2, uint action_param3, uint action_param4, uint action_param5, uint action_param6, SmartTargets t, uint target_param1, uint target_param2, uint target_param3, uint target_param4, uint phaseMask)