Beispiel #1
0
        public PK4 convertToPK4()
        {
            DateTime moment = DateTime.Now;
            PK4      pk4    = new PK4 // Convert away!
            {
                PID              = PID,
                Species          = Species,
                TID              = TID,
                SID              = SID,
                EXP              = IsEgg ? PKX.getEXP(5, Species) : EXP,
                IsEgg            = false,
                Friendship       = 40,
                Circle           = Circle,
                Square           = Square,
                Triangle         = Triangle,
                Heart            = Heart,
                Language         = Language,
                EV_HP            = EV_HP,
                EV_ATK           = EV_ATK,
                EV_DEF           = EV_DEF,
                EV_SPA           = EV_SPA,
                EV_SPD           = EV_SPD,
                EV_SPE           = EV_SPE,
                CNT_Cool         = CNT_Cool,
                CNT_Beauty       = CNT_Beauty,
                CNT_Cute         = CNT_Cute,
                CNT_Smart        = CNT_Smart,
                CNT_Tough        = CNT_Tough,
                CNT_Sheen        = CNT_Sheen,
                FatefulEncounter = Obedience,
                Move1            = Move1,
                Move2            = Move2,
                Move3            = Move3,
                Move4            = Move4,
                Move1_PPUps      = Move1_PPUps,
                Move2_PPUps      = Move2_PPUps,
                Move3_PPUps      = Move3_PPUps,
                Move4_PPUps      = Move4_PPUps,
                Move1_PP         = PKX.getMovePP(Move1, Move1_PPUps),
                Move2_PP         = PKX.getMovePP(Move2, Move2_PPUps),
                Move3_PP         = PKX.getMovePP(Move3, Move3_PPUps),
                Move4_PP         = PKX.getMovePP(Move4, Move4_PPUps),
                IV_HP            = IV_HP,
                IV_ATK           = IV_ATK,
                IV_DEF           = IV_DEF,
                IV_SPA           = IV_SPA,
                IV_SPD           = IV_SPD,
                IV_SPE           = IV_SPE,
                Ability          = PKM.Gen3Abilities[Species][Ability],
                Version          = Version,
                Ball             = Pokéball,
                PKRS_Strain      = PKRS_Strain,
                PKRS_Days        = PKRS_Days,
                OT_Gender        = OT_Gender,
                Met_Year         = moment.Year - 2000,
                Met_Month        = moment.Month,
                Met_Day          = moment.Day,
                Met_Location     = 0x37, // Pal Park
                RIB6_4           = Champion,
                RIB6_5           = Winning,
                RIB6_6           = Victory,
                RIB6_7           = Artist,
                RIB7_0           = Effort,
                RIB7_1           = Special1, // Battle Champion Ribbon
                RIB7_2           = Special2, // Regional Champion Ribbon
                RIB7_3           = Special3, // National Champion Ribbon
                RIB7_4           = Special4, // Country Ribbon
                RIB7_5           = Special5, // National Ribbon
                RIB7_6           = Special6, // Earth Ribbon
                RIB7_7           = Special7, // World Ribbon
            };

            // Remaining Ribbons
            pk4.RIB4_0 |= Cool_Ribbons > 0;
            pk4.RIB4_1 |= Cool_Ribbons > 1;
            pk4.RIB4_2 |= Cool_Ribbons > 2;
            pk4.RIB4_3 |= Cool_Ribbons > 3;
            pk4.RIB4_4 |= Beauty_Ribbons > 0;
            pk4.RIB4_5 |= Beauty_Ribbons > 1;
            pk4.RIB4_6 |= Beauty_Ribbons > 2;
            pk4.RIB4_7 |= Beauty_Ribbons > 3;
            pk4.RIB5_0 |= Cute_Ribbons > 0;
            pk4.RIB5_1 |= Cute_Ribbons > 1;
            pk4.RIB5_2 |= Cute_Ribbons > 2;
            pk4.RIB5_3 |= Cute_Ribbons > 3;
            pk4.RIB5_4 |= Smart_Ribbons > 0;
            pk4.RIB5_5 |= Smart_Ribbons > 1;
            pk4.RIB5_6 |= Smart_Ribbons > 2;
            pk4.RIB5_7 |= Smart_Ribbons > 3;
            pk4.RIB6_0 |= Tough_Ribbons > 0;
            pk4.RIB6_1 |= Tough_Ribbons > 1;
            pk4.RIB6_2 |= Tough_Ribbons > 2;
            pk4.RIB6_3 |= Tough_Ribbons > 3;

            // Yay for reusing string buffers!
            PKM.G4TransferTrashBytes[pk4.Language].CopyTo(pk4.Data, 0x48 + 4);
            pk4.Nickname = IsEgg ? PKM.getSpeciesName(pk4.Species, pk4.Language) : Nickname;
            Array.Copy(pk4.Data, 0x48, pk4.Data, 0x68, 0x10);
            pk4.OT_Name = OT_Name;

            // Set Final Data
            pk4.Met_Level    = PKX.getLevel(pk4.Species, pk4.EXP);
            pk4.Gender       = PKM.getGender(pk4.Species, pk4.PID);
            pk4.IsNicknamed |= pk4.Nickname != PKM.getSpeciesName(pk4.Species, pk4.Language);

            // Unown Form
            if (Species == 201)
            {
                pk4.AltForm = PKM.getUnownForm(PID);
            }

            // Remove HM moves
            int[] banned   = { 15, 19, 57, 70, 148, 249, 127, 291 };
            int[] newMoves = pk4.Moves;
            for (int i = 0; i < 4; i++)
            {
                if (banned.Contains(newMoves[i]))
                {
                    newMoves[i] = 0;
                }
            }
            pk4.Moves = newMoves;
            pk4.FixMoves();

            pk4.RefreshChecksum();
            return(pk4);
        }
