Scripts/Obsidian Sanctum: Fix portals not being visible

Port From (https://github.com/TrinityCore/TrinityCore/commit/d561a691220c2c0856f63ff6cbcd4d0af8c761d5)
This commit is contained in:
hondacrx
2022-04-28 10:14:22 -04:00
parent ac388f2a1a
commit a9dcb2f2d7
4 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -456,9 +456,9 @@ namespace Game.AI
return source.FindNearestCreature(entry, maxSearchRange, alive);
}
public static GameObject GetClosestGameObjectWithEntry(WorldObject source, uint entry, float maxSearchRange)
public static GameObject GetClosestGameObjectWithEntry(WorldObject source, uint entry, float maxSearchRange, bool spawnedOnly = true)
{
return source.FindNearestGameObject(entry, maxSearchRange);
return source.FindNearestGameObject(entry, maxSearchRange, spawnedOnly);
}
public bool HealthBelowPct(int pct) { return me.HealthBelowPct(pct); }
+1 -1
View File
@@ -136,7 +136,7 @@ namespace Game.AI
}
}
--mNestedEventsCounter;
--_nestedEventsCounter;
}
void ProcessAction(SmartScriptHolder e, Unit unit = null, uint var0 = 0, uint var1 = 0, bool bvar = false, SpellInfo spell = null, GameObject gob = null, string varString = "")
+2 -2
View File
@@ -1581,9 +1581,9 @@ namespace Game.Entities
return searcher.GetTarget();
}
public GameObject FindNearestGameObject(uint entry, float range)
public GameObject FindNearestGameObject(uint entry, float range, bool spawnedOnly = true)
{
var checker = new NearestGameObjectEntryInObjectRangeCheck(this, entry, range);
var checker = new NearestGameObjectEntryInObjectRangeCheck(this, entry, range, spawnedOnly);
var searcher = new GameObjectLastSearcher(this, checker);
Cell.VisitGridObjects(this, searcher, range);
+11 -9
View File
@@ -2770,26 +2770,28 @@ namespace Game.Maps
// Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO)
class NearestGameObjectEntryInObjectRangeCheck : ICheck<GameObject>
{
public NearestGameObjectEntryInObjectRangeCheck(WorldObject obj, uint entry, float range)
public NearestGameObjectEntryInObjectRangeCheck(WorldObject obj, uint entry, float range, bool spawnedOnly = true)
{
i_obj = obj;
i_entry = entry;
i_range = range;
_obj = obj;
_entry = entry;
_range = range;
_spawnedOnly = spawnedOnly;
}
public bool Invoke(GameObject go)
{
if (go.IsSpawned() && go.GetEntry() == i_entry && go.GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
if ((!_spawnedOnly || go.IsSpawned()) && go.GetEntry() == _entry && go.GetGUID() != _obj.GetGUID() && _obj.IsWithinDistInMap(go, _range))
{
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
_range = _obj.GetDistance(go); // use found GO range as new range limit for next check
return true;
}
return false;
}
WorldObject i_obj;
uint i_entry;
float i_range;
WorldObject _obj;
uint _entry;
float _range;
bool _spawnedOnly;
}
// Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest unspawned GO)