Core/SAI: Spell casts that cannot be executed because the unit is currently casting another spell will be retried asap with priority over other events

Port From (https://github.com/TrinityCore/TrinityCore/commit/f2ee365da43f851181c8a486e10325a95b75c55d)
This commit is contained in:
hondacrx
2022-03-04 17:20:01 -05:00
parent 1670c09454
commit 82389dbaeb
2 changed files with 75 additions and 4 deletions
+19 -1
View File
@@ -1907,8 +1907,10 @@ namespace Game.AI
};
}
public class SmartScriptHolder
public class SmartScriptHolder : IComparer<SmartScriptHolder>
{
public const uint DefaultPriority = uint.MaxValue;
public int EntryOrGuid;
public SmartScriptType SourceType;
public uint EventId;
@@ -1917,6 +1919,7 @@ namespace Game.AI
public SmartAction Action;
public SmartTarget Target;
public uint Timer;
public uint Priority;
public bool Active;
public bool RunOnce;
public bool EnableTimed;
@@ -1946,6 +1949,21 @@ namespace Game.AI
{
return $"Entry {EntryOrGuid} SourceType {GetScriptType()} Event {EventId} Action {GetActionType()}";
}
public int Compare(SmartScriptHolder left, SmartScriptHolder right)
{
int result = left.Priority.CompareTo(right.Priority);
if (result == 0)
result = left.EntryOrGuid.CompareTo(right.EntryOrGuid);
if (result == 0)
result = left.SourceType.CompareTo(right.SourceType);
if (result == 0)
result = left.EventId.CompareTo(right.EventId);
if (result == 0)
result = left.Link.CompareTo(right.Link);
return result;
}
}
[StructLayout(LayoutKind.Explicit)]