mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Scripts/Obsidian Sanctum: Fix portals not being visible
Change NearestGameObjectEntryInObjectRangeCheck to allow returning GameObject not spawned.
Fixes other occurrences where a similar issue exists.
(cherry picked from commit ca2159bf40)
This commit is contained in:
@@ -388,9 +388,9 @@ inline Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry,
|
||||
return source->FindNearestCreature(entry, maxSearchRange, alive);
|
||||
}
|
||||
|
||||
inline GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange)
|
||||
inline GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool spawnedOnly = true)
|
||||
{
|
||||
return source->FindNearestGameObject(entry, maxSearchRange);
|
||||
return source->FindNearestGameObject(entry, maxSearchRange, spawnedOnly);
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
|
||||
@@ -2025,10 +2025,10 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive
|
||||
return creature;
|
||||
}
|
||||
|
||||
GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
|
||||
GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range, bool spawnedOnly) const
|
||||
{
|
||||
GameObject* go = nullptr;
|
||||
Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
|
||||
Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range, spawnedOnly);
|
||||
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
|
||||
Cell::VisitGridObjects(this, searcher, range);
|
||||
return go;
|
||||
|
||||
@@ -582,7 +582,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
|
||||
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const;
|
||||
GameObject* FindNearestGameObject(uint32 entry, float range) const;
|
||||
GameObject* FindNearestGameObject(uint32 entry, float range, bool spawnedOnly = true) const;
|
||||
GameObject* FindNearestUnspawnedGameObject(uint32 entry, float range) const;
|
||||
GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const;
|
||||
Player* SelectNearestPlayer(float distance) const;
|
||||
|
||||
@@ -794,11 +794,11 @@ namespace Trinity
|
||||
class NearestGameObjectEntryInObjectRangeCheck
|
||||
{
|
||||
public:
|
||||
NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) { }
|
||||
NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range, bool spawnedOnly = true) : i_obj(obj), i_entry(entry), i_range(range), i_spawnedOnly(spawnedOnly) { }
|
||||
|
||||
bool operator()(GameObject* go)
|
||||
{
|
||||
if (go->isSpawned() && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
|
||||
if ((!i_spawnedOnly || go->isSpawned()) && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
|
||||
{
|
||||
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
|
||||
return true;
|
||||
@@ -810,6 +810,7 @@ namespace Trinity
|
||||
WorldObject const& i_obj;
|
||||
uint32 i_entry;
|
||||
float i_range;
|
||||
bool i_spawnedOnly;
|
||||
|
||||
// prevent clone this object
|
||||
NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&) = delete;
|
||||
|
||||
@@ -413,7 +413,7 @@ public:
|
||||
break;
|
||||
case SAY_PRIESTESS_ALTAR_8:
|
||||
// make the gem respawn
|
||||
if (GameObject* gem = GetClosestGameObjectWithEntry(me, GO_ELUNE_GEM, 10.0f))
|
||||
if (GameObject* gem = GetClosestGameObjectWithEntry(me, GO_ELUNE_GEM, 10.0f, false))
|
||||
{
|
||||
if (gem->isSpawned())
|
||||
break;
|
||||
|
||||
@@ -250,7 +250,7 @@ struct dummy_dragonAI : public ScriptedAI
|
||||
|
||||
// using a grid search here seem to be more efficient than caching all four guids
|
||||
// in instance script and calculate range to each.
|
||||
GameObject* portal = me->FindNearestGameObject(GO_TWILIGHT_PORTAL, 50.0f);
|
||||
GameObject* portal = me->FindNearestGameObject(GO_TWILIGHT_PORTAL, 50.0f, false);
|
||||
|
||||
switch (me->GetEntry())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user