Beispiel #2
0
        public PK4 convertToPK4(SAV6 SAV)
        {
            if (!PokémonGift)
            {
                return(null);
            }

            PK4 pk4 = new PK4(PK.Data);

            if (!IsPokémon && Detail == 0)
            {
                pk4.OT_Name   = "PKHeX";
                pk4.TID       = 12345;
                pk4.SID       = 54321;
                pk4.OT_Gender = (int)(Util.rnd32() % 2);
            }
            if (IsManaphyEgg)
            {
                // Since none of this data is populated, fill in default info.
                pk4.Species = 490;
                // Level 1 Moves
                pk4.Move1            = 294;
                pk4.Move2            = 145;
                pk4.Move3            = 346;
                pk4.FatefulEncounter = true;
                pk4.Ball             = 4;
                pk4.Version          = 10; // Diamond
                pk4.Language         = 2;  // English
                pk4.Nickname         = "MANAPHY";
                pk4.Egg_Location     = 1;  // Ranger (will be +3000 later)
            }

            // Generate IV
            uint seed = Util.rnd32();

            if (pk4.PID == 1) // Create Nonshiny
            {
                uint pid1 = PKM.LCRNG(ref seed) >> 16;
                uint pid2 = PKM.LCRNG(ref seed) >> 16;

                while ((pid1 ^ pid2 ^ pk4.TID ^ pk4.SID) < 8)
                {
                    uint testPID = pid1 | pid2 << 16;

                    // Call the ARNG to change the PID
                    testPID = testPID * 0x6c078965 + 1;

                    pid1 = testPID & 0xFFFF;
                    pid2 = testPID >> 16;
                }
                pk4.PID = pid1 | (pid2 << 16);
            }

            // Generate IVs
            if (pk4.IV32 == 0)
            {
                uint iv1 = PKM.LCRNG(ref seed) >> 16;
                uint iv2 = PKM.LCRNG(ref seed) >> 16;
                pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF;
            }

            // Generate Met Info
            DateTime dt = DateTime.Now;

            if (IsPokémon)
            {
                pk4.Met_Location = pk4.Egg_Location + 3000;
                pk4.Egg_Location = 0;
                pk4.Met_Day      = dt.Day;
                pk4.Met_Month    = dt.Month;
                pk4.Met_Year     = dt.Year - 2000;
                pk4.IsEgg        = false;
            }
            else
            {
                pk4.Egg_Location = pk4.Egg_Location + 3000;
                pk4.Egg_Day      = dt.Day;
                pk4.Egg_Month    = dt.Month;
                pk4.Egg_Year     = dt.Year - 2000;
                pk4.IsEgg        = false;
                // Met Location is modified when transferred to pk5; don't worry about it.
            }
            if (pk4.Species == 201) // Never will be true; Unown was never distributed.
            {
                pk4.AltForm = PKM.getUnownForm(pk4.PID);
            }

            return(pk4);
        }