Core/Movement: MotionMaster reimplementation
Port From (https://github.com/TrinityCore/TrinityCore/commit/426f9f2f92b26fbb68e7cda9290ccbd586c6af4e)
This commit is contained in:
@@ -158,7 +158,7 @@ namespace Game.AI
|
||||
{
|
||||
if (!HasEscortState(SmartEscortState.Escorting))
|
||||
{
|
||||
me.PauseMovement(delay, MovementSlot.Idle, forced);
|
||||
me.PauseMovement(delay, MovementSlot.Default, forced);
|
||||
if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint)
|
||||
{
|
||||
var (nodeId, pathId) = me.GetCurrentWaypointInfo();
|
||||
@@ -597,8 +597,11 @@ namespace Game.AI
|
||||
CreatureGroup formation = me.GetFormation();
|
||||
if (formation == null || formation.GetLeader() == me || !formation.IsFormed())
|
||||
{
|
||||
if (me.GetMotionMaster().GetMotionSlotType(MovementSlot.Idle) != MovementGeneratorType.Waypoint && me.GetWaypointPath() != 0)
|
||||
me.GetMotionMaster().MovePath(me.GetWaypointPath(), true);
|
||||
if (me.GetMotionMaster().GetCurrentMovementGeneratorType(MovementSlot.Default) != MovementGeneratorType.Waypoint)
|
||||
{
|
||||
if (me.GetWaypointPath() != 0)
|
||||
me.GetMotionMaster().MovePath(me.GetWaypointPath(), true);
|
||||
}
|
||||
else
|
||||
me.ResumeMovement();
|
||||
}
|
||||
@@ -644,7 +647,8 @@ namespace Game.AI
|
||||
|
||||
if (who != null && me.Attack(who, _canAutoAttack))
|
||||
{
|
||||
me.GetMotionMaster().Clear(MovementSlot.Active);
|
||||
me.GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
|
||||
me.PauseMovement();
|
||||
|
||||
if (_canCombatMove)
|
||||
{
|
||||
@@ -826,13 +830,20 @@ namespace Game.AI
|
||||
|
||||
if (me.IsEngaged())
|
||||
{
|
||||
if (on && !me.HasReactState(ReactStates.Passive) && me.GetVictim() && me.GetMotionMaster().GetMotionSlotType(MovementSlot.Active) == MovementGeneratorType.Max)
|
||||
if (on)
|
||||
{
|
||||
SetRun(_run);
|
||||
me.GetMotionMaster().MoveChase(me.GetVictim());
|
||||
if (!me.HasReactState(ReactStates.Passive) && me.GetVictim() && !me.GetMotionMaster().HasMovementGenerator(movement => movement.Mode == MovementGeneratorMode.Default && movement.Priority == MovementGeneratorPriority.Normal))
|
||||
{
|
||||
SetRun(_run);
|
||||
me.GetMotionMaster().MoveChase(me.GetVictim());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var movement = me.GetMotionMaster().GetMovementGenerator(a => a.GetMovementGeneratorType() == MovementGeneratorType.Chase && a.Mode == MovementGeneratorMode.Default && a.Priority == MovementGeneratorPriority.Normal);
|
||||
if (movement != null)
|
||||
me.GetMotionMaster().Remove(movement);
|
||||
}
|
||||
else if (!on && me.GetMotionMaster().GetMotionSlotType(MovementSlot.Active) == MovementGeneratorType.Chase)
|
||||
me.GetMotionMaster().Clear(MovementSlot.Active);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1511,7 +1511,7 @@ namespace Game.AI
|
||||
case SmartActions.RemoveAllGameobjects:
|
||||
case SmartActions.SpawnSpawngroup:
|
||||
case SmartActions.DespawnSpawngroup:
|
||||
case SmartActions.StopMotion:
|
||||
case SmartActions.RemoveMovement:
|
||||
break;
|
||||
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);
|
||||
@@ -2515,7 +2515,7 @@ namespace Game.AI
|
||||
public RandomTimedEvent randomTimedEvent;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public StopMotion stopMotion;
|
||||
public RemoveMovement removeMovement;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public RespawnData respawnData;
|
||||
@@ -3022,10 +3022,10 @@ namespace Game.AI
|
||||
public uint minId;
|
||||
public uint maxId;
|
||||
}
|
||||
public struct StopMotion
|
||||
public struct RemoveMovement
|
||||
{
|
||||
public uint stopMovement;
|
||||
public uint movementExpired;
|
||||
public uint movementType;
|
||||
public uint forced;
|
||||
}
|
||||
public struct RespawnData
|
||||
{
|
||||
|
||||
@@ -2293,16 +2293,16 @@ namespace Game.AI
|
||||
|
||||
break;
|
||||
}
|
||||
case SmartActions.StopMotion:
|
||||
case SmartActions.RemoveMovement:
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
if (IsUnit(target))
|
||||
{
|
||||
if (e.Action.stopMotion.stopMovement != 0)
|
||||
if (e.Action.removeMovement.movementType != 0 && e.Action.removeMovement.movementType < (uint)MovementGeneratorType.Max)
|
||||
target.ToUnit().GetMotionMaster().Remove((MovementGeneratorType)e.Action.removeMovement.movementType);
|
||||
if (e.Action.removeMovement.forced != 0)
|
||||
target.ToUnit().StopMoving();
|
||||
if (e.Action.stopMotion.movementExpired != 0)
|
||||
target.ToUnit().GetMotionMaster().MovementExpired();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user