Пример #1
0
 private static double dbl(object expression)
 {
     return(ScriptConversion.ToDouble(expression));
 }
Пример #2
0
 private static int @int(object expression)
 {
     return(ScriptConversion.ToInteger(expression));
 }
Пример #3
0
 private static float sng(object expression)
 {
     return(ScriptConversion.ToSingle(expression));
 }
Пример #4
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);
            }
        }