Ejemplo n.º 1
0
 // Creates unarmed damage.
 public static Damage Create(DamageNature nature)
 {
     return(new Damage(nature, UnarmedDamageRangeMin, UnarmedDamageRangeMax)
     {
         Type = DamageType.Physical
     });
 }
Ejemplo n.º 2
0
 public bool MatchesExceptType(DamageNature nature)
 {
     return((Form == DamageForm.Any || (nature.Form & Form) != 0) &&
            (WeaponHand == WeaponHand.Any || (nature.WeaponHand & WeaponHand) != 0) &&
            (WeaponType == WeaponType.Any || (nature.WeaponType & WeaponType) != 0) &&
            (Source == DamageSource.Any || nature.Source == Source));
 }
Ejemplo n.º 3
0
 // Damage from specified source with specified type.
 public Damage(DamageSource source, DamageType type, float min, float max)
     : base(source, type)
 {
     Origin = new DamageNature(Source, Type);
     Min    = min;
     Max    = max;
 }
Ejemplo n.º 4
0
 // Damage with specified nature but with different type.
 Damage(DamageNature nature, string type, float min, float max)
     : base(nature, type)
 {
     Origin = new DamageNature(this);
     Min    = min;
     Max    = max;
 }
Ejemplo n.º 5
0
 // Copy constructor.
 public Damage(Damage damage)
     : base(damage)
 {
     Origin = new DamageNature(damage.Origin);
     Min    = damage.Min;
     Max    = damage.Max;
 }
Ejemplo n.º 6
0
 public DamageNature(DamageNature nature)
 {
     Form       = nature.Form;
     Source     = nature.Source;
     Type       = nature.Type;
     WeaponHand = nature.WeaponHand;
     WeaponType = nature.WeaponType;
 }
Ejemplo n.º 7
0
 // Damage originated from specified damage but with different type.
 // Used in Damage.PercentOf.
 Damage(Damage damage, DamageType type, float min, float max)
     : base(damage)
 {
     Origin = new DamageNature(damage);
     Type   = type;
     Min    = min;
     Max    = max;
 }
Ejemplo n.º 8
0
        // Creates attack from gem.
        AttackSkill(Item gem, Computation compute)
        {
            Gem           = gem;
            Name          = gem.Name;
            Nature        = GemDB.Instance.NatureOf(gem);
            HitsPerAttack = GemDB.Instance.HitsPerAttackOf(gem);
            IsStrikingWithBothWeaponsAtOnce = GemDB.Instance.IsStrikingWithBothWeaponsAtOnce(gem);

            Effectiveness = gem.Properties.First("Damage Effectiveness: #%", 0, 100);
            Compute       = compute;
        }
Ejemplo n.º 9
0
        // Creates damage from attribute.
        public static Damage Create(DamageNature nature, string attrName, IReadOnlyList <float> attrValues)
        {
            Match m = ReDamageAttribute.Match(attrName);

            if (m.Success)
            {
                return(new Damage(nature, m.Groups[1].Value, attrValues[0], attrValues[1]));
            }
            else
            {
                m = ReDamageMod.Match(attrName);
                if (m.Success)
                {
                    return(new Damage(nature, m.Groups[1].Value, attrValues[0], attrValues[1]));
                }
            }

            return(null);
        }
Ejemplo n.º 10
0
        public AttackSource(string name, AttackSkill skill, Weapon weapon, Computation compute)
        {
            Name    = name;
            Compute = compute;

            if (weapon == null) // Spells get damage from gem local attributes.
            {
                Nature = new DamageNature(skill.Nature);

                foreach (var attr in skill.Local)
                {
                    Damage damage = Damage.Create(skill.Nature, attr.Key, attr.Value);
                    if (damage != null)
                    {
                        Deals.Add(damage);
                    }
                }

                if (skill.Gem.Properties.TryGetValue("Cast Time: # sec", 0, out CastTime))
                {
                    APS = 1 / CastTime;
                }
                else
                {
                    APS = CastTime = 1; // Spell without Cast Time has cast time of 1 second.
                }
                if (!skill.Gem.Properties.TryGetValue("Critical Strike Chance: #%", 0, out CriticalChance))
                {
                    CriticalChance = 0;     // Spell without Critical Strike Chance has none.
                }
                Local = new AttributeSet(); // No local weapon attributes.
            }
            else
            {
                if ((skill.Nature.WeaponType & weapon.Nature.WeaponType) == 0) // Skill can't be used.
                                                                               // Override weapon type and form of skill with actual weapon (client shows damage of unuseable skills as well).
                {
                    Nature = new DamageNature(skill.Nature)
                    {
                        Form = weapon.Nature.Form, WeaponHand = weapon.Hand, WeaponType = weapon.Nature.WeaponType
                    }
                }
                ;
                else // Narrow down weapon type and form of skill gem to actual weapon (e.g. Frenzy).
                {
                    Nature = new DamageNature(skill.Nature)
                    {
                        Form       = skill.Nature.ChooseWeaponForm(weapon.Nature), // XXX: Choose between melee or projectile form according to weapon.
                        WeaponHand = weapon.Hand,
                        WeaponType = skill.Nature.WeaponType & weapon.Nature.WeaponType
                    }
                };

                // XXX: If source has no form, but skill has form defined, then force form of skill.
                // This happens in form transition from melee to projectile with skills like Spectral Throw.
                if (Nature.Form == DamageForm.Any && skill.Nature.Form != DamageForm.Any)
                {
                    Nature.Form = skill.Nature.Form;
                }

                foreach (Damage damage in weapon.Deals)
                {
                    Deals.Add(new Damage(damage)
                    {
                        Form = Nature.Form, Source = Nature.Source, WeaponHand = Nature.WeaponHand, WeaponType = Nature.WeaponType
                    });
                }

                foreach (Damage.Added added in weapon.Added)
                {
                    if (weapon.Is(added.Hand)) // Added damage may require specific hand.
                    {
                        added.Apply(this, 100);
                    }
                }

                APS = weapon.Attributes["Attacks per Second: #"][0];

                if (weapon.Attributes.ContainsKey("Critical Strike Chance: #%"))
                {
                    CriticalChance = weapon.Attributes["Critical Strike Chance: #%"][0];
                }
                else
                {
                    CriticalChance = 0; // Weapon without Critical Strike Chance has none.
                }
                Local = weapon.Attributes;
            }
        }
Ejemplo n.º 11
0
 public DamageNature(DamageNature nature, string str)
     : this(nature)
 {
     SetFromString(str);
 }
Ejemplo n.º 12
0
 // Returns damage form narrowed down according to weapon.
 public DamageForm ChooseWeaponForm(DamageNature weapon)
 {
     return((Form & ~DamageForm.WeaponMask) | (Form & weapon.Form));
 }
Ejemplo n.º 13
0
 // Returns true if damage or its origin matches nature, false otherwise.
 new public bool Matches(DamageNature nature)
 {
     return(nature.Matches(this) || nature.Matches(Origin));
 }