Пример #1
0
        public PKM convertPK1toPK7()
        {
            if (Format != 1)
            {
                return(null);
            }
            if (Species > 151)
            {
                return(null);
            }

            var pk = new PK7();

            TransferPropertiesWithReflection(this, pk);
            pk.EVs    = new int[6];
            pk.Nature = IVs.Sum() % 25;
            pk.IVs    = new[] { 31, 31, 31, 31, 31, 31 };
            pk.RefreshChecksum();
            if (!IsNicknamed)
            {
                pk.Nickname = Nickname.ToLower();
            }
            pk.Version = -1;
            pk.Ability = PersonalTable.SM[Species].Abilities[0];
            do
            {
                PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID);
            } while (!IsShiny);
            return(pk);
        }
Пример #2
0
        public PK7 convertToPK7()
        {
            PK7 pk7 = new PK7(Data)
            {
                Markings = Markings,       // Clears old Super Training Bag & Hits Remaining
                Data     = { [0x2A] = 0 }, // Clears old Marking Value
            };

            switch (AbilityNumber)
            {
            case 1:
            case 2:
            case 4:                                           // Valid Ability Numbers
                int index = AbilityNumber >> 1;
                if (PersonalInfo.Abilities[index] == Ability) // correct pair
                {
                    pk7.Ability = pk7.PersonalInfo.Abilities[index];
                }
                break;
            }

            pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm
            pk7.Geo1_Country = PKMConverter.Country;
            pk7.Geo1_Region  = PKMConverter.Region;

            // Bank-accurate data zeroing
            for (var i = 0x94; i < 0x9E; i++)
            {
                pk7.Data[i] = 0;                               /* Geolocations. */
            }
            for (var i = 0xAA; i < 0xB0; i++)
            {
                pk7.Data[i] = 0;                               /* Unused/Amie Fullness & Enjoyment. */
            }
            for (var i = 0xE4; i < 0xE8; i++)
            {
                pk7.Data[i] = 0;    /* Unused. */
            }
            pk7.Data[0x72] &= 0xFC; /* Clear lower two bits of Super training flags. */
            pk7.Data[0xDE]  = 0;    /* Gen IV encounter type. */

            // Fix Checksum
            pk7.RefreshChecksum();

            return(pk7); // Done!
        }
Пример #3
0
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
            {
                return(null);
            }

            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32() % 100 + 1);
            int metLevel     = MetLevel > 0 ? MetLevel : currentLevel;
            var pi           = PersonalTable.SM[Species];
            PK7 pk           = new PK7
            {
                Species            = Species,
                HeldItem           = HeldItem,
                TID                = TID,
                SID                = SID,
                Met_Level          = metLevel,
                Nature             = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25),
                Gender             = Gender != 3 ? Gender : pi.RandomGender,
                AltForm            = Form,
                EncryptionConstant = EncryptionConstant != 0 ? EncryptionConstant : Util.rnd32(),
                Version            = OriginGame != 0 ? OriginGame : SAV.Game,
                Language           = Language != 0 ? Language : SAV.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    = pi.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);
        }
Пример #4
0
        public PK7 convertToPK7()
        {
            var pk7 = new PK7
            {
                EncryptionConstant = Util.rnd32(),
                Species            = Species,
                TID          = TID,
                CurrentLevel = CurrentLevel,
                EXP          = EXP,
                Met_Level    = CurrentLevel,
                Nature       = (int)(EXP % 25),
                PID          = Util.rnd32(),
                Ball         = 4,
                MetDate      = DateTime.Now,
                Version      = (int)GameVersion.RD, // Default to red, for now?
                Move1        = Move1,
                Move2        = Move2,
                Move3        = Move3,
                Move4        = Move4,
                Move1_PPUps  = Move1_PPUps,
                Move2_PPUps  = Move2_PPUps,
                Move3_PPUps  = Move3_PPUps,
                Move4_PPUps  = Move4_PPUps,
                Move1_PP     = Move1_PP,
                Move2_PP     = Move2_PP,
                Move3_PP     = Move3_PP,
                Move4_PP     = Move4_PP,
                Met_Location = 30013, // "Kanto region", hardcoded.
                Gender       = PersonalTable.SM[Species].RandomGender,
                OT_Name      = PKX.getG1ConvertedString(otname, Japanese),
                IsNicknamed  = false,

                Country        = PKMConverter.Country,
                Region         = PKMConverter.Region,
                ConsoleRegion  = PKMConverter.ConsoleRegion,
                CurrentHandler = 1,
                HT_Name        = PKMConverter.OT_Name,
                HT_Gender      = PKMConverter.OT_Gender,
                Language       = PKMConverter.Language,
                Geo1_Country   = PKMConverter.Country,
                Geo1_Region    = PKMConverter.Region
            };

            pk7.Nickname = PKX.getSpeciesNameGeneration(pk7.Species, pk7.Language, pk7.Format);
            if (otname[0] == 0x5D) // Ingame Trade
            {
                var s = PKX.getG1Char(0x5D, Japanese);
                pk7.OT_Name = s.Substring(0, 1) + s.Substring(1).ToLower();
            }
            pk7.OT_Friendship = pk7.HT_Friendship = PersonalTable.SM[Species].BaseFriendship;

            // IVs
            var new_ivs  = new int[6];
            int flawless = Species == 151 ? 5 : 3;

            for (var i = 0; i < new_ivs.Length; i++)
            {
                new_ivs[i] = (int)(Util.rnd32() & 31);
            }
            for (var i = 0; i < flawless; i++)
            {
                new_ivs[i] = 31;
            }
            Util.Shuffle(new_ivs);
            pk7.IVs = new_ivs;

            // Really? :(
            if (IsShiny)
            {
                pk7.setShinyPID();
            }

            int abil = 2; // Hidden

            if (Legal.TransferSpeciesDefaultAbility_1.Contains(Species))
            {
                abil = 0;             // Reset
            }
            pk7.RefreshAbility(abil); // 0/1/2 (not 1/2/4)

            if (Species == 151)       // Mew gets special treatment.
            {
                pk7.FatefulEncounter = true;
            }
            else if (IsNicknamedBank)
            {
                pk7.IsNicknamed = true;
                pk7.Nickname    = PKX.getG1ConvertedString(nick, Japanese);
            }

            pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm

            if (pk7.Species == 150)      // Pay Day Mewtwo
            {
                var moves = pk7.Moves;
                var index = Array.IndexOf(moves, 6);
                if (index != -1)
                {
                    moves[index] = 0;
                    pk7.Moves    = moves;
                    pk7.FixMoves();
                }
            }

            pk7.RefreshChecksum();
            return(pk7);
        }
Пример #5
0
Файл: WC7.cs Проект: 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;
        }
Пример #6
0
Файл: PKM.cs Проект: kwsch/PKHeX
        public PKM convertPK1toPK7()
        {
            if (Format != 1)
                return null;
            if (Species > 151)
                return null;

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