Item balls

This page describes how to create **item balls**, objects on a map that the player can pick up. This article covers visible item balls, hidden items, and balls containing Pokémon.

## Item balls

To create an item that can be picked up, create a new event with the name "`Item:XXX`", where "`XXX`" is the ID of the item (e.g. "`Item:POTION`"). When the game is compiled, this event will be edited automatically to turn it into a proper item ball, complete with graphic.

The item's name is only important for turning the item into a proper item ball when compiling the game. Once this has been done, the item's name is not important. However, it should not be renamed back to "`Item:XXX`" then, because when the game is next compiled, the event will be edited again, potentially overwriting any changes you may have made to the item ball.

### Item ball event

Item ball events have two event pages. The first page has an "Action Button" trigger and looks like this:

```
@>Conditional Branch: Script: pbItemBall(:POTION)
  @>Control Self Switch: A =ON
  @>
 : Branch End
@>

```

The second event page is blank, and depends on the event's Self Switch A being ON.

The `def pbItemBall` displays two messages: the first is that the player has found the item, and the second is that the player has put it in a particular pocket of their Bag (or that their Bag is full, in which case the item is not picked up). This is described a little more in the page Manipulating items.

## Hidden items

Hidden items are identical to regular item balls, with three exceptions: they are invisible, the player can walk over them, and they can be detected by an Itemfinder. Also, the player cannot interact with hidden items while standing directly on them; they must stand to the side of a hidden item to interact with it.

To create a hidden item, create a new event with the name "`HiddenItem:XXX`", where "`XXX`" is the ID of the item (e.g. "`HiddenItem:NUGGET`"). When the game is compiled, this event will be edited automatically to turn it into a proper hidden item.

Unlike regular item balls, hidden items *must* have the text "`HiddenItem`" in their name (note the lack of a space). This is because the Itemfinder looks for nearby events with that text in their name, and reacts if there are any. The name above that includes "`XXX`" is automatically changed to this when the game is compiled.

### Hidden item event

The structure of hidden item events is just the same as for regular item ball events, with two exceptions: the first page has no graphic (to make it invisible), and it has the "Through" option checked (to allow the player to walk over it).

## Pokémon balls

These are item balls that, rather than giving an item, give a Pokémon instead. There is no simple way to automatically generate a Pokémon ball, so you will need to create the event yourself.

Rather than having to make a Pokémon ball from scratch (although it is easy to do), you can instead create an item ball (it doesn't matter what item it is), compile the game, and then modify the event to make it give a Pokémon instead of an item.

### Pokémon ball event

The structure of Pokémon ball events are identical to item ball events, except the Conditional Branch script in the first page is different, e.g.

```
@>Conditional Branch: Script: pbAddPokemon(:MEW, 20)
  @>Control Self Switch: A =ON
  @>
 : Branch End
@>

```

This will give the player a Level 20 Mew, but only if the player has an empty spot in their party. See Manipulating Pokémon for how `def pbAddPokemon` works.

Remember that Pokémon ball events still need a second, blank page, just like the other item ball events.