Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the amount of damage a shield absorbs from magic projectile
        /// </summary>
        public float GetShieldMod(Creature target)
        {
            // ensure combat stance
            if (target.CombatMode == CombatMode.NonCombat)
            {
                return(1.0f);
            }

            // does the player have a shield equipped?
            var shield = target.GetEquippedShield();

            if (shield == null || shield.GetProperty(PropertyFloat.AbsorbMagicDamage) == null)
            {
                return(1.0f);
            }

            // is spell projectile in front of player,
            // within shield effectiveness area?
            var effectiveAngle = 180.0f;
            var angle          = target.GetAngle(this);

            if (Math.Abs(angle) > effectiveAngle / 2.0f)
            {
                return(1.0f);
            }

            // https://asheron.fandom.com/wiki/Shield
            // The formula to determine magic absorption for shields is:
            // Reduction Percent = (cap * specMod * baseSkill * 0.003f) - (cap * specMod * 0.3f)
            // Cap = Maximum reduction
            // SpecMod = 1.0 for spec, 0.8 for trained
            // BaseSkill = 100 to 433 (above 433 base shield you always achieve the maximum %)

            var shieldSkill = target.GetCreatureSkill(Skill.Shield);

            // ensure trained?
            if (shieldSkill.AdvancementClass < SkillAdvancementClass.Trained || shieldSkill.Base < 100)
            {
                return(1.0f);
            }

            var baseSkill = Math.Min(shieldSkill.Base, 433);
            var specMod   = shieldSkill.AdvancementClass == SkillAdvancementClass.Specialized ? 1.0f : 0.8f;
            var cap       = (float)(shield.GetProperty(PropertyFloat.AbsorbMagicDamage) ?? 0.0f);

            // speced, 100 skill = 0%
            // trained, 100 skill = 0%
            // speced, 200 skill = 30%
            // trained, 200 skill = 24%
            // speced, 300 skill = 60%
            // trained, 300 skill = 48%
            // speced, 433 skill = 100%
            // trained, 433 skill = 80%

            var reduction = (cap * specMod * baseSkill * 0.003f) - (cap * specMod * 0.3f);

            var shieldMod = 1.0f - reduction;

            return(shieldMod);
        }
Ejemplo n.º 2
0
        public float GetAbsorbMod(Creature target)
        {
            switch (target.CombatMode)
            {
                case CombatMode.Melee:

                    // does target have shield equipped?
                    var shield = target.GetEquippedShield();
                    if (shield != null && shield.AbsorbMagicDamage != null)
                        return GetShieldMod(target, shield);

                    break;

                case CombatMode.Missile:

                    var weapon = target.GetEquippedMissileWeapon();
                    if (weapon != null && weapon.AbsorbMagicDamage != null)
                        return AbsorbMagic(target, weapon);

                    break;

                case CombatMode.Magic:

                    weapon = target.GetEquippedWand();
                    if (weapon != null && weapon.AbsorbMagicDamage != null)
                        return AbsorbMagic(target, weapon);

                    break;
            }
            return 1.0f;
        }
Ejemplo n.º 3
0
        public float GetAbsorbMod(Creature target)
        {
            switch (target.CombatMode)
            {
            case CombatMode.Melee:

                // does target have shield equipped?
                var shield = target.GetEquippedShield();
                if (shield != null && shield.AbsorbMagicDamage != null)
                {
                    return(GetShieldMod(target, shield));
                }

                break;

            case CombatMode.Missile:

                var missileLauncherOrShield = target.GetEquippedMissileLauncher() ?? target.GetEquippedShield();
                if (missileLauncherOrShield != null && missileLauncherOrShield.AbsorbMagicDamage != null)
                {
                    return(AbsorbMagic(target, missileLauncherOrShield));
                }

                break;

            case CombatMode.Magic:

                var caster = target.GetEquippedWand();
                if (caster != null && caster.AbsorbMagicDamage != null)
                {
                    return(AbsorbMagic(target, caster));
                }

                break;
            }
            return(1.0f);
        }