-
Notifications
You must be signed in to change notification settings - Fork 989
Add a new item
This tutorial is for how to add different kinds of new items, including a healing item, Poké Ball, evolution stone, and key item.
Item constants are defined in constants/item_constants.asm. To append items at the end, you have to append them after the elevator floor names.
-
NO_ITEM
is the first item ID, which is used to indicate a lack of item. Leave this alone. - Item constants start out as an ordinary sequence, from
MASTER_BALL
toMAX_ELIXIER
, including 1UNUSED_ITEM
constant. It's the simplest to replace with any kind of item you want, except for TMs or HMs. It's important to understand that there's nothing special about the specific numeric values, except $00 forNO_ITEM
and $FF which represents the end of the inventory.
You may have already guessed this from the comment at the top of constants/item_constants.asm:
; item ids
; indexes for:
; - ItemNames (see data/items/names.asm)
; - ItemPrices (see data/items/prices.asm)
; - TechnicalMachinePrices (see data/items/tm_prices.asm)
; - KeyItemFlags (see data/items/key_items.asm)
; - ItemUsePtrTable (see engine/items/item_effects.asm)
Every kind of item has these pieces of data. ItemNames
, ItemPrices
and TechnicalMachinePrices
, KeyItemFlags
, and ItemUsePtrTable
are five tables with an entry for each item constant, one after another. It's important for them all to be in sync so that the Nth constant correctly matches the Nth name, the Nth price, and so on.
Names are defined in data/items/names.asm. They're simply written as li "NAME"
: an opening quote, the name and a closing quote. Names can be up to 12 characters long. The number of printed characters also matters, since screens like the Pack and the Mart menus are a fixed width. For example, when the name "# DOLL"
gets printed as "POKé DOLL", that's 9 characters, not 6.
Prices are defined in data/items/prices.asm. Each entry is a 6-digit BCD number, represented by the bcd3
macro.
Effects are defined in engine/items/item_effects.asm. Their address is stored in a pointer table called ItemUsePtrTable
defined in the same file.
To start with, we'll implement a new item that just has the essential data. A Big Nugget doesn't do anything, it just has a high price. So here's how to add one:
Edit constants/item_constants.asm:
...
const SECRET_KEY ; $2B
- const ITEM_2C ; $2C ; unused
+ const BIG_NUGGET ; $2C
const BIKE_VOUCHER ; $2D
...
Edit data/items/names.asm:
...
li "SECRET KEY"
- li "?????" ; ITEM_2C
+ li "BIG NUGGET"
li "BIKE VOUCHER"
...
Edit data/items/prices.asm:
...
bcd3 0 ; SECRET_KEY
- bcd3 0 ; ITEM_2C
+ bcd3 20000 ; BIG_NUGGET
bcd3 0 ; BIKE_VOUCHER
...
Edit engine/items/item_effects.asm:
...
dw UnusableItem ; SECRET_KEY
- dw UnusableItem ; ITEM_2C
+ dw UnusableItem ; BIG_NUGGET
dw UnusableItem ; BIKE_VOUCHER
...
Anyway, that's all you need to add a basic item:
Screenshot TBD
TBD
TBD
TBD
TBD
TBD
Edit constants/item_constants.asm:
const SECRET_KEY ; $2B
- const UNUSED_ITEM ; $2C "?????"
+ const SUN_STONE ; $2C
const BIKE_VOUCHER ; $2D
Edit data/items/names.asm:
li "SECRET KEY"
- li "?????"
+ li "SUN STONE"
li "BIKE VOUCHER"
Edit data/items/prices.asm:
bcd3 0 ; SECRET_KEY
- bcd3 0 ; ?????
+ bcd3 2100 ; SUN_STONE
bcd3 0 ; BIKE_VOUCHER
Edit engine/items/item_effects.asm:
dw UnusableItem ; SECRET_KEY
- dw UnusableItem
+ dw ItemUseEvoStone ; SUN_STONE
dw UnusableItem ; BIKE_VOUCHER
Edit data/items/use_party.asm:
UsableItems_PartyMenu:
db MOON_STONE
+ db SUN_STONE
db ANTIDOTE
Edit data/items/key_items.asm:
dbit TRUE ; SECRET_KEY
- dbit TRUE ; UNUSED_ITEM
+ dbit FALSE ; SUN_STONE
dbit TRUE ; BIKE_VOUCHER