diff options
-rw-r--r-- | Add-a-new-Pokémon.md | 12 | ||||
-rw-r--r-- | Add-different-kinds-of-new-items.md | 13 |
2 files changed, 13 insertions, 12 deletions
diff --git a/Add-a-new-Pokémon.md b/Add-a-new-Pokémon.md index 45d63c6..df43af1 100644 --- a/Add-a-new-Pokémon.md +++ b/Add-a-new-Pokémon.md @@ -654,4 +654,14 @@ That's it—we're done! Munchlax works just like every other Pokémon. ## 12. Adding up to 253 Pokémon -TODO +We just added Pokémon #252; adding #253 is basically the same. However, instead of just replacing `MON_FE` the way we replaced `MON_FC`, I would recommend swapping `MON_FE` and `EGG`. That way `MON_FE` is $FD and `EGG` is $FE. + +This has multiple benefits: + +- Pokémon IDs will be contiguous, from #1 to #253. No #254 with a missing #253 where Egg exists. +- Many data tables don't have an entry for `EGG` since it would be superfluous. But if there were a Pokémon #254, they would need filler entries for #253 in order to reach entry #254. +- `EGG` does not count as a Pokémon, so if it came before a valid Pokémon ID, then `NUM_POKEMON` would have to be adjusted to compensate, and certain other checks in the code would no longer be able to assume that any ID below some number *N* is a valid one. + +It's easy to do; just make sure that the various tables have their entries in the right order: Bulbasaur, Ivysaur, Venusaur, …, Celebi, #252, #253, Egg. + +Unfortunately, you can't have more than 253 Pokémon. IDs are one byte each, so they have 256 possible values. Of those values, $00 indicates a lack of a Pokémon; $FF (−1) is an end-of-list marker; and $FD is `EGG` (though you can change this to $FE, as discussed above). If you value having a 254th Pokémon more than allowing breeding, you could replace `EGG`, but you would also have to carefully remove a lot of code that treats `EGG` specially. diff --git a/Add-different-kinds-of-new-items.md b/Add-different-kinds-of-new-items.md index b783fbe..2ddf592 100644 --- a/Add-different-kinds-of-new-items.md +++ b/Add-different-kinds-of-new-items.md @@ -13,7 +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) +4. [Adding up to 254 items](#4-adding-up-to-254-items) ## 1. How item constants work @@ -540,17 +540,8 @@ In general, if you're implementing a custom held item effect, think about which ## 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. +Like most IDs in pokecrystal, item IDs are one byte each, so they can go from 0 to 255. Item $00 is `NO_ITEM` and $FF (−1) is an end-of-list marker, which leaves 254 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`. |