From 39ec9e309ff290d0bcd33e7e646c250495da2803 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 5 May 2022 10:02:40 -0400 Subject: [PATCH] Core/Objects: Use player as summoner for personal clones Port From (https://github.com/TrinityCore/TrinityCore/commit/79c605436942d652c50e4cfeac9d1b20a86a2343) --- Source/Game/AI/SmartScripts/SmartScript.cs | 5 ++- Source/Game/Entities/Object/WorldObject.cs | 4 +-- Source/Game/Entities/TemporarySummon.cs | 37 +++++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 1e1728058..55f2df0e8 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -2483,13 +2483,12 @@ namespace Game.AI { WorldObject baseObject = GetBaseObject(); - void doCreatePersonalClone(Position position, Unit owner) + void doCreatePersonalClone(Position position, Player privateObjectOwner) { - ObjectGuid privateObjectOwner = owner.GetGUID(); Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, TimeSpan.FromMilliseconds(e.Action.becomePersonalClone.duration), 0, 0, privateObjectOwner); if (summon != null) if (IsSmart(summon)) - ((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, owner, e.EventId + 1); + ((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, privateObjectOwner, e.EventId + 1); } // if target is position then targets container was empty diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index ede676d14..c8d763454 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -1473,12 +1473,12 @@ namespace Game.Entities return null; } - public TempSummon SummonPersonalClone(Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default) + public TempSummon SummonPersonalClone(Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, Player privateObjectOwner = null) { Map map = GetMap(); if (map != null) { - TempSummon summon = map.SummonCreature(GetEntry(), pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner, new SmoothPhasingInfo(GetGUID(), true, true)); + TempSummon summon = map.SummonCreature(GetEntry(), pos, null, (uint)despawnTime.TotalMilliseconds, privateObjectOwner, spellId, vehId, privateObjectOwner.GetGUID(), new SmoothPhasingInfo(GetGUID(), true, true)); if (summon != null) { summon.SetTempSummonType(despawnType); diff --git a/Source/Game/Entities/TemporarySummon.cs b/Source/Game/Entities/TemporarySummon.cs index 49156ae49..a3b81d473 100644 --- a/Source/Game/Entities/TemporarySummon.cs +++ b/Source/Game/Entities/TemporarySummon.cs @@ -246,10 +246,16 @@ namespace Game.Entities objectsToUpdate.Add(this); SmoothPhasing smoothPhasing = GetSmoothPhasing(); - WorldObject original = GetSummoner(); - if (original != null) - if (smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID())) - objectsToUpdate.Add(original); + if (smoothPhasing != null) + { + SmoothPhasingInfo infoForSeer = smoothPhasing.GetInfoForSeer(GetDemonCreatorGUID()); + if (infoForSeer != null && infoForSeer.ReplaceObject.HasValue && smoothPhasing.IsReplacing(infoForSeer.ReplaceObject.Value)) + { + WorldObject original = Global.ObjAccessor.GetWorldObject(this, infoForSeer.ReplaceObject.Value); + if (original != null) + objectsToUpdate.Add(original); + } + } VisibleChangesNotifier notifier = new(objectsToUpdate); Cell.VisitWorldObjects(this, notifier, GetVisibilityRange()); @@ -260,22 +266,29 @@ namespace Game.Entities List objectsToUpdate = new(); objectsToUpdate.Add(this); - WorldObject original = GetSummoner(); + WorldObject original = null; SmoothPhasing smoothPhasing = GetSmoothPhasing(); - if (original != null && smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID())) + if (smoothPhasing != null) { - objectsToUpdate.Add(original); + SmoothPhasingInfo infoForSeer = smoothPhasing.GetInfoForSeer(GetDemonCreatorGUID()); + if (infoForSeer != null && infoForSeer.ReplaceObject.HasValue && smoothPhasing.IsReplacing(infoForSeer.ReplaceObject.Value)) + original = Global.ObjAccessor.GetWorldObject(this, infoForSeer.ReplaceObject.Value); - // disable replacement without removing - it is still needed for next step (visibility update) - SmoothPhasing originalSmoothPhasing = original.GetSmoothPhasing(); - if (originalSmoothPhasing != null) - originalSmoothPhasing.DisableReplacementForSeer(GetDemonCreatorGUID()); + if (original != null) + { + objectsToUpdate.Add(original); + + // disable replacement without removing - it is still needed for next step (visibility update) + SmoothPhasing originalSmoothPhasing = original.GetSmoothPhasing(); + if (originalSmoothPhasing != null) + originalSmoothPhasing.DisableReplacementForSeer(GetDemonCreatorGUID()); + } } VisibleChangesNotifier notifier = new(objectsToUpdate); Cell.VisitWorldObjects(this, notifier, GetVisibilityRange()); - if (original != null && smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID())) + if (original != null) // original is only != null when it was replaced { SmoothPhasing originalSmoothPhasing = original.GetSmoothPhasing(); if (originalSmoothPhasing != null)