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
+27
View File
@@ -3538,6 +3538,33 @@ namespace Game.Spells
target.ModifyPower(powerType, change);
}
[AuraEffectHandler(AuraType.TriggerSpellOnHealthPct)]
void HandleTriggerSpellOnHealthPercent(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasFlag(AuraEffectHandleModes.Real) || !apply)
return;
Unit target = aurApp.GetTarget();
int thresholdPct = GetAmount();
uint triggerSpell = GetSpellEffectInfo().TriggerSpell;
switch ((AuraTriggerOnHealthChangeDirection)GetMiscValue())
{
case AuraTriggerOnHealthChangeDirection.Above:
if (!target.HealthAbovePct(thresholdPct))
return;
break;
case AuraTriggerOnHealthChangeDirection.Below:
if (!target.HealthBelowPct(thresholdPct))
return;
break;
default:
break;
}
target.CastSpell(target, triggerSpell, new CastSpellExtraArgs(this));
}
/********************************/
/*** FIGHT ***/
/********************************/