private void saveFavPKM()
        {
            if (loading || !GB_PKM.Enabled)
            {
                return;
            }
            int index = currentpkm;

            byte[] pkm = new Byte[0x34];

            Array.Copy(BitConverter.GetBytes(Util.getHEXval(TB_EC)), 0, pkm, 0, 4);  // EC
            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Species)), 0, pkm, 8, 2);
            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_HeldItem)), 0, pkm, 0xA, 2);
            pkm[0xC]  = (byte)Array.IndexOf(abilitylist, (CB_Ability.Text).Remove((CB_Ability.Text).Length - 4)); // Ability
            pkm[0xD]  = (byte)(CB_Ability.SelectedIndex << 1);                                                    // Number
            pkm[0x14] = (byte)Util.getIndex(CB_Nature);

            int fegform = 0;

            fegform  += (Convert.ToInt32(Label_Gender.Text == "♀") * 2);                        // Female Gender
            fegform  += (Convert.ToInt32(Label_Gender.Text == "-") * 4);                        // Genderless
            fegform  += ((Util.getIndex(CB_Form)) * 8);
            pkm[0x15] = (byte)fegform;

            pkm[0x16] = (byte)(Convert.ToByte(TB_HPEV.Text) & 0x1F);
            pkm[0x17] = (byte)(Convert.ToByte(TB_ATKEV.Text) & 0x1F);
            pkm[0x18] = (byte)(Convert.ToByte(TB_DEFEV.Text) & 0x1F);
            pkm[0x19] = (byte)(Convert.ToByte(TB_SPAEV.Text) & 0x1F);
            pkm[0x1A] = (byte)(Convert.ToByte(TB_SPDEV.Text) & 0x1F);
            pkm[0x1B] = (byte)(Convert.ToByte(TB_SPEEV.Text) & 0x1F);

            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Move1)), 0, pkm, 0x1C, 2);
            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Move2)), 0, pkm, 0x1E, 2);
            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Move3)), 0, pkm, 0x20, 2);
            Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Move4)), 0, pkm, 0x22, 2);

            pkm[0x24] = (byte)CB_PPu1.SelectedIndex;
            pkm[0x25] = (byte)CB_PPu2.SelectedIndex;
            pkm[0x26] = (byte)CB_PPu3.SelectedIndex;
            pkm[0x27] = (byte)CB_PPu4.SelectedIndex;

            pkm[0x28] = (byte)(Convert.ToByte(TB_HPIV.Text) & 0x1F);
            pkm[0x29] = (byte)(Convert.ToByte(TB_ATKIV.Text) & 0x1F);
            pkm[0x2A] = (byte)(Convert.ToByte(TB_DEFIV.Text) & 0x1F);
            pkm[0x2B] = (byte)(Convert.ToByte(TB_SPAIV.Text) & 0x1F);
            pkm[0x2C] = (byte)(Convert.ToByte(TB_SPDIV.Text) & 0x1F);
            pkm[0x2D] = (byte)(Convert.ToByte(TB_SPEIV.Text) & 0x1F);
            int shiny = (checkBox1.Checked? 1 : 0) << 6;

            pkm[0x2D] |= (byte)shiny;

            pkm[0x2E] = Convert.ToByte(TB_Friendship.Text);
            pkm[0x2F] = (byte)Util.getIndex(CB_Ball);
            pkm[0x30] = Convert.ToByte(TB_Level.Text);

            for (int i = 0; i < 0x34; i++) // Copy data back to storage.
            {
                pkmdata[index - 1, i] = pkm[i];
            }
        }
