Ejemplo n.º 1
0
 private static Image getSprite(SaveFile SAV)
 {
     string file = "tr_00";
     if (SAV.Generation == 6 && (SAV.ORAS || SAV.ORASDEMO))
         file = "tr_" + SAV.MultiplayerSpriteID.ToString("00");
     return Resources.ResourceManager.GetObject(file) as Image;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks a <see cref="PKM"/> file for compatibility to the <see cref="SaveFile"/>.
 /// </summary>
 /// <param name="sav"><see cref="SaveFile"/> that is being checked.</param>
 /// <param name="pkm"><see cref="PKM"/> that is being tested for compatibility.</param>
 /// <returns></returns>
 public static IReadOnlyList <string> IsPKMCompatible(this SaveFile sav, PKM pkm)
 {
     return(sav.GetSaveFileErrata(pkm, GameInfo.Strings));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Checks if the <see cref="PKM"/> is compatible with the input <see cref="SaveFile"/>, and makes any necessary modifications to force compatibility.
 /// </summary>
 /// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
 /// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
 /// <param name="sav">Save File target that the PKM will be injected.</param>
 /// <param name="pk">PKM input that is to be injected into the Save File.</param>
 /// <returns>Indication whether or not the PKM is compatible.</returns>
 public static bool IsPKMCompatibleWithModifications(this SaveFile sav, PKM pk) => PKMConverter.IsPKMCompatibleWithModifications(pk, sav);
Ejemplo n.º 4
0
 /// <summary>
 /// Gets a blank file for the save file. If the template path exists, a template load will be attempted.
 /// </summary>
 /// <param name="sav">Save File to fetch a template for</param>
 /// <returns>Template if it exists, or a blank <see cref="PKM"/> from the <see cref="sav"/></returns>
 private static PKM LoadTemplateInternal(this SaveFile sav) => sav.BlankPKM;
Ejemplo n.º 5
0
 public Zukan7(SaveFile sav, int dex, int langflag) : base(sav, dex, langflag)
 {
     DexFormIndexFetcher = SAV is SAV7USUM ? (Func <int, int, int, int>)DexFormUtil.GetDexFormIndexUSUM : DexFormUtil.GetDexFormIndexSM;
     LoadDexList();
     Debug.Assert(!SAV.Exportable || BitConverter.ToUInt32(SAV.Data, PokeDex) == MAGIC);
 }
Ejemplo n.º 6
0
 public static PKM[] GetExtraPKM(this SaveFile sav) => sav.GetExtraPKM(sav.GetExtraSlots());
Ejemplo n.º 7
0
Archivo: Main.cs Proyecto: kwsch/PKHeX
        private void openSAV(SaveFile sav, string path)
        {
            if (sav == null || sav.Version == GameVersion.Invalid)
            { WinFormsUtil.Error("Invalid save file loaded. Aborting.", path); return; }

            if (!string.IsNullOrEmpty(path)) // If path is null, this is the default save
            {
                if (sav.RequiresMemeCrypto && !MemeCrypto.CanUseMemeCrypto())
                {
                    WinFormsUtil.Error("Your platform does not support the required cryptography components.", "In order to be able to save your changes, you must either upgrade to a newer version of Windows or disable FIPS compliance mode.");
                    // Don't abort loading; user can still view save and fix checksum on another platform.
                }
            }            

            // Finish setting up the save file.
            if (sav.IndeterminateGame && sav.Generation == 3)
            {
                // Hacky cheats invalidated the Game Code value.
                var drGame = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
                    "Unknown Gen3 Game Detected. Select Origins:",
                    "Yes: Ruby / Sapphire" + Environment.NewLine +
                    "No: Emerald" + Environment.NewLine +
                    "Cancel: FireRed / LeafGreen");

                switch (drGame) // Reset save file info
                {
                    case DialogResult.Yes: sav = new SAV3(sav.BAK, GameVersion.RS); break;
                    case DialogResult.No: sav = new SAV3(sav.BAK, GameVersion.E); break;
                    case DialogResult.Cancel: sav = new SAV3(sav.BAK, GameVersion.FRLG); break;
                    default: return;
                }
            }
            if (sav.IndeterminateLanguage)
            {
                // Japanese Save files are different. Get isJapanese
                var drJP = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, $"{sav.Version} Save File detected. Select language...", 
                    "Yes: International" + Environment.NewLine + "No: Japanese");
                if (drJP == DialogResult.Cancel)
                    return;

                sav.Japanese = drJP == DialogResult.No;
            }
            if (sav.IndeterminateSubVersion && sav.Version == GameVersion.FRLG)
            {
                var drFRLG = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, $"{sav.Version} detected. Select version...",
                    "Yes: FireRed" + Environment.NewLine + "No: LeafGreen");
                if (drFRLG == DialogResult.Cancel)
                    return;

                sav.Personal = drFRLG == DialogResult.Yes ? PersonalTable.FR : PersonalTable.LG;
            }

            // clean fields
            PKM pk = preparePKM();
            populateFields(SAV.BlankPKM);
            SAV = sav;

            string title = $"PKH{(HaX ? "a" : "e")}X ({Resources.ProgramVersion}) - " + $"SAV{SAV.Generation}: ";
            if (path != null) // Actual save file
            {
                SAV.FilePath = Path.GetDirectoryName(path);
                SAV.FileName = Path.GetExtension(path) == ".bak"
                    ? Path.GetFileName(path).Split(new[] { " [" }, StringSplitOptions.None)[0]
                    : Path.GetFileName(path);
                Text = title + $"{Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName))}"; // more descriptive

                // If backup folder exists, save a backup.
                string backupName = Path.Combine(BackupPath, Util.CleanFileName(SAV.BAKName));
                if (SAV.Exportable && Directory.Exists(BackupPath) && !File.Exists(backupName))
                    File.WriteAllBytes(backupName, SAV.BAK);

                GB_SAVtools.Visible = true;
            }
            else // Blank save file
            {
                SAV.FilePath = null;
                SAV.FileName = "Blank Save File";
                Text = title + $"{SAV.FileName} [{SAV.OT} ({SAV.Version})]";

                GB_SAVtools.Visible = false;
            }
            Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable;

            // Close subforms that are save dependent
            Type[] f = { typeof(SAV_BoxViewer), typeof(f2_Text) };
            foreach (var form in Application.OpenForms.Cast<Form>().Where(form => f.Contains(form.GetType())).ToArray())
                form.Close();

            setBoxNames();   // Display the Box Names
            if (SAV.HasBox)
            {
                int startBox = path == null ? 0 : SAV.CurrentBox; // FF if BattleBox
                if (startBox > SAV.BoxCount - 1) { tabBoxMulti.SelectedIndex = 1; CB_BoxSelect.SelectedIndex = 0; }
                else { tabBoxMulti.SelectedIndex = 0; CB_BoxSelect.SelectedIndex = startBox; }
            }
            setPKXBoxes();   // Reload all of the PKX Windows

            bool WindowTranslationRequired = false;

            // Hide content if not present in game.
            GB_SUBE.Visible = SAV.HasSUBE;
            PB_Locked.Visible = SAV.HasBattleBox && SAV.BattleBoxLocked;

            if (!SAV.HasBox && tabBoxMulti.TabPages.Contains(Tab_Box))
                tabBoxMulti.TabPages.Remove(Tab_Box);
            else if (SAV.HasBox && !tabBoxMulti.TabPages.Contains(Tab_Box))
            {
                tabBoxMulti.TabPages.Insert(0, Tab_Box);
                WindowTranslationRequired = true;
            }
            Menu_LoadBoxes.Enabled = Menu_DumpBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.HasBox;

            int BoxTab = tabBoxMulti.TabPages.IndexOf(Tab_Box);
            int PartyTab = tabBoxMulti.TabPages.IndexOf(Tab_PartyBattle);

            if (!SAV.HasParty && tabBoxMulti.TabPages.Contains(Tab_PartyBattle))
                tabBoxMulti.TabPages.Remove(Tab_PartyBattle);
            else if (SAV.HasParty && !tabBoxMulti.TabPages.Contains(Tab_PartyBattle))
            {
                int index = BoxTab;
                if (index < 0)
                    index = -1;
                tabBoxMulti.TabPages.Insert(index + 1, Tab_PartyBattle);
                WindowTranslationRequired = true;
            }

            if (!SAV.HasDaycare && tabBoxMulti.TabPages.Contains(Tab_Other))
                tabBoxMulti.TabPages.Remove(Tab_Other);
            else if (SAV.HasDaycare && !tabBoxMulti.TabPages.Contains(Tab_Other))
            {
                int index = PartyTab;
                if (index < 0)
                    index = BoxTab;
                if (index < 0)
                    index = -1;
                tabBoxMulti.TabPages.Insert(index + 1, Tab_Other);
                WindowTranslationRequired = true;
            }

            if (path != null) // Actual save file
            {
                PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.HasBattleBox;
                GB_Daycare.Visible = SAV.HasDaycare;
                GB_Fused.Visible = SAV.HasFused;
                GB_GTS.Visible = SAV.HasGTS;
                B_OpenSecretBase.Enabled = SAV.HasSecretBase;
                B_OpenPokepuffs.Enabled = SAV.HasPuff;
                B_OpenPokeBeans.Enabled = SAV.Generation == 7;
                B_OpenZygardeCells.Enabled = SAV.Generation == 7;
                B_OUTPasserby.Enabled = SAV.HasPSS;
                B_OpenBoxLayout.Enabled = SAV.HasBoxWallpapers;
                B_OpenWondercards.Enabled = SAV.HasWondercards;
                B_OpenSuperTraining.Enabled = SAV.HasSuperTrain;
                B_OpenHallofFame.Enabled = SAV.HasHoF;
                B_OpenOPowers.Enabled = SAV.HasOPower;
                B_OpenPokedex.Enabled = SAV.HasPokeDex;
                B_OpenBerryField.Enabled = SAV.HasBerryField && SAV.XY;
                B_OpenPokeblocks.Enabled = SAV.HasPokeBlock;
                B_JPEG.Visible = SAV.HasJPEG;
                B_OpenEventFlags.Enabled = SAV.HasEvents;
                B_OpenLinkInfo.Enabled = SAV.HasLink;
                B_CGearSkin.Enabled = SAV.Generation == 5;

                B_OpenTrainerInfo.Enabled = B_OpenItemPouch.Enabled = SAV.HasParty; // Box RS
            }
            GB_SAVtools.Visible = (path != null) && FLP_SAVtools.Controls.Cast<Control>().Any(c => c.Enabled);
            foreach (Control c in FLP_SAVtools.Controls.Cast<Control>())
                c.Visible = c.Enabled;


            // Generational Interface
            byte[] extraBytes = new byte[1];
            Tip1.RemoveAll(); Tip2.RemoveAll(); Tip3.RemoveAll(); // TSV/PSV

            FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = SAV.Generation >= 6;
            Label_EncryptionConstant.Visible = BTN_RerollEC.Visible = TB_EC.Visible = SAV.Generation >= 6;
            GB_nOT.Visible = GB_RelearnMoves.Visible = BTN_Medals.Visible = BTN_History.Visible = SAV.Generation >= 6;
            PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = SAV.Generation >= 6;

            PB_MarkPentagon.Visible = SAV.Generation >= 6;
            PB_MarkAlola.Visible = SAV.Generation >= 7;
            TB_Secure1.Visible = TB_Secure2.Visible = L_Secure1.Visible = L_Secure2.Visible = SAV.Exportable && SAV.Generation >= 6;
            TB_GameSync.Visible = L_GameSync.Visible = SAV.Exportable && SAV.Generation >= 6;

            FLP_NSparkle.Visible = L_NSparkle.Visible = CHK_NSparkle.Visible = SAV.Generation == 5;

            CB_Form.Visible = Label_Form.Visible = CHK_AsEgg.Visible = GB_EggConditions.Visible = PB_Mark5.Visible = PB_Mark6.Visible = SAV.Generation >= 4;

            DEV_Ability.Enabled = DEV_Ability.Visible = SAV.Generation > 3 && HaX;
            CB_Ability.Visible = !DEV_Ability.Enabled && SAV.Generation >= 3;
            FLP_Nature.Visible = SAV.Generation >= 3;
            FLP_Ability.Visible = SAV.Generation >= 3;
            FLP_Language.Visible = SAV.Generation >= 3;
            GB_ExtraBytes.Visible = GB_ExtraBytes.Enabled = SAV.Generation >= 3;
            GB_Markings.Visible = SAV.Generation >= 3;
            BTN_Ribbons.Visible = SAV.Generation >= 3;
            CB_HPType.Enabled = CB_Form.Enabled = SAV.Generation >= 3;
            BTN_RerollPID.Visible = Label_PID.Visible = TB_PID.Visible = Label_SID.Visible = TB_SID.Visible = SAV.Generation >= 3;

            FLP_FriendshipForm.Visible = SAV.Generation >= 2;
            FLP_HeldItem.Visible = SAV.Generation >= 2;
            CHK_IsEgg.Visible = Label_Gender.Visible = SAV.Generation >= 2;
            FLP_PKRS.Visible = FLP_EggPKRSRight.Visible = SAV.Generation >= 2;
            Label_OTGender.Visible = SAV.Generation >= 2;

            if (SAV.Generation == 1)
                Label_IsShiny.Visible = false;

            if (SAV.Version == GameVersion.BATREV)
            {
                L_SaveSlot.Visible = CB_SaveSlot.Visible = true;
                CB_SaveSlot.DisplayMember = "Text"; CB_SaveSlot.ValueMember = "Value";
                CB_SaveSlot.DataSource = new BindingSource(((SAV4BR) SAV).SaveSlots.Select(i => new ComboItem
                {
                    Text = ((SAV4BR) SAV).SaveNames[i],
                    Value = i
                }).ToList(), null);
                CB_SaveSlot.SelectedValue = ((SAV4BR)SAV).CurrentSlot;
            }
            else
                L_SaveSlot.Visible = CB_SaveSlot.Visible = false;
            
            FLP_Purification.Visible = FLP_ShadowID.Visible = SAV.Version == GameVersion.COLO || SAV.Version == GameVersion.XD;
            NUD_ShadowID.Maximum = SAV.MaxShadowID;

            // HaX override, needs to be after DEV_Ability enabled assignment.
            TB_AbilityNumber.Visible = SAV.Generation >= 6 && DEV_Ability.Enabled;

            // Met Tab
            FLP_MetDate.Visible = SAV.Generation >= 4;
            FLP_Fateful.Visible = FLP_Ball.Visible = FLP_OriginGame.Visible = SAV.Generation >= 3;
            FLP_MetLocation.Visible = FLP_MetLevel.Visible = SAV.Generation >= 2;
            FLP_TimeOfDay.Visible = SAV.Generation == 2;

            // Stats
            FLP_StatsTotal.Visible = SAV.Generation >= 3;
            FLP_Characteristic.Visible = SAV.Generation >= 3;
            FLP_HPType.Visible = SAV.Generation >= 2;

            PAN_Contest.Visible = SAV.Generation >= 3;

            // Second daycare slot
            SlotPictureBoxes[43].Visible = SAV.Generation >= 2;

            if (sav.Generation == 1)
            {
                FLP_SpD.Visible = false;
                Label_SPA.Visible = false;
                Label_SPC.Visible = true;
                TB_HPIV.Enabled = false;
                MaskedTextBox[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV };
                foreach (var ctrl in evControls)
                {
                    ctrl.Mask = "00000";
                    ctrl.Size = Stat_HP.Size;
                }
            }
            else if (sav.Generation == 2)
            {
                FLP_SpD.Visible = true;
                Label_SPA.Visible = true;
                Label_SPC.Visible = false;
                TB_SPDEV.Enabled = TB_SPDIV.Enabled = false;
                TB_HPIV.Enabled = false;
                MaskedTextBox[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV };
                foreach (var ctrl in evControls)
                {
                    ctrl.Mask = "00000";
                    ctrl.Size = Stat_HP.Size;
                }
            }
            else
            {
                FLP_SpD.Visible = true;
                Label_SPA.Visible = true;
                Label_SPC.Visible = false;
                TB_SPDEV.Enabled = TB_SPDIV.Enabled = true;
                TB_HPIV.Enabled = true;
                MaskedTextBox[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV };
                foreach (var ctrl in evControls)
                {
                    ctrl.Mask = "000";
                    ctrl.Size = TB_ExtraByte.Size;
                }
            }

            // Recenter PKM SubEditors
            FLP_PKMEditors.Location = new Point((Tab_OTMisc.Width - FLP_PKMEditors.Width) / 2, FLP_PKMEditors.Location.Y);

            bool init = fieldsInitialized;
            fieldsInitialized = fieldsLoaded = false;

            switch (SAV.Generation)
            {
                case 6:
                    TB_GameSync.Enabled = SAV.GameSyncID != null;
                    TB_GameSync.MaxLength = SAV.GameSyncIDSize;
                    TB_GameSync.Text = (SAV.GameSyncID ?? 0.ToString()).PadLeft(SAV.GameSyncIDSize, '0');
                    TB_Secure1.Text = SAV.Secure1?.ToString("X16");
                    TB_Secure2.Text = SAV.Secure2?.ToString("X16");
                    break;
                case 7:
                    TB_GameSync.Enabled = SAV.GameSyncID != null;
                    TB_GameSync.MaxLength = SAV.GameSyncIDSize;
                    TB_GameSync.Text = (SAV.GameSyncID ?? 0.ToString()).PadLeft(SAV.GameSyncIDSize, '0');
                    TB_Secure1.Text = SAV.Secure1?.ToString("X16");
                    TB_Secure2.Text = SAV.Secure2?.ToString("X16");
                    break;
            }
            pkm = pkm.GetType() != SAV.PKMType ? SAV.BlankPKM : pk;
            if (pkm.Format < 3)
                pkm = SAV.BlankPKM;
            populateFilteredDataSources();
            populateFields(pkm);
            fieldsInitialized |= init;

            // SAV Specific Limits
            TB_OT.MaxLength = SAV.OTLength;
            TB_OTt2.MaxLength = SAV.OTLength;
            TB_Nickname.MaxLength = SAV.NickLength;

            // Hide Unused Tabs
            if (SAV.Generation == 1 && tabMain.TabPages.Contains(Tab_Met))
                tabMain.TabPages.Remove(Tab_Met);
            else if (SAV.Generation != 1 && !tabMain.TabPages.Contains(Tab_Met))
            {
                tabMain.TabPages.Insert(1, Tab_Met);
                WindowTranslationRequired = true;
            }

            // Common HaX Interface
            CHK_HackedStats.Enabled = CHK_HackedStats.Visible = MT_Level.Enabled = MT_Level.Visible = MT_Form.Enabled = MT_Form.Visible = HaX;
            TB_Level.Visible = !HaX;

            // Setup PKM Preparation/Extra Bytes
            setPKMFormatMode(SAV.Generation, SAV.Version);

            // pk2 save files do not have an Origin Game stored. Prompt the met location list to update.
            if (SAV.Generation == 2)
                updateOriginGame(null, null);

            // Refresh PK* conversion info
            PKMConverter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender);

            if (WindowTranslationRequired) // force update -- re-added controls may be untranslated
                WinFormsUtil.TranslateInterface(this, curlanguage);
            
            // No changes made yet
            UndoStack.Clear(); Menu_Undo.Enabled = false;
            RedoStack.Clear(); Menu_Redo.Enabled = false;

            // Indicate audibly the save is loaded
            SystemSounds.Beep.Play();
        }
