Core/Objects: Pass privateObjectOwner guid directly to SummonCreature functions

Port From (https://github.com/TrinityCore/TrinityCore/commit/33b3ebcae67870f704d86d30aa357781b33bb411)
This commit is contained in:
hondacrx
2021-03-29 17:31:48 -04:00
parent 1ca5b5bcad
commit 98f9fdaf53
4 changed files with 18 additions and 16 deletions
+5 -3
View File
@@ -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);
+4 -4
View File
@@ -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);
+2 -4
View File
@@ -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();
+7 -5
View File
@@ -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