示例#1
0
文件: PKM.cs 项目: Arch9SK7/PKHeX
        public PKM convertPK1toPK7()
        {
            if (Format != 1)
            {
                return(null);
            }
            if (Species > 151)
            {
                return(null);
            }

            var pk = new PK7();

            TransferPropertiesWithReflection(this, pk);
            pk.EVs    = new int[6];
            pk.Nature = IVs.Sum() % 25;
            pk.IVs    = new[] { 31, 31, 31, 31, 31, 31 };
            pk.RefreshChecksum();
            if (!IsNicknamed)
            {
                pk.Nickname = Nickname.ToLower();
            }
            pk.Version = -1;
            pk.Ability = PersonalTable.SM[Species].Abilities[0];
            do
            {
                PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID);
            } while (!IsShiny);
            return(pk);
        }
示例#2
0
        private PKM preparePK7()
        {
            PK7 pk7 = pkm as PK7;

            if (pk7 == null)
            {
                return(null);
            }

            // Repopulate PK6 with Edited Stuff
            if (Util.getIndex(CB_GameOrigin) < 24)
            {
                uint EC  = Util.getHEXval(TB_EC.Text);
                uint PID = Util.getHEXval(TB_PID.Text);
                uint SID = Util.ToUInt32(TB_TID.Text);
                uint TID = Util.ToUInt32(TB_TID.Text);
                uint LID = PID & 0xFFFF;
                uint HID = PID >> 16;
                uint XOR = TID ^ LID ^ SID ^ HID;

                // Ensure we don't have a shiny.
                if (XOR >> 3 == 1) // Illegal, fix. (not 16<XOR>=8)
                {
                    // Keep as shiny, so we have to mod the PID
                    PID        ^= XOR;
                    TB_PID.Text = PID.ToString("X8");
                    TB_EC.Text  = PID.ToString("X8");
                }
                else if ((XOR ^ 0x8000) >> 3 == 1 && PID != EC)
                {
                    TB_EC.Text = (PID ^ 0x80000000).ToString("X8");
                }
                else // Not Illegal, no fix.
                {
                    TB_EC.Text = PID.ToString("X8");
                }
            }

            pk7.EncryptionConstant = Util.getHEXval(TB_EC.Text);
            pk7.Checksum           = 0; // 0 CHK for now

            // Block A
            pk7.Species       = Util.getIndex(CB_Species);
            pk7.HeldItem      = Util.getIndex(CB_HeldItem);
            pk7.TID           = Util.ToInt32(TB_TID.Text);
            pk7.SID           = Util.ToInt32(TB_SID.Text);
            pk7.EXP           = Util.ToUInt32(TB_EXP.Text);
            pk7.Ability       = (byte)Array.IndexOf(GameStrings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
            pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);   // Number
            // pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
            pk7.PID              = Util.getHEXval(TB_PID.Text);
            pk7.Nature           = (byte)Util.getIndex(CB_Nature);
            pk7.FatefulEncounter = CHK_Fateful.Checked;
            pk7.Gender           = PKX.getGender(Label_Gender.Text);
            pk7.AltForm          = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
            pk7.EV_HP            = Util.ToInt32(TB_HPEV.Text); // EVs
            pk7.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk7.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk7.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk7.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk7.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk7.CNT_Cool   = Util.ToInt32(TB_Cool.Text);     // CNT
            pk7.CNT_Beauty = Util.ToInt32(TB_Beauty.Text);
            pk7.CNT_Cute   = Util.ToInt32(TB_Cute.Text);
            pk7.CNT_Smart  = Util.ToInt32(TB_Smart.Text);
            pk7.CNT_Tough  = Util.ToInt32(TB_Tough.Text);
            pk7.CNT_Sheen  = Util.ToInt32(TB_Sheen.Text);

            pk7.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk7.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            // Already in buff (then transferred to new pkx)
            // 0x2C, 0x2D, 0x2E, 0x2F
            // 0x30, 0x31, 0x32, 0x33
            // 0x34, 0x35, 0x36, 0x37
            // 0x38, 0x39

            // Unused
            // 0x3A, 0x3B
            // 0x3C, 0x3D, 0x3E, 0x3F

            // Block B
            // Convert Nickname field back to bytes
            pk7.Nickname     = TB_Nickname.Text;
            pk7.Move1        = Util.getIndex(CB_Move1);
            pk7.Move2        = Util.getIndex(CB_Move2);
            pk7.Move3        = Util.getIndex(CB_Move3);
            pk7.Move4        = Util.getIndex(CB_Move4);
            pk7.Move1_PP     = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk7.Move2_PP     = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk7.Move3_PP     = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk7.Move4_PP     = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk7.Move1_PPUps  = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk7.Move2_PPUps  = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk7.Move3_PPUps  = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk7.Move4_PPUps  = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
            pk7.RelearnMove1 = Util.getIndex(CB_RelearnMove1);
            pk7.RelearnMove2 = Util.getIndex(CB_RelearnMove2);
            pk7.RelearnMove3 = Util.getIndex(CB_RelearnMove3);
            pk7.RelearnMove4 = Util.getIndex(CB_RelearnMove4);
            // 0x72 - Ribbon editor sets this flag (Secret Super Training)
            // 0x73
            pk7.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk7.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk7.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk7.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk7.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk7.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk7.IsEgg       = CHK_IsEgg.Checked;
            pk7.IsNicknamed = CHK_Nicknamed.Checked;

            // Block C
            pk7.HT_Name = TB_OTt2.Text;

            // 0x90-0xAF
            pk7.HT_Gender = PKX.getGender(Label_CTGender.Text);
            // Plus more, set by MemoryAmie (already in buff)

            // Block D
            pk7.OT_Name           = TB_OT.Text;
            pk7.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            DateTime?egg_date     = null;
            int      egg_location = 0;

            if (CHK_AsEgg.Checked)      // If encountered as an egg, load the Egg Met data from fields.
            {
                egg_date     = CAL_EggDate.Value;
                egg_location = Util.getIndex(CB_EggLocation);
            }
            // Egg Met Data
            pk7.EggMetDate   = egg_date;
            pk7.Egg_Location = egg_location;
            // Met Data
            pk7.MetDate      = CAL_MetDate.Value;
            pk7.Met_Location = Util.getIndex(CB_MetLocation);

            if (pk7.IsEgg && pk7.Met_Location == 0)    // If still an egg, it has no hatch location/date. Zero it!
            {
                pk7.MetDate = null;
            }

            // 0xD7 Unknown

            pk7.Ball          = Util.getIndex(CB_Ball);
            pk7.Met_Level     = Util.ToInt32(TB_MetLevel.Text);
            pk7.OT_Gender     = PKX.getGender(Label_OTGender.Text);
            pk7.EncounterType = Util.getIndex(CB_EncounterType);
            pk7.Version       = Util.getIndex(CB_GameOrigin);
            pk7.Country       = Util.getIndex(CB_Country);
            pk7.Region        = Util.getIndex(CB_SubRegion);
            pk7.ConsoleRegion = Util.getIndex(CB_3DSReg);
            pk7.Language      = Util.getIndex(CB_Language);
            // 0xE4-0xE7

            // Toss in Party Stats
            Array.Resize(ref pk7.Data, pk7.SIZE_PARTY);
            pk7.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk7.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk7.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk7.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk7.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk7.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            // Unneeded Party Stats (Status, Flags, Unused)
            pk7.Data[0xE8]              = pk7.Data[0xE9] = pk7.Data[0xEA] = pk7.Data[0xEB] =
                pk7.Data[0xED]          = pk7.Data[0xEE] = pk7.Data[0xEF] =
                    pk7.Data[0xFE]      = pk7.Data[0xFF] = pk7.Data[0x100] =
                        pk7.Data[0x101] = pk7.Data[0x102] = pk7.Data[0x103] = 0;

            // Hax Illegality
            if (HaX)
            {
                pk7.Ability    = (byte)Util.getIndex(DEV_Ability);
                pk7.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk7.FixMoves();
            pk7.FixRelearn();

            // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs)
            if (Menu_ModifyPKM.Checked)
            {
                pk7.FixMemories();
            }

            // PKX is now filled
            pk7.RefreshChecksum();
            return(pk7);
        }
示例#3
0
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
            {
                return(null);
            }

            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1);
            int metLevel     = MetLevel > 0 ? MetLevel : currentLevel;
            PK7 pk           = new PK7
            {
                Species            = Species,
                HeldItem           = HeldItem,
                TID                = TID,
                SID                = SID,
                Met_Level          = metLevel,
                Nature             = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25),
                Gender             = PersonalTable.AO[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PersonalTable.AO[Species].RandomGender),
                AltForm            = Form,
                EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant,
                Version            = OriginGame == 0 ? SAV.Game : OriginGame,
                Language           = Language == 0 ? SAV.Language : Language,
                Ball               = Ball,
                Country            = SAV.Country,
                Region             = SAV.SubRegion,
                ConsoleRegion      = SAV.ConsoleRegion,
                Move1              = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4,
                RelearnMove1       = RelearnMove1, RelearnMove2 = RelearnMove2,
                RelearnMove3       = RelearnMove3, RelearnMove4 = RelearnMove4,
                Met_Location       = MetLocation,
                Egg_Location       = EggLocation,
                CNT_Cool           = CNT_Cool,
                CNT_Beauty         = CNT_Beauty,
                CNT_Cute           = CNT_Cute,
                CNT_Smart          = CNT_Smart,
                CNT_Tough          = CNT_Tough,
                CNT_Sheen          = CNT_Sheen,

                OT_Name        = OT.Length > 0 ? OT : SAV.OT,
                OT_Gender      = OTGender != 3 ? OTGender % 2 : SAV.Gender,
                HT_Name        = OT.Length > 0 ? SAV.OT : "",
                HT_Gender      = OT.Length > 0 ? SAV.Gender : 0,
                CurrentHandler = OT.Length > 0 ? 1 : 0,

                EXP = PKX.getEXP(currentLevel, Species),

                // Ribbons
                RibbonCountry  = RibbonCountry,
                RibbonNational = RibbonNational,

                RibbonEarth    = RibbonEarth,
                RibbonWorld    = RibbonWorld,
                RibbonClassic  = RibbonClassic,
                RibbonPremier  = RibbonPremier,
                RibbonEvent    = RibbonEvent,
                RibbonBirthday = RibbonBirthday,
                RibbonSpecial  = RibbonSpecial,
                RibbonSouvenir = RibbonSouvenir,

                RibbonWishing          = RibbonWishing,
                RibbonChampionBattle   = RibbonChampionBattle,
                RibbonChampionRegional = RibbonChampionRegional,
                RibbonChampionNational = RibbonChampionNational,
                RibbonChampionWorld    = RibbonChampionWorld,

                OT_Friendship    = PersonalTable.AO[Species].BaseFriendship,
                OT_Intensity     = OT_Intensity,
                OT_Memory        = OT_Memory,
                OT_TextVar       = OT_TextVar,
                OT_Feeling       = OT_Feeling,
                FatefulEncounter = true,
            };

            pk.Move1_PP = pk.getMovePP(Move1, 0);
            pk.Move2_PP = pk.getMovePP(Move2, 0);
            pk.Move3_PP = pk.getMovePP(Move3, 0);
            pk.Move4_PP = pk.getMovePP(Move4, 0);

            if (OTGender == 3)
            {
                pk.TID = SAV.TID;
                pk.SID = SAV.SID;
            }

            pk.MetDate = Date ?? DateTime.Now;

            pk.IsNicknamed = IsNicknamed;
            pk.Nickname    = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language);

            // More 'complex' logic to determine final values

            // Dumb way to generate random IVs.
            int[] finalIVs = new int[6];
            switch (IVs[0])
            {
            case 0xFE:
                finalIVs[0] = 31;
                do       // 31 HP IV, 2 other 31s
                {
                    for (int i = 1; i < 6; i++)
                    {
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    }
                } while (finalIVs.Count(r => r == 31) < 3);     // 31 + 2*31
                break;

            case 0xFD:
                do       // 2 other 31s
                {
                    for (int i = 0; i < 6; i++)
                    {
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    }
                } while (finalIVs.Count(r => r == 31) < 2);     // 2*31
                break;

            default:     // Random IVs
                for (int i = 0; i < 6; i++)
                {
                    finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                }
                break;
            }
            pk.IVs = finalIVs;

            int av = 0;

            switch (AbilityType)
            {
            case 00:     // 0 - 0
            case 01:     // 1 - 1
            case 02:     // 2 - H
                av = AbilityType;
                break;

            case 03:     // 0/1
            case 04:     // 0/1/H
                av = (int)(Util.rnd32() % (AbilityType - 1));
                break;
            }
            pk.Ability       = PersonalTable.SM.getAbilities(Species, pk.AltForm)[av];
            pk.AbilityNumber = 1 << av;

            switch (PIDType)
            {
            case 00:     // Specified
                pk.PID = PID;
                break;

            case 01:     // Random
                pk.PID = Util.rnd32();
                break;

            case 02:     // Random Shiny
                pk.PID = Util.rnd32();
                pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF));
                break;

            case 03:     // Random Nonshiny
                do
                {
                    pk.PID = Util.rnd32();
                } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16);
                break;
            }

            if (IsEgg)
            {
                pk.IsEgg      = true;
                pk.EggMetDate = Date;
            }

            pk.RefreshChecksum();
            return(pk);
        }