Ejemplo n.º 8
0
Archivo: Main.cs Proyecto: kwsch/PKHeX
 // PKM Get Set
 public static PKM getPKMfromSource(SaveFile SAV)
 {
     int o = slotSourceOffset;
     return SourceParty ? SAV.getPartySlot(o) : SAV.getStoredSlot(o);
 }
Ejemplo n.º 9
0
 public SaveFileMetadata(SaveFile sav) => SAV = sav;
Ejemplo n.º 10
0
 public PlayTime8(SaveFile sav, SCBlock block) : base(sav, block.Data)
 {
 }
Ejemplo n.º 11
0
 private Zukan7(SaveFile sav, int dex, int langflag, Func <int, int, int, int> form) : base(sav, dex, langflag)
 {
     DexFormIndexFetcher = form;
     FormBaseSpecies     = GetFormIndexBaseSpeciesList();
     Debug.Assert(!SAV.State.Exportable || BitConverter.ToUInt32(SAV.Data, PokeDex) == MAGIC);
 }
Ejemplo n.º 12
0
 public override void CopyTo(SaveFile sav) => sav.SetData(((SAV4)sav).General, Data, DataOffset);
Ejemplo n.º 13
0
 public Puff6(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
Ejemplo n.º 14
0
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
            {
                return(null);
            }

            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1);
            PK6 pk           = new PK6
            {
                Species            = Species,
                HeldItem           = HeldItem,
                TID                = TID,
                SID                = SID,
                Met_Level          = currentLevel,
                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(Level, 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,

                EVs = EVs,
            };

            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);

            pk.MetDate = Date ?? DateTime.Now;

            if (SAV.Generation > 6) // Gen7
            {
                pk.Version = (int)GameVersion.OR;
            }

            if (pk.CurrentHandler == 0) // OT
            {
                pk.OT_Memory    = 3;
                pk.OT_TextVar   = 9;
                pk.OT_Intensity = 1;
                pk.OT_Feeling   = Util.rand.Next(0, 9);
            }
            else
            {
                pk.HT_Memory     = 3;
                pk.HT_TextVar    = 9;
                pk.HT_Intensity  = 1;
                pk.HT_Feeling    = Util.rand.Next(0, 9);
                pk.HT_Friendship = pk.OT_Friendship;
            }
            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.AO.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);
        }
