2121};
2222
2323npc_escortAI::npc_escortAI (Creature* pCreature) : ScriptedAI(pCreature),
24- IsBeingEscorted(false ),
25- IsOnHold(false ),
2624 m_uiPlayerGUID(0 ),
2725 m_uiPlayerCheckTimer(1000 ),
2826 m_uiWPWaitTimer(2500 ),
2927 m_uiEscortState(STATE_ESCORT_NONE ),
30- m_bIsReturning(false ),
3128 m_bIsActiveAttacker(true ),
3229 m_bIsRunning(false ),
3330 m_pQuestForEscort(NULL ),
@@ -116,7 +113,7 @@ void npc_escortAI::MoveInLineOfSight(Unit* pWho)
116113{
117114 if (!m_creature->hasUnitState (UNIT_STAT_STUNNED ) && pWho->isTargetableForAttack () && pWho->isInAccessablePlaceFor (m_creature))
118115 {
119- if (IsBeingEscorted && AssistPlayerInCombat (pWho))
116+ if (HasEscortState ( STATE_ESCORT_ESCORTING ) && AssistPlayerInCombat (pWho))
120117 return ;
121118
122119 if (!m_creature->canFly () && m_creature->GetDistanceZ (pWho) > CREATURE_Z_ATTACK_RANGE )
@@ -144,7 +141,7 @@ void npc_escortAI::MoveInLineOfSight(Unit* pWho)
144141
145142void npc_escortAI::JustDied (Unit* pKiller)
146143{
147- if (!IsBeingEscorted || !m_uiPlayerGUID || !m_pQuestForEscort)
144+ if (!HasEscortState ( STATE_ESCORT_ESCORTING ) || !m_uiPlayerGUID || !m_pQuestForEscort)
148145 return ;
149146
150147 if (Player* pPlayer = GetPlayerForEscort ())
@@ -170,8 +167,7 @@ void npc_escortAI::JustDied(Unit* pKiller)
170167
171168void npc_escortAI::JustRespawned ()
172169{
173- IsBeingEscorted = false ;
174- IsOnHold = false ;
170+ m_uiEscortState = STATE_ESCORT_NONE ;
175171
176172 if (!IsCombatMovement ())
177173 SetCombatMovement (true );
@@ -192,13 +188,13 @@ void npc_escortAI::EnterEvadeMode()
192188 m_creature->CombatStop (true );
193189 m_creature->SetLootRecipient (NULL );
194190
195- if (IsBeingEscorted )
191+ if (HasEscortState ( STATE_ESCORT_ESCORTING ) )
196192 {
197193 debug_log (" SD2: EscortAI has left combat and is now returning to CombatStartPosition." );
198194
199195 if (m_creature->GetMotionMaster ()->GetCurrentMovementGeneratorType () == TARGETED_MOTION_TYPE )
200196 {
201- m_bIsReturning = true ;
197+ AddEscortState ( STATE_ESCORT_RETURNING ) ;
202198
203199 float fPosX , fPosY , fPosZ ;
204200 m_creature->GetCombatStartPosition (fPosX , fPosY , fPosZ );
@@ -243,7 +239,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange()
243239void npc_escortAI::UpdateAI (const uint32 uiDiff)
244240{
245241 // Waypoint Updating
246- if (IsBeingEscorted && !m_creature->getVictim () && m_uiWPWaitTimer && !m_bIsReturning )
242+ if (HasEscortState ( STATE_ESCORT_ESCORTING ) && !m_creature->getVictim () && m_uiWPWaitTimer && !HasEscortState ( STATE_ESCORT_RETURNING ) )
247243 {
248244 if (m_uiWPWaitTimer <= uiDiff)
249245 {
@@ -276,7 +272,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
276272 return ;
277273 }
278274
279- if (!IsOnHold )
275+ if (!HasEscortState ( STATE_ESCORT_PAUSED ) )
280276 {
281277 m_creature->GetMotionMaster ()->MovePoint (CurrentWP->id , CurrentWP->x , CurrentWP->y , CurrentWP->z );
282278 debug_log (" SD2: EscortAI start waypoint %u (%f, %f, %f)." , CurrentWP->id , CurrentWP->x , CurrentWP->y , CurrentWP->z );
@@ -291,7 +287,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
291287 }
292288
293289 // Check if player or any member of his group is within range
294- if (IsBeingEscorted && m_uiPlayerGUID && !m_creature->getVictim () && !m_bIsReturning )
290+ if (HasEscortState ( STATE_ESCORT_ESCORTING ) && m_uiPlayerGUID && !m_creature->getVictim () && !HasEscortState ( STATE_ESCORT_RETURNING ) )
295291 {
296292 if (m_uiPlayerCheckTimer < uiDiff)
297293 {
@@ -330,7 +326,7 @@ void npc_escortAI::UpdateEscortAI(const uint32 uiDiff)
330326
331327void npc_escortAI::MovementInform (uint32 uiMoveType, uint32 uiPointId)
332328{
333- if (uiMoveType != POINT_MOTION_TYPE || !IsBeingEscorted )
329+ if (uiMoveType != POINT_MOTION_TYPE || !HasEscortState ( STATE_ESCORT_ESCORTING ) )
334330 return ;
335331
336332 // Combat start position reached, continue waypoint movement
@@ -343,7 +339,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
343339 else if (!m_bIsRunning && !m_creature->HasMonsterMoveFlag (MONSTER_MOVE_WALK ))
344340 m_creature->AddMonsterMoveFlag (MONSTER_MOVE_WALK );
345341
346- m_bIsReturning = false ;
342+ RemoveEscortState ( STATE_ESCORT_RETURNING ) ;
347343
348344 if (!m_uiWPWaitTimer)
349345 m_uiWPWaitTimer = 1 ;
@@ -426,7 +422,7 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID,
426422 return ;
427423 }
428424
429- if (IsBeingEscorted )
425+ if (HasEscortState ( STATE_ESCORT_ESCORTING ) )
430426 {
431427 error_log (" SD2: EscortAI attempt to Start while already escorting" );
432428 return ;
@@ -474,7 +470,7 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID,
474470 if (m_bIsRunning)
475471 m_creature->RemoveMonsterMoveFlag (MONSTER_MOVE_WALK );
476472
477- IsBeingEscorted = true ;
473+ AddEscortState ( STATE_ESCORT_ESCORTING ) ;
478474}
479475
480476void npc_escortAI::SetEscortPaused (bool bPaused)
0 commit comments