Core/Creatures: Implemented sending different creature id for summoner
Port From (https://github.com/TrinityCore/TrinityCore/commit/ebf1b6eb5cbfd1dc8f1b0d26c29ae1423784cabb)
This commit is contained in:
@@ -410,6 +410,13 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public class CreatureSummonedData
|
||||
{
|
||||
public uint? CreatureIDVisibleToSummoner;
|
||||
public uint? GroundMountDisplayID;
|
||||
public uint? FlyingMountDisplayID;
|
||||
}
|
||||
|
||||
public class CreatureAddon
|
||||
{
|
||||
public uint path_id;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Game.Entities
|
||||
|
||||
public void WriteCreate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, WorldObject owner, Player receiver)
|
||||
{
|
||||
data.WriteUInt32(EntryId);
|
||||
data.WriteUInt32(GetViewerDependentEntryId(this, owner, receiver));
|
||||
data.WriteUInt32(GetViewerDependentDynamicFlags(this, owner, receiver));
|
||||
data.WriteFloat(Scale);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (changesMask[1])
|
||||
{
|
||||
data.WriteUInt32(EntryId);
|
||||
data.WriteUInt32(GetViewerDependentEntryId(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[2])
|
||||
{
|
||||
@@ -77,6 +77,21 @@ namespace Game.Entities
|
||||
_changesMask.ResetAll();
|
||||
}
|
||||
|
||||
uint GetViewerDependentEntryId(ObjectFieldData objectData, WorldObject obj, Player receiver)
|
||||
{
|
||||
uint entryId = objectData.EntryId;
|
||||
Unit unit = obj.ToUnit();
|
||||
if (unit != null)
|
||||
{
|
||||
TempSummon summon = unit.ToTempSummon();
|
||||
if (summon != null)
|
||||
if (summon.GetSummonerGUID() == receiver.GetGUID() && summon.GetCreatureIdVisibleToSummoner().HasValue)
|
||||
entryId = summon.GetCreatureIdVisibleToSummoner().Value;
|
||||
}
|
||||
|
||||
return entryId;
|
||||
}
|
||||
|
||||
uint GetViewerDependentDynamicFlags(ObjectFieldData objectData, WorldObject obj, Player receiver)
|
||||
{
|
||||
uint unitDynFlags = objectData.DynamicFlags;
|
||||
@@ -2217,6 +2232,18 @@ namespace Game.Entities
|
||||
if (unit.IsCreature())
|
||||
{
|
||||
CreatureTemplate cinfo = unit.ToCreature().GetCreatureTemplate();
|
||||
TempSummon summon = unit.ToTempSummon();
|
||||
if (summon != null)
|
||||
{
|
||||
if (summon.GetSummonerGUID() == receiver.GetGUID())
|
||||
{
|
||||
if (summon.GetCreatureIdVisibleToSummoner().HasValue)
|
||||
cinfo = Global.ObjectMgr.GetCreatureTemplate(summon.GetCreatureIdVisibleToSummoner().Value);
|
||||
|
||||
if (summon.GetDisplayIdVisibleToSummoner().HasValue)
|
||||
displayId = summon.GetDisplayIdVisibleToSummoner().Value;
|
||||
}
|
||||
}
|
||||
|
||||
// this also applies for transform auras
|
||||
SpellInfo transform = Global.SpellMgr.GetSpellInfo(unit.GetTransformSpell(), unit.GetMap().GetDifficultyID());
|
||||
|
||||
@@ -193,6 +193,20 @@ namespace Game.Entities
|
||||
if (owner.IsTypeId(TypeId.Player))
|
||||
m_ControlledByPlayer = true;
|
||||
|
||||
if (owner != null && owner.IsPlayer())
|
||||
{
|
||||
CreatureSummonedData summonedData = Global.ObjectMgr.GetCreatureSummonedData(GetEntry());
|
||||
if (summonedData != null)
|
||||
{
|
||||
m_creatureIdVisibleToSummoner = summonedData.CreatureIDVisibleToSummoner;
|
||||
if (summonedData.CreatureIDVisibleToSummoner.HasValue)
|
||||
{
|
||||
CreatureTemplate creatureTemplateVisibleToSummoner = Global.ObjectMgr.GetCreatureTemplate(summonedData.CreatureIDVisibleToSummoner.Value);
|
||||
m_displayIdVisibleToSummoner = ObjectManager.ChooseDisplayId(creatureTemplateVisibleToSummoner, null).CreatureDisplayID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Properties == null)
|
||||
return;
|
||||
|
||||
@@ -367,6 +381,9 @@ namespace Game.Entities
|
||||
|
||||
public uint GetTimer() { return m_timer; }
|
||||
|
||||
public uint? GetCreatureIdVisibleToSummoner() { return m_creatureIdVisibleToSummoner; }
|
||||
public uint? GetDisplayIdVisibleToSummoner() { return m_displayIdVisibleToSummoner; }
|
||||
|
||||
public bool CanFollowOwner() { return m_canFollowOwner; }
|
||||
public void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
|
||||
|
||||
@@ -375,6 +392,8 @@ namespace Game.Entities
|
||||
uint m_timer;
|
||||
uint m_lifetime;
|
||||
ObjectGuid m_summonerGUID;
|
||||
uint? m_creatureIdVisibleToSummoner;
|
||||
uint? m_displayIdVisibleToSummoner;
|
||||
bool m_canFollowOwner;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user