From a9dcb2f2d78ff833be86801e073dd4414587f7dd Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 28 Apr 2022 10:14:22 -0400 Subject: [PATCH] Scripts/Obsidian Sanctum: Fix portals not being visible Port From (https://github.com/TrinityCore/TrinityCore/commit/d561a691220c2c0856f63ff6cbcd4d0af8c761d5) --- Source/Game/AI/ScriptedAI/ScriptedAI.cs | 4 ++-- Source/Game/AI/SmartScripts/SmartScript.cs | 2 +- Source/Game/Entities/Object/WorldObject.cs | 4 ++-- Source/Game/Maps/GridNotifiers.cs | 20 +++++++++++--------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Source/Game/AI/ScriptedAI/ScriptedAI.cs b/Source/Game/AI/ScriptedAI/ScriptedAI.cs index 550d2af32..4fe580760 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedAI.cs @@ -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); } diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 0ee81ddd7..386d8f13b 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -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 = "") diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index c8318bf3a..5286748aa 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -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); diff --git a/Source/Game/Maps/GridNotifiers.cs b/Source/Game/Maps/GridNotifiers.cs index 92484c781..097ea5f79 100644 --- a/Source/Game/Maps/GridNotifiers.cs +++ b/Source/Game/Maps/GridNotifiers.cs @@ -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 { - 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)