示例#4
0
        private PKM PreparePK7()
        {
            PK7 pk7 = pkm as PK7;

            if (pk7 == null)
            {
                return(null);
            }

            // Repopulate PK7 with Edited Stuff
            CheckTransferPIDValid();

            pk7.EncryptionConstant = Util.GetHexValue(TB_EC.Text);
            pk7.Checksum           = 0; // 0 CHK for now

            // Block A
            pk7.Species  = WinFormsUtil.GetIndex(CB_Species);
            pk7.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem);
            pk7.TID      = Util.ToInt32(TB_TID.Text);
            pk7.SID      = Util.ToInt32(TB_SID.Text);
            pk7.EXP      = Util.ToUInt32(TB_EXP.Text);

            if (CB_Ability.Text.Length >= 4)
            {
                pk7.Ability       = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
                pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);   // Number
            }

            pk7.PID              = Util.GetHexValue(TB_PID.Text);
            pk7.Nature           = (byte)WinFormsUtil.GetIndex(CB_Nature);
            pk7.FatefulEncounter = CHK_Fateful.Checked;
            pk7.Gender           = PKX.GetGender(Label_Gender.Text);
            pk7.AltForm          = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
            pk7.EV_HP            = Util.ToInt32(TB_HPEV.Text); // EVs
            pk7.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk7.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk7.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk7.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk7.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk7.CNT_Cool   = Contest.Cool;
            pk7.CNT_Beauty = Contest.Beauty;
            pk7.CNT_Cute   = Contest.Cute;
            pk7.CNT_Smart  = Contest.Smart;
            pk7.CNT_Tough  = Contest.Tough;
            pk7.CNT_Sheen  = Contest.Sheen;

            pk7.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk7.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            // Already in buff (then transferred to new pkx)
            // 0x2C, 0x2D, 0x2E, 0x2F
            // 0x30, 0x31, 0x32, 0x33
            // 0x34, 0x35, 0x36, 0x37
            // 0x38, 0x39

            // Unused
            // 0x3A, 0x3B
            // 0x3C, 0x3D, 0x3E, 0x3F

            // Block B
            // Convert Nickname field back to bytes
            pk7.Nickname     = TB_Nickname.Text;
            pk7.Move1        = WinFormsUtil.GetIndex(CB_Move1);
            pk7.Move2        = WinFormsUtil.GetIndex(CB_Move2);
            pk7.Move3        = WinFormsUtil.GetIndex(CB_Move3);
            pk7.Move4        = WinFormsUtil.GetIndex(CB_Move4);
            pk7.Move1_PP     = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk7.Move2_PP     = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk7.Move3_PP     = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk7.Move4_PP     = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk7.Move1_PPUps  = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk7.Move2_PPUps  = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk7.Move3_PPUps  = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk7.Move4_PPUps  = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
            pk7.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1);
            pk7.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2);
            pk7.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3);
            pk7.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4);
            // 0x72 - Ribbon editor sets this flag (Secret Super Training)
            // 0x73
            pk7.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk7.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk7.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk7.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk7.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk7.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk7.IsEgg       = CHK_IsEgg.Checked;
            pk7.IsNicknamed = CHK_Nicknamed.Checked;

            // Block C
            pk7.HT_Name = TB_OTt2.Text;

            // 0x90-0xAF
            pk7.HT_Gender = PKX.GetGender(Label_CTGender.Text) & 1;
            // Plus more, set by MemoryAmie (already in buff)

            // Block D
            pk7.OT_Name           = TB_OT.Text;
            pk7.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            DateTime?egg_date     = null;
            int      egg_location = 0;

            if (CHK_AsEgg.Checked)      // If encountered as an egg, load the Egg Met data from fields.
            {
                egg_date     = CAL_EggDate.Value;
                egg_location = WinFormsUtil.GetIndex(CB_EggLocation);
            }
            // Egg Met Data
            pk7.EggMetDate   = egg_date;
            pk7.Egg_Location = egg_location;
            // Met Data
            pk7.MetDate      = CAL_MetDate.Value;
            pk7.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation);

            if (pk7.IsEgg && pk7.Met_Location == 0)    // If still an egg, it has no hatch location/date. Zero it!
            {
                pk7.MetDate = null;
            }

            // 0xD7 Unknown

            pk7.Ball          = WinFormsUtil.GetIndex(CB_Ball);
            pk7.Met_Level     = Util.ToInt32(TB_MetLevel.Text);
            pk7.OT_Gender     = PKX.GetGender(Label_OTGender.Text);
            pk7.EncounterType = WinFormsUtil.GetIndex(CB_EncounterType);
            pk7.Version       = WinFormsUtil.GetIndex(CB_GameOrigin);
            pk7.Country       = WinFormsUtil.GetIndex(CB_Country);
            pk7.Region        = WinFormsUtil.GetIndex(CB_SubRegion);
            pk7.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
            pk7.Language      = WinFormsUtil.GetIndex(CB_Language);
            // 0xE4-0xE7

            // Toss in Party Stats
            Array.Resize(ref pk7.Data, pk7.SIZE_PARTY);
            pk7.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk7.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk7.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk7.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk7.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk7.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            // Unneeded Party Stats (Status, Flags, Unused)
            pk7.Data[0xE8]              = pk7.Data[0xE9] = pk7.Data[0xEA] = pk7.Data[0xEB] =
                pk7.Data[0xED]          = pk7.Data[0xEE] = pk7.Data[0xEF] =
                    pk7.Data[0xFE]      = pk7.Data[0xFF] = pk7.Data[0x100] =
                        pk7.Data[0x101] = pk7.Data[0x102] = pk7.Data[0x103] = 0;

            // Hax Illegality
            if (HaX)
            {
                pk7.Ability    = (byte)WinFormsUtil.GetIndex(DEV_Ability);
                pk7.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk7.FixMoves();
            pk7.FixRelearn();

            // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs)
            if (ModifyPKM)
            {
                pk7.FixMemories();
            }

            // PKX is now filled
            pk7.RefreshChecksum();
            return(pk7);
        }
