diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 89f76920a..92c69672e 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1124,7 +1124,9 @@ namespace Game.AI if (summoner == null) break; - bool personalSpawn = flags.HasAnyFlag(SmartActionSummonCreatureFlags.PersonalSpawn); + ObjectGuid privateObjectOwner; + if (flags.HasAnyFlag(SmartActionSummonCreatureFlags.PersonalSpawn)) + privateObjectOwner = summoner.IsPrivateObject() ? summoner.GetPrivateObjectOwner() : summoner.GetGUID(); float x, y, z, o; foreach (var target in targets) @@ -1134,7 +1136,7 @@ namespace Game.AI y += e.Target.y; z += e.Target.z; o += e.Target.o; - Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, personalSpawn); + Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner); if (summon != null) if (e.Action.summonCreature.attackInvoker != 0) summon.GetAI().AttackStart(target.ToUnit()); @@ -1143,7 +1145,7 @@ namespace Game.AI if (e.GetTargetType() != SmartTargets.Position) break; - Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, personalSpawn); + Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner); if (summon1 != null) if (unit != null && e.Action.summonCreature.attackInvoker != 0) summon1.GetAI().AttackStart(unit); diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index a35b2c070..306f64365 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -1430,7 +1430,7 @@ namespace Game.Entities return null; } - public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, bool personalSpawn = false) + public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, ObjectGuid privateObjectOwner = default) { if (x == 0.0f && y == 0.0f && z == 0.0f) GetClosePoint(out x, out y, out z, GetCombatReach()); @@ -1438,15 +1438,15 @@ namespace Game.Entities if (o == 0.0f) o = GetOrientation(); - return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, personalSpawn); + return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, privateObjectOwner); } - public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, bool personalSpawn = false) + public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, ObjectGuid privateObjectOwner = default) { Map map = GetMap(); if (map != null) { - TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, ToUnit(), 0, vehId, personalSpawn); + TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, ToUnit(), 0, vehId, privateObjectOwner); if (summon != null) { summon.SetTempSummonType(despawnType); diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 78946e91a..daba742e7 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -3913,7 +3913,7 @@ namespace Game.Maps } } - public TempSummon SummonCreature(uint entry, Position pos, SummonPropertiesRecord properties = null, uint duration = 0, Unit summoner = null, uint spellId = 0, uint vehId = 0, bool personalSpawn = false) + public TempSummon SummonCreature(uint entry, Position pos, SummonPropertiesRecord properties = null, uint duration = 0, Unit summoner = null, uint spellId = 0, uint vehId = 0, ObjectGuid privateObjectOwner = default) { var mask = UnitTypeMask.Summon; if (properties != null) @@ -3995,9 +3995,7 @@ namespace Game.Maps summon.SetCreatedBySpell(spellId); summon.SetHomePosition(pos); summon.InitStats(duration); - - if (personalSpawn && summoner != null) - summon.SetPrivateObjectOwner(summoner.IsPrivateObject() ? summoner.GetPrivateObjectOwner() : summoner.GetGUID()); + summon.SetPrivateObjectOwner(privateObjectOwner); AddToMap(summon.ToCreature()); summon.InitSummon(); diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 750a267c1..19e51f51c 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1595,7 +1595,9 @@ namespace Game.Spells if (m_originalCaster == null) return; - bool personalSpawn = (properties.Flags & SummonPropFlags.PersonalSpawn) != 0; + ObjectGuid privateObjectOwner = ObjectGuid.Empty; + if (properties.Flags.HasAnyFlag(SummonPropFlags.PersonalSpawn)) + privateObjectOwner = m_originalCaster.IsPrivateObject() ? m_originalCaster.GetPrivateObjectOwner() : m_originalCaster.GetGUID(); int duration = m_spellInfo.CalcDuration(m_originalCaster); @@ -1658,7 +1660,7 @@ namespace Game.Spells case SummonTitle.LightWell: case SummonTitle.Totem: { - summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, personalSpawn); + summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, privateObjectOwner); if (summon == null || !summon.IsTotem()) return; @@ -1671,7 +1673,7 @@ namespace Game.Spells } case SummonTitle.Companion: { - summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, personalSpawn); + summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, privateObjectOwner); if (summon == null || !summon.HasUnitTypeMask(UnitTypeMask.Minion)) return; @@ -1699,7 +1701,7 @@ namespace Game.Spells // randomize position for multiple summons pos = m_caster.GetRandomPoint(destTarget, radius); - summon = m_originalCaster.SummonCreature(entry, pos, summonType, (uint)duration, 0, personalSpawn); + summon = m_originalCaster.SummonCreature(entry, pos, summonType, (uint)duration, 0, privateObjectOwner); if (summon == null) continue; @@ -1720,7 +1722,7 @@ namespace Game.Spells SummonGuardian(effIndex, entry, properties, numSummons); break; case SummonCategory.Puppet: - summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, personalSpawn); + summon = m_caster.GetMap().SummonCreature(entry, destTarget, properties, (uint)duration, m_originalCaster, m_spellInfo.Id, 0, privateObjectOwner); break; case SummonCategory.Vehicle: // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker