예제 #1
0
        private void savePersonal()
        {
            pkm.HP  = Convert.ToByte(TB_BaseHP.Text);
            pkm.ATK = Convert.ToByte(TB_BaseATK.Text);
            pkm.DEF = Convert.ToByte(TB_BaseDEF.Text);
            pkm.SPE = Convert.ToByte(TB_BaseSPE.Text);
            pkm.SPA = Convert.ToByte(TB_BaseSPA.Text);
            pkm.SPD = Convert.ToByte(TB_BaseSPD.Text);

            pkm.EV_HP  = Convert.ToByte(TB_HPEVs.Text);
            pkm.EV_ATK = Convert.ToByte(TB_ATKEVs.Text);
            pkm.EV_DEF = Convert.ToByte(TB_DEFEVs.Text);
            pkm.EV_SPE = Convert.ToByte(TB_SPEEVs.Text);
            pkm.EV_SPA = Convert.ToByte(TB_SPAEVs.Text);
            pkm.EV_SPD = Convert.ToByte(TB_SPDEVs.Text);

            pkm.CatchRate = Convert.ToByte(TB_CatchRate.Text);
            pkm.EvoStage  = Convert.ToByte(TB_Stage.Text);

            pkm.Types[0] = (byte)CB_Type1.SelectedIndex;
            pkm.Types[1] = (byte)CB_Type2.SelectedIndex;
            pkm.Items[0] = (ushort)CB_HeldItem1.SelectedIndex;
            pkm.Items[1] = (ushort)CB_HeldItem2.SelectedIndex;
            pkm.Items[2] = (ushort)CB_HeldItem3.SelectedIndex;

            pkm.Gender         = Convert.ToByte(TB_Gender.Text);
            pkm.HatchCycles    = Convert.ToByte(TB_HatchCycles.Text);
            pkm.BaseFriendship = Convert.ToByte(TB_Friendship.Text);
            pkm.EXPGrowth      = (byte)CB_EXPGroup.SelectedIndex;
            pkm.EggGroups[0]   = (byte)CB_EggGroup1.SelectedIndex;
            pkm.EggGroups[1]   = (byte)CB_EggGroup2.SelectedIndex;

            pkm.Abilities[0] = (byte)CB_Ability1.SelectedIndex;
            pkm.Abilities[1] = (byte)CB_Ability2.SelectedIndex;
            pkm.Abilities[2] = (byte)CB_Ability3.SelectedIndex;

            pkm.FormeSprite = Convert.ToUInt16(TB_FormeSprite.Text);
            pkm.FormeCount  = Convert.ToByte(TB_FormeCount.Text);
            pkm.Color       = (byte)(Convert.ToByte(CB_Color.SelectedIndex) | (Convert.ToByte(TB_RawColor.Text) & 0xF0));
            pkm.BaseEXP     = Convert.ToUInt16(TB_BaseExp.Text);

            pkm.Height = (float)Convert.ToDouble(TB_Height.Text) * 100;
            pkm.Weight = (float)Convert.ToDouble(TB_Weight.Text) * 10;

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
            {
                pkm.TMHM[i] = CLB_TMHM.GetItemChecked(i);
            }

            for (int t = 0; t < CLB_MoveTutors.Items.Count; t++)
            {
                pkm.Tutors[t] = CLB_MoveTutors.GetItemChecked(t);
            }

            if (!Main.oras)
            {
                return;
            }

            int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
            int   ctr = 0;

            for (int i = 0; i < 4; i++)
            {
                for (int t = 0; t < len[i]; t++)
                {
                    pkm.ORASTutors[i][t] = CLB_OrasTutors.GetItemChecked(ctr++);
                }
            }
        }
