Example #1
0
        /// <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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <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;
        }
Example #5
0
        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);
        }
Example #6
0
 public int GetResistance(DamageSchool school)
 {
     if (this.Resistances == null)
     {
         return(0);
     }
     return(this.Resistances.Get <int>((uint)school));
 }
Example #7
0
 public override float GetDamageDoneFactor(DamageSchool school)
 {
     if (m_damageDoneFactors == null)
     {
         return(1);
     }
     return(1 + m_damageDoneFactors[(int)school]);
 }
Example #8
0
		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;
		}
Example #9
0
 public void ModDebuffResistance(DamageSchool school, int delta)
 {
     if (m_debuffResistances == null)
     {
         m_debuffResistances = CreateDamageSchoolArr();
     }
     m_debuffResistances[(int)school] += delta;
 }
Example #10
0
		/// <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;
		}
Example #11
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_targetResistances == null)
            {
                return(0);
            }
            return(m_targetResistances[(int)school]);
        }
Example #12
0
		public override float GetDamageDoneFactor(DamageSchool school)
		{
			if (m_damageDoneFactors == null)
			{
				return 1;
			}
			return 1 + m_damageDoneFactors[(int)school];
		}
Example #13
0
 /// <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;
 }
Example #14
0
 /// <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;
 }
Example #15
0
 public int GetSpellInterruptProt(DamageSchool school)
 {
     if (m_spellInterruptProt == null)
     {
         return(0);
     }
     return(m_spellInterruptProt[(int)school]);
 }
Example #16
0
 /// <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);
 }
Example #17
0
 protected override void OnResistanceChanged(DamageSchool school)
 {
     base.OnResistanceChanged(school);
     if (m_activePet != null && m_activePet.IsHunterPet)
     {
         m_activePet.UpdatePetResistance(school);
     }
 }
Example #18
0
 public void SetDebuffResistance(DamageSchool school, int value)
 {
     if (m_debuffResistances == null)
     {
         m_debuffResistances = CreateDamageSchoolArr();
     }
     m_debuffResistances[(uint)school] = value;
 }
Example #19
0
		/// <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;
		}
Example #20
0
 public int GetResistance(DamageSchool school)
 {
     if (Resistances == null)
     {
         return(0);
     }
     return(Resistances.Get((uint)school));
 }
Example #21
0
 public int GetDebuffResistance(DamageSchool school)
 {
     if (m_debuffResistances == null)
     {
         return(0);
     }
     return(m_debuffResistances[(int)school]);
 }
Example #22
0
 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;
 }
        /// <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);
        }
Example #24
0
        /// <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);
        }
Example #25
0
 public void SetBaseResistance(DamageSchool school, int value)
 {
     if (value < 0)
     {
         value = 0;
     }
     m_baseResistances[(uint)school] = value;
     OnResistanceChanged(school);
 }
Example #26
0
        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);
            }
        }
Example #27
0
        private void ModDmgAbsorption(DamageSchool school, int delta)
        {
            int val = m_dmgAbsorb[(int)school] + delta;

            if (val < 0)
            {
                val = 0;
            }
            m_dmgAbsorb[(int)school] = val;
        }
Example #28
0
        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;
        }
Example #29
0
        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 );
        }
Example #31
0
 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;
     }
 }
Example #32
0
        /// <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);
        }
Example #33
0
        /// <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);
        }
Example #34
0
        /// <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);
        }
Example #35
0
		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;
		}
Example #36
0
		/// <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;
		}
Example #37
0
 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;
 }
Example #38
0
		public int GetResistance(DamageSchool school)
		{
			if (Resistances == null)
			{
				return 0;
			}
			return Resistances.Get((uint)school);
		}
Example #39
0
		public void SetResistance(DamageSchool school, int value)
		{
			Resistances[(uint)school] = value;
		}
Example #40
0
		/// <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;
		}
Example #41
0
		/// <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;
		}
Example #42
0
		/// <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]--;
			}
		}
Example #43
0
		/// <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;
		}
Example #44
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];
		}
Example #45
0
		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);
			}
		}
Example #46
0
		public void ModDebuffResistance(DamageSchool school, int delta)
		{
			if (m_debuffResistances == null)
			{
				m_debuffResistances = CreateDamageSchoolArr();
			}
			m_debuffResistances[(int)school] += delta;
		}
Example #47
0
		public void SetDebuffResistance(DamageSchool school, int value)
		{
			if (m_debuffResistances == null)
			{
				m_debuffResistances = CreateDamageSchoolArr();
			}
			m_debuffResistances[(uint)school] = value;
		}
Example #48
0
		public int GetDebuffResistance(DamageSchool school)
		{
			if (m_debuffResistances == null)
			{
				return 0;
			}
			return m_debuffResistances[(int)school];
		}
Example #49
0
		/// <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);
		}
Example #50
0
		public int GetSpellHitChanceMod(DamageSchool school)
		{
			return m_SpellHitChance != null ? m_SpellHitChance[(int)school] : 0;
		}
Example #51
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);
			}
		}
Example #52
0
		/// <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]++;
		}
Example #53
0
		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;
		}
Example #54
0
 public int CalcPowerCost(Unit caster, DamageSchool school)
 {
     return caster.GetPowerCost(school, this, CalcBasePowerCost(caster));
 }
Example #55
0
		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);
		}
Example #56
0
		/// <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;
		}
Example #57
0
		/// <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;
		}
Example #58
0
		public void ModDamageTakenPctMod(DamageSchool school, int delta)
		{
			if (m_damageTakenPctMods == null)
			{
				m_damageTakenPctMods = CreateDamageSchoolArr();
			}
			m_damageTakenPctMods[(int)school] += delta;
		}
Example #59
0
		/// <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));
		}
Example #60
0
		public void ModDamageTakenPctMod(DamageSchool[] schools, int delta)
		{
			if (m_damageTakenPctMods == null)
			{
				m_damageTakenPctMods = CreateDamageSchoolArr();
			}

			foreach (var school in schools)
			{
				m_damageTakenPctMods[(int)school] += delta;
			}
		}