Ejemplo n.º 15
0
 public SlotEditor(SaveFile sav) => SAV = sav;
Ejemplo n.º 16
0
 public PlayTime7b(SaveFile sav) : base(sav)
 {
     Offset = ((SAV7b)sav).GetBlockOffset(BelugaBlockIndex.PlayTime);
 }
Ejemplo n.º 17
0
Archivo: PGT.cs Proyecto: kwsch/PKHeX
 public override PKM convertToPKM(SaveFile SAV)
 {
     return Gift.convertToPKM(SAV);
 }
Ejemplo n.º 18
0
 public GameTime8(SaveFile sav, int offset) : base(sav) => Offset = offset;
Ejemplo n.º 19
0
Archivo: Main.cs Proyecto: kwsch/PKHeX
            public static void setPKMtoSource(SaveFile SAV, PKM pk)
            {
                int o = slotSourceOffset;
                if (!SourceParty)
                { SAV.setStoredSlot(pk, o); return; }

                if (pk.Species == 0) // Empty Slot
                { SAV.deletePartySlot(slotSourceSlotNumber-30); return; }

                if (pk.Stat_HPMax == 0) // Without Stats (Box)
                {
                    pk.setStats(pk.getStats(SAV.Personal.getFormeEntry(pk.Species, pk.AltForm)));
                    pk.Stat_Level = pk.CurrentLevel;
                }
                SAV.setPartySlot(pk, o);
            }
