Core/Entities: Replace existing GetAuraEffectsByType + iteration uses with proper helper functions
This commit is contained in:
@@ -557,11 +557,7 @@ namespace Game.Entities
|
|||||||
addvalue = maxValue / 3;
|
addvalue = maxValue / 3;
|
||||||
|
|
||||||
// Apply modifiers (if any).
|
// Apply modifiers (if any).
|
||||||
var ModPowerRegenPCTAuras = GetAuraEffectsByType(AuraType.ModPowerRegenPercent);
|
addvalue *= (int)GetTotalAuraMultiplierByMiscValue(AuraType.ModPowerRegenPercent, (int)PowerType.Mana);
|
||||||
foreach (var eff in ModPowerRegenPCTAuras)
|
|
||||||
if (eff.GetMiscValue() == (int)PowerType.Mana)
|
|
||||||
MathFunctions.AddPct(ref addvalue, eff.GetAmount());
|
|
||||||
|
|
||||||
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)PowerType.Mana) * SharedConst.CreatureRegenInterval / (5 * Time.InMilliseconds);
|
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)PowerType.Mana) * SharedConst.CreatureRegenInterval / (5 * Time.InMilliseconds);
|
||||||
|
|
||||||
ModifyPower(PowerType.Mana, addvalue);
|
ModifyPower(PowerType.Mana, addvalue);
|
||||||
@@ -590,11 +586,8 @@ namespace Game.Entities
|
|||||||
addvalue = (long)maxValue / 3;
|
addvalue = (long)maxValue / 3;
|
||||||
|
|
||||||
// Apply modifiers (if any).
|
// Apply modifiers (if any).
|
||||||
var ModPowerRegenPCTAuras = GetAuraEffectsByType(AuraType.ModHealthRegenPercent);
|
addvalue *= (int)GetTotalAuraMultiplier(AuraType.ModHealthRegenPercent);
|
||||||
foreach (var eff in ModPowerRegenPCTAuras)
|
addvalue += GetTotalAuraModifier(AuraType.ModRegen) * SharedConst.CreatureRegenInterval / (5 * Time.InMilliseconds);
|
||||||
MathFunctions.AddPct(ref addvalue, eff.GetAmount());
|
|
||||||
|
|
||||||
addvalue += (uint)GetTotalAuraModifier(AuraType.ModRegen) * SharedConst.CreatureRegenInterval / (5 * Time.InMilliseconds);
|
|
||||||
|
|
||||||
ModifyHealth(addvalue);
|
ModifyHealth(addvalue);
|
||||||
}
|
}
|
||||||
@@ -628,11 +621,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply modifiers (if any).
|
// Apply modifiers (if any).
|
||||||
var ModPowerRegenPCTAuras = GetAuraEffectsByType(AuraType.ModPowerRegenPercent);
|
addvalue *= GetTotalAuraMultiplierByMiscValue(AuraType.ModPowerRegenPercent, (int)power);
|
||||||
foreach (var i in ModPowerRegenPCTAuras)
|
|
||||||
if ((PowerType)i.GetMiscValue() == power)
|
|
||||||
MathFunctions.AddPct(ref addvalue, i.GetAmount());
|
|
||||||
|
|
||||||
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)power) * (IsHunterPet() ? SharedConst.PetFocusRegenInterval : SharedConst.CreatureRegenInterval) / (5 * Time.InMilliseconds);
|
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)power) * (IsHunterPet() ? SharedConst.PetFocusRegenInterval : SharedConst.CreatureRegenInterval) / (5 * Time.InMilliseconds);
|
||||||
|
|
||||||
ModifyPower(power, (int)addvalue);
|
ModifyPower(power, (int)addvalue);
|
||||||
|
|||||||
@@ -3789,11 +3789,7 @@ namespace Game.Entities
|
|||||||
// Mana regen calculated in Player.UpdateManaRegen()
|
// Mana regen calculated in Player.UpdateManaRegen()
|
||||||
if (power != PowerType.Mana)
|
if (power != PowerType.Mana)
|
||||||
{
|
{
|
||||||
var ModPowerRegenPCTAuras = GetAuraEffectsByType(AuraType.ModPowerRegenPercent);
|
addvalue *= GetTotalAuraMultiplierByMiscValue(AuraType.ModPowerRegenPercent, (int)power);
|
||||||
foreach (var eff in ModPowerRegenPCTAuras)
|
|
||||||
if ((PowerType)eff.GetMiscValue() == power)
|
|
||||||
MathFunctions.AddPct(ref addvalue, eff.GetAmount());
|
|
||||||
|
|
||||||
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)power) * ((power != PowerType.Energy) ? m_regenTimerCount : m_regenTimer) / (5 * Time.InMilliseconds);
|
addvalue += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)power) * ((power != PowerType.Energy) ? m_regenTimerCount : m_regenTimer) / (5 * Time.InMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3873,43 +3869,40 @@ namespace Game.Entities
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
float HealthIncreaseRate = WorldConfig.GetFloatValue(WorldCfg.RateHealth);
|
float HealthIncreaseRate = WorldConfig.GetFloatValue(WorldCfg.RateHealth);
|
||||||
float addvalue = 0.0f;
|
float addValue = 0.0f;
|
||||||
|
|
||||||
// polymorphed case
|
// polymorphed case
|
||||||
if (IsPolymorphed())
|
if (IsPolymorphed())
|
||||||
addvalue = (float)GetMaxHealth() / 3;
|
addValue = (float)GetMaxHealth() / 3;
|
||||||
// normal regen case (maybe partly in combat case)
|
// normal regen case (maybe partly in combat case)
|
||||||
else if (!IsInCombat() || HasAuraType(AuraType.ModRegenDuringCombat))
|
else if (!IsInCombat() || HasAuraType(AuraType.ModRegenDuringCombat))
|
||||||
{
|
{
|
||||||
addvalue = HealthIncreaseRate;
|
addValue = HealthIncreaseRate;
|
||||||
if (!IsInCombat())
|
if (!IsInCombat())
|
||||||
{
|
{
|
||||||
if (getLevel() < 15)
|
if (getLevel() < 15)
|
||||||
addvalue = (0.20f * (GetMaxHealth()) / getLevel() * HealthIncreaseRate);
|
addValue = (0.20f * (GetMaxHealth()) / getLevel() * HealthIncreaseRate);
|
||||||
else
|
else
|
||||||
addvalue = 0.015f * (GetMaxHealth()) * HealthIncreaseRate;
|
addValue = 0.015f * (GetMaxHealth()) * HealthIncreaseRate;
|
||||||
|
|
||||||
var mModHealthRegenPct = GetAuraEffectsByType(AuraType.ModHealthRegenPercent);
|
addValue *= GetTotalAuraMultiplier(AuraType.ModHealthRegenPercent);
|
||||||
foreach (var eff in mModHealthRegenPct)
|
addValue += GetTotalAuraModifier(AuraType.ModRegen) * 2 * Time.InMilliseconds / (5 * Time.InMilliseconds);
|
||||||
MathFunctions.AddPct(ref addvalue, eff.GetAmount());
|
|
||||||
|
|
||||||
addvalue += GetTotalAuraModifier(AuraType.ModRegen) * 2 * Time.InMilliseconds / (5 * Time.InMilliseconds);
|
|
||||||
}
|
}
|
||||||
else if (HasAuraType(AuraType.ModRegenDuringCombat))
|
else if (HasAuraType(AuraType.ModRegenDuringCombat))
|
||||||
MathFunctions.ApplyPct(ref addvalue, GetTotalAuraModifier(AuraType.ModRegenDuringCombat));
|
MathFunctions.ApplyPct(ref addValue, GetTotalAuraModifier(AuraType.ModRegenDuringCombat));
|
||||||
|
|
||||||
if (!IsStandState())
|
if (!IsStandState())
|
||||||
addvalue *= 1.5f;
|
addValue *= 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// always regeneration bonus (including combat)
|
// always regeneration bonus (including combat)
|
||||||
addvalue += GetTotalAuraModifier(AuraType.ModHealthRegenInCombat);
|
addValue += GetTotalAuraModifier(AuraType.ModHealthRegenInCombat);
|
||||||
addvalue += m_baseHealthRegen / 2.5f;
|
addValue += m_baseHealthRegen / 2.5f;
|
||||||
|
|
||||||
if (addvalue < 0)
|
if (addValue < 0)
|
||||||
addvalue = 0;
|
addValue = 0;
|
||||||
|
|
||||||
ModifyHealth((int)addvalue);
|
ModifyHealth((int)addValue);
|
||||||
}
|
}
|
||||||
public void ResetAllPowers()
|
public void ResetAllPowers()
|
||||||
{
|
{
|
||||||
@@ -4421,9 +4414,7 @@ namespace Game.Entities
|
|||||||
if (!IsAlive() || HasAuraType(AuraType.WaterBreathing) || GetSession().GetSecurity() >= (AccountTypes)WorldConfig.GetIntValue(WorldCfg.DisableBreathing))
|
if (!IsAlive() || HasAuraType(AuraType.WaterBreathing) || GetSession().GetSecurity() >= (AccountTypes)WorldConfig.GetIntValue(WorldCfg.DisableBreathing))
|
||||||
return -1;
|
return -1;
|
||||||
int UnderWaterTime = 3 * Time.Minute * Time.InMilliseconds;
|
int UnderWaterTime = 3 * Time.Minute * Time.InMilliseconds;
|
||||||
var mModWaterBreathing = GetAuraEffectsByType(AuraType.WaterBreathing);
|
UnderWaterTime *= (int)GetTotalAuraMultiplier(AuraType.ModWaterBreathing);
|
||||||
foreach (var eff in mModWaterBreathing)
|
|
||||||
MathFunctions.AddPct(ref UnderWaterTime, eff.GetAmount());
|
|
||||||
return UnderWaterTime;
|
return UnderWaterTime;
|
||||||
}
|
}
|
||||||
case MirrorTimerType.Fire:
|
case MirrorTimerType.Fire:
|
||||||
|
|||||||
@@ -660,14 +660,13 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
chance += victim.GetTotalAuraModifier(AuraType.ModAttackerMeleeCritChance);
|
chance += victim.GetTotalAuraModifier(AuraType.ModAttackerMeleeCritChance);
|
||||||
|
|
||||||
var critChanceForCaster = victim.GetAuraEffectsByType(AuraType.ModCritChanceForCaster);
|
chance += victim.GetTotalAuraModifier(AuraType.ModCritChanceForCaster, aurEff =>
|
||||||
foreach (AuraEffect aurEff in critChanceForCaster)
|
|
||||||
{
|
{
|
||||||
if (aurEff.GetCasterGUID() != GetGUID())
|
if (aurEff.GetCasterGUID() == GetGUID())
|
||||||
continue;
|
return true;
|
||||||
|
|
||||||
chance += aurEff.GetAmount();
|
return false;
|
||||||
}
|
});
|
||||||
|
|
||||||
chance += victim.GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance);
|
chance += victim.GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance);
|
||||||
|
|
||||||
@@ -1195,14 +1194,14 @@ namespace Game.Entities
|
|||||||
// Apply bonus from SPELL_AURA_MOD_RATING_FROM_STAT
|
// Apply bonus from SPELL_AURA_MOD_RATING_FROM_STAT
|
||||||
// stat used stored in miscValueB for this aura
|
// stat used stored in miscValueB for this aura
|
||||||
var modRatingFromStat = GetAuraEffectsByType(AuraType.ModRatingFromStat);
|
var modRatingFromStat = GetAuraEffectsByType(AuraType.ModRatingFromStat);
|
||||||
foreach (var i in modRatingFromStat)
|
foreach (var aurEff in modRatingFromStat)
|
||||||
if (Convert.ToBoolean(i.GetMiscValue() & (1 << (int)cr)))
|
if (Convert.ToBoolean(aurEff.GetMiscValue() & (1 << (int)cr)))
|
||||||
amount += (int)MathFunctions.CalculatePct(GetStat((Stats)i.GetMiscValueB()), i.GetAmount());
|
amount += (int)MathFunctions.CalculatePct(GetStat((Stats)aurEff.GetMiscValueB()), aurEff.GetAmount());
|
||||||
|
|
||||||
var modRatingPct = GetAuraEffectsByType(AuraType.ModRatingPct);
|
var modRatingPct = GetAuraEffectsByType(AuraType.ModRatingPct);
|
||||||
foreach (var i in modRatingPct)
|
foreach (var aurEff in modRatingPct)
|
||||||
if (Convert.ToBoolean(i.GetMiscValue() & (1 << (int)cr)))
|
if (Convert.ToBoolean(aurEff.GetMiscValue() & (1 << (int)cr)))
|
||||||
amount += MathFunctions.CalculatePct(amount, i.GetAmount());
|
amount += MathFunctions.CalculatePct(amount, aurEff.GetAmount());
|
||||||
|
|
||||||
if (amount < 0)
|
if (amount < 0)
|
||||||
amount = 0;
|
amount = 0;
|
||||||
@@ -1478,16 +1477,17 @@ namespace Game.Entities
|
|||||||
|
|
||||||
Item weapon = GetWeaponForAttack(attack, true);
|
Item weapon = GetWeaponForAttack(attack, true);
|
||||||
|
|
||||||
var expAuras = GetAuraEffectsByType(AuraType.ModExpertise);
|
expertise += GetTotalAuraModifier(AuraType.ModExpertise, aurEff =>
|
||||||
foreach (var eff in expAuras)
|
|
||||||
{
|
{
|
||||||
// item neutral spell
|
// item neutral spell
|
||||||
if ((int)eff.GetSpellInfo().EquippedItemClass == -1)
|
if ((int)aurEff.GetSpellInfo().EquippedItemClass == -1)
|
||||||
expertise += eff.GetAmount();
|
return true;
|
||||||
// item dependent spell
|
// item dependent spell
|
||||||
else if (weapon != null && weapon.IsFitToSpellRequirements(eff.GetSpellInfo()))
|
else if (weapon != null && weapon.IsFitToSpellRequirements(aurEff.GetSpellInfo()))
|
||||||
expertise += eff.GetAmount();
|
return true;
|
||||||
}
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
if (expertise < 0)
|
if (expertise < 0)
|
||||||
expertise = 0;
|
expertise = 0;
|
||||||
|
|||||||
@@ -2268,13 +2268,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (victimResistance > 0)
|
if (victimResistance > 0)
|
||||||
{
|
{
|
||||||
int ignoredResistance = 0;
|
int ignoredResistance = GetTotalAuraModifierByMiscMask(AuraType.ModIgnoreTargetResist, (int)schoolMask);
|
||||||
|
|
||||||
var ResIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
|
|
||||||
foreach (var eff in ResIgnoreAuras)
|
|
||||||
if (Convert.ToBoolean(eff.GetMiscValue() & (int)schoolMask))
|
|
||||||
ignoredResistance += eff.GetAmount();
|
|
||||||
|
|
||||||
ignoredResistance = Math.Min(ignoredResistance, 100);
|
ignoredResistance = Math.Min(ignoredResistance, 100);
|
||||||
MathFunctions.ApplyPct(ref victimResistance, 100 - ignoredResistance);
|
MathFunctions.ApplyPct(ref victimResistance, 100 - ignoredResistance);
|
||||||
}
|
}
|
||||||
@@ -2320,18 +2314,16 @@ namespace Game.Entities
|
|||||||
// Ignore Absorption Auras
|
// Ignore Absorption Auras
|
||||||
float auraAbsorbMod = GetMaxPositiveAuraModifierByMiscMask(AuraType.ModTargetAbsorbSchool, (uint)damageInfo.GetSchoolMask());
|
float auraAbsorbMod = GetMaxPositiveAuraModifierByMiscMask(AuraType.ModTargetAbsorbSchool, (uint)damageInfo.GetSchoolMask());
|
||||||
|
|
||||||
var abilityAbsorbAuras = GetAuraEffectsByType(AuraType.ModTargetAbilityAbsorbSchool);
|
auraAbsorbMod = Math.Max(auraAbsorbMod, (float)GetMaxPositiveAuraModifier(AuraType.ModTargetAbilityAbsorbSchool, aurEff =>
|
||||||
foreach (AuraEffect aurEff in abilityAbsorbAuras)
|
|
||||||
{
|
{
|
||||||
if (!Convert.ToBoolean(aurEff.GetMiscValue() & (int)damageInfo.GetSchoolMask()))
|
if (!Convert.ToBoolean(aurEff.GetMiscValue() & (int)damageInfo.GetSchoolMask()))
|
||||||
continue;
|
return false;
|
||||||
|
|
||||||
if (!aurEff.IsAffectingSpell(damageInfo.GetSpellInfo()))
|
if (!aurEff.IsAffectingSpell(damageInfo.GetSpellInfo()))
|
||||||
continue;
|
return false;
|
||||||
|
|
||||||
if ((aurEff.GetAmount() > auraAbsorbMod))
|
return true;
|
||||||
auraAbsorbMod = aurEff.GetAmount();
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
MathFunctions.RoundToInterval(ref auraAbsorbMod, 0.0f, 100.0f);
|
MathFunctions.RoundToInterval(ref auraAbsorbMod, 0.0f, 100.0f);
|
||||||
|
|
||||||
@@ -2596,7 +2588,7 @@ namespace Game.Entities
|
|||||||
var resIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
|
var resIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
|
||||||
foreach (var eff in resIgnoreAuras)
|
foreach (var eff in resIgnoreAuras)
|
||||||
{
|
{
|
||||||
if (eff.GetMiscValue().HasAnyFlag((int)SpellSchoolMask.Normal))
|
if (eff.GetMiscValue().HasAnyFlag((int)SpellSchoolMask.Normal) && eff.IsAffectingSpell(spellInfo))
|
||||||
armor = (float)Math.Floor(MathFunctions.AddPct(ref armor, -eff.GetAmount()));
|
armor = (float)Math.Floor(MathFunctions.AddPct(ref armor, -eff.GetAmount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2643,10 +2635,7 @@ namespace Game.Entities
|
|||||||
int DoneFlatBenefit = 0;
|
int DoneFlatBenefit = 0;
|
||||||
|
|
||||||
// ..done
|
// ..done
|
||||||
var mDamageDoneCreature = GetAuraEffectsByType(AuraType.ModDamageDoneCreature);
|
DoneFlatBenefit += GetTotalAuraModifierByMiscMask(AuraType.ModDamageDoneCreature, (int)creatureTypeMask);
|
||||||
foreach (var eff in mDamageDoneCreature)
|
|
||||||
if (Convert.ToBoolean(creatureTypeMask & eff.GetMiscValue()))
|
|
||||||
DoneFlatBenefit += eff.GetAmount();
|
|
||||||
|
|
||||||
// ..done
|
// ..done
|
||||||
// SPELL_AURA_MOD_DAMAGE_DONE included in weapon damage
|
// SPELL_AURA_MOD_DAMAGE_DONE included in weapon damage
|
||||||
@@ -2659,20 +2648,14 @@ namespace Game.Entities
|
|||||||
APbonus += victim.GetTotalAuraModifier(AuraType.RangedAttackPowerAttackerBonus);
|
APbonus += victim.GetTotalAuraModifier(AuraType.RangedAttackPowerAttackerBonus);
|
||||||
|
|
||||||
// ..done (base at attack power and creature type)
|
// ..done (base at attack power and creature type)
|
||||||
var mCreatureAttackPower = GetAuraEffectsByType(AuraType.ModRangedAttackPowerVersus);
|
APbonus += GetTotalAuraModifierByMiscMask(AuraType.ModRangedAttackPowerVersus, (int)creatureTypeMask);
|
||||||
foreach (var eff in mCreatureAttackPower)
|
|
||||||
if (Convert.ToBoolean(creatureTypeMask & eff.GetMiscValue()))
|
|
||||||
APbonus += eff.GetAmount();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
APbonus += victim.GetTotalAuraModifier(AuraType.MeleeAttackPowerAttackerBonus);
|
APbonus += victim.GetTotalAuraModifier(AuraType.MeleeAttackPowerAttackerBonus);
|
||||||
|
|
||||||
// ..done (base at attack power and creature type)
|
// ..done (base at attack power and creature type)
|
||||||
var mCreatureAttackPower = GetAuraEffectsByType(AuraType.ModMeleeAttackPowerVersus);
|
APbonus += GetTotalAuraModifierByMiscMask(AuraType.ModMeleeAttackPowerVersus, (int)creatureTypeMask);
|
||||||
foreach (var eff in mCreatureAttackPower)
|
|
||||||
if (Convert.ToBoolean(creatureTypeMask & eff.GetMiscValue()))
|
|
||||||
APbonus += eff.GetAmount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APbonus != 0) // Can be negative
|
if (APbonus != 0) // Can be negative
|
||||||
@@ -2701,16 +2684,15 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mDamageDoneVersus = GetAuraEffectsByType(AuraType.ModDamageDoneVersus);
|
DoneTotalMod *= GetTotalAuraMultiplierByMiscMask(AuraType.ModDamageDoneVersus, (uint)creatureTypeMask);
|
||||||
foreach (var eff in mDamageDoneVersus)
|
|
||||||
if (Convert.ToBoolean(creatureTypeMask & eff.GetMiscValue()))
|
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, eff.GetAmount());
|
|
||||||
|
|
||||||
// bonus against aurastate
|
// bonus against aurastate
|
||||||
var mDamageDoneVersusAurastate = GetAuraEffectsByType(AuraType.ModDamageDoneVersusAurastate);
|
DoneTotalMod *= GetTotalAuraMultiplier(AuraType.ModDamageDoneVersusAurastate, aurEff =>
|
||||||
foreach (var eff in mDamageDoneVersusAurastate)
|
{
|
||||||
if (victim.HasAuraState((AuraStateType)eff.GetMiscValue()))
|
if (victim.HasAuraState((AuraStateType)aurEff.GetMiscValue()))
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
// Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
|
// Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
|
||||||
if (spellProto != null)
|
if (spellProto != null)
|
||||||
@@ -2739,18 +2721,10 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
|
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
|
||||||
int attackSchoolMask = (int)(spellProto != null ? spellProto.GetSchoolMask() : SpellSchoolMask.Normal);
|
int attackSchoolMask = (int)(spellProto != null ? spellProto.GetSchoolMask() : SpellSchoolMask.Normal);
|
||||||
var IgnoreResistAuras = attacker.GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
|
TakenTotalCasterMod += attacker.GetTotalAuraModifierByMiscMask(AuraType.ModIgnoreTargetResist, attackSchoolMask);
|
||||||
foreach (var eff in IgnoreResistAuras)
|
|
||||||
{
|
|
||||||
if (eff.GetMiscValue().HasAnyFlag(attackSchoolMask))
|
|
||||||
TakenTotalCasterMod += eff.GetAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ..taken
|
// ..taken
|
||||||
var mDamageTaken = GetAuraEffectsByType(AuraType.ModDamageTaken);
|
TakenFlatBenefit += GetTotalAuraModifierByMiscMask(AuraType.ModDamageTaken, (int)attacker.GetMeleeDamageSchoolMask());
|
||||||
foreach (var eff in mDamageTaken)
|
|
||||||
if (Convert.ToBoolean(eff.GetMiscValue() & (int)attacker.GetMeleeDamageSchoolMask()))
|
|
||||||
TakenFlatBenefit += eff.GetAmount();
|
|
||||||
|
|
||||||
if (attType != WeaponAttackType.RangedAttack)
|
if (attType != WeaponAttackType.RangedAttack)
|
||||||
TakenFlatBenefit += GetTotalAuraModifier(AuraType.ModMeleeDamageTaken);
|
TakenFlatBenefit += GetTotalAuraModifier(AuraType.ModMeleeDamageTaken);
|
||||||
@@ -2767,10 +2741,12 @@ namespace Game.Entities
|
|||||||
if (spellProto != null)
|
if (spellProto != null)
|
||||||
{
|
{
|
||||||
// From caster spells
|
// From caster spells
|
||||||
var mOwnerTaken = GetAuraEffectsByType(AuraType.ModSpellDamageFromCaster);
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModSpellDamageFromCaster, aurEff =>
|
||||||
foreach (var eff in mOwnerTaken)
|
{
|
||||||
if (eff.GetCasterGUID() == attacker.GetGUID() && eff.IsAffectingSpell(spellProto))
|
if (aurEff.GetCasterGUID() == attacker.GetGUID() && aurEff.IsAffectingSpell(spellProto))
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
// Mod damage from spell mechanic
|
// Mod damage from spell mechanic
|
||||||
uint mechanicMask = spellProto.GetAllEffectsMechanicMask();
|
uint mechanicMask = spellProto.GetAllEffectsMechanicMask();
|
||||||
@@ -2781,10 +2757,12 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (mechanicMask != 0)
|
if (mechanicMask != 0)
|
||||||
{
|
{
|
||||||
var mDamageDoneMechanic = GetAuraEffectsByType(AuraType.ModMechanicDamageTakenPercent);
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModMechanicDamageTakenPercent, aurEff =>
|
||||||
foreach (var eff in mDamageDoneMechanic)
|
{
|
||||||
if (mechanicMask.HasAnyFlag((uint)(1 << eff.GetMiscValue())))
|
if ((mechanicMask & (1 << (aurEff.GetMiscValue()))) != 0)
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2793,17 +2771,9 @@ namespace Game.Entities
|
|||||||
MathFunctions.AddPct(ref TakenTotalMod, cheatDeath.GetAmount());
|
MathFunctions.AddPct(ref TakenTotalMod, cheatDeath.GetAmount());
|
||||||
|
|
||||||
if (attType != WeaponAttackType.RangedAttack)
|
if (attType != WeaponAttackType.RangedAttack)
|
||||||
{
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModMeleeDamageTakenPct);
|
||||||
var mModMeleeDamageTakenPercent = GetAuraEffectsByType(AuraType.ModMeleeDamageTakenPct);
|
|
||||||
foreach (var eff in mModMeleeDamageTakenPercent)
|
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModRangedDamageTakenPct);
|
||||||
var mModRangedDamageTakenPercent = GetAuraEffectsByType(AuraType.ModRangedDamageTakenPct);
|
|
||||||
foreach (var eff in mModRangedDamageTakenPercent)
|
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
float tmpDamage = 0.0f;
|
float tmpDamage = 0.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,7 @@ namespace Game.Entities
|
|||||||
return (int)(MathFunctions.CalculatePct(GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), overrideSP) + 0.5f);
|
return (int)(MathFunctions.CalculatePct(GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), overrideSP) + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DoneAdvertisedBenefit = 0;
|
int DoneAdvertisedBenefit = GetTotalAuraModifierByMiscMask(AuraType.ModDamageDone, (int)schoolMask);
|
||||||
|
|
||||||
var mDamageDone = GetAuraEffectsByType(AuraType.ModDamageDone);
|
|
||||||
foreach (var eff in mDamageDone)
|
|
||||||
{
|
|
||||||
if ((eff.GetMiscValue() & (int)schoolMask) != 0)
|
|
||||||
DoneAdvertisedBenefit += eff.GetAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsTypeId(TypeId.Player))
|
if (IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
@@ -91,14 +84,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public int SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
public int SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
||||||
{
|
{
|
||||||
int TakenAdvertisedBenefit = 0;
|
return GetTotalAuraModifierByMiscMask(AuraType.ModDamageTaken, (int)schoolMask);
|
||||||
|
|
||||||
var mDamageTaken = GetAuraEffectsByType(AuraType.ModDamageTaken);
|
|
||||||
foreach (var eff in mDamageTaken)
|
|
||||||
if ((eff.GetMiscValue() & (int)schoolMask) != 0)
|
|
||||||
TakenAdvertisedBenefit += eff.GetAmount();
|
|
||||||
|
|
||||||
return TakenAdvertisedBenefit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint SpellDamageBonusDone(Unit victim, SpellInfo spellProto, uint pdamage, DamageEffectType damagetype, SpellEffectInfo effect, uint stack = 1)
|
public uint SpellDamageBonusDone(Unit victim, SpellInfo spellProto, uint pdamage, DamageEffectType damagetype, SpellEffectInfo effect, uint stack = 1)
|
||||||
@@ -210,20 +196,15 @@ namespace Game.Entities
|
|||||||
|
|
||||||
uint creatureTypeMask = victim.GetCreatureTypeMask();
|
uint creatureTypeMask = victim.GetCreatureTypeMask();
|
||||||
|
|
||||||
var mDamageDoneVersus = GetAuraEffectsByType(AuraType.ModDamageDoneVersus);
|
DoneTotalMod *= GetTotalAuraMultiplierByMiscMask(AuraType.ModDamageDoneVersus, creatureTypeMask);
|
||||||
foreach (var eff in mDamageDoneVersus)
|
|
||||||
{
|
|
||||||
if (creatureTypeMask.HasAnyFlag((uint)eff.GetMiscValue()))
|
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, eff.GetAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus against aurastate
|
// bonus against aurastate
|
||||||
var mDamageDoneVersusAurastate = GetAuraEffectsByType(AuraType.ModDamageDoneVersusAurastate);
|
DoneTotalMod *= GetTotalAuraMultiplier(AuraType.ModDamageDoneVersusAurastate, aurEff =>
|
||||||
foreach (var eff in mDamageDoneVersusAurastate)
|
|
||||||
{
|
{
|
||||||
if (victim.HasAuraState((AuraStateType)eff.GetMiscValue()))
|
if (victim.HasAuraState((AuraStateType)aurEff.GetMiscValue()))
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, eff.GetAmount());
|
return true;
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
// Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
|
// Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, GetTotalAuraModifierByMiscValue(AuraType.ModDamageDoneForMechanic, (int)spellProto.Mechanic));
|
MathFunctions.AddPct(ref DoneTotalMod, GetTotalAuraModifierByMiscValue(AuraType.ModDamageDoneForMechanic, (int)spellProto.Mechanic));
|
||||||
@@ -270,10 +251,12 @@ namespace Game.Entities
|
|||||||
uint mechanicMask = spellProto.GetAllEffectsMechanicMask();
|
uint mechanicMask = spellProto.GetAllEffectsMechanicMask();
|
||||||
if (mechanicMask != 0)
|
if (mechanicMask != 0)
|
||||||
{
|
{
|
||||||
var mDamageDoneMechanic = GetAuraEffectsByType(AuraType.ModMechanicDamageTakenPercent);
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModMechanicDamageTakenPercent, aurEff =>
|
||||||
foreach (var eff in mDamageDoneMechanic)
|
{
|
||||||
if (Convert.ToBoolean(mechanicMask & (1 << eff.GetMiscValue())))
|
if ((mechanicMask & (1 << aurEff.GetMiscValue())) != 0)
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AuraEffect cheatDeath = GetAuraEffect(45182, 0);
|
AuraEffect cheatDeath = GetAuraEffect(45182, 0);
|
||||||
@@ -285,22 +268,19 @@ namespace Game.Entities
|
|||||||
if (!spellProto.HasAttribute(SpellAttr4.FixedDamage))
|
if (!spellProto.HasAttribute(SpellAttr4.FixedDamage))
|
||||||
{
|
{
|
||||||
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
|
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
|
||||||
var IgnoreResistAuras = caster.GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
|
TakenTotalCasterMod += GetTotalAuraModifierByMiscMask(AuraType.ModIgnoreTargetResist, (int)spellProto.GetSchoolMask());
|
||||||
foreach (var eff in IgnoreResistAuras)
|
|
||||||
{
|
|
||||||
if (Convert.ToBoolean(eff.GetMiscValue() & (int)spellProto.GetSchoolMask()))
|
|
||||||
TakenTotalCasterMod += eff.GetAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
|
// from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
|
||||||
// multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085)
|
// multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085)
|
||||||
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(AuraType.ModDamagePercentTaken, (uint)spellProto.GetSchoolMask());
|
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(AuraType.ModDamagePercentTaken, (uint)spellProto.GetSchoolMask());
|
||||||
|
|
||||||
// From caster spells
|
// From caster spells
|
||||||
var mOwnerTaken = GetAuraEffectsByType(AuraType.ModSpellDamageFromCaster);
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModSpellDamageFromCaster, aurEff =>
|
||||||
foreach (var eff in mOwnerTaken)
|
{
|
||||||
if (eff.GetCasterGUID() == caster.GetGUID() && eff.IsAffectingSpell(spellProto))
|
if (aurEff.GetCasterGUID() == caster.GetGUID() && aurEff.IsAffectingSpell(spellProto))
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
int TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(spellProto.GetSchoolMask());
|
int TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(spellProto.GetSchoolMask());
|
||||||
|
|
||||||
@@ -351,12 +331,12 @@ namespace Game.Entities
|
|||||||
return (uint)(MathFunctions.CalculatePct(GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), overrideSP) + 0.5f);
|
return (uint)(MathFunctions.CalculatePct(GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), overrideSP) + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint advertisedBenefit = 0;
|
uint advertisedBenefit = (uint)GetTotalAuraModifier(AuraType.ModHealingDone, aurEff =>
|
||||||
|
{
|
||||||
var mHealingDone = GetAuraEffectsByType(AuraType.ModHealingDone);
|
if (aurEff.GetMiscValue() == 0 || (aurEff.GetMiscValue() & (int)schoolMask) != 0)
|
||||||
foreach (var i in mHealingDone)
|
return true;
|
||||||
if (i.GetMiscValue() == 0 || (i.GetMiscValue() & (int)schoolMask) != 0)
|
return false;
|
||||||
advertisedBenefit += (uint)i.GetAmount();
|
});
|
||||||
|
|
||||||
// Healing bonus of spirit, intellect and strength
|
// Healing bonus of spirit, intellect and strength
|
||||||
if (IsTypeId(TypeId.Player))
|
if (IsTypeId(TypeId.Player))
|
||||||
@@ -388,14 +368,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
int SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask)
|
int SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask)
|
||||||
{
|
{
|
||||||
int advertisedBenefit = 0;
|
return GetTotalAuraModifierByMiscMask(AuraType.ModHealing, (int)schoolMask);
|
||||||
|
|
||||||
var mDamageTaken = GetAuraEffectsByType(AuraType.ModHealing);
|
|
||||||
foreach (var i in mDamageTaken)
|
|
||||||
if ((i.GetMiscValue() & (int)schoolMask) != 0)
|
|
||||||
advertisedBenefit += i.GetAmount();
|
|
||||||
|
|
||||||
return advertisedBenefit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SpellCriticalHealingBonus(SpellInfo spellProto, int damage, Unit victim)
|
public int SpellCriticalHealingBonus(SpellInfo spellProto, int damage, Unit victim)
|
||||||
@@ -520,9 +493,7 @@ namespace Game.Entities
|
|||||||
float DoneTotalMod = 1.0f;
|
float DoneTotalMod = 1.0f;
|
||||||
|
|
||||||
// Healing done percent
|
// Healing done percent
|
||||||
var mHealingDonePct = GetAuraEffectsByType(AuraType.ModHealingDonePercent);
|
DoneTotalMod *= GetTotalAuraMultiplier(AuraType.ModHealingDonePercent);
|
||||||
foreach (var eff in mHealingDonePct)
|
|
||||||
MathFunctions.AddPct(ref DoneTotalMod, eff.GetAmount());
|
|
||||||
|
|
||||||
return DoneTotalMod;
|
return DoneTotalMod;
|
||||||
}
|
}
|
||||||
@@ -586,10 +557,12 @@ namespace Game.Entities
|
|||||||
TakenTotal += (int)(TakenAdvertisedBenefit * coeff * stack);
|
TakenTotal += (int)(TakenAdvertisedBenefit * coeff * stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mHealingGet = GetAuraEffectsByType(AuraType.ModHealingReceived);
|
TakenTotalMod *= GetTotalAuraMultiplier(AuraType.ModHealingReceived, aurEff =>
|
||||||
foreach (var eff in mHealingGet)
|
{
|
||||||
if (caster.GetGUID() == eff.GetCasterGUID() && eff.IsAffectingSpell(spellProto))
|
if (caster.GetGUID() == aurEff.GetCasterGUID() && aurEff.IsAffectingSpell(spellProto))
|
||||||
MathFunctions.AddPct(ref TakenTotalMod, eff.GetAmount());
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
foreach (SpellEffectInfo eff in spellProto.GetEffectsForDifficulty(GetMap().GetDifficultyID()))
|
foreach (SpellEffectInfo eff in spellProto.GetEffectsForDifficulty(GetMap().GetDifficultyID()))
|
||||||
{
|
{
|
||||||
@@ -731,10 +704,16 @@ namespace Game.Entities
|
|||||||
if (modOwner != null)
|
if (modOwner != null)
|
||||||
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.CriticalChance, ref crit_chance);
|
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.CriticalChance, ref crit_chance);
|
||||||
|
|
||||||
var critChanceForCaster = victim.GetAuraEffectsByType(AuraType.ModCritChanceForCaster);
|
// for this types the bonus was already added in GetUnitCriticalChance, do not add twice
|
||||||
foreach (AuraEffect aurEff in critChanceForCaster)
|
if (spellProto.DmgClass != SpellDmgClass.Melee && spellProto.DmgClass != SpellDmgClass.Ranged)
|
||||||
if (aurEff.GetCasterGUID() == GetGUID() && aurEff.IsAffectingSpell(spellProto))
|
{
|
||||||
crit_chance += aurEff.GetAmount();
|
crit_chance += victim.GetTotalAuraModifier(AuraType.ModCritChanceForCaster, aurEff =>
|
||||||
|
{
|
||||||
|
if (aurEff.GetCasterGUID() == GetGUID() && aurEff.IsAffectingSpell(spellProto))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Math.Max(crit_chance, 0.0f);
|
return Math.Max(crit_chance, 0.0f);
|
||||||
}
|
}
|
||||||
@@ -778,10 +757,7 @@ namespace Game.Entities
|
|||||||
if (canReflect)
|
if (canReflect)
|
||||||
{
|
{
|
||||||
int reflectchance = victim.GetTotalAuraModifier(AuraType.ReflectSpells);
|
int reflectchance = victim.GetTotalAuraModifier(AuraType.ReflectSpells);
|
||||||
var mReflectSpellsSchool = victim.GetAuraEffectsByType(AuraType.ReflectSpellsSchool);
|
reflectchance += victim.GetTotalAuraModifierByMiscMask(AuraType.ReflectSpellsSchool, (int)spellInfo.GetSchoolMask());
|
||||||
foreach (var eff in mReflectSpellsSchool)
|
|
||||||
if (Convert.ToBoolean(eff.GetMiscValue() & (int)spellInfo.GetSchoolMask()))
|
|
||||||
reflectchance += eff.GetAmount();
|
|
||||||
|
|
||||||
if (reflectchance > 0 && RandomHelper.randChance(reflectchance))
|
if (reflectchance > 0 && RandomHelper.randChance(reflectchance))
|
||||||
return SpellMissInfo.Reflect;
|
return SpellMissInfo.Reflect;
|
||||||
@@ -3765,24 +3741,23 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public bool HasAuraState(AuraStateType flag, SpellInfo spellProto = null, Unit Caster = null)
|
public bool HasAuraState(AuraStateType flag, SpellInfo spellProto = null, Unit caster = null)
|
||||||
{
|
{
|
||||||
if (Caster != null)
|
if (caster != null)
|
||||||
{
|
{
|
||||||
if (spellProto != null)
|
if (spellProto != null)
|
||||||
{
|
{
|
||||||
var stateAuras = Caster.GetAuraEffectsByType(AuraType.AbilityIgnoreAurastate);
|
if (caster.HasAuraTypeWithAffectMask(AuraType.AbilityIgnoreAurastate, spellProto))
|
||||||
foreach (var aura in stateAuras)
|
return true;
|
||||||
if (aura.IsAffectingSpell(spellProto))
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check per caster aura state
|
// Check per caster aura state
|
||||||
// If aura with aurastate by caster not found return false
|
// If aura with aurastate by caster not found return false
|
||||||
if (Convert.ToBoolean((1 << (int)flag) & (int)AuraStateType.PerCasterAuraStateMask))
|
if (Convert.ToBoolean((1 << (int)flag) & (int)AuraStateType.PerCasterAuraStateMask))
|
||||||
{
|
{
|
||||||
var range = m_auraStateAuras.LookupByKey(flag);
|
var range = m_auraStateAuras.LookupByKey(flag);
|
||||||
foreach (var auraApp in range)
|
foreach (var auraApp in range)
|
||||||
if (auraApp.GetBase().GetCasterGUID() == Caster.GetGUID())
|
if (auraApp.GetBase().GetCasterGUID() == caster.GetGUID())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4509,10 +4509,8 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockSpells = m_caster.GetAuraEffectsByType(AuraType.BlockSpellFamily);
|
if (m_caster.HasAuraTypeWithMiscvalue(AuraType.BlockSpellFamily, (int)m_spellInfo.SpellFamilyName))
|
||||||
foreach (var block in blockSpells)
|
return SpellCastResult.SpellUnavailable;
|
||||||
if (block.GetMiscValue() == (int)m_spellInfo.SpellFamilyName)
|
|
||||||
return SpellCastResult.SpellUnavailable;
|
|
||||||
|
|
||||||
bool reqCombat = true;
|
bool reqCombat = true;
|
||||||
var stateAuras = m_caster.GetAuraEffectsByType(AuraType.AbilityIgnoreAurastate);
|
var stateAuras = m_caster.GetAuraEffectsByType(AuraType.AbilityIgnoreAurastate);
|
||||||
|
|||||||
Reference in New Issue
Block a user