public override void UpdateInventory(Player player) { currentWaitTime++; if (currentWaitTime < WaitTime * 60) { return; } if (PokemonName == null || PokemonName == string.Empty) { item.TurnToAir();//This is invalid item return; } ParentPokemon hatchedPokemon = TerramonMod.GetPokemon(PokemonName); string pokemonName = hatchedPokemon?.GetType().Name; if (player.whoAmI != Main.myPlayer) { return; } switch (Main.netMode) { case NetmodeID.MultiplayerClient: { var packet = new BaseCatchPacket(); packet.Send((TerramonMod)mod, pokemonName, pokemonName, player.getRect(), ItemType <PokeballCaught>()); break; } case NetmodeID.Server: { BaseCaughtClass.writeDetour(pokemonName, pokemonName, GetSmallSpritePath(pokemonName), 1, "", false); //This force server to write data when SetDefault() was called Item.NewItem(player.position, ItemType <PokeballCaught>()); // Within this call SetDefault was called break; } default: { int pokeballIndex = Item.NewItem(player.position, ItemType <PokeballCaught>()); BaseCaughtClass pokeballItem = Main.item[pokeballIndex].modItem as BaseCaughtClass; pokeballItem.PokemonName = pokeballItem.CapturedPokemon = pokemonName; pokeballItem.SmallSpritePath = GetSmallSpritePath(pokemonName); break; } } Main.NewText(player.name + " the " + pokemonName + " Egg has hatched!", Color.Orange); player.ConsumeItem(item.type); currentWaitTime = 0; }
private void Catch(ref Projectile proj, ref bool crit, ref int dmg, int type) { var PokeNam = Regex.Replace(HomeClass().Name, nameMatcher, "$1 "); if (pokeName.Value != PokeNam) { pokeName = TerramonMod.Localisation.GetLocalisedString(new LocalisedString(PokeNam)); } proj.ai[1] = 2; crit = false; dmg = npc.lifeMax; CreateDust(4); CombatText.NewText(npc.Hitbox, Color.Orange, $"{pokeName.Value} was caught!", true); if (Main.netMode == NetmodeID.MultiplayerClient) { var packet = new BaseCatchPacket(); packet.Send((TerramonMod)mod, HomeClass().Name, npc.TypeName, npc.getRect(), type, shiny); } else { if (Main.netMode == NetmodeID.Server) { BaseCaughtClass.writeDetour(HomeClass().Name, npc.TypeName, GetSmallSpritePath(npc), 1, "", shiny); } int index = Item.NewItem(npc.getRect(), type); if (index >= 400) { return; } if (Main.netMode == NetmodeID.Server) { return; } if (!(Main.item[index].modItem is BaseCaughtClass item)) { return; } item.PokemonName = npc.TypeName; if (shiny) { item.isShiny = true; } else { item.isShiny = false; } item.CapturedPokemon = HomeClass().Name; } }
private void EvolveButtonClicked(UIMouseEvent evt, UIElement listeningElement) { int whicheverballtype = TerramonMod.PokeballFactory.GetPokeballType(partyslot1.Item.modItem); // stuff break if (partyslot1.Item.modItem is BaseCaughtClass pokeball) { var mon = TerramonMod.GetPokemon(pokeball.CapturedPokemon); if (mon == null) { Main.NewText("This Pokémon cannot evolve!"); return; } var evolved = TerramonMod.GetPokemon(mon.EvolveTo.Name); if (evolved == null) { Main.NewText("This Pokémon cannot evolve!"); return; } if (Main.netMode == NetmodeID.MultiplayerClient) { BaseCatchPacket packet = new BaseCatchPacket(); packet.Send(TerramonMod.Instance, evolved.GetType().Name, evolved.GetType().Name, Main.LocalPlayer.getRect(), whicheverballtype); } else { int index = Item.NewItem(Main.LocalPlayer.getRect(), whicheverballtype); if (index >= 400) { return; } if (Main.item[index].modItem is BaseCaughtClass item) { item.PokemonName = evolved.GetType().Name; item.CapturedPokemon = evolved.GetType().Name; } } } Visible = false; partyslot1.Item.TurnToAir(); partyslot2.Item.TurnToAir(); mainPanel.RemoveChild(SaveButton); Main.LocalPlayer.talkNPC = 0; }