Ejemplo n.º 20
0
 public SlotChangelog(SaveFile sav) => SAV = sav;
Ejemplo n.º 21
0
 private static Image getWallpaper(SaveFile SAV, int box)
 {
     string s = BoxWallpaper.getWallpaper(SAV, box);
     return (Bitmap)(Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy);
 }
Ejemplo n.º 22
0
 public MyStatus6XY(SaveFile sav, int offset) : base(sav, offset)
 {
 }
Ejemplo n.º 23
0
        private const int Berry    = 0xA68; // 4

        public MyItem6XY(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
Ejemplo n.º 24
0
 public ItemInfo6(SaveFile sav, int offset) : base(sav) => Offset = offset;
Ejemplo n.º 25
0
Archivo: PGF.cs Proyecto: kwsch/PKHeX
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
                return null;

            DateTime dt = DateTime.Now;
            if (Day == 0)
            {
                Day = (byte)dt.Day;
                Month = (byte)dt.Month;
                Year = (byte)dt.Year;
            }
            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1);
            PK5 pk = new PK5
            {
                Species = Species,
                HeldItem = HeldItem,
                Met_Level = currentLevel,
                Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25),
                Gender = PersonalTable.B2W2[Species].Gender == 255 ? 2 : (Gender != 2 ? Gender : PersonalTable.B2W2[Species].RandomGender),
                AltForm = Form,
                Version = OriginGame == 0 ? new[] {20, 21, 22, 23}[Util.rnd32() & 0x3] : OriginGame,
                Language = Language == 0 ? SAV.Language : Language,
                Ball = Ball,
                Move1 = Move1,
                Move2 = Move2,
                Move3 = Move3,
                Move4 = Move4,
                Met_Location = MetLocation,
                MetDate = Date,
                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,

                EXP = PKX.getEXP(Level, 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.B2W2[Species].BaseFriendship,
                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) // User's
            {
                pk.TID = SAV.TID;
                pk.SID = SAV.SID;
                pk.OT_Name = SAV.OT;
                pk.OT_Gender = 1; // Red PKHeX OT
            }
            else
            {
                pk.TID = IsEgg ? SAV.TID : TID;
                pk.SID = IsEgg ? SAV.SID : SID;
                pk.OT_Name = OT.Length > 0 ? OT : SAV.OT;
                pk.OT_Gender = OTGender % 2; // %2 just in case?
            }
            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];
            for (int i = 0; i < IVs.Length; i++)
                finalIVs[i] = IVs[i] == 0xFF ? (int)(Util.rnd32() & 0x1F) : IVs[i];
            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.HiddenAbility = av == 2;
            pk.Ability = PersonalTable.B2W2.getAbilities(Species, pk.AltForm)[av];

            if (PID != 0) 
                pk.PID = PID;
            else
            {
                pk.PID = Util.rnd32();
                // Force Ability
                if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000;
                // Force Gender
                do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid());
                if (PIDType == 2) // Force Shiny
                {
                    uint gb = pk.PID & 0xFF;
                    pk.PID = (uint)(((gb ^ pk.TID ^ pk.SID) & 0xFFFE) << 16) | gb;
                    if (av == 0) pk.PID &= 0xFFFEFFFE; else pk.PID |= 0x10001;
                }
                else if (PIDType != 1) // Force Not Shiny
                {
                    if (((pk.PID >> 16) ^ (pk.PID & 0xffff) ^ pk.SID ^ pk.TID) < 8)
                        pk.PID ^= 0x80000000;
                }
            }

            if (IsEgg)
            {
                // pk.IsEgg = true;
                pk.EggMetDate = Date;
                // Force hatch
                pk.IsEgg = false;
                pk.Met_Location = 4; // Nuvema Town
            }

            pk.RefreshChecksum();
            return pk;
        }
