aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKudlaty <none@none>2009-07-24 05:27:49 +0200
committerKudlaty <none@none>2009-07-24 05:27:49 +0200
commit607dfaf8c9cf723a9a2244f88de506b609651341 (patch)
treebc905c394fd8a1fdf5cf6f3dadc505bbb259b78b /src
parentff1b2ed88c11927b8fdbfee34086e1c7dab05167 (diff)
Merge [SD2]
r1088 Add grid searcher class PlayerAtMinimumRangeAway and create ScriptedAI function GetPlayerAtMinimumRange that return player in grid with at least the defined range away from m_creature. r1089 Remove no longer needed grid search code and use function instead. - skip r1090 Rename and clarify function variables - skip r1091 Add two new grid search functions to return list of creature and gameobject. Remove unused class. r1092 Remove more grid search code in scripts and use functions instead. r1093 Remove obsolete grid search class and rename new to a more consistent name. r1094 Speed up functions GetCreature/GameObjectListWithEntryInGrid a bit --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp19
-rw-r--r--src/bindings/scripts/include/sc_creature.h4
-rw-r--r--src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp15
-rw-r--r--src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp13
-rw-r--r--src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp28
-rw-r--r--src/game/GridNotifiers.h61
-rw-r--r--src/game/Object.cpp30
-rw-r--r--src/game/Object.h3
-rw-r--r--src/shared/Errors.h4
9 files changed, 102 insertions, 75 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index 159fc4419ba..6083e4d4af5 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -533,6 +533,25 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 s
return pList;
}
+Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange)
+{
+ Player* pPlayer = NULL;
+
+ CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ Trinity::PlayerAtMinimumRangeAway check(m_creature, fMinimumRange);
+ Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(m_creature, pPlayer, check);
+ TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap()));
+
+ return pPlayer;
+}
+
void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
{
if (bLoadDefault)
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 13713a56100..7c57367332a 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -169,6 +169,9 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
//Returns a list of all friendly units missing a specific buff within range
std::list<Creature*> DoFindFriendlyMissingBuff(float range, uint32 spellid);
+ //Return a player with at least minimumRange from m_creature
+ Player* GetPlayerAtMinimumRange(float fMinimumRange);
+
//Spawns a creature relative to m_creature
Creature* DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime);
Creature *DoSummon(uint32 entry, const float pos[4], uint32 despawntime = 30000, TempSummonType type = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
@@ -248,6 +251,5 @@ struct TRINITY_DLL_DECL BossAI : public ScriptedAI
//return closest creature alive in grid, with range from pSource
Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange);
-
#endif
diff --git a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp
index 9974bc80fd9..f52a3bc59e9 100644
--- a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp
+++ b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp
@@ -441,8 +441,6 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
{
npc_geezleAI(Creature *c) : ScriptedAI(c) {}
- std::list<GameObject*> FlagList;
-
uint64 SparkGUID;
uint32 Step;
@@ -516,17 +514,8 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
void DespawnNagaFlag(bool despawn)
{
- CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- Trinity::AllGameObjectsWithEntryInGrid go_check(GO_NAGA_FLAG);
- Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInGrid> go_search(m_creature, FlagList, go_check);
- TypeContainerVisitor
- <Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInGrid>, GridTypeMapContainer> go_visit(go_search);
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, go_visit, *(m_creature->GetMap()));
+ std::list<GameObject*> FlagList;
+ m_creature->GetGameObjectListWithEntryInGrid(FlagList,GO_NAGA_FLAG, 50.0f);
Player* player = NULL;
if (!FlagList.empty())
diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp
index 5255a443b39..0cf81a8cd67 100644
--- a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp
+++ b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp
@@ -342,19 +342,8 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
void FindChannelers()
{
- CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
std::list<Creature*> ChannelerList;
-
- Trinity::AllCreaturesOfEntryInRange check(m_creature, CREATURE_CHANNELER, 50);
- Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(m_creature, ChannelerList, check);
- TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap()));
+ m_creature->GetCreatureListWithEntryInGrid(ChannelerList,CREATURE_CHANNELER,50.0f);
if(!ChannelerList.empty())
{
diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
index b45097d7f97..953fbcb198c 100644
--- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
+++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
@@ -53,21 +53,6 @@ EndScriptData */
#define SPELL_STORM_BUFF 2148
#define SPELL_STORM 26546
-class NearbyAQSentinel
-{
- public:
- NearbyAQSentinel(Unit const* obj) : i_obj(obj) {}
- bool operator()(Unit* u)
- {
- if (u->GetEntry() == 15264 && i_obj->IsWithinDistInMap(u, 70) && !u->isDead())
- return true;
- else
- return false;
- }
- private:
- Unit const* i_obj;
-};
-
struct TRINITY_DLL_DECL aqsentinelAI;
class TRINITY_DLL_DECL SentinelAbilityAura : public Aura
{
@@ -166,18 +151,11 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
void AddSentinelsNear(Unit *nears)
{
- CellPair p(Trinity::ComputeCellPair(nears->GetPositionX(), nears->GetPositionY()));
- Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
std::list<Creature*> assistList;
+ m_creature->GetCreatureListWithEntryInGrid(assistList,15264,70.0f);
- NearbyAQSentinel u_check(nears);
- Trinity::CreatureListSearcher<NearbyAQSentinel> searcher(m_creature, assistList, u_check);
- TypeContainerVisitor<Trinity::CreatureListSearcher<NearbyAQSentinel>, GridTypeMapContainer > grid_creature_searcher(searcher);
- CellLock<GridReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, grid_creature_searcher, *(nears->GetMap()));
+ if (assistList.empty())
+ return;
for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
AddBuddyToList((*iter));
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index 64deb0d3123..997f0806369 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -1135,48 +1135,69 @@ namespace Trinity
Unit const* pUnit;
};
- class AllGameObjectsWithEntryInGrid
+ class AllGameObjectsWithEntryInRange
{
public:
- AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
- bool operator() (GameObject* g)
+ AllGameObjectsWithEntryInRange(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
+ bool operator() (GameObject* pGo)
{
- if(g->GetEntry() == entry)
+ if (pGo->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pGo,m_fRange,false))
return true;
return false;
}
private:
- uint32 entry;
+ const WorldObject* m_pObject;
+ uint32 m_uiEntry;
+ float m_fRange;
};
- class GameObjectInRangeCheck
+ class AllCreaturesOfEntryInRange
{
- public:
- GameObjectInRangeCheck(float _x, float _y, float _z, float _range) : x(_x), y(_y), z(_z), range(_range) {}
- bool operator() (GameObject* go)
- {
- return go->IsInRange(x, y, z, range);
- }
- private:
- float x, y, z, range;
+ public:
+ AllCreaturesOfEntryInRange(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
+ bool operator() (Unit* pUnit)
+ {
+ if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false))
+ return true;
+
+ return false;
+ }
+
+ private:
+ const WorldObject* m_pObject;
+ uint32 m_uiEntry;
+ float m_fRange;
};
- class AllCreaturesOfEntryInRange
+ class PlayerAtMinimumRangeAway
{
public:
- AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
- bool operator() (Unit* u)
+ PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : pUnit(unit), fRange(fMinRange) {}
+ bool operator() (Player* pPlayer)
{
- if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
+ //No threat list check, must be done explicit if expected to be in combat with creature
+ if (!pPlayer->isGameMaster() && pPlayer->isAlive() && !pUnit->IsWithinDist(pPlayer,fRange,false))
return true;
return false;
}
+
private:
Unit const* pUnit;
- uint32 entry;
- float range;
+ float fRange;
+ };
+
+ class GameObjectInRangeCheck
+ {
+ public:
+ GameObjectInRangeCheck(float _x, float _y, float _z, float _range) : x(_x), y(_y), z(_z), range(_range) {}
+ bool operator() (GameObject* go)
+ {
+ return go->IsInRange(x, y, z, range);
+ }
+ private:
+ float x, y, z, range;
};
// Player checks and do
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 76041d8792c..d565818910e 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1992,6 +1992,36 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range)
return go;
}
+void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange)
+{
+ CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange);
+ Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
+ TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
+}
+
+void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange)
+{
+ CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange);
+ Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check);
+ TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
+}
+
/*
namespace MaNGOS
{
diff --git a/src/game/Object.h b/src/game/Object.h
index 2eba206ae64..b7e5a6efa3e 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -548,6 +548,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true);
GameObject* FindNearestGameObject(uint32 entry, float range);
+ void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange);
+ void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange);
+
bool isActiveObject() const { return m_isActive; }
void setActive(bool isActiveObject);
void SetWorldObject(bool apply);
diff --git a/src/shared/Errors.h b/src/shared/Errors.h
index 5cfd109ee01..992b1752a0f 100644
--- a/src/shared/Errors.h
+++ b/src/shared/Errors.h
@@ -23,10 +23,6 @@
#include "Common.h"
-#ifndef HAVE_CONFIG_H
-#define HAVE_ACE_STACK_TRACE_H 1
-#endif
-
#ifdef HAVE_ACE_STACK_TRACE_H
#include "ace/Stack_Trace.h"
#endif