Core/Objects: Move personal summon handling from TemporarySummon/GameObject to WorldObject and check it using dedicated guid field
Port From (https://github.com/TrinityCore/TrinityCore/commit/1082a6645e96c611b3145b5d6208fc4db6e4b2d3)
This commit is contained in:
@@ -88,20 +88,10 @@ namespace Game.Combat
|
|||||||
Unit redirectTarget = victim.GetRedirectThreatTarget();
|
Unit redirectTarget = victim.GetRedirectThreatTarget();
|
||||||
|
|
||||||
// If victim is personnal spawn, redirect all aggro to summoner
|
// If victim is personnal spawn, redirect all aggro to summoner
|
||||||
TempSummon tempSummonVictim = victim.ToTempSummon();
|
if (victim.IsPrivateObject() && GetOwner().IsPrivateObject() && GetOwner().CanSeeOrDetect(victim))
|
||||||
if (tempSummonVictim)
|
|
||||||
{
|
{
|
||||||
if (tempSummonVictim.IsVisibleBySummonerOnly())
|
redirectThreadPct = 100;
|
||||||
{
|
redirectTarget = Global.ObjAccessor.GetUnit(GetOwner(), victim.GetPrivateObjectOwner());
|
||||||
// Personnal Spawns from same summoner can aggro each other
|
|
||||||
if (!GetOwner().ToTempSummon() ||
|
|
||||||
!GetOwner().ToTempSummon().IsVisibleBySummonerOnly() ||
|
|
||||||
tempSummonVictim.GetSummonerGUID() != GetOwner().ToTempSummon().GetSummonerGUID())
|
|
||||||
{
|
|
||||||
redirectThreadPct = 100;
|
|
||||||
redirectTarget = tempSummonVictim.GetSummoner();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// must check > 0.0f, otherwise dead loop
|
// must check > 0.0f, otherwise dead loop
|
||||||
|
|||||||
@@ -2824,10 +2824,6 @@ namespace Game.Entities
|
|||||||
// There's many places not ready for dynamic spawns. This allows them to live on for now.
|
// There's many places not ready for dynamic spawns. This allows them to live on for now.
|
||||||
void SetRespawnCompatibilityMode(bool mode = true) { m_respawnCompatibilityMode = mode; }
|
void SetRespawnCompatibilityMode(bool mode = true) { m_respawnCompatibilityMode = mode; }
|
||||||
public bool GetRespawnCompatibilityMode() { return m_respawnCompatibilityMode; }
|
public bool GetRespawnCompatibilityMode() { return m_respawnCompatibilityMode; }
|
||||||
|
|
||||||
public void SetVisibleByUnitOnly(ObjectGuid unit) { m_visibleByUnitOnly = unit; }
|
|
||||||
public bool IsVisibleByUnitOnly() { return !m_visibleByUnitOnly.IsEmpty(); }
|
|
||||||
public ObjectGuid GetVisibleByUnitOnly() { return m_visibleByUnitOnly; }
|
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
protected GameObjectFieldData m_gameObjectData;
|
protected GameObjectFieldData m_gameObjectData;
|
||||||
@@ -2863,7 +2859,6 @@ namespace Game.Entities
|
|||||||
bool m_respawnCompatibilityMode;
|
bool m_respawnCompatibilityMode;
|
||||||
ushort _animKitId;
|
ushort _animKitId;
|
||||||
uint _worldEffectID;
|
uint _worldEffectID;
|
||||||
ObjectGuid m_visibleByUnitOnly;
|
|
||||||
|
|
||||||
GameObjectState m_prevGoState; // What state to set whenever resetting
|
GameObjectState m_prevGoState; // What state to set whenever resetting
|
||||||
|
|
||||||
|
|||||||
@@ -1105,6 +1105,9 @@ namespace Game.Entities
|
|||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!obj.GetPrivateObjectOwner().IsEmpty())
|
||||||
|
return GetGUID() == obj.GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj.GetPrivateObjectOwner();
|
||||||
|
|
||||||
if (obj.IsNeverVisibleFor(this) || CanNeverSee(obj))
|
if (obj.IsNeverVisibleFor(this) || CanNeverSee(obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1145,20 +1148,8 @@ namespace Game.Entities
|
|||||||
WorldObject viewpoint = this;
|
WorldObject viewpoint = this;
|
||||||
Player player = ToPlayer();
|
Player player = ToPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
|
||||||
viewpoint = player.GetViewpoint();
|
viewpoint = player.GetViewpoint();
|
||||||
|
|
||||||
Creature creature = obj.ToCreature();
|
|
||||||
if (creature)
|
|
||||||
if (TempSummon.IsPersonalSummonOfAnotherPlayer(creature, GetGUID()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject go = obj.ToGameObject();
|
|
||||||
if ( go != null)
|
|
||||||
if (go.IsVisibleByUnitOnly() && GetGUID() != go.GetVisibleByUnitOnly())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (viewpoint == null)
|
if (viewpoint == null)
|
||||||
viewpoint = this;
|
viewpoint = this;
|
||||||
|
|
||||||
@@ -1423,7 +1414,7 @@ namespace Game.Entities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, bool visibleBySummonerOnly = false)
|
public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, bool personalSpawn = false)
|
||||||
{
|
{
|
||||||
if (x == 0.0f && y == 0.0f && z == 0.0f)
|
if (x == 0.0f && y == 0.0f && z == 0.0f)
|
||||||
GetClosePoint(out x, out y, out z, GetCombatReach());
|
GetClosePoint(out x, out y, out z, GetCombatReach());
|
||||||
@@ -1431,15 +1422,15 @@ namespace Game.Entities
|
|||||||
if (o == 0.0f)
|
if (o == 0.0f)
|
||||||
o = GetOrientation();
|
o = GetOrientation();
|
||||||
|
|
||||||
return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, visibleBySummonerOnly);
|
return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, personalSpawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, bool visibleBySummonerOnly = false)
|
public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, bool personalSpawn = false)
|
||||||
{
|
{
|
||||||
Map map = GetMap();
|
Map map = GetMap();
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, ToUnit(), 0, vehId, visibleBySummonerOnly);
|
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, ToUnit(), 0, vehId, personalSpawn);
|
||||||
if (summon != null)
|
if (summon != null)
|
||||||
{
|
{
|
||||||
summon.SetTempSummonType(despawnType);
|
summon.SetTempSummonType(despawnType);
|
||||||
@@ -1697,6 +1688,11 @@ namespace Game.Entities
|
|||||||
public virtual ushort GetMovementAnimKitId() { return 0; }
|
public virtual ushort GetMovementAnimKitId() { return 0; }
|
||||||
public virtual ushort GetMeleeAnimKitId() { return 0; }
|
public virtual ushort GetMeleeAnimKitId() { return 0; }
|
||||||
|
|
||||||
|
// Watcher
|
||||||
|
public bool IsPrivateObject() { return !_privateObjectOwner.IsEmpty(); }
|
||||||
|
public ObjectGuid GetPrivateObjectOwner() { return _privateObjectOwner; }
|
||||||
|
public void SetPrivateObjectOwner(ObjectGuid owner) { _privateObjectOwner = owner; }
|
||||||
|
|
||||||
public virtual string GetName(Locale locale = Locale.enUS) { return _name; }
|
public virtual string GetName(Locale locale = Locale.enUS) { return _name; }
|
||||||
public void SetName(string name) { _name = name; }
|
public void SetName(string name) { _name = name; }
|
||||||
|
|
||||||
@@ -2383,6 +2379,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
NotifyFlags m_notifyflags;
|
NotifyFlags m_notifyflags;
|
||||||
|
|
||||||
|
ObjectGuid _privateObjectOwner;
|
||||||
|
|
||||||
public FlaggedArray<StealthType> m_stealth = new(2);
|
public FlaggedArray<StealthType> m_stealth = new(2);
|
||||||
public FlaggedArray<StealthType> m_stealthDetect = new(2);
|
public FlaggedArray<StealthType> m_stealthDetect = new(2);
|
||||||
|
|
||||||
|
|||||||
@@ -42,16 +42,6 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
return !m_summonerGUID.IsEmpty() ? ObjectAccessor.GetCreature(this, m_summonerGUID) : null;
|
return !m_summonerGUID.IsEmpty() ? ObjectAccessor.GetCreature(this, m_summonerGUID) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsPersonalSummonOfAnotherPlayer(Creature summon, ObjectGuid playerToCheck)
|
|
||||||
{
|
|
||||||
TempSummon tempSummon = summon.ToTempSummon();
|
|
||||||
if (tempSummon != null)
|
|
||||||
if (tempSummon.IsVisibleBySummonerOnly() && playerToCheck != tempSummon.GetSummonerGUID())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(uint diff)
|
public override void Update(uint diff)
|
||||||
{
|
{
|
||||||
@@ -290,15 +280,11 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public uint GetTimer() { return m_timer; }
|
public uint GetTimer() { return m_timer; }
|
||||||
|
|
||||||
public void SetVisibleBySummonerOnly(bool visibleBySummonerOnly) { m_visibleBySummonerOnly = visibleBySummonerOnly; }
|
|
||||||
public bool IsVisibleBySummonerOnly() { return m_visibleBySummonerOnly; }
|
|
||||||
|
|
||||||
public SummonPropertiesRecord m_Properties;
|
public SummonPropertiesRecord m_Properties;
|
||||||
TempSummonType m_type;
|
TempSummonType m_type;
|
||||||
uint m_timer;
|
uint m_timer;
|
||||||
uint m_lifetime;
|
uint m_lifetime;
|
||||||
ObjectGuid m_summonerGUID;
|
ObjectGuid m_summonerGUID;
|
||||||
bool m_visibleBySummonerOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Minion : TempSummon
|
public class Minion : TempSummon
|
||||||
|
|||||||
@@ -2300,7 +2300,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public bool Invoke(Creature u)
|
public bool Invoke(Creature u)
|
||||||
{
|
{
|
||||||
if (u.GetDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range) && !TempSummon.IsPersonalSummonOfAnotherPlayer(u, i_obj.GetGUID()))
|
if (u.GetDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range) && u.CanSeeOrDetect(i_obj))
|
||||||
{
|
{
|
||||||
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -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 visibleBySummonerOnly = false)
|
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)
|
||||||
{
|
{
|
||||||
var mask = UnitTypeMask.Summon;
|
var mask = UnitTypeMask.Summon;
|
||||||
if (properties != null)
|
if (properties != null)
|
||||||
@@ -3995,7 +3995,9 @@ namespace Game.Maps
|
|||||||
summon.SetCreatedBySpell(spellId);
|
summon.SetCreatedBySpell(spellId);
|
||||||
summon.SetHomePosition(pos);
|
summon.SetHomePosition(pos);
|
||||||
summon.InitStats(duration);
|
summon.InitStats(duration);
|
||||||
summon.SetVisibleBySummonerOnly(visibleBySummonerOnly);
|
|
||||||
|
if (personalSpawn && summoner != null)
|
||||||
|
summon.SetPrivateObjectOwner(summoner.IsPrivateObject() ? summoner.GetPrivateObjectOwner() : summoner.GetGUID());
|
||||||
|
|
||||||
AddToMap(summon.ToCreature());
|
AddToMap(summon.ToCreature());
|
||||||
summon.InitSummon();
|
summon.InitSummon();
|
||||||
|
|||||||
@@ -5211,7 +5211,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
go.SetSpellId(m_spellInfo.Id);
|
go.SetSpellId(m_spellInfo.Id);
|
||||||
go.SetVisibleByUnitOnly(m_caster.GetGUID());
|
go.SetPrivateObjectOwner(m_caster.GetGUID());
|
||||||
|
|
||||||
ExecuteLogEffectSummonObject(effIndex, go);
|
ExecuteLogEffectSummonObject(effIndex, go);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user