diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-05-15 22:04:24 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-05 16:50:53 +0100 |
commit | 88f5536c43713c1a253d73fce3049a6696bb44b8 (patch) | |
tree | a4648db9caab94a5630efd57982bcc15db4a148c | |
parent | edbf45404be2cf003ceec7b4344180616b0e2315 (diff) |
Core/AI: streamline FollowerAI::MoveInLineOfSight with SmartAI and EscortAI
plus another method reorganization
(cherry picked from commit d3b8d69e38122d64daaac2d1cb7dd002ade7fbd5)
-rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 75 |
1 files changed, 27 insertions, 48 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 3eb44ba0038..088e9a17efb 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -69,35 +69,14 @@ void FollowerAI::AttackStart(Unit* who) void FollowerAI::MoveInLineOfSight(Unit* who) { + // TODO: what in the world is this? if (me->HasReactState(REACT_AGGRESSIVE) && !me->HasUnitState(UNIT_STATE_STUNNED) && who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me)) - { - if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombatAgainst(who)) - return; - - if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; + 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(UNIT_STATE_DISTRACTED)) - { - me->ClearUnitState(UNIT_STATE_DISTRACTED); - me->GetMotionMaster()->Clear(); - } + if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombatAgainst(who)) + return; - AttackStart(who); - } - else if (me->GetMap()->IsDungeon()) - me->EngageWithTarget(who); - } - } - } + ScriptedAI::MoveInLineOfSight(who); } void FollowerAI::JustDied(Unit* /*killer*/) @@ -263,28 +242,6 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest co TC_LOG_DEBUG("scripts.ai.followerai", "FollowerAI::StartFollow: start follow %s - %s (%s)", player->GetName().c_str(), _leaderGUID.ToString().c_str(), me->GetGUID().ToString().c_str()); } -void FollowerAI::SetFollowComplete(bool withEndEvent) -{ - if (me->HasUnitState(UNIT_STATE_FOLLOW)) - { - me->ClearUnitState(UNIT_STATE_FOLLOW); - - me->StopMoving(); - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); - } - - if (withEndEvent) - AddFollowState(STATE_FOLLOW_POSTEVENT); - else - { - if (HasFollowState(STATE_FOLLOW_POSTEVENT)) - RemoveFollowState(STATE_FOLLOW_POSTEVENT); - } - - AddFollowState(STATE_FOLLOW_COMPLETE); -} - void FollowerAI::SetFollowPaused(bool paused) { if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || HasFollowState(STATE_FOLLOW_COMPLETE)) @@ -312,6 +269,28 @@ void FollowerAI::SetFollowPaused(bool paused) } } +void FollowerAI::SetFollowComplete(bool withEndEvent) +{ + if (me->HasUnitState(UNIT_STATE_FOLLOW)) + { + me->ClearUnitState(UNIT_STATE_FOLLOW); + + me->StopMoving(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); + } + + if (withEndEvent) + AddFollowState(STATE_FOLLOW_POSTEVENT); + else + { + if (HasFollowState(STATE_FOLLOW_POSTEVENT)) + RemoveFollowState(STATE_FOLLOW_POSTEVENT); + } + + AddFollowState(STATE_FOLLOW_COMPLETE); +} + Player* FollowerAI::GetLeaderForFollower() { if (Player* player = ObjectAccessor::GetPlayer(*me, _leaderGUID)) |