예제 #2
0
        private void SavePersonal()
        {
            pkm.HP  = Convert.ToByte(TB_BaseHP.Text);
            pkm.ATK = Convert.ToByte(TB_BaseATK.Text);
            pkm.DEF = Convert.ToByte(TB_BaseDEF.Text);
            pkm.SPE = Convert.ToByte(TB_BaseSPE.Text);
            pkm.SPA = Convert.ToByte(TB_BaseSPA.Text);
            pkm.SPD = Convert.ToByte(TB_BaseSPD.Text);

            pkm.EV_HP  = Convert.ToByte(TB_HPEVs.Text);
            pkm.EV_ATK = Convert.ToByte(TB_ATKEVs.Text);
            pkm.EV_DEF = Convert.ToByte(TB_DEFEVs.Text);
            pkm.EV_SPE = Convert.ToByte(TB_SPEEVs.Text);
            pkm.EV_SPA = Convert.ToByte(TB_SPAEVs.Text);
            pkm.EV_SPD = Convert.ToByte(TB_SPDEVs.Text);

            pkm.CatchRate = Convert.ToByte(TB_CatchRate.Text);
            pkm.EvoStage  = Convert.ToByte(TB_Stage.Text);

            pkm.Types = new[] { CB_Type1.SelectedIndex, CB_Type2.SelectedIndex };
            pkm.Items = new[] { CB_HeldItem1.SelectedIndex, CB_HeldItem2.SelectedIndex, CB_HeldItem3.SelectedIndex };

            pkm.Gender         = Convert.ToByte(TB_Gender.Text);
            pkm.HatchCycles    = Convert.ToByte(TB_HatchCycles.Text);
            pkm.BaseFriendship = Convert.ToByte(TB_Friendship.Text);
            pkm.EXPGrowth      = (byte)CB_EXPGroup.SelectedIndex;
            pkm.EggGroups      = new[] { CB_EggGroup1.SelectedIndex, CB_EggGroup2.SelectedIndex };
            pkm.Abilities      = new[] { CB_Ability1.SelectedIndex, CB_Ability2.SelectedIndex, CB_Ability3.SelectedIndex };

            pkm.FormeSprite = Convert.ToUInt16(TB_FormeSprite.Text);
            pkm.FormeCount  = Convert.ToByte(TB_FormeCount.Text);
            pkm.Color       = (byte)(Convert.ToByte(CB_Color.SelectedIndex) | (Convert.ToByte(TB_RawColor.Text) & 0xF0));
            pkm.BaseEXP     = Convert.ToUInt16(TB_BaseExp.Text);

            decimal.TryParse(TB_Height.Text, out var h);
            decimal.TryParse(TB_Weight.Text, out var w);
            pkm.Height = (int)(h * 100);
            pkm.Weight = (int)(w * 10);

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
            {
                pkm.TMHM[i] = CLB_TMHM.GetItemChecked(i);
            }

            for (int t = 0; t < CLB_MoveTutors.Items.Count; t++)
            {
                pkm.TypeTutors[t] = CLB_MoveTutors.GetItemChecked(t);
            }

            if (!Main.Config.ORAS)
            {
                return;
            }

            int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
            int   ctr = 0;

            for (int i = 0; i < 4; i++)
            {
                for (int t = 0; t < len[i]; t++)
                {
                    pkm.SpecialTutors[i][t] = CLB_ORASTutors.GetItemChecked(ctr++);
                }
            }
        }
