Ejemplo n.º 1
0
        private static Modifier ThickFat(DefContext def)
        {
            BattleType type = def.AtkContext.Move.Move.Type;

            return((Modifier)((type == BattleType.Ice || type == BattleType.Fire) && def.AbilityE(As.THICK_FAT) ? 0x800 : 0x1000));
        }
Ejemplo n.º 2
0
        public static void Execute(DefContext def)
        {
            var der  = def.Defender;
            var atk  = def.AtkContext;
            var aer  = atk.Attacker;
            var move = atk.Move;

            switch (move.Id)
            {
            case Ms.TRI_ATTACK:     //161
                TriAttack(def);
                break;

            case Ms.THIEF:     //168
            case Ms.COVET:     //343
                Thief(def);
                break;

            case Ms.KNOCK_OFF:     //282
                RemoveItem(def, false, "KnockOff");
                break;

            case Ms.INCINERATE:     //510
                RemoveItem(def, true, "Incinerate");
                break;

            case Ms.SECRET_POWER:     //290
                SecretPower(def);
                break;

            case Ms.NATURAL_GIFT:     //363
                def.AtkContext.Attacker.ConsumeItem(false);
                break;

            case Ms.PLUCK:     //365
            case Ms.BUG_BITE:  //450
                EatDefenderBerry(def);
                break;

            case Ms.FLING:     //374
            {
                var i = aer.Pokemon.Item;
                aer.ConsumeItem(false);
                ITs.RaiseItemByMove(def.Defender, i, aer);
            }
            break;

            case Ms.SHADOW_FORCE:     //467
            case Ms.PHANTOM_FORCE:
            case Ms.HYPERSPACE_HOLE:
            case Ms.HYPERSPACE_FURY:
                if (def.Defender.OnboardPokemon.RemoveCondition(Cs.Protect))
                {
                    def.Defender.ShowLogPm("DeProtect");
                }
                break;

            case Ms.CLEAR_SMOG:     //499
                der.OnboardPokemon.SetLv7D(0, 0, 0, 0, 0, 0, 0);
                der.ShowLogPm("7DReset");
                break;

            case Ms.Core_Enforcer:
                if (der.LastMoveTurn == der.Controller.TurnNumber && !GameHelper.CantLoseAbility(der.Ability) && der.OnboardPokemon.AddCondition(Cs.GastroAcid))
                {
                    der.ShowLogPm("LoseAbility");
                }
                break;

            default:
                if (der.Hp > 0)
                {
                    if (move.Class == MoveClass.AttackWithTargetLv7DChange)
                    {
                        der.ChangeLv7D(def);
                    }
                    else if (move.Class == MoveClass.AttackWithState)
                    {
                        der.AddState(def);
                    }
                    if (!def.AbilityE(As.INNER_FOCUS) && (move.FlinchProbability != 0 && def.RandomHappen(move.FlinchProbability) || ATs.Stench(def) || ITs.CanAttackFlinch(def)))
                    {
                        der.OnboardPokemon.SetTurnCondition(Cs.Flinch);
                    }
                }
                break;
            }
            switch (move.Id)
            {
            case Ms.RELIC_SONG:
                if (aer.CanChangeForm(648))
                {
                    aer.ChangeForm(1 - aer.OnboardPokemon.Form.Index);
                }
                break;
            }
        }
