Core/Creatures: Implement StringId for Creatures, a custom identifier to make finding specific creatures in script easier

Port From (https://github.com/TrinityCore/TrinityCore/commit/61c51b76c00d932a9180bc6781a244dc18375ef7)
This commit is contained in:
hondacrx
2023-01-05 16:44:30 -05:00
parent 23c3084f00
commit 0c782c60c2
11 changed files with 110 additions and 22 deletions
@@ -27,6 +27,9 @@ namespace Game.Entities
CreatureTemplate m_creatureInfo;
CreatureData m_creatureData;
string[] m_stringIds = new string[3];
string m_scriptStringId;
SpellFocusInfo _spellFocusInfo;
long _lastDamagedTime; // Part of Evade mechanics
+25
View File
@@ -433,6 +433,8 @@ namespace Game.Entities
//We must update last scriptId or it looks like we reloaded a script, breaking some things such as gossip temporarily
LastUsedScriptID = GetScriptId();
m_stringIds[0] = cInfo.StringId;
return true;
}
@@ -2759,6 +2761,27 @@ namespace Game.Entities
return Global.ObjectMgr.GetCreatureTemplate(GetEntry()) != null ? Global.ObjectMgr.GetCreatureTemplate(GetEntry()).ScriptID : 0;
}
public bool HasStringId(string id)
{
return m_stringIds.Contains(id);
}
void SetScriptStringId(string id)
{
if (!id.IsEmpty())
{
m_scriptStringId = id;
m_stringIds[2] = m_scriptStringId;
}
else
{
m_scriptStringId = null;
m_stringIds[2] = null;
}
}
public string[] GetStringIds() { return m_stringIds; }
public VendorItemData GetVendorItems()
{
return Global.ObjectMgr.GetNpcVendorItemList(GetEntry());
@@ -3293,6 +3316,8 @@ namespace Game.Entities
// checked at creature_template loading
DefaultMovementType = (MovementGeneratorType)data.movementType;
m_stringIds[1] = data.StringId;
if (addToMap && !GetMap().AddToMap(this))
return false;
return true;
@@ -92,6 +92,7 @@ namespace Game.Entities
public uint SpellSchoolImmuneMask;
public CreatureFlagsExtra FlagsExtra;
public uint ScriptID;
public string StringId;
public QueryCreatureResponse QueryData;