From 998e53913fa60a2028441fab123bd5f6dd3ea9b9 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 7 Dec 2021 17:50:38 -0500 Subject: [PATCH] Core/AI: streamline FollowerAI::MoveInLineOfSight with SmartAI and EscortAI Port From (https://github.com/TrinityCore/TrinityCore/commit/88f5536c43713c1a253d73fce3049a6696bb44b8) --- .../Game/AI/ScriptedAI/ScriptedFollowerAI.cs | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/Source/Game/AI/ScriptedAI/ScriptedFollowerAI.cs b/Source/Game/AI/ScriptedAI/ScriptedFollowerAI.cs index 91d03898b..7ed506241 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedFollowerAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedFollowerAI.cs @@ -84,35 +84,14 @@ namespace Game.AI 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 (HasFollowState(FollowState.Inprogress) && AssistPlayerInCombatAgainst(who)) - return; + return; - if (!me.CanFly() && me.GetDistanceZ(who) > SharedConst.CreatureAttackRangeZ) - return; + if (HasFollowState(FollowState.Inprogress) && AssistPlayerInCombatAgainst(who)) + return; - if (me.IsHostileTo(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); - } - } - } + base.MoveInLineOfSight(who); } 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()); } - void SetFollowPaused(bool paused) + public void SetFollowPaused(bool paused) { if (!HasFollowState(FollowState.Inprogress) || HasFollowState(FollowState.Complete)) 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)) { @@ -323,7 +302,7 @@ namespace Game.AI me.GetMotionMaster().MoveIdle(); } - if (bWithEndEvent) + if (withEndEvent) AddFollowState(FollowState.PostEvent); else {