示例#1
0
 private PBEMoveData(PBEType type, PBEMoveCategory category, sbyte priority, byte ppTier, byte power, byte accuracy,
                     PBEMoveEffect effect, int effectParam, PBEMoveTarget targets,
                     PBEMoveFlag flags)
 {
     Type   = type; Category = category; Priority = priority; PPTier = ppTier; Power = power; Accuracy = accuracy;
     Effect = effect; EffectParam = effectParam; Targets = targets;
     Flags  = flags;
 }
        private int CalculateDamage(PBEBattlePokemon user, PBEBattlePokemon target, IPBEMoveData mData, PBEType moveType, float basePower, bool criticalHit)
        {
            PBEBattlePokemon aPkmn;
            PBEMoveCategory  aCat = mData.Category, dCat;

            switch (mData.Effect)
            {
            case PBEMoveEffect.FoulPlay:
            {
                aPkmn = target;
                dCat  = aCat;
                break;
            }

            case PBEMoveEffect.Psyshock:
            {
                aPkmn = user;
                dCat  = PBEMoveCategory.Physical;
                break;
            }

            default:
            {
                aPkmn = user;
                dCat  = aCat;
                break;
            }
            }

            bool  ignoreA = user != target && target.Ability == PBEAbility.Unaware && !user.HasCancellingAbility();
            bool  ignoreD = user != target && (mData.Effect == PBEMoveEffect.ChipAway || user.Ability == PBEAbility.Unaware);
            float a, d;

            if (aCat == PBEMoveCategory.Physical)
            {
                float m = ignoreA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, aPkmn.AttackChange) : aPkmn.AttackChange, false);
                a = CalculateAttack(user, target, moveType, aPkmn.Attack * m);
            }
            else
            {
                float m = ignoreA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, aPkmn.SpAttackChange) : aPkmn.SpAttackChange, false);
                a = CalculateSpAttack(user, target, moveType, aPkmn.SpAttack * m);
            }
            if (dCat == PBEMoveCategory.Physical)
            {
                float m = ignoreD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false);
                d = CalculateDefense(user, target, target.Defense * m);
            }
            else
            {
                float m = ignoreD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.SpDefenseChange) : target.SpDefenseChange, false);
                d = CalculateSpDefense(user, target, target.SpDefense * m);
            }

            return(CalculateDamage(user, a, d, basePower));
        }
        private ushort CalculateDamage(PBEPokemon user, PBEPokemon target, PBEMove move, PBEType moveType, PBEMoveCategory moveCategory, double basePower, bool criticalHit)
        {
            ushort damage;
            double a = 0, d = 0;

            bool unawareA = user != target && target.Ability == PBEAbility.Unaware && !user.HasCancellingAbility();
            bool unawareD = user != target && user.Ability == PBEAbility.Unaware && !target.HasCancellingAbility(); // Verified: A target with Mold Breaker will accept more damage from a user with Unaware

            switch (move)
            {
            case PBEMove.FoulPlay:
            {
                double aMod = unawareA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, target.AttackChange) : target.AttackChange, false);
                a = CalculateAttack(user, target, moveType, target.Attack * aMod);
                double dMod = unawareD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false);
                d = CalculateDefense(user, target, target.Defense * dMod);
                break;
            }

            case PBEMove.Psyshock:
            case PBEMove.Psystrike:
            case PBEMove.SecretSword:
            {
                double aMod = unawareA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false);
                a = CalculateSpAttack(user, target, moveType, user.SpAttack * aMod);
                double dMod = unawareD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false);
                d = CalculateDefense(user, target, target.Defense * dMod);
                break;
            }

            default:
            {
                if (moveCategory == PBEMoveCategory.Physical)
                {
                    double aMod = unawareA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.AttackChange) : user.AttackChange, false);
                    a = CalculateAttack(user, target, moveType, user.Attack * aMod);
                    double dMod = unawareD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false);
                    d = CalculateDefense(user, target, target.Defense * dMod);
                }
                else if (moveCategory == PBEMoveCategory.Special)
                {
                    double aMod = unawareA ? 1 : GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false);
                    a = CalculateSpAttack(user, target, moveType, user.SpAttack * aMod);
                    double dMod = unawareD ? 1 : GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.SpDefenseChange) : target.SpDefenseChange, false);
                    d = CalculateSpDefense(user, target, target.SpDefense * dMod);
                }
                break;
            }
            }

            damage  = (ushort)((2 * user.Level / 5) + 2);
            damage  = (ushort)(damage * a * basePower / d);
            damage /= 50;
            damage += 2;
            return((ushort)(damage * (100 - PBEUtils.RandomInt(0, 15)) / 100));
        }
示例#4
0
        ushort CalculateDamage(PBEPokemon user, PBEPokemon target, PBEMove move, PBEType moveType, PBEMoveCategory moveCategory, double basePower, bool criticalHit)
        {
            ushort damage;
            double a = 0, d = 0;

            switch (move)
            {
            case PBEMove.FoulPlay:
            {
                a = CalculateAttack(user, target, moveType, target.Attack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, target.AttackChange) : target.AttackChange, false));
                d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false));
                break;
            }

            case PBEMove.Psyshock:
            case PBEMove.Psystrike:
            case PBEMove.SecretSword:
            {
                a = CalculateSpAttack(user, target, moveType, user.SpAttack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false));
                d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false));
                break;
            }

            default:
            {
                if (moveCategory == PBEMoveCategory.Physical)
                {
                    a = CalculateAttack(user, target, moveType, user.Attack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.AttackChange) : user.AttackChange, false));
                    d = CalculateDefense(user, target, target.Defense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.DefenseChange) : target.DefenseChange, false));
                }
                else if (moveCategory == PBEMoveCategory.Special)
                {
                    a = CalculateSpAttack(user, target, moveType, user.SpAttack * GetStatChangeModifier(criticalHit ? Math.Max((sbyte)0, user.SpAttackChange) : user.SpAttackChange, false));
                    d = CalculateSpDefense(user, target, target.SpDefense * GetStatChangeModifier(criticalHit ? Math.Min((sbyte)0, target.SpDefenseChange) : target.SpDefenseChange, false));
                }
                break;
            }
            }

            damage  = (ushort)(2 * user.Shell.Level / 5 + 2);
            damage  = (ushort)(damage * a * basePower / d);
            damage /= 50;
            damage += 2;
            return((ushort)(damage * PBEUtils.RNG.Next(85, 101) / 100));
        }