示例#5
0
        private static PK7 convert(PK8 pk8)
        {
            PK7 pk7 = new PK7();

            pk7.EncryptionConstant = pk8.EncryptionConstant;
            pk7.Species            = pk8.Species;
            pk7.TID              = pk8.TID;
            pk7.SID              = pk8.SID;
            pk7.EXP              = pk8.EXP;
            pk7.PID              = pk8.PID;
            pk7.Ability          = pk8.Ability;
            pk7.AbilityNumber    = pk8.AbilityNumber;
            pk7.Markings         = pk8.Markings;
            pk7.Language         = pk8.Language;
            pk7.EV_HP            = pk8.EV_HP;
            pk7.EV_ATK           = pk8.EV_ATK;
            pk7.EV_DEF           = pk8.EV_DEF;
            pk7.EV_SPA           = pk8.EV_SPA;
            pk7.EV_SPD           = pk8.EV_SPD;
            pk7.EV_SPE           = pk8.EV_SPE;
            pk7.Move1            = pk8.Move1;
            pk7.Move2            = pk8.Move2;
            pk7.Move3            = pk8.Move3;
            pk7.Move4            = pk8.Move4;
            pk7.Move1_PPUps      = pk8.Move1_PPUps;
            pk7.Move2_PPUps      = pk8.Move2_PPUps;
            pk7.Move3_PPUps      = pk8.Move3_PPUps;
            pk7.Move4_PPUps      = pk8.Move4_PPUps;
            pk7.RelearnMove1     = pk8.RelearnMove1;
            pk7.RelearnMove2     = pk8.RelearnMove2;
            pk7.RelearnMove3     = pk8.RelearnMove3;
            pk7.RelearnMove4     = pk8.RelearnMove4;
            pk7.IV_HP            = pk8.IV_HP;
            pk7.IV_ATK           = pk8.IV_ATK;
            pk7.IV_DEF           = pk8.IV_DEF;
            pk7.IV_SPA           = pk8.IV_SPA;
            pk7.IV_SPD           = pk8.IV_SPD;
            pk7.IV_SPE           = pk8.IV_SPE;
            pk7.IsEgg            = pk8.IsEgg;
            pk7.IsNicknamed      = pk8.IsNicknamed;
            pk7.FatefulEncounter = pk8.FatefulEncounter;
            pk7.Gender           = pk8.Gender;
            pk7.AltForm          = pk8.AltForm;
            pk7.Nature           = pk8.Nature;
            pk7.Nickname         = pk8.Nickname;
            pk7.Version          = pk8.Version;
            pk7.OT_Name          = pk8.OT_Name;
            pk7.MetDate          = pk8.MetDate;
            pk7.EggMetDate       = pk8.EggMetDate;
            pk7.Met_Location     = pk8.Met_Location;
            pk7.Egg_Location     = pk8.Egg_Location;
            pk7.Ball             = pk8.Ball;
            pk7.Met_Level        = pk8.Met_Level;
            pk7.OT_Gender        = pk8.OT_Gender;
            pk7.HyperTrainFlags  = pk8.HyperTrainFlags;

            // Locale does not transfer. All Zero
            // Country = Country,
            // Region = Region,
            // ConsoleRegion = ConsoleRegion,

            PKMConverter.SetFirstCountryRegion(pk7);

            pk7.OT_Memory    = pk8.OT_Memory;
            pk7.OT_TextVar   = pk8.OT_TextVar;
            pk7.OT_Feeling   = pk8.OT_Feeling;
            pk7.OT_Intensity = pk8.OT_Intensity;

            pk7.PKRS_Strain = pk8.PKRS_Strain;
            pk7.PKRS_Days   = pk8.PKRS_Days;
            pk7.CNT_Cool    = pk8.CNT_Cool;
            pk7.CNT_Beauty  = pk8.CNT_Beauty;
            pk7.CNT_Cute    = pk8.CNT_Cute;
            pk7.CNT_Smart   = pk8.CNT_Smart;
            pk7.CNT_Tough   = pk8.CNT_Tough;
            pk7.CNT_Sheen   = pk8.CNT_Sheen;

            pk7.RibbonChampionG3Hoenn    = pk8.RibbonChampionG3Hoenn;
            pk7.RibbonChampionSinnoh     = pk8.RibbonChampionSinnoh;
            pk7.RibbonEffort             = pk8.RibbonEffort;
            pk7.RibbonAlert              = pk8.RibbonAlert;
            pk7.RibbonShock              = pk8.RibbonShock;
            pk7.RibbonDowncast           = pk8.RibbonDowncast;
            pk7.RibbonCareless           = pk8.RibbonCareless;
            pk7.RibbonRelax              = pk8.RibbonRelax;
            pk7.RibbonSnooze             = pk8.RibbonSnooze;
            pk7.RibbonSmile              = pk8.RibbonSmile;
            pk7.RibbonGorgeous           = pk8.RibbonGorgeous;
            pk7.RibbonRoyal              = pk8.RibbonRoyal;
            pk7.RibbonGorgeousRoyal      = pk8.RibbonGorgeousRoyal;
            pk7.RibbonArtist             = pk8.RibbonArtist;
            pk7.RibbonFootprint          = pk8.RibbonFootprint;
            pk7.RibbonRecord             = pk8.RibbonRecord;
            pk7.RibbonLegend             = pk8.RibbonLegend;
            pk7.RibbonCountry            = pk8.RibbonCountry;
            pk7.RibbonNational           = pk8.RibbonNational;
            pk7.RibbonEarth              = pk8.RibbonEarth;
            pk7.RibbonWorld              = pk8.RibbonWorld;
            pk7.RibbonClassic            = pk8.RibbonClassic;
            pk7.RibbonPremier            = pk8.RibbonPremier;
            pk7.RibbonEvent              = pk8.RibbonEvent;
            pk7.RibbonBirthday           = pk8.RibbonBirthday;
            pk7.RibbonSpecial            = pk8.RibbonSpecial;
            pk7.RibbonSouvenir           = pk8.RibbonSouvenir;
            pk7.RibbonWishing            = pk8.RibbonWishing;
            pk7.RibbonChampionBattle     = pk8.RibbonChampionBattle;
            pk7.RibbonChampionRegional   = pk8.RibbonChampionRegional;
            pk7.RibbonChampionNational   = pk8.RibbonChampionNational;
            pk7.RibbonChampionWorld      = pk8.RibbonChampionWorld;
            pk7.RibbonChampionKalos      = pk8.RibbonChampionKalos;
            pk7.RibbonChampionG6Hoenn    = pk8.RibbonChampionG6Hoenn;
            pk7.RibbonBestFriends        = pk8.RibbonBestFriends;
            pk7.RibbonTraining           = pk8.RibbonTraining;
            pk7.RibbonBattlerSkillful    = pk8.RibbonBattlerSkillful;
            pk7.RibbonBattlerExpert      = pk8.RibbonBattlerExpert;
            pk7.RibbonContestStar        = pk8.RibbonContestStar;
            pk7.RibbonMasterCoolness     = pk8.RibbonMasterCoolness;
            pk7.RibbonMasterBeauty       = pk8.RibbonMasterBeauty;
            pk7.RibbonMasterCuteness     = pk8.RibbonMasterCuteness;
            pk7.RibbonMasterCleverness   = pk8.RibbonMasterCleverness;
            pk7.RibbonMasterToughness    = pk8.RibbonMasterToughness;
            pk7.RibbonCountMemoryContest = pk8.RibbonCountMemoryContest;
            pk7.RibbonCountMemoryBattle  = pk8.RibbonCountMemoryBattle;
            pk7.RibbonChampionAlola      = pk8.RibbonChampionAlola;
            pk7.RibbonBattleRoyale       = pk8.RibbonBattleRoyale;
            pk7.RibbonBattleTreeGreat    = pk8.RibbonBattleTreeGreat;
            pk7.RibbonBattleTreeMaster   = pk8.RibbonBattleTreeMaster;

            pk7.OT_Friendship = pk8.OT_Friendship;

            // No Ribbons or Markings on transfer.

            pk7.Nature = pk8.StatNature;
            // HeightScalar = 0,
            // WeightScalar = 0,



            pk7.HealPP();
            // Fix Checksum
            pk7.RefreshChecksum();
            return(pk7);
        }