/// <summary> /// Re-calculates the offhand damage of this Unit /// See http://www.wowwiki.com/Attack_power /// </summary> internal static void UpdateOffHandDamage(this Unit unit) { if (unit.OffHandWeapon != null) { var apBonus = (unit.TotalMeleeAP * unit.OffHandAttackTime + 7000) / 14000; // rounded var weapon = unit.OffHandWeapon; var min = 0f; var max = 0f; for (DamageSchool school = 0; school < (DamageSchool)weapon.Damages.Length; school++) { var dmg = weapon.Damages[(int)school]; min += GetModifiedDamage(unit, dmg.Minimum); max += GetModifiedDamage(unit, dmg.Maximum); } if (unit is Character) { var bonus = ((Character)unit).OffhandDmgPctMod; min += min * bonus; max += max * bonus; } unit.MinOffHandDamage = (min + apBonus + weapon.BonusDamage) / 2; unit.MaxOffHandDamage = (max + apBonus + weapon.BonusDamage) / 2; } else { unit.MinOffHandDamage = 0f; unit.MaxOffHandDamage = 0f; } }
public float GetBaseCritChance(DamageSchool dmgSchool, Spell spell, IAsda2Weapon weapon) { var character = this as Character; if (character != null) { var chr = character; return(chr.CritChanceMeleePct); } var npc = this as NPC; if (npc != null) { switch (npc.Entry.Rank) { case CreatureRank.Normal: return(200); case CreatureRank.Elite: return(1000); case CreatureRank.Boss: return(1500); case CreatureRank.WorldBoss: return(2000); } } return(100); }
/// <summary> /// Calculates this Unit's chance to resist the given school. /// Value is between 0 and 100 /// </summary> public float GetResistChancePct(Unit attacker, DamageSchool school) { int attackerLevel; var res = GetResistance(school); if (attacker != null) { attackerLevel = Math.Max(1, attacker.Level); res -= attacker.GetTargetResistanceMod(school); } else { attackerLevel = 1; } res = Math.Max(0, res); var resist = (res / (attackerLevel * 5f)) * 0.75f; if (resist > 75) { resist = 75f; } if (resist < 0) { resist = 0; } return(resist); }
/// <summary> /// Re-calculates the mainhand melee damage of this Unit /// References: /// http://www.wowwiki.com/Attack_power /// </summary> internal static void UpdateMainDamage(this Unit unit) { var apBonus = (unit.TotalMeleeAP * unit.MainHandAttackTime + 7000) / 14000; // rounded //if (unit is Character) //{ // var skillId = weapon.Skill; // if (skillId != SkillId.None) // { // var skill = ((Character)unit).Skills.GetValue(skillId); // } //} float minDam = 0; float maxDam = 0; var weapon = unit.MainWeapon; for (DamageSchool school = 0; school < (DamageSchool)weapon.Damages.Length; school++) { var dmg = weapon.Damages[(int)school]; minDam += GetModifiedDamage(unit, dmg.Minimum); maxDam += GetModifiedDamage(unit, dmg.Maximum); } unit.MinDamage = minDam + apBonus + weapon.BonusDamage; unit.MaxDamage = maxDam + apBonus + weapon.BonusDamage; }
public float GetBaseCritChance(DamageSchool dmgSchool, Spell spell, IWeapon weapon) { float chance; if (this is Character) { var chr = (Character)this; if (weapon != null) { if (weapon.IsRanged) { chance = chr.CritChanceRangedPct; } else { chance = chr.CritChanceMeleePct; } } else { chance = GetCritChance(dmgSchool); } } else { chance = GetCritChance(dmgSchool); } return(chance); }
public int GetResistance(DamageSchool school) { if (this.Resistances == null) { return(0); } return(this.Resistances.Get <int>((uint)school)); }
public override float GetDamageDoneFactor(DamageSchool school) { if (m_damageDoneFactors == null) { return(1); } return(1 + m_damageDoneFactors[(int)school]); }
protected internal override void ModDamageDoneFactorSilently(DamageSchool school, float delta) { if (m_damageDoneFactors == null) { m_damageDoneFactors = new float[(int)DamageSchool.Count]; } m_damageDoneFactors[(int)school] += delta; }
public void ModDebuffResistance(DamageSchool school, int delta) { if (m_debuffResistances == null) { m_debuffResistances = CreateDamageSchoolArr(); } m_debuffResistances[(int)school] += delta; }
/// <summary> /// Modifies the damage for the given school by the given delta. /// Requires a call to <see cref="WCell.RealmServer.Modifiers.UnitUpdates.UpdateAllDamages"/> afterwards. /// </summary> /// <param name="school"></param> /// <param name="delta"></param> protected internal override void AddDamageDoneModSilently(DamageSchool school, int delta) { if (m_damageDoneMods == null) { m_damageDoneMods = new int[(int)DamageSchool.Count]; } m_damageDoneMods[(int)school] += delta; }
//public void ModDebuffResistance(DamageTypeMask schools, float delta) //{ // foreach (var school in UnitMechanics.DamageTypeMasks) { // if ((schools & school) != 0) { // ModDebuffResistance(UnitMechanics.DamageTypeLookup[school], delta); // } // } //} #endregion #region Target Resistances public int GetTargetResistanceMod(DamageSchool school) { if (m_targetResistances == null) { return(0); } return(m_targetResistances[(int)school]); }
public override float GetDamageDoneFactor(DamageSchool school) { if (m_damageDoneFactors == null) { return 1; } return 1 + m_damageDoneFactors[(int)school]; }
/// <summary> /// Modifies the damage for the given school by the given delta. /// Requires a call to <see cref="WCell.RealmServer.Modifiers.UnitUpdates.UpdateAllDamages"/> afterwards. /// </summary> /// <param name="school"></param> /// <param name="delta"></param> protected internal override void RemoveDamageDoneModSilently(DamageSchool school, int delta) { if (m_damageDoneMods == null) { return; } m_damageDoneMods[(int)school] -= delta; }
public int GetSpellInterruptProt(DamageSchool school) { if (m_spellInterruptProt == null) { return(0); } return(m_spellInterruptProt[(int)school]); }
/// <summary> /// Get total damage, after adding/subtracting all modifiers (is not used for DoT) /// </summary> public int GetFinalDamage(DamageSchool school, int dmg, Spell spell = null) { if (spell != null) { dmg = Auras.GetModifiedInt(SpellModifierType.SpellPower, spell, dmg); } return(dmg); }
protected override void OnResistanceChanged(DamageSchool school) { base.OnResistanceChanged(school); if (m_activePet != null && m_activePet.IsHunterPet) { m_activePet.UpdatePetResistance(school); } }
public void SetDebuffResistance(DamageSchool school, int value) { if (m_debuffResistances == null) { m_debuffResistances = CreateDamageSchoolArr(); } m_debuffResistances[(uint)school] = value; }
public int GetResistance(DamageSchool school) { if (Resistances == null) { return(0); } return(Resistances.Get((uint)school)); }
public int GetDebuffResistance(DamageSchool school) { if (m_debuffResistances == null) { return(0); } return(m_debuffResistances[(int)school]); }
/// <summary> /// Also adds all additional damage boni /// </summary> public int CalcTotalDamage(DamageSchool school, int damage) { damage += (int)(GetUInt32((int)PlayerFields.MOD_DAMAGE_DONE_POS + (int)school) - GetUInt32((int)PlayerFields.MOD_DAMAGE_DONE_NEG + (int)school)); //damage = UnitUpdates.GetMultiMod( GetFloat( (int)PlayerFields.MOD_DAMAGE_DONE_PCT + (int)school ) / 100f, // damage ); return(damage); }
/// <summary> /// Indicates wether the owner is immune against the given DamageSchool /// </summary> public bool IsImmune(DamageSchool school) { if (IsInvulnerable) { return(true); } return(m_dmgImmunities != null && m_dmgImmunities[(int)school] > 0); }
public void SetBaseResistance(DamageSchool school, int value) { if (value < 0) { value = 0; } m_baseResistances[(uint)school] = value; OnResistanceChanged(school); }
public override void ModSpellHitChance(DamageSchool school, int delta) { base.ModSpellHitChance(school, delta); // also modify pet's hit chance if (m_activePet != null) { m_activePet.ModSpellHitChance(school, delta); } }
private void ModDmgAbsorption(DamageSchool school, int delta) { int val = m_dmgAbsorb[(int)school] + delta; if (val < 0) { val = 0; } m_dmgAbsorb[(int)school] = val; }
public void ModSpellInterruptProt(DamageSchool school, int delta) { if (m_spellInterruptProt == null) { m_spellInterruptProt = CreateDamageSchoolArr(); } var val = m_spellInterruptProt[(int)school] + delta; m_spellInterruptProt[(int)school] = val; }
public override float GetCritChance(DamageSchool school) { var value = m_entry.Rank > CreatureRank.Normal ? BossSpellCritChance : 0; if (m_CritMods != null) { value += m_CritMods[(int)school]; } return(value); }
private void ModDamageBonusPct(DamageSchool damageSchool, float iDelta) { if (iDelta == 0) { return; } //PlayerFields field = (int)PlayerFields.MOD_DAMAGE_DONE_PCT; //SetFloat( field + (int)school, GetFloat( field + (int)school ) + delta ); }
protected override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason) { if (creatingCast != null && creatingCast.TriggerAction is DamageAction) { school = ((DamageAction)creatingCast.TriggerAction).UsedSchool; } else { failReason = SpellFailedReason.Error; } }
/// <summary> /// whether this Unit resists a debuff (independent on resistances) /// </summary> public bool CheckDebuffResist(int attackerLevel, DamageSchool school) { if (Utility.Random(0, 100) < GetDebuffResistance(school) - GetAttackerSpellHitChanceMod(school)) { return(true); } return(false); }
/// <summary> /// Returns the total resistance-value of the given school /// </summary> public int GetResistance(DamageSchool school) { var value = GetBaseResistance(school); value += GetInt32(UnitFields.RESISTANCEBUFFMODSPOSITIVE + (int)school); value += GetInt32(UnitFields.RESISTANCEBUFFMODSNEGATIVE + (int)school); if (value < 0) { value = 0; } return(value); }
/// <summary> /// whether this Unit completely resists a spell /// </summary> public bool CheckResist(Unit attacker, DamageSchool school, SpellMechanic mechanic) { if (Utility.Random(0f, 100f) < GetMechanicResistance(mechanic) - GetAttackerSpellHitChanceMod(school) + GetResistChancePct(attacker, school)) { return(true); } return(false); }
public override int GetDamageDoneMod(DamageSchool school) { var amount = 0; if (IsHunterPet && m_master != null) { if (school != DamageSchool.Physical) { // "0.13% spell damage (0.18 spell damage with 2/2 Wild Hunt)" var bonus = m_master.GetDamageDoneMod(school); amount += (bonus * PetMgr.PetSpellDamageOfOwnerPercent + 50) / 100; // rounding } } if (m_damageDoneMods != null) { amount += m_damageDoneMods[(int)school]; } return amount; }
/// <summary> /// Returns the modified power-cost needed to cast a Spell of the given DamageSchool /// and the given base amount of power required /// </summary> public virtual int GetPowerCost(DamageSchool school, Spell spell, int cost) { int modifier = PowerCostModifier; if (m_schoolPowerCostMods != null) { modifier += m_schoolPowerCostMods[(int)school]; } cost += modifier; cost = (int)(Math.Round(PowerCostMultiplier) * cost); return cost; }
public override float GetCritChance(DamageSchool school) { var value = m_entry.Rank > CreatureRank.Normal ? BossSpellCritChance : 0; if (m_CritMods != null) { value += m_CritMods[(int)school]; } return value; }
public int GetResistance(DamageSchool school) { if (Resistances == null) { return 0; } return Resistances.Get((uint)school); }
public void SetResistance(DamageSchool school, int value) { Resistances[(uint)school] = value; }
/// <summary> /// Tries to consume the given amount of Power, also considers modifiers to Power-cost. /// </summary> public bool ConsumePower(DamageSchool type, Spell spell, int neededPower) { neededPower = GetPowerCost(type, spell, neededPower); if (Power >= neededPower) { Power -= neededPower; return true; } return false; }
/// <summary> /// Spell avoidance /// </summary> public virtual void ModSpellHitChance(DamageSchool school, int delta) { if (m_SpellHitChance == null) { m_SpellHitChance = CreateDamageSchoolArr(); } var val = m_SpellHitChance[(int)school] + delta; m_SpellHitChance[(int)school] = val; }
/// <summary> /// Decreases immunity-count against given damage-school /// </summary> public void DecDmgImmunityCount(DamageSchool school) { if (m_dmgImmunities == null) { return; } int val = m_dmgImmunities[(int)school]; if (val > 0) { m_dmgImmunities[(int)school]--; } }
/// <summary> /// Indicates whether the owner is immune against the given DamageSchool /// </summary> public bool IsImmune(DamageSchool school) { return m_dmgImmunities != null && m_dmgImmunities[(int)school] > 0; }
//public void ModDebuffResistance(DamageTypeMask schools, float delta) //{ // foreach (var school in UnitMechanics.DamageTypeMasks) { // if ((schools & school) != 0) { // ModDebuffResistance(UnitMechanics.DamageTypeLookup[school], delta); // } // } //} #endregion #region Target Resistances public int GetTargetResistanceMod(DamageSchool school) { if (m_TargetResMods == null) { return 0; } return m_TargetResMods[(int)school]; }
void SetTargetResistanceMod(DamageSchool school, int value) { if (m_TargetResMods == null) { m_TargetResMods = CreateDamageSchoolArr(); } m_TargetResMods[(uint)school] = value; if (school == DamageSchool.Physical && this is Character) { SetInt32(PlayerFields.MOD_TARGET_PHYSICAL_RESISTANCE, value); } }
public int GetDebuffResistance(DamageSchool school) { if (m_debuffResistances == null) { return 0; } return m_debuffResistances[(int)school]; }
/// <summary> /// Threat mod in percent /// </summary> public virtual int GetGeneratedThreat(int dmg, DamageSchool school, SpellEffect effect) { if (m_threatMods == null) { return dmg; } return dmg + ((dmg * m_threatMods[(int)school]) / 100); }
public int GetSpellHitChanceMod(DamageSchool school) { return m_SpellHitChance != null ? m_SpellHitChance[(int)school] : 0; }
internal void ModTargetResistanceMod(DamageSchool school, int delta) { if (m_TargetResMods == null) { m_TargetResMods = CreateDamageSchoolArr(); } var val = m_TargetResMods[(int)school] + delta; m_TargetResMods[(int)school] = val; if (school == DamageSchool.Physical && this is Character) { SetInt32(PlayerFields.MOD_TARGET_PHYSICAL_RESISTANCE, val); } }
/// <summary> /// Adds immunity against given damage-school /// </summary> public void IncDmgImmunityCount(DamageSchool school) { if (m_dmgImmunities == null) { m_dmgImmunities = CreateDamageSchoolArr(); } var val = m_dmgImmunities[(int)school]; if (val == 0) { // new immunity: Gets rid of all Auras that use this school Auras.RemoveWhere(aura => aura.Spell.SchoolMask.HasAnyFlag((DamageSchoolMask)(1 << (int)school))); } m_dmgImmunities[(int)school]++; }
public int CalcPowerCost(Unit caster, DamageSchool school) { return caster.GetPowerCost(school, this, CalcBasePowerCost(caster)); }
public int CalcPowerCost(Unit caster, DamageSchool school, Spell spell, PowerType type) { var cost = PowerCost + (PowerCostPerlevel * GetMaxLevelDiff(caster.Level)); if (PowerCostPercentage > 0) { cost += (PowerCostPercentage * ((type == PowerType.Health ? caster.BaseHealth : caster.BasePower))) / 100; } return caster.GetPowerCost(school, spell, cost); }
/// <summary> /// Threat mod in percent /// </summary> public void ModThreat(DamageSchool school, int delta) { if (m_threatMods == null) { m_threatMods = CreateDamageSchoolArr(); } var val = m_threatMods[(int)school] + delta; m_threatMods[(int)school] = val; }
/// <summary> /// Modifies the power-cost for the given DamageSchool by value /// </summary> public void ModPowerCostPct(DamageSchool type, int value) { if (m_schoolPowerCostMods == null) { m_schoolPowerCostMods = new int[DamageSchoolCount]; } m_schoolPowerCostMods[(int)type] += value; }
public void ModDamageTakenPctMod(DamageSchool school, int delta) { if (m_damageTakenPctMods == null) { m_damageTakenPctMods = CreateDamageSchoolArr(); } m_damageTakenPctMods[(int)school] += delta; }
/// <summary> /// Drains the given amount of power and applies damage for it /// </summary> /// <param name="dmgTyp">The type of the damage applied</param> /// <param name="dmgFactor">The factor to be applied to amount for the damage to be received by this unit</param> public void BurnPower(Unit attacker, SpellEffect effect, DamageSchool dmgTyp, int amount, float dmgFactor) { int currentPower = Power; // Resilience reduces mana drain by 2.2%, amount is rounded. amount -= (amount * GetResiliencePct() * 2.2f).RoundInt(); if (amount > currentPower) { amount = currentPower; } Power = currentPower - amount; DoSpellDamage(attacker, effect, (int)(amount * dmgFactor)); }
public void ModDamageTakenPctMod(DamageSchool[] schools, int delta) { if (m_damageTakenPctMods == null) { m_damageTakenPctMods = CreateDamageSchoolArr(); } foreach (var school in schools) { m_damageTakenPctMods[(int)school] += delta; } }