Core/SAI: Split set/remove unit_flags actions
Port From (https://github.com/TrinityCore/TrinityCore/commit/e80777cb39d5eb940348300aa2a6d42cede039a8)
This commit is contained in:
@@ -824,9 +824,9 @@ namespace Game.AI
|
|||||||
SmartActions.SetHover => Marshal.SizeOf(typeof(SmartAction.SetHover)),
|
SmartActions.SetHover => Marshal.SizeOf(typeof(SmartAction.SetHover)),
|
||||||
SmartActions.SetHealthPct => Marshal.SizeOf(typeof(SmartAction.SetHealthPct)),
|
SmartActions.SetHealthPct => Marshal.SizeOf(typeof(SmartAction.SetHealthPct)),
|
||||||
SmartActions.CreateConversation => Marshal.SizeOf(typeof(SmartAction.Conversation)),
|
SmartActions.CreateConversation => Marshal.SizeOf(typeof(SmartAction.Conversation)),
|
||||||
//SmartActions.SetImmunePc => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
SmartActions.SetImmunePC => Marshal.SizeOf(typeof(SmartAction.SetImmunePC)),
|
||||||
//SmartActions.SetImmuneNpc => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
SmartActions.SetImmuneNPC => Marshal.SizeOf(typeof(SmartAction.SetImmuneNPC)),
|
||||||
//SmartActions.SetUninteractible => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
SmartActions.SetUninteractible => Marshal.SizeOf(typeof(SmartAction.SetUninteractible)),
|
||||||
//SmartActions.ActivateGameobject => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
//SmartActions.ActivateGameobject => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
||||||
SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)),
|
SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)),
|
||||||
SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)),
|
SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)),
|
||||||
@@ -1370,6 +1370,7 @@ namespace Game.AI
|
|||||||
case SmartEvents.FriendlyHealth:
|
case SmartEvents.FriendlyHealth:
|
||||||
case SmartEvents.TargetHealthPct:
|
case SmartEvents.TargetHealthPct:
|
||||||
case SmartEvents.IsBehindTarget:
|
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.");
|
Log.outWarn(LogFilter.Sql, $"SmartAIMgr: Deprecated event_type({e.GetEventType()}), {e}, it might be removed in the future, loaded for now.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2082,6 +2083,21 @@ namespace Game.AI
|
|||||||
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.setHealthRegen.regenHealth);
|
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.setHealthRegen.regenHealth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.SetImmunePC:
|
||||||
|
{
|
||||||
|
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.setImmunePC.immunePC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SmartActions.SetImmuneNPC:
|
||||||
|
{
|
||||||
|
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.setImmuneNPC.immuneNPC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SmartActions.SetUninteractible:
|
||||||
|
{
|
||||||
|
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.setUninteractible.uninteractible);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SmartActions.CreateConversation:
|
case SmartActions.CreateConversation:
|
||||||
{
|
{
|
||||||
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null)
|
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null)
|
||||||
@@ -2171,6 +2187,21 @@ namespace Game.AI
|
|||||||
return false;
|
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))
|
if (!CheckUnusedActionParams(e))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -3204,6 +3235,15 @@ namespace Game.AI
|
|||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public SetHealthPct setHealthPct;
|
public SetHealthPct setHealthPct;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public SetImmunePC setImmunePC;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public SetImmuneNPC setImmuneNPC;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public SetUninteractible setUninteractible;
|
||||||
|
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public Conversation conversation;
|
public Conversation conversation;
|
||||||
|
|
||||||
@@ -3748,6 +3788,18 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
public uint percent;
|
public uint percent;
|
||||||
}
|
}
|
||||||
|
public struct SetImmunePC
|
||||||
|
{
|
||||||
|
public uint immunePC;
|
||||||
|
}
|
||||||
|
public struct SetImmuneNPC
|
||||||
|
{
|
||||||
|
public uint immuneNPC;
|
||||||
|
}
|
||||||
|
public struct SetUninteractible
|
||||||
|
{
|
||||||
|
public uint uninteractible;
|
||||||
|
}
|
||||||
public struct Conversation
|
public struct Conversation
|
||||||
{
|
{
|
||||||
public uint id;
|
public uint id;
|
||||||
|
|||||||
@@ -2458,6 +2458,48 @@ namespace Game.AI
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.SetImmunePC:
|
||||||
|
{
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
if (IsUnit(target))
|
||||||
|
{
|
||||||
|
if (e.Action.setImmunePC.immunePC != 0)
|
||||||
|
target.ToUnit().AddUnitFlag(UnitFlags.ImmuneToPc);
|
||||||
|
else
|
||||||
|
target.ToUnit().RemoveUnitFlag(UnitFlags.ImmuneToPc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SmartActions.SetImmuneNPC:
|
||||||
|
{
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
if (IsUnit(target))
|
||||||
|
{
|
||||||
|
if (e.Action.setImmuneNPC.immuneNPC != 0)
|
||||||
|
target.ToUnit().AddUnitFlag(UnitFlags.ImmuneToNpc);
|
||||||
|
else
|
||||||
|
target.ToUnit().RemoveUnitFlag(UnitFlags.ImmuneToNpc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SmartActions.SetUninteractible:
|
||||||
|
{
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
if (IsUnit(target))
|
||||||
|
{
|
||||||
|
if (e.Action.setUninteractible.uninteractible != 0)
|
||||||
|
target.ToUnit().AddUnitFlag(UnitFlags.Uninteractible);
|
||||||
|
else
|
||||||
|
target.ToUnit().RemoveUnitFlag(UnitFlags.Uninteractible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SmartActions.CreateConversation:
|
case SmartActions.CreateConversation:
|
||||||
{
|
{
|
||||||
WorldObject baseObject = GetBaseObject();
|
WorldObject baseObject = GetBaseObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user