From 5d2d8d8074eb7f845627fcc97645c8d0081be2ba Mon Sep 17 00:00:00 2001 From: Kudlaty Date: Sun, 16 Aug 2009 22:21:57 +0200 Subject: Merge [SD2] r1321 Add support for quest 863. Some cleanup in existing script. r1322 Correct database info for current supported Mangos revision (8273+) (Windows may use from 8190+) - skip r1323 Make escortAI function IsPlayerOrGroupInRange and move existing code to this. r1324 Fixed IsEncounterInProgress for Arcatraz, The Eye and Shadow Labyrinth r1325 Renamed aunchindoun to auchindoun. Fixed comment typos. --HG-- branch : trunk --- src/bindings/scripts/base/escort_ai.cpp | 52 +++++++++++++++++---------------- src/bindings/scripts/base/escort_ai.h | 2 ++ 2 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src/bindings/scripts/base') diff --git a/src/bindings/scripts/base/escort_ai.cpp b/src/bindings/scripts/base/escort_ai.cpp index 2c28aa6b9a6..37c8c31981b 100644 --- a/src/bindings/scripts/base/escort_ai.cpp +++ b/src/bindings/scripts/base/escort_ai.cpp @@ -130,6 +130,32 @@ void npc_escortAI::EnterEvadeMode() Reset(); } +bool npc_escortAI::IsPlayerOrGroupInRange() +{ + if (Player* pPlayer = Unit::GetPlayer(PlayerGUID)) + { + if (Group* pGroup = pPlayer->GetGroup()) + { + for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next()) + { + Player* pMember = pRef->getSource(); + + if (pMember && m_creature->IsWithinDistInMap(pMember, GetMaxPlayerDistance())) + { + return true; + break; + } + } + } + else + { + if (m_creature->IsWithinDistInMap(pPlayer, GetMaxPlayerDistance())) + return true; + } + } + return false; +} + void npc_escortAI::UpdateAI(const uint32 uiDiff) { //Waypoint Updating @@ -194,31 +220,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) { if (m_uiPlayerCheckTimer < uiDiff) { - bool bIsMaxRangeExceeded = true; - - if (Player* pPlayer = Unit::GetPlayer(PlayerGUID)) - { - if (Group* pGroup = pPlayer->GetGroup()) - { - for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next()) - { - Player* pMember = pRef->getSource(); - - if (pMember && m_creature->IsWithinDistInMap(pMember, GetMaxPlayerDistance())) - { - bIsMaxRangeExceeded = false; - break; - } - } - } - else - { - if (m_creature->IsWithinDistInMap(pPlayer, GetMaxPlayerDistance())) - bIsMaxRangeExceeded = false; - } - } - - if (DespawnAtFar && bIsMaxRangeExceeded) + if (DespawnAtFar && !IsPlayerOrGroupInRange()) { debug_log("TSCR: EscortAI failed because player/group was to far away or not found"); diff --git a/src/bindings/scripts/base/escort_ai.h b/src/bindings/scripts/base/escort_ai.h index 663e11d79f6..243e64d6d21 100644 --- a/src/bindings/scripts/base/escort_ai.h +++ b/src/bindings/scripts/base/escort_ai.h @@ -56,6 +56,8 @@ 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(); + void FillPointMovementListForCreature(); void Start(bool bIsActiveAttacker = true, bool bRun = false, uint64 uiPlayerGUID = 0, const Quest* pQuest = NULL, bool bInstantRespawn = false, bool bCanLoopPath = false); -- cgit v1.2.3