Ejemplo n.º 26
0
 public virtual void CopyChangesFrom(SaveFile sav) => SetData(sav.Data, 0);
Ejemplo n.º 27
0
 public MyStatus6(SaveFile sav, int offset) : base(sav) => Offset = offset;
Ejemplo n.º 28
0
 public RaidSpawnList8(SaveFile sav, SCBlock block, int legal) : base(sav, block.Data)
 {
     CountAll  = block.Data.Length / RaidSpawnDetail.SIZE;
     CountUsed = legal;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Gets a blank file for the save file. If the template path exists, a template load will be attempted.
 /// </summary>
 /// <param name="sav">Save File to fetch a template for</param>
 /// <returns>Template if it exists, or a blank <see cref="PKM"/> from the <see cref="sav"/></returns>
 public static PKM LoadTemplate(this SaveFile sav) => sav.BlankPKM;
Ejemplo n.º 30
0
 public RaidSpawnList8(SaveFile sav, SCBlock block) : base(sav, block.Data)
 {
 }
Ejemplo n.º 31
0
        public Zukan5(SaveFile sav, int dex, int langflag) : base(sav, dex, langflag)
        {
            var wrap = SAV is SAV5BW ? DexFormUtil.GetDexFormIndexBW : (Func <int, int, int>)DexFormUtil.GetDexFormIndexB2W2;

            DexFormIndexFetcher = (spec, form, _) => wrap(spec, form);
        }
Ejemplo n.º 32
0
 private Zukan7(SaveFile sav, int dex, int langflag, Func <int, int, int, int> form) : base(sav, dex, langflag)
 {
     DexFormIndexFetcher = form;
     FormBaseSpecies     = GetFormIndexBaseSpeciesList();
     Debug.Assert(!SAV.State.Exportable || ReadUInt32LittleEndian(SAV.Data.AsSpan(PokeDex)) == MAGIC);
 }
Ejemplo n.º 33
0
Archivo: PGT.cs Proyecto: kwsch/PKHeX
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
                return null;

            PK4 pk4 = new PK4(PK.Data);
            if (!IsHatched && Detail == 0)
            {
                pk4.OT_Name = SAV.OT;
                pk4.TID = SAV.TID;
                pk4.SID = SAV.SID;
                pk4.OT_Gender = SAV.Gender;
            }
            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 || IsManaphyEgg) // Create Nonshiny
            {
                uint pid1 = PKX.LCRNG(ref seed) >> 16;
                uint pid2 = PKX.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 = PKX.LCRNG(ref seed) >> 16;
                uint iv2 = PKX.LCRNG(ref seed) >> 16;
                pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF;
            }

            // Generate Met Info
            if (IsPokémon)
            {
                pk4.Met_Location = pk4.Egg_Location + 3000;
                pk4.Egg_Location = 0;
                pk4.MetDate = DateTime.Now;
                pk4.IsEgg = false;
            }
            else
            {
                pk4.Egg_Location = pk4.Egg_Location + 3000;
                pk4.MetDate = DateTime.Now;
                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 = PKX.getUnownForm(pk4.PID);
            if (IsEgg || IsManaphyEgg)
                pk4.IsEgg = true;

            pk4.RefreshChecksum();
            return pk4;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Loads a folder of files to the <see cref="SaveFile"/>.
        /// </summary>
        /// <param name="sav"><see cref="SaveFile"/> to load folder to.</param>
        /// <param name="files">Files to load <see cref="PKM"/> files from.</param>
        /// <param name="result">Result message from the method.</param>
        /// <param name="boxStart">First box to start loading to. All prior boxes are not modified.</param>
        /// <param name="boxClear">Instruction to clear boxes after the starting box.</param>
        /// <param name="overwrite">Overwrite existing full slots. If true, will only overwrite empty slots.</param>
        /// <param name="noSetb">Bypass option to not modify <see cref="PKM"/> properties when setting to Save File.</param>
        /// <returns>Count of files imported.</returns>
        public static int LoadBoxes(this SaveFile sav, IEnumerable <string> files, out string result, int boxStart = 0, bool boxClear = false, bool overwrite = false, PKMImportSetting noSetb = PKMImportSetting.UseDefault)
        {
            var pks = GetPossiblePKMsFromPaths(sav, files);

            return(sav.LoadBoxes(pks, out result, boxStart, boxClear, overwrite, noSetb));
        }
Ejemplo n.º 35
0
 public abstract PKM convertToPKM(SaveFile SAV);
Ejemplo n.º 36
0
        /// <summary>
        /// Loads a folder of files to the <see cref="SaveFile"/>.
        /// </summary>
        /// <param name="sav"><see cref="SaveFile"/> to load folder to.</param>
        /// <param name="encounters">Encounters to create <see cref="PKM"/> files from.</param>
        /// <param name="result">Result message from the method.</param>
        /// <param name="boxStart">First box to start loading to. All prior boxes are not modified.</param>
        /// <param name="boxClear">Instruction to clear boxes after the starting box.</param>
        /// <param name="overwrite">Overwrite existing full slots. If true, will only overwrite empty slots.</param>
        /// <param name="noSetb">Bypass option to not modify <see cref="PKM"/> properties when setting to Save File.</param>
        /// <returns>Count of files imported.</returns>
        public static int LoadBoxes(this SaveFile sav, IEnumerable <IEncounterable> encounters, out string result, int boxStart = 0, bool boxClear = false, bool overwrite = false, PKMImportSetting noSetb = PKMImportSetting.UseDefault)
        {
            var pks = encounters.Select(z => z.ConvertToPKM(sav));

            return(sav.LoadBoxes(pks, out result, boxStart, boxClear, overwrite, noSetb));
        }
Ejemplo n.º 37
0
Archivo: Main.cs Proyecto: kwsch/PKHeX
 public static PKM getPKMfromDestination(SaveFile SAV)
 {
     int o = slotDestinationOffset;
     return DestinationParty ? SAV.getPartySlot(o) : SAV.getStoredSlot(o);
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Loads a folder of files to the <see cref="SaveFile"/>.
        /// </summary>
        /// <param name="SAV"><see cref="SaveFile"/> to load folder to.</param>
        /// <param name="filepaths">Files to load <see cref="PKM"/> files from.</param>
        /// <param name="result">Result message from the method.</param>
        /// <param name="boxStart">First box to start loading to. All prior boxes are not modified.</param>
        /// <param name="boxClear">Instruction to clear boxes after the starting box.</param>
        /// <param name="overwrite">Overwrite existing full slots. If true, will only overwrite empty slots.</param>
        /// <param name="noSetb">Bypass option to not modify <see cref="PKM"/> properties when setting to Save File.</param>
        /// <returns>True if any files are imported.</returns>
        public static bool LoadBoxes(this SaveFile SAV, IEnumerable <string> filepaths, out string result, int boxStart = 0, bool boxClear = false, bool overwrite = false, bool?noSetb = null)
        {
            var pks = GetPossiblePKMsFromPaths(SAV, filepaths);

            return(SAV.LoadBoxes(pks, out result, boxStart, boxClear, overwrite, noSetb));
        }
Ejemplo n.º 39
0
Archivo: Main.cs Proyecto: kwsch/PKHeX
            public static void setPKMtoDestination(SaveFile SAV, PKM pk)
            {
                int o = slotDestinationOffset;
                if (!DestinationParty)
                { SAV.setStoredSlot(pk, o); return; }

                if (30 + SAV.PartyCount < slotDestinationSlotNumber)
                {
                    o = SAV.getPartyOffset(SAV.PartyCount);
                    slotDestinationSlotNumber = 30 + SAV.PartyCount;
                }
                if (pk.Stat_HPMax == 0) // Without Stats (Box/File)
                {
                    pk.setStats(pk.getStats(SAV.Personal.getFormeEntry(pk.Species, pk.AltForm)));
                    pk.Stat_Level = pk.CurrentLevel;
                }
                SAV.setPartySlot(pk, o);
            }
Ejemplo n.º 40
0
        /// <summary>
        /// Loads a folder of files to the <see cref="SaveFile"/>.
        /// </summary>
        /// <param name="SAV"><see cref="SaveFile"/> to load folder to.</param>
        /// <param name="gifts">Gifts to load <see cref="PKM"/> files from.</param>
        /// <param name="result">Result message from the method.</param>
        /// <param name="boxStart">First box to start loading to. All prior boxes are not modified.</param>
        /// <param name="boxClear">Instruction to clear boxes after the starting box.</param>
        /// <param name="overwrite">Overwrite existing full slots. If true, will only overwrite empty slots.</param>
        /// <param name="noSetb">Bypass option to not modify <see cref="PKM"/> properties when setting to Save File.</param>
        /// <returns>True if any files are imported.</returns>
        public static bool LoadBoxes(this SaveFile SAV, IEnumerable <MysteryGift> gifts, out string result, int boxStart = 0, bool boxClear = false, bool overwrite = false, bool?noSetb = null)
        {
            var pks = gifts.Select(z => z.ConvertToPKM(SAV));

            return(SAV.LoadBoxes(pks, out result, boxStart, boxClear, overwrite, noSetb));
        }
Ejemplo n.º 41
0
Archivo: WC7.cs Proyecto: kwsch/PKHeX
        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,

                EVs = EVs,
            };
            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;
        }
Ejemplo n.º 42
0
 public SavePreview(SaveFile sav, string parent, string path)
 {
     Save     = sav;
     Folder   = parent;
     FilePath = path;
 }