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
This commit is contained in:
@@ -533,6 +533,25 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 s
|
|||||||
return pList;
|
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)
|
void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
|
||||||
{
|
{
|
||||||
if (bLoadDefault)
|
if (bLoadDefault)
|
||||||
|
|||||||
@@ -169,6 +169,9 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
|||||||
//Returns a list of all friendly units missing a specific buff within range
|
//Returns a list of all friendly units missing a specific buff within range
|
||||||
std::list<Creature*> DoFindFriendlyMissingBuff(float range, uint32 spellid);
|
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
|
//Spawns a creature relative to m_creature
|
||||||
Creature* DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime);
|
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);
|
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
|
//return closest creature alive in grid, with range from pSource
|
||||||
Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange);
|
Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -441,8 +441,6 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
|
|||||||
{
|
{
|
||||||
npc_geezleAI(Creature *c) : ScriptedAI(c) {}
|
npc_geezleAI(Creature *c) : ScriptedAI(c) {}
|
||||||
|
|
||||||
std::list<GameObject*> FlagList;
|
|
||||||
|
|
||||||
uint64 SparkGUID;
|
uint64 SparkGUID;
|
||||||
|
|
||||||
uint32 Step;
|
uint32 Step;
|
||||||
@@ -516,17 +514,8 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
|
|||||||
|
|
||||||
void DespawnNagaFlag(bool despawn)
|
void DespawnNagaFlag(bool despawn)
|
||||||
{
|
{
|
||||||
CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
|
std::list<GameObject*> FlagList;
|
||||||
Cell cell(pair);
|
m_creature->GetGameObjectListWithEntryInGrid(FlagList,GO_NAGA_FLAG, 50.0f);
|
||||||
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()));
|
|
||||||
|
|
||||||
Player* player = NULL;
|
Player* player = NULL;
|
||||||
if (!FlagList.empty())
|
if (!FlagList.empty())
|
||||||
|
|||||||
@@ -342,19 +342,8 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
|
|||||||
|
|
||||||
void FindChannelers()
|
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;
|
std::list<Creature*> ChannelerList;
|
||||||
|
m_creature->GetCreatureListWithEntryInGrid(ChannelerList,CREATURE_CHANNELER,50.0f);
|
||||||
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()));
|
|
||||||
|
|
||||||
if(!ChannelerList.empty())
|
if(!ChannelerList.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,21 +53,6 @@ EndScriptData */
|
|||||||
#define SPELL_STORM_BUFF 2148
|
#define SPELL_STORM_BUFF 2148
|
||||||
#define SPELL_STORM 26546
|
#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;
|
struct TRINITY_DLL_DECL aqsentinelAI;
|
||||||
class TRINITY_DLL_DECL SentinelAbilityAura : public Aura
|
class TRINITY_DLL_DECL SentinelAbilityAura : public Aura
|
||||||
{
|
{
|
||||||
@@ -166,18 +151,11 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
|
|||||||
|
|
||||||
void AddSentinelsNear(Unit *nears)
|
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;
|
std::list<Creature*> assistList;
|
||||||
|
m_creature->GetCreatureListWithEntryInGrid(assistList,15264,70.0f);
|
||||||
|
|
||||||
NearbyAQSentinel u_check(nears);
|
if (assistList.empty())
|
||||||
Trinity::CreatureListSearcher<NearbyAQSentinel> searcher(m_creature, assistList, u_check);
|
return;
|
||||||
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()));
|
|
||||||
|
|
||||||
for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
|
for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
|
||||||
AddBuddyToList((*iter));
|
AddBuddyToList((*iter));
|
||||||
|
|||||||
+43
-22
@@ -1135,19 +1135,57 @@ namespace Trinity
|
|||||||
Unit const* pUnit;
|
Unit const* pUnit;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AllGameObjectsWithEntryInGrid
|
class AllGameObjectsWithEntryInRange
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
|
AllGameObjectsWithEntryInRange(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
|
||||||
bool operator() (GameObject* g)
|
bool operator() (GameObject* pGo)
|
||||||
{
|
{
|
||||||
if(g->GetEntry() == entry)
|
if (pGo->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pGo,m_fRange,false))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
uint32 entry;
|
const WorldObject* m_pObject;
|
||||||
|
uint32 m_uiEntry;
|
||||||
|
float m_fRange;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AllCreaturesOfEntryInRange
|
||||||
|
{
|
||||||
|
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 PlayerAtMinimumRangeAway
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : pUnit(unit), fRange(fMinRange) {}
|
||||||
|
bool operator() (Player* pPlayer)
|
||||||
|
{
|
||||||
|
//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;
|
||||||
|
float fRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameObjectInRangeCheck
|
class GameObjectInRangeCheck
|
||||||
@@ -1162,23 +1200,6 @@ namespace Trinity
|
|||||||
float x, y, z, range;
|
float x, y, z, range;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AllCreaturesOfEntryInRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
|
|
||||||
bool operator() (Unit* u)
|
|
||||||
{
|
|
||||||
if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Unit const* pUnit;
|
|
||||||
uint32 entry;
|
|
||||||
float range;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Player checks and do
|
// Player checks and do
|
||||||
|
|
||||||
// Prepare using Builder localized packets with caching and send to player
|
// Prepare using Builder localized packets with caching and send to player
|
||||||
|
|||||||
@@ -1992,6 +1992,36 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range)
|
|||||||
return go;
|
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
|
namespace MaNGOS
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -548,6 +548,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
|||||||
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true);
|
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true);
|
||||||
GameObject* FindNearestGameObject(uint32 entry, float range);
|
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; }
|
bool isActiveObject() const { return m_isActive; }
|
||||||
void setActive(bool isActiveObject);
|
void setActive(bool isActiveObject);
|
||||||
void SetWorldObject(bool apply);
|
void SetWorldObject(bool apply);
|
||||||
|
|||||||
@@ -23,10 +23,6 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#ifndef HAVE_CONFIG_H
|
|
||||||
#define HAVE_ACE_STACK_TRACE_H 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_ACE_STACK_TRACE_H
|
#ifdef HAVE_ACE_STACK_TRACE_H
|
||||||
#include "ace/Stack_Trace.h"
|
#include "ace/Stack_Trace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user