Core/Creatures: Set InteractSpellID for npc spellclick

Port From (https://github.com/TrinityCore/TrinityCore/commit/6543d23a1a70768e9dce89b33ae7bf5fe6cdcc1e)
This commit is contained in:
hondacrx
2024-02-21 17:35:54 -05:00
parent 0f4130704a
commit e81d2d4f1f
2 changed files with 39 additions and 2 deletions
+15
View File
@@ -383,6 +383,9 @@ namespace Game.Entities
if (IsTrigger())
SetUninteractible(true);
if (HasNpcFlag(NPCFlags.SpellClick))
InitializeInteractSpellId();
InitializeReactState();
if (Convert.ToBoolean(cInfo.FlagsExtra & CreatureFlagsExtra.NoTaunt))
@@ -1148,6 +1151,16 @@ namespace Game.Entities
SummonCreature(npcEntry, GetPosition(), TempSummonType.TimedDespawn, TimeSpan.FromSeconds(1), 0, 0);
}
void InitializeInteractSpellId()
{
var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(GetEntry());
// Set InteractSpellID if there is only one row in npc_spellclick_spells in db for this creature
if (clickBounds.Count == 1)
SetInteractSpellId((int)clickBounds[0].spellId);
else
SetInteractSpellId(0);
}
public bool HasFlag(CreatureStaticFlags flag) { return _staticFlags.HasFlag(flag); }
public bool HasFlag(CreatureStaticFlags2 flag) { return _staticFlags.HasFlag(flag); }
public bool HasFlag(CreatureStaticFlags3 flag) { return _staticFlags.HasFlag(flag); }
@@ -1616,6 +1629,8 @@ namespace Game.Entities
float GetSparringHealthPct() { return _sparringHealthPct; }
void SetInteractSpellId(int interactSpellId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.InteractSpellID), interactSpellId); }
public void OverrideSparringHealthPct(List<float> healthPct)
{
_sparringHealthPct = healthPct.SelectRandom();