Core/AI: Clean up charm AI handling.

Port From (https://github.com/TrinityCore/TrinityCore/commit/e4e8c1c59c8b37216814526b4d2551f23934f465)
This commit is contained in:
hondacrx
2021-10-31 13:55:26 -04:00
parent 7050fda482
commit 26940fa650
33 changed files with 472 additions and 443 deletions
+6 -5
View File
@@ -714,17 +714,18 @@ namespace Game.AI
GetScript().ProcessEventsFor(apply ? SmartEvents.PassengerBoarded : SmartEvents.PassengerRemoved, passenger, (uint)seatId, 0, apply);
}
public override void OnCharmed(bool apply)
public override void OnCharmed(bool isNew)
{
if (apply) // do this before we change charmed state, as charmed state might prevent these things from processing
bool charmed = me.IsCharmed();
if (charmed) // do this before we change charmed state, as charmed state might prevent these things from processing
{
if (HasEscortState(SmartEscortState.Escorting | SmartEscortState.Paused | SmartEscortState.Returning))
EndPath(true);
}
_isCharmed = apply;
_isCharmed = charmed;
if (!apply && !me.IsInEvadeMode())
if (!charmed && !me.IsInEvadeMode())
{
if (_repeatWaypointPath)
StartPath(_run, GetScript().GetPathId(), true);
@@ -736,7 +737,7 @@ namespace Game.AI
AttackStart(charmer);
}
GetScript().ProcessEventsFor(SmartEvents.Charmed, null, 0, 0, apply);
GetScript().ProcessEventsFor(SmartEvents.Charmed, null, 0, 0, charmed);
}
public override void DoAction(int param)