private static BasePokemon GetPredeterminedPokemon(int ID, int level, int pokemon_class)
        {
            string path = GameController.GamePath + "\\Content\\Pokemon\\Data\\frontier\\" + pokemon_class.ToString(NumberFormatInfo.InvariantInfo) + ".dat";
            // TODO:
            //Security.FileValidation.CheckFileValid(path, false, "FrontierSpawner.vb");

            List <string> data = System.IO.File.ReadAllLines(path).ToList();

            foreach (string line in data)
            {
                string[] lData    = line.Split(Convert.ToChar("|"));
                string[] InputIDs = lData[0].Split(Convert.ToChar(","));
                if (InputIDs.Contains(ID.ToString(NumberFormatInfo.InvariantInfo)) == true)
                {
                    int        OutputID = Convert.ToInt32(lData[1]);
                    List <int> Moveset  = new List <int>();
                    foreach (string move in lData[2].Split(Convert.ToChar(",")))
                    {
                        if (!string.IsNullOrEmpty(move) && move.IsNumeric())
                        {
                            Moveset.Add(Convert.ToInt32(move));
                        }
                    }
                    string[] Stats  = lData[3].Split(Convert.ToChar(","));
                    string   ItemID = lData[4];

                    BasePokemon p = BasePokemon.GetPokemonByID(OutputID);
                    p.Generate(level, true);
                    p.Item = null;
                    AddMoveset(ref p, Moveset.ToArray());
                    SetStats(ref p, Stats[0], Stats[1], pokemon_class);

                    if (!string.IsNullOrEmpty(ItemID))
                    {
                        p.Item = Item.GetItemByID(Convert.ToInt32(ItemID));
                    }
                    if (p.Item == null)
                    {
                        int[] items =
                        {
                            146,
                            2009,
                            119,
                            140,
                            73,
                            74
                        };

                        p.Item = Item.GetItemByID(items[Core.Random.Next(0, items.Length)]);
                    }

                    p.FullRestore();
                    return(p);
                }
            }

            return(null);
        }
Beispiel #2
0
        public static void DoNPCTrade(int pokeIndex)
        {
            Core.SetScreen(Core.CurrentScreen.PreScreen);

            BasePokemon ownPokemon = Core.Player.Pokemons[pokeIndex];

            int ownPokeID = ScriptConversion.ToInteger(Script.SaveNPCTrade[0]);
            int oppPokeID = ScriptConversion.ToInteger(Script.SaveNPCTrade[1]);

            BasePokemon oppPokemon = BasePokemon.GetPokemonByID(oppPokeID);

            int Level = ownPokemon.Level;

            if (Script.SaveNPCTrade[2].IsNumeric())
            {
                Level = ScriptConversion.ToInteger(Script.SaveNPCTrade[2]);
            }

            oppPokemon.Generate(Level, true);

            BasePokemon.Genders Gender = ownPokemon.Gender;

            if (Script.SaveNPCTrade[3].IsNumeric())
            {
                int genderID = ScriptConversion.ToInteger(Script.SaveNPCTrade[3]);
                if (genderID == -1)
                {
                    genderID = Core.Random.Next(0, 2);
                }

                switch (genderID)
                {
                case 0:
                    Gender = BasePokemon.Genders.Male;
                    break;

                case 1:
                    Gender = BasePokemon.Genders.Female;
                    break;

                case 2:
                    Gender = BasePokemon.Genders.Genderless;
                    break;

                default:
                    Gender = BasePokemon.Genders.Male;
                    break;
                }
            }

            oppPokemon.Gender = Gender;

            if (!String.IsNullOrEmpty(Script.SaveNPCTrade[4]))
            {
                oppPokemon.Attacks.Clear();
                string[] attacks = { Script.SaveNPCTrade[4] };
                if (Script.SaveNPCTrade[4].Contains(","))
                {
                    attacks = Script.SaveNPCTrade[4].Split(Convert.ToChar(","));
                }
                foreach (string attackID in attacks)
                {
                    if (oppPokemon.Attacks.Count < 4)
                    {
                        oppPokemon.Attacks.Add(BaseAttack.GetAttackByID(ScriptConversion.ToInteger(attackID)));
                    }
                }
            }

            if (!String.IsNullOrEmpty(Script.SaveNPCTrade[5]))
            {
                oppPokemon.IsShiny = Convert.ToBoolean(Script.SaveNPCTrade[5]);
            }

            oppPokemon.OT = Script.SaveNPCTrade[6];
            oppPokemon.CatchTrainerName = Script.SaveNPCTrade[7];
            oppPokemon.CatchBall        = Item.GetItemByID(ScriptConversion.ToInteger(Script.SaveNPCTrade[8]));

            string itemID = Script.SaveNPCTrade[9];

            if (itemID.IsNumeric())
            {
                oppPokemon.Item = Item.GetItemByID(ScriptConversion.ToInteger(itemID));
            }

            oppPokemon.CatchLocation = Script.SaveNPCTrade[10];
            oppPokemon.CatchMethod   = Script.SaveNPCTrade[11];
            oppPokemon.NickName      = Script.SaveNPCTrade[12];

            string message1 = Script.SaveNPCTrade[13];
            string message2 = Script.SaveNPCTrade[14];

            string register = Script.SaveNPCTrade[15];

            if (ownPokeID == ownPokemon.Number)
            {
                Core.Player.Pokemons.RemoveAt(pokeIndex);
                Core.Player.Pokemons.Add(oppPokemon);

                int pokedexType = 2;
                if (oppPokemon.IsShiny == true)
                {
                    pokedexType = 3;
                }

                Core.Player.PokedexData = BasePokedex.ChangeEntry(Core.Player.PokedexData, oppPokemon.Number, pokedexType);

                if (!String.IsNullOrEmpty(register))
                {
                    ActionScript.RegisterID(register);
                }

                Core.Player.AddPoints(10, "Traded with NPC.");

                SoundEffectManager.PlaySound("success_small");
                Screen.TextBox.Show(message1 + "*" + Core.Player.Name + " traded~" + oppPokemon.OriginalName + " for~" + ownPokemon.OriginalName + "!", new  Entity[] { }, false, false);
            }
            else
            {
                Screen.TextBox.Show(message2, new Entity[] { }, false, false);
            }
        }