예제 #3
0
        private void saveEntry()
        {
            int len = 0;

            if (mode == "XY")
            {
                len = 0x40;
            }
            else if (mode == "ORAS")
            {
                len = 0x50;
            }

            byte[] edits = new byte[len];
            Array.Copy(data, len * entry, edits, 0, len); //edit raw data for easiness's sake
            edits[0] = Convert.ToByte(TB_BaseHP.Text);
            edits[1] = Convert.ToByte(TB_BaseATK.Text);
            edits[2] = Convert.ToByte(TB_BaseDEF.Text);
            edits[3] = Convert.ToByte(TB_BaseSPE.Text);
            edits[4] = Convert.ToByte(TB_BaseSPA.Text);
            edits[5] = Convert.ToByte(TB_BaseSPD.Text);

            ushort evs = 0;

            evs |= (ushort)((Convert.ToByte(TB_HPEVs.Text) & 3) << 0);
            evs |= (ushort)((Convert.ToByte(TB_ATKEVs.Text) & 3) << 2);
            evs |= (ushort)((Convert.ToByte(TB_DEFEVs.Text) & 3) << 4);
            evs |= (ushort)((Convert.ToByte(TB_SPEEVs.Text) & 3) << 6);
            evs |= (ushort)((Convert.ToByte(TB_SPAEVs.Text) & 3) << 8);
            evs |= (ushort)((Convert.ToByte(TB_SPDEVs.Text) & 3) << 10);
            Array.Copy(BitConverter.GetBytes(evs), 0, edits, 0xa, 2);

            edits[6] = (byte)CB_Type1.SelectedIndex;
            edits[7] = (byte)CB_Type2.SelectedIndex;

            edits[8] = Convert.ToByte(TB_CatchRate.Text);
            edits[9] = Convert.ToByte(TB_Stage.Text);

            Array.Copy(BitConverter.GetBytes((ushort)CB_HeldItem1.SelectedIndex), 0, edits, 0xC, 2);
            Array.Copy(BitConverter.GetBytes((ushort)CB_HeldItem2.SelectedIndex), 0, edits, 0xE, 2);
            Array.Copy(BitConverter.GetBytes((ushort)CB_HeldItem3.SelectedIndex), 0, edits, 0x10, 2);

            edits[0x12] = Convert.ToByte(TB_Gender.Text);
            edits[0x13] = Convert.ToByte(TB_HatchCycles.Text);
            edits[0x14] = Convert.ToByte(TB_Friendship.Text);

            edits[0x15] = (byte)CB_EXPGroup.SelectedIndex;

            edits[0x16] = (byte)CB_EggGroup1.SelectedIndex;
            edits[0x17] = (byte)CB_EggGroup2.SelectedIndex;

            edits[0x18] = (byte)CB_Ability1.SelectedIndex;
            edits[0x19] = (byte)CB_Ability2.SelectedIndex;
            edits[0x1A] = (byte)CB_Ability3.SelectedIndex;

            //edits[0x20] = Convert.ToByte(TB_FormeCount.Text);
            //Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(TB_FormeSprite.Text)),0, edits, 0x1E,2);
            byte color = Convert.ToByte(CB_Color.SelectedIndex);

            color      |= (byte)(Convert.ToByte(TB_RawColor.Text) & (byte)0xF0);
            edits[0x21] = color;

            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(TB_BaseExp.Text)), 0, edits, 0x22, 2);

            float height = (float)Convert.ToDouble(TB_Height.Text) * 100;
            float weight = (float)Convert.ToDouble(TB_Weight.Text) * 10;

            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(height)), 0, edits, 0x24, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(weight)), 0, edits, 0x26, 2);

            //TMHM
            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (i * 8 + j < CLB_TMHM.Items.Count)
                    {
                        if (CLB_TMHM.GetItemChecked(i * 8 + j))
                        {
                            edits[0x28 + i] |= (byte)(1 << j);
                        }
                    }
                }
            }

            uint tutors = 0;

            for (int t = 0; t < 8; t++)
            {
                if (t < CLB_MoveTutors.Items.Count && CLB_MoveTutors.GetItemChecked(t))
                {
                    tutors |= (uint)(1 << t);
                }
            }

            Array.Copy(BitConverter.GetBytes(tutors), 0, edits, 0x38, 4);

            if (mode == "ORAS")
            {
                uint[] tutorm = new uint[4];
                int    ofs    = 0;
                for (int j = 0; j < tutor1.Length; j++)
                {
                    if (CLB_OrasTutors.GetItemChecked(ofs++))
                    {
                        tutorm[0] |= (uint)(1 << j);
                    }
                }

                for (int j = 0; j < tutor2.Length; j++)
                {
                    if (CLB_OrasTutors.GetItemChecked(ofs++))
                    {
                        tutorm[1] |= (uint)(1 << j);
                    }
                }

                for (int j = 0; j < tutor3.Length; j++)
                {
                    if (CLB_OrasTutors.GetItemChecked(ofs++))
                    {
                        tutorm[2] |= (uint)(1 << j);
                    }
                }

                for (int j = 0; j < tutor4.Length; j++)
                {
                    if (CLB_OrasTutors.GetItemChecked(ofs++))
                    {
                        tutorm[3] |= (uint)(1 << j);
                    }
                }

                for (int j = 0x40; j < 0x50; j += 4)
                {
                    Array.Copy(BitConverter.GetBytes(tutorm[(j - 0x40) / 4]), 0, edits, j, 4);
                }
            }

            File.WriteAllBytes(paths[entry], edits);
            Array.Copy(edits, 0, data, entry * len, len);
            File.WriteAllBytes(paths[paths.Length - 1], data);
        }