diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2018-05-06 17:35:25 -0400 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2018-05-06 17:35:25 -0400 |
commit | cdf3729080484053a8d30e34a656ac8ccd5e7d5e (patch) | |
tree | 24fdb878b32667824c1600a543d14ad1a058e8dd | |
parent | abdc7e6d541fef7667284ea26e2d94bab43eb7bd (diff) |
Clarify how to add 255 items
-rw-r--r-- | Add-different-kinds-of-new-items.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Add-different-kinds-of-new-items.md b/Add-different-kinds-of-new-items.md index 78ea050..b783fbe 100644 --- a/Add-different-kinds-of-new-items.md +++ b/Add-different-kinds-of-new-items.md @@ -13,6 +13,7 @@ This tutorial is for how to add different kinds of new items, including a healin - [`EvoStoneEffect`: Mist Stone](#evostoneeffect-mist-stone) - [`TownMapEffect`: Town Map](#townmapeffect-town-map) - [Held effect: Eviolite](#held-effect-eviolite) +4. [Adding up to 255 items](#4-adding-up-to-255-items) ## 1. How item constants work @@ -535,3 +536,21 @@ The implementation of `UnevolvedEviolite` is very similar to `DittoMetalPowder`, In general, if you're implementing a custom held item effect, think about which items have similar effects, and which other code might already do something like what you want.  + + +## 4. Adding up to 255 items + +Like most IDs in pokecrystal, item IDs are one byte each, so they can go from 0 to 255. Item $00 is `NO_ITEM`, which leaves 255 usable IDs. + +We've been replacing unused items with useful ones, but in principle you can also add new items (as long as you're careful to arrange regular items before TMs, then HMs last). Only 251 item constants are defined, from `NO_ITEM` to `ITEM_FA`, but the tables of `ItemNames`, `ItemDescriptions`, and `ItemAttributes` already have 256 entries each (and `ItemEffects` has entries for every regular item; the TMs and HMs don't use effects). So just be careful to keep the constants and all those tables in sync. Remember that adding a new constant in the middle of a sequence will shift all the ones after it. + +If `make` gives you the error "Expression must be 8-bit", you're probably using an ID constant greater than 255, which won't fit in one byte (eight bits). Double-check the constants and make sure they're all between $00 and $FF. It's easy to forget about the useless `ITEM_FA` at the very end, which can end up shifted beyond the 8-bit range if you add too many new items. Feel free to delete it, and remove its entry from `TimeCapsule_CatchRateItems` (the only place `ITEM_FA` is ever used). + +Also, even though $FF is the special `ITEM_FROM_MEM` value, you can still use it for a 255th item. The only item code that treats $FF specially are the `giveitem` and `verbosegiveitem` scripting commands. So if you've defined an `ITEM_FF`, you'll have to give it to the player like this: + +``` + writebyte ITEM_FF + verbosegiveitem ITEM_FROM_MEM +``` + +`writebyte ITEM_FF` stores `ITEM_FF` in `wScriptVar`, so when `(verbose)giveitem` sees `ITEM_FROM_MEM` and gives the item stored in `wScriptVar`, it will just give `ITEM_FF`. |