From 54e6b02ffc51ef2ef55cc19d4f00d6b4da89930b Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 5 Aug 2024 15:03:26 -0400 Subject: [PATCH] Core/Entities: Added possibility to inherit StringIds from other entities Port From (https://github.com/TrinityCore/TrinityCore/commit/88bbd27f8d007dca17bb0d244fcf7e753506734e) --- Source/Game/Entities/Creature/Creature.cs | 9 +++++++++ Source/Game/Entities/GameObject/GameObject.cs | 9 +++++++++ Source/Game/Entities/Object/WorldObject.cs | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 3e77989cc..1036ace80 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -2915,6 +2915,15 @@ namespace Game.Entities return Global.ObjectMgr.GetCreatureTemplate(GetEntry()) != null ? Global.ObjectMgr.GetCreatureTemplate(GetEntry()).ScriptID : 0; } + public void InheritStringIds(Creature parent) + { + // copy references to stringIds from template and spawn + m_stringIds = parent.m_stringIds; + + // then copy script stringId, not just its reference + SetScriptStringId(parent.GetStringId(StringIdType.Script)); + } + public bool HasStringId(string id) { return m_stringIds.Contains(id); diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index 648f66cdc..43c6ed931 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -2665,6 +2665,15 @@ namespace Game.Entities return GetGoInfo().ScriptId; } + public void InheritStringIds(GameObject parent) + { + // copy references to stringIds from template and spawn + m_stringIds = parent.m_stringIds; + + // then copy script stringId, not just its reference + SetScriptStringId(parent.GetStringId(StringIdType.Script)); + } + public bool HasStringId(string id) { return m_stringIds.Contains(id); diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 07e194ccd..5e90cf3f0 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -1597,6 +1597,10 @@ namespace Game.Entities if (summon != null) { summon.SetTempSummonType(despawnType); + + Creature thisCreature = ToCreature(); + if (thisCreature != null) + summon.InheritStringIds(thisCreature); return summon; } }