mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Entities: Added possibility to inherit StringIds from other entities (#29908)
* also implicitly do so for personal summons
This commit is contained in:
@@ -3137,6 +3137,15 @@ uint32 Creature::GetScriptId() const
|
||||
return ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(GetEntry()))->ScriptID;
|
||||
}
|
||||
|
||||
void Creature::InheritStringIds(Creature const* parent)
|
||||
{
|
||||
// copy references to stringIds from template and spawn
|
||||
m_stringIds = parent->m_stringIds;
|
||||
|
||||
// then copy script stringId, not just its reference
|
||||
SetScriptStringId(std::string(parent->GetStringId(StringIdType::Script)));
|
||||
}
|
||||
|
||||
bool Creature::HasStringId(std::string_view id) const
|
||||
{
|
||||
return std::find(m_stringIds.begin(), m_stringIds.end(), id) != m_stringIds.end();
|
||||
|
||||
@@ -255,6 +255,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
std::string const& GetAIName() const;
|
||||
std::string GetScriptName() const;
|
||||
uint32 GetScriptId() const;
|
||||
void InheritStringIds(Creature const* parent);
|
||||
bool HasStringId(std::string_view id) const;
|
||||
void SetScriptStringId(std::string id);
|
||||
std::array<std::string_view, 3> const& GetStringIds() const { return m_stringIds; }
|
||||
|
||||
@@ -3497,6 +3497,15 @@ uint32 GameObject::GetScriptId() const
|
||||
return GetGOInfo()->ScriptId;
|
||||
}
|
||||
|
||||
void GameObject::InheritStringIds(GameObject const* parent)
|
||||
{
|
||||
// copy references to stringIds from template and spawn
|
||||
m_stringIds = parent->m_stringIds;
|
||||
|
||||
// then copy script stringId, not just its reference
|
||||
SetScriptStringId(std::string(parent->GetStringId(StringIdType::Script)));
|
||||
}
|
||||
|
||||
bool GameObject::HasStringId(std::string_view id) const
|
||||
{
|
||||
return std::find(m_stringIds.begin(), m_stringIds.end(), id) != m_stringIds.end();
|
||||
|
||||
@@ -378,6 +378,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
uint32 GetScriptId() const;
|
||||
GameObjectAI* AI() const { return m_AI; }
|
||||
|
||||
void InheritStringIds(GameObject const* parent);
|
||||
bool HasStringId(std::string_view id) const;
|
||||
void SetScriptStringId(std::string id);
|
||||
std::array<std::string_view, 3> const& GetStringIds() const { return m_stringIds; }
|
||||
|
||||
@@ -2060,6 +2060,9 @@ TempSummon* WorldObject::SummonPersonalClone(Position const& pos, TempSummonType
|
||||
if (TempSummon* summon = map->SummonCreature(GetEntry(), pos, nullptr, despawnTime, privateObjectOwner, spellId, vehId, privateObjectOwner->GetGUID(), &smoothPhasingInfo))
|
||||
{
|
||||
summon->SetTempSummonType(despawnType);
|
||||
|
||||
if (Creature* thisCreature = ToCreature())
|
||||
summon->InheritStringIds(thisCreature);
|
||||
return summon;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user