aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts/base
diff options
context:
space:
mode:
authorKudlaty <none@none>2009-08-16 22:21:57 +0200
committerKudlaty <none@none>2009-08-16 22:21:57 +0200
commit5d2d8d8074eb7f845627fcc97645c8d0081be2ba (patch)
tree638ba1111cb802a78c55f43ab23a7d8313223d36 /src/bindings/scripts/base
parent91f3d69edf754c4e62d973cf1ae81e9a2e36d7bc (diff)
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
Diffstat (limited to 'src/bindings/scripts/base')
-rw-r--r--src/bindings/scripts/base/escort_ai.cpp52
-rw-r--r--src/bindings/scripts/base/escort_ai.h2
2 files changed, 29 insertions, 25 deletions
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);