Core/Auras: Implemented SPELL_AURA_TRIGGER_SPELL_ON_HEALTH_PCT
Port From (https://github.com/TrinityCore/TrinityCore/commit/b221f4b37251db2206dd14d46c00f1b6f1f16480)
This commit is contained in:
@@ -545,6 +545,18 @@ namespace Framework.Constants
|
|||||||
RealOrReapplyMask = (Reapply | Real)
|
RealOrReapplyMask = (Reapply | Real)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AuraTriggerOnPowerChangeDirection
|
||||||
|
{
|
||||||
|
Gain = 0,
|
||||||
|
Loss = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AuraTriggerOnHealthChangeDirection
|
||||||
|
{
|
||||||
|
Above = 0,
|
||||||
|
Below = 1,
|
||||||
|
}
|
||||||
|
|
||||||
// Diminishing Returns Types
|
// Diminishing Returns Types
|
||||||
public enum DiminishingReturnsType
|
public enum DiminishingReturnsType
|
||||||
{
|
{
|
||||||
@@ -578,10 +590,4 @@ namespace Framework.Constants
|
|||||||
Level4 = 3,
|
Level4 = 3,
|
||||||
TauntImmune = 4
|
TauntImmune = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AuraTriggerOnPowerChangeDirection
|
|
||||||
{
|
|
||||||
Gain = 0,
|
|
||||||
Loss = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,13 +242,13 @@ namespace Game.Entities
|
|||||||
_spellHistory.Update();
|
_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();
|
EmoteMessage packet = new();
|
||||||
packet.Guid = GetGUID();
|
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 != null && spellVisualKitIds != null)
|
||||||
if (emotesEntry.AnimId == (uint)Anim.MountSpecial || emotesEntry.AnimId == (uint)Anim.MountSelfSpecial)
|
if (emotesEntry.AnimId == (uint)Anim.MountSpecial || emotesEntry.AnimId == (uint)Anim.MountSelfSpecial)
|
||||||
packet.SpellVisualKitIDs.AddRange(spellVisualKitIds);
|
packet.SpellVisualKitIDs.AddRange(spellVisualKitIds);
|
||||||
@@ -2880,6 +2880,32 @@ namespace Game.Entities
|
|||||||
return gain;
|
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 bool IsImmuneToAll() { return IsImmuneToPC() && IsImmuneToNPC(); }
|
||||||
|
|
||||||
public void SetImmuneToAll(bool apply, bool keepCombat)
|
public void SetImmuneToAll(bool apply, bool keepCombat)
|
||||||
|
|||||||
@@ -3538,6 +3538,33 @@ namespace Game.Spells
|
|||||||
target.ModifyPower(powerType, change);
|
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 ***/
|
/*** FIGHT ***/
|
||||||
/********************************/
|
/********************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user