Core/SAI: Remove deprecated events and actions
Port From (https://github.com/TrinityCore/TrinityCore/commit/29190e56428afa8d5acd2cf6ca3d712c2558899d)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user