Core/Auras: Implemented SPELL_AURA_TRIGGER_SPELL_ON_HEALTH_PCT

Port From (https://github.com/TrinityCore/TrinityCore/commit/b221f4b37251db2206dd14d46c00f1b6f1f16480)
This commit is contained in:
hondacrx
2022-01-07 13:46:21 -05:00
parent 49f32780dc
commit 5bb553b0e3
3 changed files with 68 additions and 9 deletions
+29 -3
View File
@@ -242,13 +242,13 @@ namespace Game.Entities
_spellHistory.Update();
}
public void HandleEmoteCommand(Emote animId, Player target = null, uint[] spellVisualKitIds = null)
public void HandleEmoteCommand(Emote emoteId, Player target = null, uint[] spellVisualKitIds = null)
{
EmoteMessage packet = new();
packet.Guid = GetGUID();
packet.EmoteID = (uint)animId;
packet.EmoteID = (uint)emoteId;
var emotesEntry = CliDB.EmotesStorage.LookupByKey(animId);
var emotesEntry = CliDB.EmotesStorage.LookupByKey(emoteId);
if (emotesEntry != null && spellVisualKitIds != null)
if (emotesEntry.AnimId == (uint)Anim.MountSpecial || emotesEntry.AnimId == (uint)Anim.MountSelfSpecial)
packet.SpellVisualKitIDs.AddRange(spellVisualKitIds);
@@ -2880,6 +2880,32 @@ namespace Game.Entities
return gain;
}
void TriggerOnHealthChangeAuras(ulong oldVal, ulong newVal)
{
foreach (AuraEffect effect in GetAuraEffectsByType(AuraType.TriggerSpellOnHealthPct))
{
int triggerHealthPct = effect.GetAmount();
uint triggerSpell = effect.GetSpellEffectInfo().TriggerSpell;
ulong threshold = CountPctFromMaxHealth(triggerHealthPct);
switch ((AuraTriggerOnHealthChangeDirection)effect.GetMiscValue())
{
case AuraTriggerOnHealthChangeDirection.Above:
if (newVal < threshold || oldVal > threshold)
continue;
break;
case AuraTriggerOnHealthChangeDirection.Below:
if (newVal > threshold || oldVal < threshold)
continue;
break;
default:
break;
}
CastSpell(this, triggerSpell, new CastSpellExtraArgs(effect));
}
}
public bool IsImmuneToAll() { return IsImmuneToPC() && IsImmuneToNPC(); }
public void SetImmuneToAll(bool apply, bool keepCombat)