diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 8ebbf9e1d..3c8aaa318 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -166,13 +166,13 @@ namespace Framework.Constants Range = 9, // Mindist, Maxdist, Repeatmin, Repeatmax OocLos = 10, // HostilityMode, Maxrnage, Cooldownmin, Cooldownmax Respawn = 11, // Type, Mapid, Zoneid - TargetHealthPct = 12, // Hpmin%, Hpmax%, Repeatmin, Repeatmax + TargetHealthPct = 12, // UNUSED, do not reuse VictimCasting = 13, // Repeatmin, Repeatmax - FriendlyHealth = 14, // Hpdeficit, Radius, Repeatmin, Repeatmax + FriendlyHealth = 14, // UNUSED, do not reuse FriendlyIsCc = 15, // Radius, Repeatmin, Repeatmax FriendlyMissingBuff = 16, // Spellid, Radius, Repeatmin, Repeatmax SummonedUnit = 17, // Creatureid(0 All), Cooldownmin, Cooldownmax - TargetManaPct = 18, // Manamin%, Manamax%, Repeatmin, Repeatmax + TargetManaPct = 18, // UNUSED, do not reuse AcceptedQuest = 19, // QuestID (0 = any), CooldownMin, CooldownMax RewardQuest = 20, // QuestID (0 = any), CooldownMin, CooldownMax ReachedHome = 21, // None @@ -221,7 +221,7 @@ namespace Framework.Constants GossipHello = 64, // noReportUse (for GOs) FollowCompleted = 65, // None PhaseChange = 66, - IsBehindTarget = 67, // Cooldownmin, Cooldownmax + IsBehindTarget = 67, // UNUSED, do not reuse GameEventStart = 68, // GameEvent.Entry GameEventEnd = 69, // GameEvent.Entry GoLootStateChanged = 70, // Go State @@ -261,8 +261,8 @@ namespace Framework.Constants CallAreaexploredoreventhappens = 15, // Questid SetIngamePhaseGroup = 16, // phaseGroupId, apply SetEmoteState = 17, // Emoteid - SetUnitFlag = 18, // Flags - RemoveUnitFlag = 19, // Flags + SetUnitFlag = 18, // UNUSED, do not reuse + RemoveUnitFlag = 19, // UNUSED, do not reuse AutoAttack = 20, // Allowattackstate (0 = Stop Attack, Anything Else Means Continue Attacking) AllowCombatMovement = 21, // Allowcombatmovement (0 = Stop Combat Based Movement, Anything Else Continue Attacking) SetEventPhase = 22, // Phase @@ -301,7 +301,7 @@ namespace Framework.Constants WpStop = 55, // Despawntime, Quest, Fail? AddItem = 56, // Itemid, Count RemoveItem = 57, // Itemid, Count - InstallAITemplate = 58, // do not use + InstallAITemplate = 58, // UNUSED, do not reuse SetRun = 59, // 0/1 SetDisableGravity = 60, // 0/1 SetSwim = 61, // 0/1 @@ -337,9 +337,9 @@ namespace Framework.Constants RemoveUnitFieldBytes1 = 91, // Bytes, Target InterruptSpell = 92, SendGoCustomAnim = 93, // Anim Id - SetDynamicFlag = 94, // do not use - AddDynamicFlag = 95, // Flags - RemoveDynamicFlag = 96, // Flags + SetDynamicFlag = 94, // UNUSED, do not reuse + AddDynamicFlag = 95, // UNUSED, do not reuse + RemoveDynamicFlag = 96, // UNUSED, do not reuse JumpToPos = 97, // Speedxy, Speedz, Targetx, Targety, Targetz SendGossipMenu = 98, // Menuid, optionIndex GoSetLootState = 99, // State diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 0fea3bae4..27fa8e09c 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -249,11 +249,8 @@ namespace Game.AI case SmartEvents.UpdateOoc: case SmartEvents.UpdateIc: case SmartEvents.HealthPct: - case SmartEvents.TargetHealthPct: case SmartEvents.ManaPct: - case SmartEvents.TargetManaPct: case SmartEvents.Range: - case SmartEvents.FriendlyHealth: case SmartEvents.FriendlyHealthPCT: case SmartEvents.FriendlyMissingBuff: case SmartEvents.HasAura: @@ -414,17 +411,13 @@ namespace Game.AI case SmartEvents.IcLos: case SmartEvents.OocLos: case SmartEvents.DistanceCreature: - case SmartEvents.FriendlyHealth: case SmartEvents.FriendlyHealthPCT: case SmartEvents.FriendlyIsCc: case SmartEvents.FriendlyMissingBuff: case SmartEvents.ActionDone: - case SmartEvents.TargetHealthPct: - case SmartEvents.TargetManaPct: case SmartEvents.Range: case SmartEvents.VictimCasting: case SmartEvents.TargetBuffed: - case SmartEvents.IsBehindTarget: case SmartEvents.InstancePlayerEnter: case SmartEvents.TransportAddcreature: case SmartEvents.DataSet: @@ -572,13 +565,10 @@ namespace Game.AI SmartEvents.Range => Marshal.SizeOf(typeof(SmartEvent.MinMaxRepeat)), SmartEvents.OocLos => Marshal.SizeOf(typeof(SmartEvent.Los)), SmartEvents.Respawn => Marshal.SizeOf(typeof(SmartEvent.Respawn)), - SmartEvents.TargetHealthPct => Marshal.SizeOf(typeof(SmartEvent.MinMaxRepeat)), SmartEvents.VictimCasting => Marshal.SizeOf(typeof(SmartEvent.TargetCasting)), - SmartEvents.FriendlyHealth => Marshal.SizeOf(typeof(SmartEvent.FriendlyHealth)), SmartEvents.FriendlyIsCc => Marshal.SizeOf(typeof(SmartEvent.FriendlyCC)), SmartEvents.FriendlyMissingBuff => Marshal.SizeOf(typeof(SmartEvent.MissingBuff)), SmartEvents.SummonedUnit => Marshal.SizeOf(typeof(SmartEvent.Summoned)), - SmartEvents.TargetManaPct => Marshal.SizeOf(typeof(SmartEvent.MinMaxRepeat)), SmartEvents.AcceptedQuest => Marshal.SizeOf(typeof(SmartEvent.Quest)), SmartEvents.RewardQuest => Marshal.SizeOf(typeof(SmartEvent.Quest)), SmartEvents.ReachedHome => 0, @@ -627,7 +617,6 @@ namespace Game.AI SmartEvents.GossipHello => Marshal.SizeOf(typeof(SmartEvent.GossipHello)), SmartEvents.FollowCompleted => 0, SmartEvents.PhaseChange => Marshal.SizeOf(typeof(SmartEvent.EventPhaseChange)), - SmartEvents.IsBehindTarget => Marshal.SizeOf(typeof(SmartEvent.BehindTarget)), SmartEvents.GameEventStart => Marshal.SizeOf(typeof(SmartEvent.GameEvent)), SmartEvents.GameEventEnd => Marshal.SizeOf(typeof(SmartEvent.GameEvent)), SmartEvents.GoLootStateChanged => Marshal.SizeOf(typeof(SmartEvent.GoLootStateChanged)), @@ -700,8 +689,6 @@ namespace Game.AI SmartActions.CallAreaexploredoreventhappens => Marshal.SizeOf(typeof(SmartAction.Quest)), SmartActions.SetIngamePhaseGroup => Marshal.SizeOf(typeof(SmartAction.IngamePhaseGroup)), SmartActions.SetEmoteState => Marshal.SizeOf(typeof(SmartAction.Emote)), - SmartActions.SetUnitFlag => Marshal.SizeOf(typeof(SmartAction.UnitFlag)), - SmartActions.RemoveUnitFlag => Marshal.SizeOf(typeof(SmartAction.UnitFlag)), SmartActions.AutoAttack => Marshal.SizeOf(typeof(SmartAction.AutoAttack)), SmartActions.AllowCombatMovement => Marshal.SizeOf(typeof(SmartAction.CombatMove)), SmartActions.SetEventPhase => Marshal.SizeOf(typeof(SmartAction.SetEventPhase)), @@ -987,8 +974,6 @@ namespace Game.AI case SmartEvents.UpdateOoc: case SmartEvents.HealthPct: case SmartEvents.ManaPct: - case SmartEvents.TargetHealthPct: - case SmartEvents.TargetManaPct: case SmartEvents.Range: case SmartEvents.Damaged: case SmartEvents.DamagedTarget: @@ -1041,13 +1026,6 @@ namespace Game.AI return false; } break; - case SmartEvents.FriendlyHealth: - if (!NotNULL(e, e.Event.friendlyHealth.radius)) - return false; - - if (!IsMinMaxValid(e, e.Event.friendlyHealth.repeatMin, e.Event.friendlyHealth.repeatMax)) - return false; - break; case SmartEvents.FriendlyIsCc: if (!IsMinMaxValid(e, e.Event.friendlyCC.repeatMin, e.Event.friendlyCC.repeatMax)) return false; @@ -1184,12 +1162,6 @@ namespace Game.AI } break; } - case SmartEvents.IsBehindTarget: - { - if (!IsMinMaxValid(e, e.Event.behindTarget.cooldownMin, e.Event.behindTarget.cooldownMax)) - return false; - break; - } case SmartEvents.GameEventStart: case SmartEvents.GameEventEnd: { @@ -1358,24 +1330,18 @@ namespace Game.AI case SmartEvents.SceneComplete: case SmartEvents.SceneTrigger: break; + + //Unused + case SmartEvents.TargetHealthPct: + case SmartEvents.FriendlyHealth: + case SmartEvents.TargetManaPct: + case SmartEvents.IsBehindTarget: + Log.outError(LogFilter.Sql, $"SmartAIMgr: Unused event_type {e} skipped."); + return false; default: Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Not handled event_type({0}), Entry {1} SourceType {2} Event {3} Action {4}, skipped.", e.GetEventType(), e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType()); return false; } - - // Additional check for deprecated - switch (e.GetEventType()) - { - // Deprecated - case SmartEvents.FriendlyHealth: - case SmartEvents.TargetHealthPct: - case SmartEvents.IsBehindTarget: - case SmartEvents.TargetManaPct: - Log.outWarn(LogFilter.Sql, $"SmartAIMgr: Deprecated event_type({e.GetEventType()}), {e}, it might be removed in the future, loaded for now."); - break; - default: - break; - } } if (!CheckUnusedEventParams(e)) @@ -2127,8 +2093,6 @@ namespace Game.AI case SmartActions.AttackStop: case SmartActions.WpPause: case SmartActions.ForceDespawn: - case SmartActions.SetUnitFlag: - case SmartActions.RemoveUnitFlag: case SmartActions.Playmovie: case SmartActions.CloseGossip: case SmartActions.TriggerTimedEvent: @@ -2146,8 +2110,6 @@ namespace Game.AI case SmartActions.SetUnitFieldBytes1: case SmartActions.RemoveUnitFieldBytes1: case SmartActions.SendGoCustomAnim: - case SmartActions.AddDynamicFlag: - case SmartActions.RemoveDynamicFlag: case SmartActions.JumpToPos: case SmartActions.SendGossipMenu: case SmartActions.GoSetLootState: @@ -2178,30 +2140,19 @@ namespace Game.AI break; } // No longer supported + case SmartActions.SetUnitFlag: + case SmartActions.RemoveUnitFlag: case SmartActions.InstallAITemplate: case SmartActions.SetDynamicFlag: - Log.outError(LogFilter.Sql, $"SmartAIMgr: No longer supported action_type: {e} Skipped."); + case SmartActions.AddDynamicFlag: + case SmartActions.RemoveDynamicFlag: + Log.outError(LogFilter.Sql, $"SmartAIMgr: Unused action_type: {e} Skipped."); return false; default: Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Not handled action_type({0}), event_type({1}), Entry {2} SourceType {3} Event {4}, skipped.", e.GetActionType(), e.GetEventType(), e.EntryOrGuid, e.GetScriptType(), e.EventId); return false; } - // Additional check for deprecated - switch (e.GetActionType()) - { - // Deprecated - case SmartActions.SetUnitFlag: - case SmartActions.RemoveUnitFlag: - case SmartActions.AddItem: - case SmartActions.AddDynamicFlag: - case SmartActions.RemoveDynamicFlag: - Log.outWarn(LogFilter.Sql, $"SmartAIMgr: Deprecated action_type: {e}, it might be removed in the future, loaded for now."); - break; - default: - break; - } - if (!CheckUnusedActionParams(e)) return false; @@ -2612,9 +2563,6 @@ namespace Game.AI [FieldOffset(16)] public TargetCasting targetCasting; - [FieldOffset(16)] - public FriendlyHealth friendlyHealth; - [FieldOffset(16)] public FriendlyCC friendlyCC; @@ -2675,9 +2623,6 @@ namespace Game.AI [FieldOffset(16)] public EventPhaseChange eventPhaseChange; - [FieldOffset(16)] - public BehindTarget behindTarget; - [FieldOffset(16)] public GameEvent gameEvent; @@ -2755,13 +2700,6 @@ namespace Game.AI public uint repeatMax; public uint spellId; } - public struct FriendlyHealth - { - public uint hpDeficit; - public uint radius; - public uint repeatMin; - public uint repeatMax; - } public struct FriendlyCC { public uint radius; @@ -2865,11 +2803,6 @@ namespace Game.AI { public uint phasemask; } - public struct BehindTarget - { - public uint cooldownMin; - public uint cooldownMax; - } public struct GameEvent { public uint gameEventId; @@ -3097,9 +3030,6 @@ namespace Game.AI [FieldOffset(4)] public Equip equip; - [FieldOffset(4)] - public UnitFlag unitFlag; - [FieldOffset(4)] public Flag flag; @@ -3555,10 +3485,6 @@ namespace Game.AI public uint slot2; public uint slot3; } - public struct UnitFlag - { - public uint flag; - } public struct Flag { public uint flag; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index f2aba031f..1c5b2cd4a 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -626,32 +626,6 @@ namespace Game.AI } break; } - case SmartActions.SetUnitFlag: - { - foreach (var target in targets) - { - if (IsUnit(target)) - { - target.ToUnit().AddUnitFlag((UnitFlags)e.Action.unitFlag.flag); - Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_UNIT_FLAG. Unit {0} added flag {1} to UNIT_FIELD_FLAGS", - target.GetGUID().ToString(), e.Action.unitFlag.flag); - } - } - break; - } - case SmartActions.RemoveUnitFlag: - { - foreach (var target in targets) - { - if (IsUnit(target)) - { - target.ToUnit().RemoveUnitFlag((UnitFlags)e.Action.unitFlag.flag); - Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_REMOVE_UNIT_FLAG. Unit {0} removed flag {1} to UNIT_FIELD_FLAGS", - target.GetGUID().ToString(), e.Action.unitFlag.flag); - } - } - break; - } case SmartActions.AutoAttack: { if (!IsSmart()) @@ -3149,16 +3123,6 @@ namespace Game.AI ProcessTimedAction(e, e.Event.minMaxRepeat.repeatMin, e.Event.minMaxRepeat.repeatMax); break; } - case SmartEvents.TargetHealthPct: - { - if (_me == null || !_me.IsEngaged() || _me.GetVictim() == null || _me.GetVictim().GetMaxHealth() == 0) - return; - uint perc = (uint)_me.GetVictim().GetHealthPct(); - if (perc > e.Event.minMaxRepeat.max || perc < e.Event.minMaxRepeat.min) - return; - ProcessTimedAction(e, e.Event.minMaxRepeat.repeatMin, e.Event.minMaxRepeat.repeatMax, _me.GetVictim()); - break; - } case SmartEvents.ManaPct: { if (_me == null || !_me.IsEngaged() || _me.GetMaxPower(PowerType.Mana) == 0) @@ -3169,16 +3133,6 @@ namespace Game.AI ProcessTimedAction(e, e.Event.minMaxRepeat.repeatMin, e.Event.minMaxRepeat.repeatMax); break; } - case SmartEvents.TargetManaPct: - { - if (_me == null || !_me.IsEngaged() || _me.GetVictim() == null || _me.GetVictim().GetMaxPower(PowerType.Mana) == 0) - return; - uint perc = (uint)_me.GetVictim().GetPowerPct(PowerType.Mana); - if (perc > e.Event.minMaxRepeat.max || perc < e.Event.minMaxRepeat.min) - return; - ProcessTimedAction(e, e.Event.minMaxRepeat.repeatMin, e.Event.minMaxRepeat.repeatMax, _me.GetVictim()); - break; - } case SmartEvents.Range: { if (_me == null || !_me.IsEngaged() || _me.GetVictim() == null) @@ -3211,22 +3165,6 @@ namespace Game.AI ProcessTimedAction(e, e.Event.targetCasting.repeatMin, e.Event.targetCasting.repeatMax, _me.GetVictim()); break; } - case SmartEvents.FriendlyHealth: - { - if (_me == null || !_me.IsEngaged()) - return; - - Unit target = DoSelectLowestHpFriendly(e.Event.friendlyHealth.radius, e.Event.friendlyHealth.hpDeficit); - if (target == null || !target.IsInCombat()) - { - // if there are at least two same npcs, they will perform the same action immediately even if this is useless... - RecalcTimer(e, 1000, 3000); - return; - } - - ProcessTimedAction(e, e.Event.friendlyHealth.repeatMin, e.Event.friendlyHealth.repeatMax, target); - break; - } case SmartEvents.FriendlyIsCc: { if (_me == null || !_me.IsEngaged()) @@ -3336,19 +3274,6 @@ namespace Game.AI ProcessAction(e, unit, var0, var1, bvar, spell, gob); break; } - case SmartEvents.IsBehindTarget: - { - if (_me == null) - return; - - Unit victim = _me.GetVictim(); - if (victim != null) - { - if (!victim.HasInArc(MathFunctions.PI, _me)) - ProcessTimedAction(e, e.Event.behindTarget.cooldownMin, e.Event.behindTarget.cooldownMax, victim); - } - break; - } case SmartEvents.ReceiveEmote: if (e.Event.emote.emoteId == var0) { @@ -3810,17 +3735,13 @@ namespace Game.AI case SmartEvents.UpdateIc: case SmartEvents.UpdateOoc: case SmartEvents.HealthPct: - case SmartEvents.TargetHealthPct: case SmartEvents.ManaPct: - case SmartEvents.TargetManaPct: case SmartEvents.Range: case SmartEvents.VictimCasting: - case SmartEvents.FriendlyHealth: case SmartEvents.FriendlyIsCc: case SmartEvents.FriendlyMissingBuff: case SmartEvents.HasAura: case SmartEvents.TargetBuffed: - case SmartEvents.IsBehindTarget: case SmartEvents.FriendlyHealthPCT: case SmartEvents.DistanceCreature: case SmartEvents.DistanceGameobject: