diff options
Diffstat (limited to 'src')
24 files changed, 222 insertions, 144 deletions
diff --git a/src/bindings/scripts/base/escort_ai.cpp b/src/bindings/scripts/base/escort_ai.cpp index 34b4efcbe60..b5bbc74265e 100644 --- a/src/bindings/scripts/base/escort_ai.cpp +++ b/src/bindings/scripts/base/escort_ai.cpp @@ -11,7 +11,6 @@ EndScriptData */ #include "precompiled.h" #include "escort_ai.h" -#include "../system/system.h" enum { @@ -20,14 +19,12 @@ enum }; npc_escortAI::npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature), - IsBeingEscorted(false), - IsOnHold(false), m_uiPlayerGUID(0), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), m_uiPlayerCheckTimer(1000), m_uiWPWaitTimer(2500), - m_bIsReturning(false), + m_uiEscortState(STATE_ESCORT_NONE), m_bIsActiveAttacker(true), m_bIsRunning(false), DespawnAtEnd(true), @@ -53,17 +50,77 @@ void npc_escortAI::AttackStart(Unit* pWho) } } +//see followerAI +bool npc_escortAI::AssistPlayerInCombat(Unit* pWho) +{ + if (!pWho || !pWho->getVictim()) + return false; + + //experimental (unknown) flag not present + if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) + return false; + + //not a player + if (!pWho->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()) + return false; + + //never attack friendly + if (m_creature->IsFriendlyTo(pWho)) + return false; + + //too far away and no free sight? + if (m_creature->IsWithinDistInMap(pWho, GetMaxPlayerDistance()) && m_creature->IsWithinLOSInMap(pWho)) + { + //already fighting someone? + if (!m_creature->getVictim()) + { + AttackStart(pWho); + return true; + } + else + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + return true; + } + } + + return false; +} + void npc_escortAI::MoveInLineOfSight(Unit* pWho) { - if (IsBeingEscorted && !m_bIsActiveAttacker) - return; + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature)) + { + if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(pWho)) + return; + + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; - ScriptedAI::MoveInLineOfSight(pWho); + if (m_creature->IsHostileTo(pWho)) + { + float fAttackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, fAttackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + pWho->RemoveAurasDueToSpell(SPELL_AURA_MOD_STEALTH); + AttackStart(pWho); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } } void npc_escortAI::JustDied(Unit* pKiller) { - if (!IsBeingEscorted || !m_uiPlayerGUID || !m_pQuestForEscort) + if (!HasEscortState(STATE_ESCORT_ESCORTING) || !m_uiPlayerGUID || !m_pQuestForEscort) return; if (Player* pPlayer = GetPlayerForEscort()) @@ -74,8 +131,8 @@ void npc_escortAI::JustDied(Unit* pKiller) { if (Player* pMember = pRef->getSource()) { - if (pPlayer->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE) - pPlayer->FailQuest(m_pQuestForEscort->GetQuestId()); + if (pMember->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE) + pMember->FailQuest(m_pQuestForEscort->GetQuestId()); } } } @@ -89,8 +146,7 @@ void npc_escortAI::JustDied(Unit* pKiller) void npc_escortAI::JustRespawned() { - IsBeingEscorted = false; - IsOnHold = false; + m_uiEscortState = STATE_ESCORT_NONE; if (!IsCombatMovement()) SetCombatMovement(true); @@ -118,9 +174,9 @@ void npc_escortAI::EnterEvadeMode() m_creature->CombatStop(true); m_creature->SetLootRecipient(NULL); - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { - m_bIsReturning = true; + AddEscortState(STATE_ESCORT_RETURNING); ReturnToLastPoint(); debug_log("TSCR: EscortAI has left combat and is now returning to last point"); } @@ -159,7 +215,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange() void npc_escortAI::UpdateAI(const uint32 uiDiff) { //Waypoint Updating - if (IsBeingEscorted && !m_creature->getVictim() && m_uiWPWaitTimer && !m_bIsReturning) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_creature->getVictim() && m_uiWPWaitTimer && !HasEscortState(STATE_ESCORT_RETURNING)) { if (m_uiWPWaitTimer <= uiDiff) { @@ -201,7 +257,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } } - if (!IsOnHold) + if (!HasEscortState(STATE_ESCORT_PAUSED)) { m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); debug_log("TSCR: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); @@ -216,7 +272,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } //Check if player or any member of his group is within range - if (IsBeingEscorted && m_uiPlayerGUID && !m_creature->getVictim() && !m_bIsReturning) + if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !m_creature->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING)) { if (m_uiPlayerCheckTimer < uiDiff) { @@ -252,7 +308,7 @@ void npc_escortAI::UpdateEscortAI(const uint32 uiDiff) void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) { - if (uiMoveType != POINT_MOTION_TYPE || !IsBeingEscorted) + if (uiMoveType != POINT_MOTION_TYPE || !HasEscortState(STATE_ESCORT_ESCORTING)) return; //Combat start position reached, continue waypoint movement @@ -265,7 +321,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) else if (!m_bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - m_bIsReturning = false; + RemoveEscortState(STATE_ESCORT_RETURNING); if (!m_uiWPWaitTimer) m_uiWPWaitTimer = 1; @@ -282,11 +338,11 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) //Make sure that we are still on the right waypoint if (CurrentWP->id != uiPointId) { - debug_log("TSCR ERROR: EscortAI reached waypoint out of order %d, expected %d", uiPointId, CurrentWP->id); + error_log("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u", uiPointId, CurrentWP->id); return; } - debug_log("TSCR: EscortAI Waypoint %d reached", CurrentWP->id); + debug_log("TSCR: EscortAI Waypoint %u reached", CurrentWP->id); //Call WP function WaypointReached(CurrentWP->id); @@ -302,7 +358,7 @@ void npc_escortAI::OnPossess(bool apply) { // We got possessed in the middle of being escorted, store the point // where we left off to come back to when possess is removed - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (apply) m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); @@ -374,13 +430,13 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, { if (m_creature->getVictim()) { - debug_log("TSCR ERROR: EscortAI attempt to Start while in combat"); + error_log("TSCR ERROR: EscortAI attempt to Start while in combat."); return; } - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { - error_log("TSCR: EscortAI attempt to Start while already escorting"); + error_log("TSCR: EscortAI attempt to Start while already escorting."); return; } @@ -396,7 +452,7 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, if (WaypointList.empty()) { - error_db_log("TSCR: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint)"); + error_db_log("TSCR: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint)."); return; } @@ -423,7 +479,7 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, //disable npcflags m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - debug_log("TSCR: EscortAI started with %d waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %d", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); + debug_log("TSCR: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); CurrentWP = WaypointList.begin(); @@ -433,5 +489,16 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - IsBeingEscorted = true; + AddEscortState(STATE_ESCORT_ESCORTING); +} + +void npc_escortAI::SetEscortPaused(bool bPaused) +{ + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + return; + + if (bPaused) + AddEscortState(STATE_ESCORT_PAUSED); + else + RemoveEscortState(STATE_ESCORT_PAUSED); } diff --git a/src/bindings/scripts/base/escort_ai.h b/src/bindings/scripts/base/escort_ai.h index 60e555dcfd4..d0cb55b100a 100644 --- a/src/bindings/scripts/base/escort_ai.h +++ b/src/bindings/scripts/base/escort_ai.h @@ -5,6 +5,8 @@ #ifndef SC_ESCORTAI_H #define SC_ESCORTAI_H +#include "../system/system.h" + #define DEFAULT_MAX_PLAYER_DISTANCE 50 struct Escort_Waypoint @@ -25,16 +27,20 @@ struct Escort_Waypoint uint32 WaitTimeMs; }; +enum eEscortState +{ + STATE_ESCORT_NONE = 0x000, //nothing in progress + STATE_ESCORT_ESCORTING = 0x001, //escort are in progress + STATE_ESCORT_RETURNING = 0x002, //escort is returning after being in combat + STATE_ESCORT_PAUSED = 0x004 //will not proceed with waypoints before state is removed +}; + struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI { public: explicit npc_escortAI(Creature* pCreature); ~npc_escortAI() {} - // Pure Virtual Functions - virtual void WaypointReached(uint32 uiPointId) = 0; - virtual void WaypointStart(uint32 uiPointId) {} - // CreatureAI functions void AttackStart(Unit* who); @@ -56,42 +62,41 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI // EscortAI functions void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0); - bool IsPlayerOrGroupInRange(); - - Player* GetPlayerForEscort() - { - return Unit::GetPlayer(m_uiPlayerGUID); - } - - void FillPointMovementListForCreature(); + virtual void WaypointReached(uint32 uiPointId) = 0; + virtual void WaypointStart(uint32 uiPointId) {} void Start(bool bIsActiveAttacker = true, bool bRun = false, uint64 uiPlayerGUID = 0, const Quest* pQuest = NULL, bool bInstantRespawn = false, bool bCanLoopPath = false); void SetRun(bool bRun = true); + void SetEscortPaused(bool uPaused); + + bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); } void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; } float GetMaxPlayerDistance() { return MaxPlayerDistance; } - bool IsEscorted() {return IsBeingEscorted;} - void SetCanMelee(bool usemelee) { CanMelee = usemelee; } void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; } void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; } bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override - bool GetIsBeingEscorted() { return IsBeingEscorted; }//used in EnterEvadeMode override - void SetReturning(bool returning) { m_bIsReturning = returning; }//used in EnterEvadeMode override void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; } uint64 GetEventStarterGUID() { return m_uiPlayerGUID; } - // EscortAI variables protected: - bool IsBeingEscorted; - bool IsOnHold; + Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*m_creature, m_uiPlayerGUID); } private: + bool AssistPlayerInCombat(Unit* pWho); + bool IsPlayerOrGroupInRange(); + void FillPointMovementListForCreature(); + + void AddEscortState(uint32 uiEscortState) { m_uiEscortState |= uiEscortState; } + void RemoveEscortState(uint32 uiEscortState) { m_uiEscortState &= ~uiEscortState; } + uint64 m_uiPlayerGUID; uint32 m_uiWPWaitTimer; uint32 m_uiPlayerCheckTimer; + uint32 m_uiEscortState; float MaxPlayerDistance; const Quest* m_pQuestForEscort; //generally passed in Start() when regular escort script. @@ -99,8 +104,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI std::list<Escort_Waypoint> WaypointList; std::list<Escort_Waypoint>::iterator CurrentWP; - bool m_bIsActiveAttacker; //possible obsolete, and should be determined with db only (civilian) - bool m_bIsReturning; //in use when creature leave combat, and are returning to combat start position + bool m_bIsActiveAttacker; //obsolete, determined by faction. bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK) bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used) bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests. diff --git a/src/bindings/scripts/base/follower_ai.cpp b/src/bindings/scripts/base/follower_ai.cpp index 5ac139015f2..25ee1265a91 100644 --- a/src/bindings/scripts/base/follower_ai.cpp +++ b/src/bindings/scripts/base/follower_ai.cpp @@ -45,38 +45,60 @@ void FollowerAI::AttackStart(Unit* pWho) } } +//This part provides assistance to a player that are attacked by pWho, even if out of normal aggro range +//It will cause m_creature to attack pWho that are attacking _any_ player (which has been confirmed may happen also on offi) +//The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate. +bool FollowerAI::AssistPlayerInCombat(Unit* pWho) +{ + if (!pWho || !pWho->getVictim()) + return false; + + //experimental (unknown) flag not present + if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) + return false; + + //not a player + if (!pWho->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()) + return false; + + //never attack friendly + if (m_creature->IsFriendlyTo(pWho)) + return false; + + //too far away and no free sight? + if (m_creature->IsWithinDistInMap(pWho, MAX_PLAYER_DISTANCE) && m_creature->IsWithinLOSInMap(pWho)) + { + //already fighting someone? + if (!m_creature->getVictim()) + { + AttackStart(pWho); + return true; + } + else + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + return true; + } + } + + return false; +} + void FollowerAI::MoveInLineOfSight(Unit* pWho) { - if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && - m_creature->IsHostileTo(pWho) && pWho->isInAccessiblePlaceFor(m_creature)) + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature)) { + if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(pWho)) + return; + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) return; - //This part provides assistance to a player that are attacked by pWho, even if out of normal aggro range - //It will cause m_creature to attack pWho that are attacking _any_ player (which has been confirmed may happen also on offi) - //The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate. - if (m_creature->hasUnitState(UNIT_STAT_FOLLOW) && - m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13 && - pWho->getVictim() && - pWho->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() && - m_creature->IsWithinDistInMap(pWho, MAX_PLAYER_DISTANCE) && - m_creature->IsWithinLOSInMap(pWho)) - { - if (!m_creature->getVictim()) - { - AttackStart(pWho); - } - else - { - pWho->SetInCombatWith(m_creature); - m_creature->AddThreat(pWho, 0.0f); - } - } - else + if (m_creature->IsHostileTo(pWho)) { - float attackRadius = m_creature->GetAttackDistance(pWho); - if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + float fAttackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, fAttackRadius) && m_creature->IsWithinLOSInMap(pWho)) { if (!m_creature->getVictim()) { @@ -162,8 +184,6 @@ void FollowerAI::EnterEvadeMode() void FollowerAI::UpdateAI(const uint32 uiDiff) { - Unit* pUnit = m_creature->getVictim(); - if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !m_creature->getVictim()) { if (m_uiUpdateFollowTimer < uiDiff) diff --git a/src/bindings/scripts/base/follower_ai.h b/src/bindings/scripts/base/follower_ai.h index 372fe38a581..289efd4a6b0 100644 --- a/src/bindings/scripts/base/follower_ai.h +++ b/src/bindings/scripts/base/follower_ai.h @@ -5,6 +5,8 @@ #ifndef SC_FOLLOWERAI_H #define SC_FOLLOWERAI_H +#include "../system/system.h" + enum eFollowState { STATE_FOLLOW_NONE = 0x000, @@ -42,18 +44,19 @@ class TRINITY_DLL_DECL FollowerAI : public ScriptedAI void StartFollow(Player* pPlayer, uint32 uiFactionForFollower = 0, const Quest* pQuest = NULL); void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow + void SetFollowComplete(bool bWithEndEvent = false); bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState); } protected: - void SetFollowComplete(bool bWithEndEvent = false); - Player* GetLeaderForFollower(); private: void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; } void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; } + bool AssistPlayerInCombat(Unit* pWho); + uint64 m_uiLeaderGUID; uint32 m_uiUpdateFollowTimer; uint32 m_uiFollowState; diff --git a/src/bindings/scripts/scripts/custom/test.cpp b/src/bindings/scripts/scripts/custom/test.cpp index d643484c6fb..fb29a0a05b2 100644 --- a/src/bindings/scripts/scripts/custom/test.cpp +++ b/src/bindings/scripts/scripts/custom/test.cpp @@ -87,7 +87,7 @@ struct TRINITY_DLL_DECL npc_testAI : public npc_escortAI void Aggro(Unit*) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) m_creature->Say(SAY_AGGRO1, LANG_UNIVERSAL, PlayerGUID); else m_creature->Say(SAY_AGGRO2, LANG_UNIVERSAL, 0); } @@ -100,7 +100,7 @@ struct TRINITY_DLL_DECL npc_testAI : public npc_escortAI void JustDied(Unit* killer) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { //killer = m_creature when player got to far from creature if (killer == m_creature) @@ -132,7 +132,7 @@ struct TRINITY_DLL_DECL npc_testAI : public npc_escortAI }else { //Out of combat but being escorted - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) if (ChatTimer < diff) { if (m_creature->HasAura(3593, 0)) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp index 8aa5d3e5aa6..243ce83963b 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp @@ -715,7 +715,7 @@ struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI { if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_NOT_STARTED) return; if (pInstance->GetData(DATA_DUGHAL) == ENCOUNTER_STATE_OBJECTIVE_COMPLETED) - IsOnHold = false; + SetEscortPaused(false); if (!pInstance->GetData(DATA_GATE_D) && pInstance->GetData(DATA_DUGHAL) == ENCOUNTER_STATE_NOT_STARTED) { m_creature->Say(SAY_WINDSOR_4_2, LANG_UNIVERSAL, PlayerGUID); @@ -873,7 +873,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI void MoveInLineOfSight(Unit *who) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; if (who->GetTypeId() == TYPEID_PLAYER) @@ -883,7 +883,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI float Radius = 10.0; if (m_creature->IsWithinDistInMap(who, Radius)) { - IsOnHold = false; + SetEscortPaused(false); Start(true, false, who->GetGUID()); } } @@ -918,7 +918,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI } if (pInstance->GetData(DATA_CREATURE_JAZ) && pInstance->GetData(DATA_CREATURE_OGRABISI) && pInstance->GetData(DATA_JAZ) == ENCOUNTER_STATE_IN_PROGRESS) { - IsOnHold = false; + SetEscortPaused(false); pInstance->SetData(DATA_JAZ,ENCOUNTER_STATE_ENDED); } } @@ -932,7 +932,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI if (pInstance->GetData(DATA_CREATURE_SHILL) && pInstance->GetData(DATA_SHILL) == ENCOUNTER_STATE_IN_PROGRESS) { pInstance->SetData(DATA_SHILL,ENCOUNTER_STATE_ENDED); - IsOnHold = false; + SetEscortPaused(false); } } else if (wp==20) @@ -945,11 +945,11 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI } if (pInstance->GetData(DATA_CREATURE_CREST) && pInstance->GetData(DATA_CREST) == ENCOUNTER_STATE_IN_PROGRESS) { - IsOnHold = false; + SetEscortPaused(false); pInstance->SetData(DATA_CREST,ENCOUNTER_STATE_ENDED); } } - if (pInstance->GetData(DATA_TOBIAS)==ENCOUNTER_STATE_OBJECTIVE_COMPLETED) IsOnHold = false; + if (pInstance->GetData(DATA_TOBIAS)==ENCOUNTER_STATE_OBJECTIVE_COMPLETED) SetEscortPaused(false); npc_escortAI::UpdateAI(diff); } }; @@ -1113,7 +1113,7 @@ struct TRINITY_DLL_DECL npc_rocknotAI : public npc_escortAI void Reset() { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; BreakKeg_Timer = 0; diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp index 286e5eee787..781f93e095f 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp @@ -206,7 +206,7 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI void EnterCombat(Unit* pWho) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (pWho->GetEntry() == NPC_OUTRUNNER && !m_bIsByOutrunner) { @@ -281,7 +281,7 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI //Check if we have a current target if (!UpdateVictim()) { - if (IsBeingEscorted && m_uiPostEventCount) + if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPostEventCount) { if (m_uiPostEventTimer < uiDiff) { diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp index 71cb24009f8..c8829f4d2ba 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp @@ -164,7 +164,7 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI break; case 4: TalkCount = 0; - IsOnHold = true; + SetEscortPaused(true); if (Creature* pSpotlight = m_creature->SummonCreature(CREATURE_SPOTLIGHT, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0.0f, @@ -260,7 +260,7 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI { npc_escortAI::UpdateAI(diff); - if (IsOnHold) + if (HasEscortState(STATE_ESCORT_PAUSED)) { if (TalkTimer < diff) { @@ -269,7 +269,7 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI if (Creature* pSpotlight = Unit::GetCreature(*m_creature, m_uiSpotlightGUID)) pSpotlight->ForcedDespawn(); - IsOnHold = false; + SetEscortPaused(false); return; } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp index 34e5e6d820a..f3563908409 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp @@ -179,7 +179,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) { m_uiWave = 0; m_uiWave_Timer = 3000; @@ -208,7 +208,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI me->LoadEquipment(me->GetEquipmentId()); break; case 3: - IsOnHold = true; + SetEscortPaused(true); me->SetStandState(UNIT_STAND_STATE_KNEEL); DoScriptText(SAY_BREAKOUT2, me); DoCast(me, SPELL_ANTI_MAGIC_ZONE); // cast again that makes bubble up @@ -249,7 +249,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI { npc_escortAI::UpdateAI(uiDiff); - if (IsOnHold) + if (HasEscortState(STATE_ESCORT_PAUSED)) { if (m_uiWave_Timer < uiDiff) { @@ -299,7 +299,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI break; case 6: DoScriptText(SAY_BREAKOUT10, me); - IsOnHold = false; + SetEscortPaused(false); break; } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp index d41cc852791..2aed67def40 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp @@ -332,7 +332,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) { bIsBattle = false; uiStep = 0; @@ -458,7 +458,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI void SetHoldState(bool bOnHold) { - IsOnHold = bOnHold; + SetEscortPaused(bOnHold); } void WaypointReached(uint32 i) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp index 0799f745a70..93d12371396 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp @@ -56,7 +56,7 @@ struct TRINITY_DLL_DECL npc_daphne_stilwellAI : public npc_escortAI void Reset() { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { switch(uiWPHolder) { diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp index 94cf73bebeb..50bb8f5035b 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp @@ -51,7 +51,7 @@ struct TRINITY_DLL_DECL npc_tapoke_slim_jahnAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) m_bFriendSummoned = false; } @@ -73,7 +73,7 @@ struct TRINITY_DLL_DECL npc_tapoke_slim_jahnAI : public npc_escortAI { Player* pPlayer = GetPlayerForEscort(); - if (IsBeingEscorted && !m_bFriendSummoned && pPlayer) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_bFriendSummoned && pPlayer) { for(uint8 i = 0; i < 3; ++i) m_creature->CastSpell(m_creature, SPELL_CALL_FRIENDS, true); diff --git a/src/bindings/scripts/scripts/examples/example_escort.cpp b/src/bindings/scripts/scripts/examples/example_escort.cpp index 4fdc1b7e1ad..e53e65ebdce 100644 --- a/src/bindings/scripts/scripts/examples/example_escort.cpp +++ b/src/bindings/scripts/scripts/examples/example_escort.cpp @@ -89,7 +89,7 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI void EnterCombat(Unit* pWho) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (Player* pPlayer = GetPlayerForEscort()) DoScriptText(SAY_AGGRO1, m_creature, pPlayer); @@ -106,7 +106,7 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI void JustDied(Unit* pKiller) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (Player* pPlayer = GetPlayerForEscort()) { @@ -143,7 +143,7 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI else { //Out of combat but being escorted - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (m_uiChatTimer < uiDiff) { diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp index af41f926e87..52aa9b6dc9a 100644 --- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp @@ -244,7 +244,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI //temporary,skarloc should rather be triggered to walk up to thrall break; case 30: - IsOnHold = true; + SetEscortPaused(true); m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); SetRun(false); break; @@ -268,7 +268,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI case 60: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); //make horsie run off - IsOnHold = true; + SetEscortPaused(true); m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); pInstance->SetData(TYPE_THRALL_PART2, DONE); SetRun(); @@ -318,7 +318,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI case 95: DoScriptText(SAY_TH_MEET_TARETHA, m_creature); pInstance->SetData(TYPE_THRALL_PART3,DONE); - IsOnHold = true; + SetEscortPaused(true); break; case 96: DoScriptText(SAY_TH_EPOCH_WONDER, m_creature); @@ -372,7 +372,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI if (HadMount) DoMount(); - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) { DoUnmount(); HadMount = false; @@ -380,7 +380,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0); m_creature->SetDisplayId(THRALL_MODEL_UNEQUIPPED); } - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) { switch(rand()%3) { @@ -393,7 +393,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI void StartWP() { m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - IsOnHold = false; + SetEscortPaused(false); } void DoMount() { diff --git a/src/bindings/scripts/scripts/kalimdor/feralas.cpp b/src/bindings/scripts/scripts/kalimdor/feralas.cpp index 1ee17bb3524..1eb673c5990 100644 --- a/src/bindings/scripts/scripts/kalimdor/feralas.cpp +++ b/src/bindings/scripts/scripts/kalimdor/feralas.cpp @@ -122,7 +122,7 @@ struct TRINITY_DLL_DECL npc_oox22feAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) m_creature->SetStandState(UNIT_STAND_STATE_DEAD); } diff --git a/src/bindings/scripts/scripts/kalimdor/tanaris.cpp b/src/bindings/scripts/scripts/kalimdor/tanaris.cpp index 6635b5b6e2c..c934a3d7b63 100644 --- a/src/bindings/scripts/scripts/kalimdor/tanaris.cpp +++ b/src/bindings/scripts/scripts/kalimdor/tanaris.cpp @@ -188,7 +188,7 @@ struct TRINITY_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI void MoveInLineOfSight(Unit *who) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; if (who->GetTypeId() == TYPEID_PLAYER) diff --git a/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp b/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp index 283ca7005f1..07e914e5a46 100644 --- a/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp +++ b/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp @@ -537,7 +537,7 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) { if (m_creature->getStandState() == UNIT_STAND_STATE_DEAD) m_creature->SetStandState(UNIT_STAND_STATE_STAND); diff --git a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp index 143b3430a36..b18c7c61ff6 100644 --- a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp +++ b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp @@ -148,22 +148,6 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI summoned->AI()->AttackStart(m_creature); } - void EnterEvadeMode() - { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(false);//do not interrupt channeling - m_creature->SetLootRecipient(NULL); - if (GetIsBeingEscorted()) - { - SetReturning(true); - ReturnToLastPoint(); - debug_log("TSCR: EscortAI (EnterEvadeMode() Override) has left combat and is now returning to last point"); - } - else - m_creature->GetMotionMaster()->MoveTargetedHome(); - } - void UpdateAI(const uint32 diff) { if (currentEvent != TYPE_NARALEX_PART3) diff --git a/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp b/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp index f29e6684f8f..582caec864c 100644 --- a/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp +++ b/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp @@ -104,7 +104,7 @@ struct TRINITY_DLL_DECL npc_injured_rainspeaker_oracleAI : public npc_escortAI void JustDied(Unit* killer) { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) return; if (Player* pPlayer = GetPlayerForEscort()) diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp index 05b00e65ae2..4176829895f 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp @@ -252,7 +252,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI void Reset() { - if (!IsBeingEscorted) + if (!HasEscortState(STATE_ESCORT_ESCORTING)) { bIsLowHP = false; bIsBattle = false; @@ -295,7 +295,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI break; case 13: DoScriptText(SAY_EVENT_INTRO_1, m_creature); - IsOnHold = true; + SetEscortPaused(true); SetRun(true); JumpToNextStep(20000); break; @@ -304,11 +304,11 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI if (pInstance) pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_TRIBUNAL_CONSOLE),true); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); - IsOnHold = true; + SetEscortPaused(true); JumpToNextStep(8500); break; case 18: - IsOnHold = true; + SetEscortPaused(true); break; } } @@ -351,7 +351,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI void StartWP() { m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - IsOnHold = false; + SetEscortPaused(false); uiStep = 1; } @@ -373,7 +373,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI JumpToNextStep(0); break; case 3: - IsOnHold = false; + SetEscortPaused(false); JumpToNextStep(0); break; case 5: @@ -507,7 +507,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI if (Creature* pTemp = Unit::GetCreature(*m_creature, uiControllerGUID)) pTemp->DealDamage(pTemp, pTemp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); bIsBattle = true; - IsOnHold = false; + SetEscortPaused(false); JumpToNextStep(6500); break; case 29: @@ -629,7 +629,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI break; } case 50: - IsOnHold = false; + SetEscortPaused(false); break; } } else uiPhaseTimer -= uiDiff; diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp index 66e6b3a108d..d28b512ae3b 100644 --- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp +++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp @@ -145,7 +145,7 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI void UpdateAI(const uint32 diff) { - if (!Intro && !IsBeingEscorted) + if (!Intro && !HasEscortState(STATE_ESCORT_ESCORTING)) { if (EventCheck_Timer < diff) { diff --git a/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp b/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp index 6050e4c7eae..83afc585be3 100644 --- a/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp +++ b/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp @@ -376,7 +376,7 @@ struct TRINITY_DLL_DECL npc_wounded_blood_elfAI : public npc_escortAI void EnterCombat(Unit* who) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) DoScriptText(SAY_ELF_AGGRO, m_creature); } diff --git a/src/bindings/scripts/scripts/outland/shattrath_city.cpp b/src/bindings/scripts/scripts/outland/shattrath_city.cpp index 23d54ce83b6..54aa5dc7670 100644 --- a/src/bindings/scripts/scripts/outland/shattrath_city.cpp +++ b/src/bindings/scripts/scripts/outland/shattrath_city.cpp @@ -320,7 +320,7 @@ public: void MoveInLineOfSight(Unit* pWho) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; if (pWho->GetTypeId() == TYPEID_PLAYER) diff --git a/src/bindings/scripts/scripts/outland/terokkar_forest.cpp b/src/bindings/scripts/scripts/outland/terokkar_forest.cpp index 9bb0a152cce..194eddc1e43 100644 --- a/src/bindings/scripts/scripts/outland/terokkar_forest.cpp +++ b/src/bindings/scripts/scripts/outland/terokkar_forest.cpp @@ -195,7 +195,7 @@ public: void MoveInLineOfSight(Unit *who) { - if (IsBeingEscorted) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; if (who->GetTypeId() == TYPEID_PLAYER) |