Exemple #1
0
            // Applies damage added with nature of source.
            public void Apply(AttackSource source, float effectiveness)
            {
                Damage damage = new Damage(source.Nature, Min, Max)
                {
                    Type = Type
                };

                damage.Mul(effectiveness);

                source.Deals.Add(damage);
            }
Exemple #2
0
        private void ApplyDamageSource(List <Damage.Increased> increases, List <Damage.More> mores, AttributeSet attrs, AttackSource source, Damage damage)
        {
            float inc = 0;

            foreach (Damage.Increased increase in increases)
            {
                if (damage.Matches(increase))
                {
                    inc += increase.Percent;
                }
            }
            if (Compute.IsDualWielding && damage.Matches(PhysicalWeaponDamage))
            {
                inc += attrs.GetOrDefault("#% increased Physical Weapon Damage while Dual Wielding");
            }
            if (OffHand.IsShield() && damage.Matches(PhysicalWeaponDamage))
            {
                inc += attrs.GetOrDefault("#% increased Physical Weapon Damage while holding a Shield");
            }
            if (OffHand.IsShield() && source.Nature.Is(DamageSource.Attack))
            {
                inc += attrs.GetOrDefault("#% increased Physical Attack Damage while holding a Shield");
            }
            if (OffHand.IsShield() && source.Nature.Is(DamageForm.Melee))
            {
                inc += attrs.GetOrDefault("#% increased Melee Physical Damage while holding a Shield");
            }
            if (source.Nature.Is(DamageSource.Spell))
            {
                inc += attrs.GetOrDefault("Supported Triggered Spells have #% increased Spell Damage");
            }
            if (inc != 0)
            {
                damage.Increase(inc);
            }

            // Apply all less multipliers.
            float mul = 1;

            foreach (Damage.More more in mores.FindAll(m => m.IsLess && damage.Matches(m)))
            {
                mul *= (100 + more.Percent) / 100;
            }
            if (mul != 1)
            {
                damage.Multiply(RoundHalfDownValue(mul, 2));
            }
            // Apply all more multipliers.
            mul = 1;
            foreach (Damage.More more in mores.FindAll(m => !m.IsLess && damage.Matches(m)))
            {
                mul *= (100 + more.Percent) / 100;
            }
            if (mul != 1)
            {
                damage.Multiply(RoundHalfDownValue(mul, 2));
            }
        }
Exemple #3
0
        private void ApplyAttackSource(List <Damage.Added> adds, List <Damage.Increased> increases, List <Damage.More> mores, AttributeSet attrs, AttackSource source)
        {
            // Apply damage added.
            foreach (Damage.Added added in adds)
            {
                if (added.MatchesExceptType(source.Nature))
                {
                    added.Apply(source, Effectiveness);
                }
            }

            // Apply damage conversions and gains.
            Convert(source.Deals);

            // For each damage dealt apply its increases and multipliers.
            foreach (Damage damage in source.Deals)
            {
                ApplyDamageSource(increases, mores, attrs, source, damage);
            }

            // Avatar of Fire (remove non-Fire damage).
            if (Compute.AvatarOfFire)
            {
                foreach (Damage damage in new List <Damage>(source.Deals))
                {
                    if (!damage.Is(DamageType.Fire))
                    {
                        source.Deals.Remove(damage);
                    }
                }
            }

            // Summarize, round and combine damage dealt.
            source.Combine();

            source.AccuracyRating(attrs);

            source.AttackSpeed(this, attrs);

            source.CriticalStrike(attrs);
        }