aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Creature
diff options
context:
space:
mode:
authorModoX <moardox@gmail.com>2024-04-10 20:03:14 +0200
committerGitHub <noreply@github.com>2024-04-10 20:03:14 +0200
commit88bbd27f8d007dca17bb0d244fcf7e753506734e (patch)
treef57a6b609cd6fee7deee7ed4adad2e24ab74659f /src/server/game/Entities/Creature
parent9b6a1b9be99accdfb85777a03e57b80e37b5861f (diff)
Core/Entities: Added possibility to inherit StringIds from other entities (#29908)
* also implicitly do so for personal summons
Diffstat (limited to 'src/server/game/Entities/Creature')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp9
-rw-r--r--src/server/game/Entities/Creature/Creature.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 6690f565ae5..3fa5f6cc487 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -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();
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 29865455d23..86933743b25 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -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; }