Core/AI: streamline FollowerAI::MoveInLineOfSight with SmartAI and EscortAI
Port From (https://github.com/TrinityCore/TrinityCore/commit/88f5536c43713c1a253d73fce3049a6696bb44b8)
This commit is contained in:
@@ -84,35 +84,14 @@ namespace Game.AI
|
|||||||
|
|
||||||
public override void MoveInLineOfSight(Unit who)
|
public override void MoveInLineOfSight(Unit who)
|
||||||
{
|
{
|
||||||
|
// TODO: what in the world is this?
|
||||||
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.IsTargetableForAttack() && who.IsInAccessiblePlaceFor(me))
|
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.IsTargetableForAttack() && who.IsInAccessiblePlaceFor(me))
|
||||||
{
|
return;
|
||||||
if (HasFollowState(FollowState.Inprogress) && AssistPlayerInCombatAgainst(who))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!me.CanFly() && me.GetDistanceZ(who) > SharedConst.CreatureAttackRangeZ)
|
if (HasFollowState(FollowState.Inprogress) && AssistPlayerInCombatAgainst(who))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (me.IsHostileTo(who))
|
base.MoveInLineOfSight(who);
|
||||||
{
|
|
||||||
float fAttackRadius = me.GetAttackDistance(who);
|
|
||||||
if (me.IsWithinDistInMap(who, fAttackRadius) && me.IsWithinLOSInMap(who))
|
|
||||||
{
|
|
||||||
if (!me.GetVictim())
|
|
||||||
{
|
|
||||||
// Clear distracted state on combat
|
|
||||||
if (me.HasUnitState(UnitState.Distracted))
|
|
||||||
{
|
|
||||||
me.ClearUnitState(UnitState.Distracted);
|
|
||||||
me.GetMotionMaster().Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
AttackStart(who);
|
|
||||||
}
|
|
||||||
else if (me.GetMap().IsDungeon())
|
|
||||||
me.EngageWithTarget(who);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void JustDied(Unit killer)
|
public override void JustDied(Unit killer)
|
||||||
@@ -290,7 +269,7 @@ namespace Game.AI
|
|||||||
Log.outDebug(LogFilter.Scripts, "FollowerAI start follow {0} ({1})", player.GetName(), _leaderGUID.ToString());
|
Log.outDebug(LogFilter.Scripts, "FollowerAI start follow {0} ({1})", player.GetName(), _leaderGUID.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFollowPaused(bool paused)
|
public void SetFollowPaused(bool paused)
|
||||||
{
|
{
|
||||||
if (!HasFollowState(FollowState.Inprogress) || HasFollowState(FollowState.Complete))
|
if (!HasFollowState(FollowState.Inprogress) || HasFollowState(FollowState.Complete))
|
||||||
return;
|
return;
|
||||||
@@ -312,7 +291,7 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFollowComplete(bool bWithEndEvent = false)
|
public void SetFollowComplete(bool withEndEvent = false)
|
||||||
{
|
{
|
||||||
if (me.HasUnitState(UnitState.Follow))
|
if (me.HasUnitState(UnitState.Follow))
|
||||||
{
|
{
|
||||||
@@ -323,7 +302,7 @@ namespace Game.AI
|
|||||||
me.GetMotionMaster().MoveIdle();
|
me.GetMotionMaster().MoveIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bWithEndEvent)
|
if (withEndEvent)
|
||||||
AddFollowState(FollowState.PostEvent);
|
AddFollowState(FollowState.PostEvent);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user