Ejemplo n.º 1
0
        private static bool CombatCheck(Mobile attacker, Mobile defender)         /* mod'd from baseweapon */
        {
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;

            Skill atkSkill = defender.Skills.Ninjitsu;
            Skill defSkill = defender.Skills[defWeapon.Skill];

            double atSkillValue  = attacker.Skills.Ninjitsu.Value;
            double defSkillValue = defWeapon.GetDefendSkillValue(attacker, defender);

            double attackValue = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);

            if (defSkillValue <= -20.0)
            {
                defSkillValue = -19.9;
            }

            if (HitLower.IsUnderAttackEffect(attacker))
            {
                attackValue -= 25;
            }

            if (attackValue > 45)
            {
                attackValue = 45;
            }

            attackValue = (atSkillValue + 20.0) * (100 + attackValue);

            double defenseValue = AosAttributes.GetValue(defender, AosAttribute.DefendChance);

            if (HitLower.IsUnderDefenseEffect(defender))
            {
                defenseValue -= 25;
            }

            int refBonus = 0;

            if (SkillHandlers.Discordance.GetEffect(attacker, ref refBonus))
            {
                defenseValue -= refBonus;
            }

            if (defenseValue > 45)
            {
                defenseValue = 45;
            }

            defenseValue = (defSkillValue + 20.0) * (100 + defenseValue);

            double chance = attackValue / (defenseValue * 2.0);

            if (chance < 0.02)
            {
                chance = 0.02;
            }

            return(attacker.CheckSkill(atkSkill.SkillName, chance));
        }
Ejemplo n.º 2
0
        private static bool CombatCheck(Mobile attacker, Mobile defender) /* mod'd from baseweapon */
        {
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;

            Skill atkSkill = defender.Skills.Ninjitsu;
            Skill defSkill = defender.Skills[defWeapon.Skill];

            double atSkillValue  = attacker.Skills.Ninjitsu.Value;
            double defSkillValue = defWeapon.GetDefendSkillValue(attacker, defender);

            double attackValue = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);

            if (defSkillValue <= -20.0)
            {
                defSkillValue = -19.9;
            }

            if (Spells.Chivalry.DivineFurySpell.UnderEffect(attacker))
            {
                attackValue += 10;
            }

            if (AnimalForm.UnderTransformation(attacker, typeof(GreyWolf)) || AnimalForm.UnderTransformation(attacker, typeof(BakeKitsune)))
            {
                attackValue += 20;
            }

            if (HitLower.IsUnderAttackEffect(attacker))
            {
                attackValue -= 25;
            }

            if (attackValue > 45)
            {
                attackValue = 45;
            }

            attackValue = (atSkillValue + 20.0) * (100 + attackValue);

            double defenseValue = AosAttributes.GetValue(defender, AosAttribute.DefendChance);

            if (Spells.Chivalry.DivineFurySpell.UnderEffect(defender))
            {
                defenseValue -= 20;
            }

            if (HitLower.IsUnderDefenseEffect(defender))
            {
                defenseValue -= 25;
            }

            int refBonus = 0;

            if (Block.GetBonus(defender, ref refBonus))
            {
                defenseValue += refBonus;
            }

            if (SkillHandlers.Discordance.GetEffect(attacker, ref refBonus))
            {
                defenseValue -= refBonus;
            }

            if (defenseValue > 45)
            {
                defenseValue = 45;
            }

            defenseValue = (defSkillValue + 20.0) * (100 + defenseValue);

            double chance = attackValue / (defenseValue * 2.0);

            if (chance < 0.02)
            {
                chance = 0.02;
            }

            return(attacker.CheckSkill(atkSkill.SkillName, chance));
        }
Ejemplo n.º 3
0
        // Taken from BaseWeapon.cs
        // TODO: Make static function to use everywhere
        public static bool CheckHitChance(Mobile attacker, Mobile defender)
        {
//			BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;

            Skill atkSkill = attacker.Skills[SkillName.Ninjitsu];
            Skill defSkill = defender.Skills[defWeapon.Skill];

            double atkValue = atkSkill.Value;
            double defValue = defWeapon.GetDefendSkillValue(attacker, defender);

            //attacker.CheckSkill( atkSkill.SkillName, defValue - 20.0, 120.0 );
            //defender.CheckSkill( defSkill.SkillName, atkValue - 20.0, 120.0 );

            double ourValue, theirValue;

            int bonus = 0;

            if (Core.AOS)
            {
                if (atkValue <= -20.0)
                {
                    atkValue = -19.9;
                }

                if (defValue <= -20.0)
                {
                    defValue = -19.9;
                }

                // Hit Chance Increase = 45%
                int atkChance = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);
                if (atkChance > 45)
                {
                    atkChance = 45;
                }

                bonus += atkChance;

                if (attacker.BodyMod == 0xF6 || attacker.BodyMod == 0x19)
                {
                    bonus += (int)(attacker.Skills[SkillName.Ninjitsu].Value * 0.1);
                }                 // TODO: verify

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(attacker))
                {
                    bonus += 10;
                }                 // attacker gets 10% bonus when they're under divine fury

                if (HitLower.IsUnderAttackEffect(attacker))
                {
                    bonus -= 25;
                }                 // Under Hit Lower Attack effect -> 25% malus

                if (LightningStrike.UnderEffect(attacker))
                {
                    bonus = 45;
                }

                ourValue = (atkValue + 20.0) * (100 + bonus);

                // Defense Chance Increase = 45%
                bonus = AosAttributes.GetValue(defender, AosAttribute.DefendChance);
                if (bonus > 45)
                {
                    bonus = 45;
                }

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(defender))
                {
                    bonus -= 20;
                }                 // defender loses 20% bonus when they're under divine fury

                if (HitLower.IsUnderDefenseEffect(defender))
                {
                    bonus -= 25;
                }                 // Under Hit Lower Defense effect -> 25% malus


                if (BaseWeapon.UnderSurprise(defender))
                {
                    bonus -= 20;
                }                 // TODO: verify


                if (Feint.UnderEffect(defender) && defender.Combatant != null && defender.Combatant == attacker)
                {
                    int chf = Utility.Random(10, 15);

                    bonus += (int)((chf / 100.0) * bonus);
                }

                if (Block.UnderEffect(defender))
                {
                    int chb = Utility.Random(10, 15);

                    bonus += (int)((chb / 100.0) * bonus);
                }

                double discordanceScalar = 0.0;

                if (SkillHandlers.Discordance.GetScalar(attacker, ref discordanceScalar))
                {
                    bonus += (int)(discordanceScalar * 100);
                }

                theirValue = (defValue + 20.0) * (100 + bonus);

                bonus = 0;
            }
            else
            {
                if (atkValue <= -50.0)
                {
                    atkValue = -49.9;
                }

                if (defValue <= -50.0)
                {
                    defValue = -49.9;
                }

                ourValue   = (atkValue + 50.0);
                theirValue = (defValue + 50.0);
            }

            double chance = ourValue / (theirValue * 2.0);

            chance *= 1.0 + ((double)bonus / 100);

            if (Core.AOS && chance < 0.02)
            {
                chance = 0.02;
            }

            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            if (ability != null)
            {
                chance *= ability.AccuracyScalar;
            }

            return(attacker.CheckSkill(atkSkill.SkillName, chance));

            //return ( chance >= Utility.RandomDouble() );
        }