Ejemplo n.º 3
0
        private static void CalculateDamage(DefContext def)
        {
            var atk  = def.AtkContext;
            var aer  = atk.Attacker;
            var c    = aer.Controller;
            var move = atk.Move;

            Ct(def);

            def.Damage = aer.Pokemon.Lv * 2 / 5 + 2;
            {
                MoveBasePower.Execute(def);
                def.Damage *= def.BasePower * PowerModifier.Execute(def);
            }
            {
                int a;
                {
                    OnboardPokemon p;
                    if (move.Id == Ms.FOUL_PLAY)
                    {
                        p = def.Defender.OnboardPokemon;
                    }
                    else
                    {
                        p = atk.Attacker.OnboardPokemon;
                    }
                    StatType st = move.Move.Category == MoveCategory.Physical ? StatType.Atk : StatType.SpAtk;
                    a = p.FiveD.GetStat(st);
                    if (!def.AbilityE(As.UNAWARE))
                    {
                        int atkLv = p.Lv5D.GetStat(st);
                        if (!(def.IsCt && atkLv < 0))
                        {
                            a = OnboardPokemon.Get5D(a, atkLv);
                        }
                    }
                }
                a          *= AModifier.Hustle(atk);
                def.Damage *= a * AModifier.Execute(def);
            }
            {
                StatType st = move.Move.Category == MoveCategory.Physical || move.UsePhysicalDef ? StatType.Def : StatType.SpDef;
                int      d  = def.Defender.OnboardPokemon.FiveD.GetStat(st);
                int      defLv;
                if (aer.AbilityE(As.UNAWARE) || move.IgnoreDefenderLv7D)
                {
                    defLv = 0;
                }
                else
                {
                    defLv = def.Defender.OnboardPokemon.Lv5D.GetStat(st);
                    if (!(def.IsCt && defLv > 0))
                    {
                        d = OnboardPokemon.Get5D(d, defLv);
                    }
                }
                d          *= DModifier.Sandstorm(def);
                def.Damage /= d * DModifier.Execute(def);
            }
            def.Damage /= 50;
            def.Damage += 2;
            //1.Apply the multi-target modifier
            if (atk.MultiTargets)
            {
                def.ModifyDamage(0xC00);
            }
            //2.Apply the weather modifier
            {
                Weather    w    = c.Weather;
                BattleType type = atk.Type;
                if (w == Weather.IntenseSunlight)
                {
                    if (type == BattleType.Water)
                    {
                        def.ModifyDamage(0x800);
                    }
                    else if (type == BattleType.Fire)
                    {
                        def.ModifyDamage(0x1800);
                    }
                }
                else if (w == Weather.Rain)
                {
                    if (type == BattleType.Water)
                    {
                        def.ModifyDamage(0x1800);
                    }
                    else if (type == BattleType.Fire)
                    {
                        def.ModifyDamage(0x800);
                    }
                }
            }
            //3.In case of a critical hit, double the value
            if (def.IsCt)
            {
                def.ModifyDamage(0x1800);
            }
            //4.Alter with a random factor
            def.Damage *= aer.Controller.GetRandomInt(85, 100);
            def.Damage /= 100;
            //5.Apply STAB modifier
            if (atk.Attacker.OnboardPokemon.HasType(atk.Type))
            {
                def.ModifyDamage((Modifier)(atk.Attacker.AbilityE(As.ADAPTABILITY) ? 0x2000 : 0x1800));
            }
            //6.Alter with type effectiveness
            CalculateEffectRevise(def);
            if (def.EffectRevise > 0)
            {
                if (atk.Type.EffectRevise(BattleType.Flying) > 0 && def.Defender.OnboardPokemon.HasType(BattleType.Flying) && aer.Controller.Board.GetCondition <int>(Cs.SpWeather) == As.DELTA_STREAM)
                {
                    c.ReportBuilder.ShowLog(Ls.MysteriousAirCurrent);
                    def.ModifyDamage(0x800);
                }
                def.Damage <<= def.EffectRevise;
            }
            else if (def.EffectRevise < 0)
            {
                def.Damage >>= -def.EffectRevise;
            }
            //7.Alter with user's burn
            if (move.Move.Category == MoveCategory.Physical && aer.State == PokemonState.BRN && !aer.AbilityE(As.GUTS) && move.Id != Ms.FACADE)
            {
                def.Damage >>= 1;
            }
            //8.Make sure damage is at least 1
            if (def.Damage < 1)
            {
                def.Damage = 1;
            }
            //9.Apply the final modifier
            def.Damage *= DamageModifier.Execute(def);
        }
        public static Modifier Execute(DefContext def)
        {
            var der  = def.Defender;
            var atk  = def.AtkContext;
            var move = atk.Move;
            var aer  = atk.Attacker;

            //If the target's side is affected by Reflect, the move used was physical, the user's ability isn't Infiltrator and the critical hit flag isn't set.
            //The value of the modificator is 0xA8F if there is more than one Pokemon per side of the field and 0x800 otherwise.
            //Same as above with Light Screen and special moves.
            Modifier m = (Modifier)(!def.IsCt && (der.Pokemon.TeamId == aer.Pokemon.TeamId || !aer.AbilityE(As.INFILTRATOR)) &&
                                    (move.Move.Category == MoveCategory.Physical && der.Field.HasCondition(Cs.Reflect) || move.Move.Category == MoveCategory.Special && der.Field.HasCondition(Cs.LightScreen)) ?
                                    atk.MultiTargets ? 0xA8F : 0x800 : 0x1000);

            {
                //If the target's ability is Multiscale and the target is at full health.
                m *= (Modifier)(def.AbilityE(As.MULTISCALE) && der.Hp == der.Pokemon.MaxHp ? 0x800 : 0x1000);
                //If the user's ability is Tinted Lens and the move wasn't very effective.
                if (def.EffectRevise < 0 && aer.AbilityE(As.TINTED_LENS))
                {
                    m *= 0x2000;
                }
                //If one of the target's allies' ability is Friend Guard.
                foreach (PokemonProxy pm in der.Controller.GetOnboardPokemons(der.Pokemon.TeamId))
                {
                    if (pm != der && pm.AbilityE(As.FRIEND_GUARD))
                    {
                        m *= 0xC00;
                    }
                }
                //If user has ability Sniper and move was a critical hit.
                if (def.IsCt && aer.AbilityE(As.SNIPER))
                {
                    m *= 0x1800;
                }
                //If the target's ability is Solid Rock or Filter and the move was super effective.
                if (def.EffectRevise > 0 && (def.AbilityE(As.FILTER) || def.AbilityE(As.SOLID_ROCK)))
                {
                    m *= 0xC00;
                }
                if (atk.Hit == 2 && atk.HasCondition(Cs.ParentalBond))
                {
                    m *= 0x800;
                }
            }

            switch (aer.Item)
            {
            //If the user is holding an expert belt and the move was super effective.
            case Is.EXPERT_BELT:
                if (def.EffectRevise > 0)
                {
                    m *= 0x1333;
                }
                break;

            //If the user is holding a Life Orb.
            case Is.LIFE_ORB:
                m *= 0x14cc;
                break;

            //If the user is holding the item Metronome. If n is the number of time the current move was used successfully and successively, the value of the modifier is 0x1000+n*0x333 if n≤4 and 0x2000 otherwise.
            case Is.METRONOME:
                var c = aer.OnboardPokemon.GetCondition(Cs.LastMove);
                if (c != null && move == c.Move)
                {
                    if (c.Int < 5)
                    {
                        m *= (ushort)(0x1000 + c.Int * 0x333);
                    }
                    else
                    {
                        m *= 0x2000;
                    }
                }
                break;
            }

            //If the target is holding a damage lowering berry of the attack's type.
            {
                var item = der.Item;
                if (
                    item == Is.CHILAN_BERRY && atk.Type == BattleType.Normal ||
                    atk.Type == AntiBerry(item) && def.EffectRevise > 0
                    )
                {
                    def.SetCondition(Cs.Antiberry);
                    m *= 0x800;
                }
            }

            switch (move.Id)
            {
            case Ms.STOMP:       //23
            case Ms.DRAGON_RUSH:
            case Ms.STEAMROLLER: //537
            case Ms.PHANTOM_FORCE:
            case Ms.FLYING_PRESS:
                if (der.OnboardPokemon.HasCondition(Cs.Minimize))
                {
                    m *= 0x2000;
                }
                break;

            case Ms.SURF:
            case Ms.WHIRLPOOL:
                if (der.CoordY == CoordY.Water)
                {
                    m *= 0x2000;
                }
                break;

            case Ms.EARTH_POWER: //89
            case Ms.MAGNITUDE:   //222
                if (der.CoordY == CoordY.Underground)
                {
                    m *= 0x2000;
                }
                break;

            case Ms.KNOCK_OFF:
                if (der.Pokemon.Item != 0 && !ITs.NeverLostItem(der.Pokemon))
                {
                    m *= 0x1800;
                }
                break;
            }

            return(m);
        }