示例#2
0
        private void B_Add_Click(object sender, EventArgs e)
        {
            // Add the new code to the textbox.
            if (!loaddata())
            {
                return;
            }
            uint writeoffset = Util.getHEXval(TB_Write.Text);

            for (int i = 0; i < newdata.Length / 4; i++)
            {
                RTB_Code.AppendText((writeoffset + i * 4 + 0x20000000).ToString("X8") + " ");
                RTB_Code.AppendText(BitConverter.ToUInt32(newdata, i * 4).ToString("X8") + Environment.NewLine);
            }

            // Mat's Code - Unfinished
            //for (int i = 0; i < newdata.Length / (4); i++)
            //{
            //    // Add Operator

            //    RTB_Code.AppendText("00000001 ");   // 01 00 00 00
            //    RTB_Code.AppendText((writeoffset + i * 4).ToString("X8") + " ");
            //    RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + Environment.NewLine);
            //}
        }
示例#3
0
        private void saveFavPKM()
        {
            if (loading || !GB_PKM.Enabled)
            {
                return;
            }
            int index = currentpkm;

            byte[] pkm = new byte[0x34];

            BitConverter.GetBytes(Util.getHEXval(TB_EC.Text)).CopyTo(pkm, 0);
            BitConverter.GetBytes((ushort)Util.getIndex(CB_Species)).CopyTo(pkm, 8);
            BitConverter.GetBytes((ushort)Util.getIndex(CB_HeldItem)).CopyTo(pkm, 0xA);
            pkm[0xC]  = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
            pkm[0xD]  = (byte)(CB_Ability.SelectedIndex << 1);
            pkm[0x14] = (byte)Util.getIndex(CB_Nature);

            int fegform = 0;

            fegform  += PKX.getGender(Label_Gender.Text) << 1;
            fegform  += CB_Form.SelectedIndex << 3;
            pkm[0x15] = (byte)fegform;

            pkm[0x16] = (byte)Math.Min(Convert.ToInt32(TB_HPEV.Text), 252);
            pkm[0x17] = (byte)Math.Min(Convert.ToInt32(TB_ATKEV.Text), 252);
            pkm[0x18] = (byte)Math.Min(Convert.ToInt32(TB_DEFEV.Text), 252);
            pkm[0x19] = (byte)Math.Min(Convert.ToInt32(TB_SPAEV.Text), 252);
            pkm[0x1A] = (byte)Math.Min(Convert.ToInt32(TB_SPDEV.Text), 252);
            pkm[0x1B] = (byte)Math.Min(Convert.ToInt32(TB_SPEEV.Text), 252);

            BitConverter.GetBytes((ushort)Util.getIndex(CB_Move1)).CopyTo(pkm, 0x1C);
            BitConverter.GetBytes((ushort)Util.getIndex(CB_Move2)).CopyTo(pkm, 0x1E);
            BitConverter.GetBytes((ushort)Util.getIndex(CB_Move3)).CopyTo(pkm, 0x20);
            BitConverter.GetBytes((ushort)Util.getIndex(CB_Move4)).CopyTo(pkm, 0x22);

            pkm[0x24] = (byte)CB_PPu1.SelectedIndex;
            pkm[0x25] = (byte)CB_PPu2.SelectedIndex;
            pkm[0x26] = (byte)CB_PPu3.SelectedIndex;
            pkm[0x27] = (byte)CB_PPu4.SelectedIndex;

            pkm[0x28] = (byte)(Convert.ToByte(TB_HPIV.Text) & 0x1F);
            pkm[0x29] = (byte)(Convert.ToByte(TB_ATKIV.Text) & 0x1F);
            pkm[0x2A] = (byte)(Convert.ToByte(TB_DEFIV.Text) & 0x1F);
            pkm[0x2B] = (byte)(Convert.ToByte(TB_SPAIV.Text) & 0x1F);
            pkm[0x2C] = (byte)(Convert.ToByte(TB_SPDIV.Text) & 0x1F);
            pkm[0x2D] = (byte)(Convert.ToByte(TB_SPEIV.Text) & 0x1F);
            int shiny = (CHK_Shiny.Checked? 1 : 0) << 6;

            pkm[0x2D] |= (byte)shiny;

            pkm[0x2E] = Convert.ToByte(TB_Friendship.Text);
            pkm[0x2F] = (byte)Util.getIndex(CB_Ball);
            pkm[0x30] = Convert.ToByte(TB_Level.Text);

            for (int i = 0; i < 0x34; i++) // Copy data back to storage.
            {
                pkmdata[index - 1, i] = pkm[i];
            }
        }
        private void saveChanges()
        {
            // Save back the Species Bools
            // Return to Byte Array
            for (int p = 0; p < 9; p++)
            {
                byte[] sdata = new byte[0x60];

                for (int i = 0; i < 0x60 * 8; i++)
                {
                    if (specbools[p, i])
                    {
                        sdata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(sdata, 0, sav, sv + dexoffset + 0x8 + 0x60 * p, 0x60);
            }

            // Build new bool array for the Languages
            {
                bool[] languagedata = new bool[0x27C * 8];
                for (int i = 0; i < 722; i++)
                {
                    for (int l = 0; l < 7; l++)
                    {
                        languagedata[i * 7 + l] = langbools[l, i];
                    }
                }

                // Return to Byte Array
                byte[] ldata = new byte[languagedata.Length / 8];

                for (int i = 0; i < languagedata.Length; i++)
                {
                    if (languagedata[i])
                    {
                        ldata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(ldata, 0, sav, sv + dexoffset + 0x400, 0x27C);
            }

            // Store Spinda Spot
            try
            {
                uint PID = Util.getHEXval(TB_Spinda);
                Array.Copy(BitConverter.GetBytes(PID), 0, sav, dexoffset + 0x680, 4);
            }
            catch { };
        }
示例#5
0
        private void setData()
        {
            // Save back the Species Bools
            // Return to Byte Array
            for (int p = 0; p < 9; p++)
            {
                byte[] sdata = new byte[0x60];

                for (int i = 0; i < 0x60 * 8; i++)
                {
                    if (specbools[p, i])
                    {
                        sdata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                sdata.CopyTo(sav, Main.SAV.PokeDex + 8 + 0x60 * p);
            }

            // Build new bool array for the Languages
            bool[] languagedata = new bool[0x27C * 8];
            for (int i = 0; i < 722; i++)
            {
                for (int l = 0; l < 7; l++)
                {
                    languagedata[i * 7 + l] = langbools[l, i];
                }
            }

            // Return to Byte Array
            byte[] ldata = new byte[languagedata.Length / 8];

            for (int i = 0; i < languagedata.Length; i++)
            {
                if (languagedata[i])
                {
                    ldata[i / 8] |= (byte)(1 << i % 8);
                }
            }

            ldata.CopyTo(sav, Main.SAV.PokeDexLanguageFlags);

            formbools.CopyTo(sav, Main.SAV.PokeDex + 0x368);

            // Store Spinda Spot
            uint PID = Util.getHEXval(TB_Spinda.Text);

            BitConverter.GetBytes(PID).CopyTo(sav, Main.SAV.Spinda);
        }
示例#6
0
        private PKM preparePK4()
        {
            PK4 pk4 = pkm as PK4;

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

            pk4.Species  = Util.getIndex(CB_Species);
            pk4.HeldItem = Util.getIndex(CB_HeldItem);
            pk4.TID      = Util.ToInt32(TB_TID.Text);
            pk4.SID      = Util.ToInt32(TB_SID.Text);
            pk4.EXP      = Util.ToUInt32(TB_EXP.Text);
            pk4.PID      = Util.getHEXval(TB_PID.Text);
            pk4.Ability  = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));

            pk4.FatefulEncounter = CHK_Fateful.Checked;
            pk4.Gender           = PKX.getGender(Label_Gender.Text);
            pk4.AltForm          = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
            pk4.EV_HP            = Util.ToInt32(TB_HPEV.Text);
            pk4.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk4.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk4.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk4.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk4.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

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

            pk4.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk4.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            pk4.Nickname    = TB_Nickname.Text;
            pk4.Move1       = Util.getIndex(CB_Move1);
            pk4.Move2       = Util.getIndex(CB_Move2);
            pk4.Move3       = Util.getIndex(CB_Move3);
            pk4.Move4       = Util.getIndex(CB_Move4);
            pk4.Move1_PP    = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk4.Move2_PP    = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk4.Move3_PP    = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk4.Move4_PP    = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk4.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk4.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk4.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk4.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;

            pk4.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk4.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk4.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk4.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk4.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk4.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk4.IsEgg       = CHK_IsEgg.Checked;
            pk4.IsNicknamed = CHK_Nicknamed.Checked;

            pk4.OT_Name           = TB_OT.Text;
            pk4.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            pk4.Ball          = Util.getIndex(CB_Ball);
            pk4.Met_Level     = Util.ToInt32(TB_MetLevel.Text);
            pk4.OT_Gender     = PKX.getGender(Label_OTGender.Text);
            pk4.EncounterType = Util.getIndex(CB_EncounterType);
            pk4.Version       = Util.getIndex(CB_GameOrigin);
            pk4.Language      = Util.getIndex(CB_Language);

            // Default Dates
            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
            pk4.EggMetDate   = egg_date;
            pk4.Egg_Location = egg_location;
            // Met Data
            pk4.MetDate      = CAL_MetDate.Value;
            pk4.Met_Location = Util.getIndex(CB_MetLocation);

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

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

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

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

            pk4.RefreshChecksum();
            return(pk4);
        }
示例#7
0
        private PKM preparePK6()
        {
            PK6 pk6 = pkm as PK6;

            if (pk6 == 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");
                }
            }

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

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

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

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

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

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

            // Block D
            pk6.OT_Name           = TB_OT.Text;
            pk6.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
            pk6.EggMetDate   = egg_date;
            pk6.Egg_Location = egg_location;
            // Met Data
            pk6.MetDate      = CAL_MetDate.Value;
            pk6.Met_Location = Util.getIndex(CB_MetLocation);

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

            // 0xD7 Unknown

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

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

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

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

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

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

            // PKX is now filled
            pk6.RefreshChecksum();
            return(pk6);
        }
示例#8
0
        private PKM preparePK3()
        {
            PK3 pk3 = pkm as PK3;

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

            pk3.Species       = Util.getIndex(CB_Species);
            pk3.HeldItem      = Util.getIndex(CB_HeldItem);
            pk3.TID           = Util.ToInt32(TB_TID.Text);
            pk3.SID           = Util.ToInt32(TB_SID.Text);
            pk3.EXP           = Util.ToUInt32(TB_EXP.Text);
            pk3.PID           = Util.getHEXval(TB_PID.Text);
            pk3.AbilityNumber = CB_Ability.SelectedIndex; // 0/1 (stored in IVbits)

            pk3.FatefulEncounter = CHK_Fateful.Checked;
            pk3.Gender           = PKX.getGender(Label_Gender.Text);
            pk3.EV_HP            = Util.ToInt32(TB_HPEV.Text);
            pk3.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk3.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk3.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk3.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk3.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

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

            pk3.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk3.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            pk3.Nickname    = TB_Nickname.Text;
            pk3.Move1       = Util.getIndex(CB_Move1);
            pk3.Move2       = Util.getIndex(CB_Move2);
            pk3.Move3       = Util.getIndex(CB_Move3);
            pk3.Move4       = Util.getIndex(CB_Move4);
            pk3.Move1_PP    = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk3.Move2_PP    = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk3.Move3_PP    = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk3.Move4_PP    = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk3.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk3.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk3.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk3.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;

            pk3.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk3.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk3.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk3.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk3.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk3.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk3.IsEgg       = CHK_IsEgg.Checked;
            pk3.IsNicknamed = CHK_Nicknamed.Checked;

            pk3.OT_Name           = TB_OT.Text;
            pk3.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            pk3.Ball      = Util.getIndex(CB_Ball);
            pk3.Met_Level = Util.ToInt32(TB_MetLevel.Text);
            pk3.OT_Gender = PKX.getGender(Label_OTGender.Text);
            pk3.Version   = Util.getIndex(CB_GameOrigin);
            pk3.Language  = Util.getIndex(CB_Language);

            pk3.Met_Location = Util.getIndex(CB_MetLocation);

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

            if (HaX)
            {
                pk3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

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

            pk3.RefreshChecksum();
            return(pk3);
        }
示例#9
0
        private void saveChanges()
        {
            // Save back the Species Bools
            // Return to Byte Array
            for (int p = 0; p < 10; p++)
            {
                byte[] sdata = new byte[0x60];

                for (int i = 0; i < 0x60 * 8; i++)
                {
                    if (specbools[p, i])
                    {
                        sdata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(sdata, 0, sav, savshift + 0x1A408 + 0x60 * p, 0x60);
            }

            // Build new bool array for the Languages
            {
                bool[] languagedata = new bool[0x280 * 8];
                for (int i = 0; i < 731; i++)
                {
                    for (int l = 0; l < 7; l++)
                    {
                        languagedata[i * 7 + l] = langbools[l, i];
                    }
                }

                // Return to Byte Array
                byte[] ldata = new byte[languagedata.Length / 8];

                for (int i = 0; i < languagedata.Length; i++)
                {
                    if (languagedata[i])
                    {
                        ldata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(ldata, 0, sav, savshift + 0x1A7C8, 0x280);
            }

            // Return Foreign Array
            {
                byte[] foreigndata = new byte[0x52];
                for (int i = 0; i < 0x52 * 8; i++)
                {
                    if (foreignbools[i])
                    {
                        foreigndata[i / 8] |= (byte)(1 << i % 8);
                    }
                }
                Array.Copy(foreigndata, 0, sav, savshift + 0x1AA4C, 0x52);
            }

            // Store Spinda Spot
            uint PID = Util.getHEXval(TB_Spinda);

            Array.Copy(BitConverter.GetBytes(PID), 0, sav, 0x1AA48 + Convert.ToInt16(m_parent.savegame_oras) * 0x38 + savshift, 4);
        }
示例#10
0
        private void saveChanges()
        {
            // Save back the Species Bools
            // Return to Byte Array
            for (int p = 0; p < 9; p++)
            {
                byte[] sdata = new byte[0x60];

                for (int i = 0; i < 0x60 * 8; i++)
                {
                    if (specbools[p, i])
                    {
                        sdata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(sdata, 0, sav, Main.SAV.PokeDex + 8 + 0x60 * p, 0x60);
            }

            // Build new bool array for the Languages
            {
                bool[] languagedata = new bool[0x280 * 8];
                for (int i = 0; i < 731; i++)
                {
                    for (int l = 0; l < 7; l++)
                    {
                        languagedata[i * 7 + l] = langbools[l, i];
                    }
                }

                // Return to Byte Array
                byte[] ldata = new byte[languagedata.Length / 8];

                for (int i = 0; i < languagedata.Length; i++)
                {
                    if (languagedata[i])
                    {
                        ldata[i / 8] |= (byte)(1 << i % 8);
                    }
                }

                Array.Copy(ldata, 0, sav, Main.SAV.PokeDexLanguageFlags, 0x280);
            }

            // Return Foreign Array
            {
                byte[] foreigndata = new byte[0x52];
                for (int i = 0; i < 0x52 * 8; i++)
                {
                    if (foreignbools[i])
                    {
                        foreigndata[i / 8] |= (byte)(1 << i % 8);
                    }
                }
                Array.Copy(foreigndata, 0, sav, Main.SAV.PokeDex + 0x64C, 0x52);
            }

            // Store Spinda Spot
            uint PID = Util.getHEXval(TB_Spinda);

            Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SAV.Spinda, 4);
        }