Core/Spells Handle auras 328 & 396 (SPELL_AURA_TRIGGER_SPELL_ON_POWER_*)
Port From (https://github.com/TrinityCore/TrinityCore/commit/56e9560661adca81fc1e9a297cb6823cf7a6cb22)
This commit is contained in:
@@ -603,6 +603,7 @@ namespace Game.Entities
|
||||
if (maxPower < val)
|
||||
val = maxPower;
|
||||
|
||||
int oldPower = m_unitData.Power[(int)powerIndex];
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Power, (int)powerIndex), val);
|
||||
|
||||
if (IsInWorld)
|
||||
@@ -613,6 +614,8 @@ namespace Game.Entities
|
||||
SendMessageToSet(packet, IsTypeId(TypeId.Player));
|
||||
}
|
||||
|
||||
TriggerOnPowerChangeAuras(powerType, oldPower, val);
|
||||
|
||||
// group update
|
||||
if (IsTypeId(TypeId.Player))
|
||||
{
|
||||
@@ -658,6 +661,48 @@ namespace Game.Entities
|
||||
public virtual uint GetPowerIndex(PowerType powerType) { return 0; }
|
||||
public float GetPowerPct(PowerType powerType) { return GetMaxPower(powerType) != 0 ? 100.0f* GetPower(powerType) / GetMaxPower(powerType) : 0.0f; }
|
||||
|
||||
void TriggerOnPowerChangeAuras(PowerType power, int oldVal, int newVal)
|
||||
{
|
||||
var effects = GetAuraEffectsByType(AuraType.TriggerSpellOnPowerPct);
|
||||
var effectsAmount = GetAuraEffectsByType(AuraType.TriggerSpellOnPowerAmount);
|
||||
effects.AddRange(effectsAmount);
|
||||
|
||||
foreach (AuraEffect effect in effects)
|
||||
{
|
||||
if (effect.GetMiscValue() == (int)power)
|
||||
{
|
||||
uint effectAmount = (uint)effect.GetAmount();
|
||||
uint triggerSpell = effect.GetSpellEffectInfo().TriggerSpell;
|
||||
|
||||
float oldValueCheck = oldVal;
|
||||
float newValueCheck = newVal;
|
||||
|
||||
if (effect.GetAuraType() == AuraType.TriggerSpellOnPowerPct)
|
||||
{
|
||||
int maxPower = GetMaxPower(power);
|
||||
oldValueCheck = MathFunctions.GetPctOf(oldVal, maxPower);
|
||||
newValueCheck = MathFunctions.GetPctOf(newVal, maxPower);
|
||||
}
|
||||
|
||||
switch ((AuraTriggerOnPowerChangeDirection)effect.GetMiscValueB())
|
||||
{
|
||||
case AuraTriggerOnPowerChangeDirection.Gain:
|
||||
if (oldValueCheck >= effect.GetAmount() || newValueCheck < effectAmount)
|
||||
continue;
|
||||
break;
|
||||
case AuraTriggerOnPowerChangeDirection.Loss:
|
||||
if (oldValueCheck <= effect.GetAmount() || newValueCheck > effectAmount)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CastSpell(this, triggerSpell, true, null, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyResilience(Unit victim, ref uint damage)
|
||||
{
|
||||
// player mounted on multi-passenger mount is also classified as vehicle
|
||||
|
||||
Reference in New Issue
Block a user