From ecd2e055e91ca4f7519276756fd78976e6c74fab Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:42:46 -0600 Subject: [PATCH] Created Shop Items By Badge Count (markdown) --- Shop-Items-By-Badge-Count.md | 223 +++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 Shop-Items-By-Badge-Count.md diff --git a/Shop-Items-By-Badge-Count.md b/Shop-Items-By-Badge-Count.md new file mode 100644 index 0000000..1a1c0e0 --- /dev/null +++ b/Shop-Items-By-Badge-Count.md @@ -0,0 +1,223 @@ +## Shop Items By Badge Count + +Pokemart/Shop Items have been determined by the player's badge count for some time. So let's add this feature with Generation VIII items! + +### Add the item lists +Open [src/shop.c](../blob/master/src/shop.c). Add the following above _sShopPurchaseYesNoFuncs_ +```c +static const u16 sShopInventory_ZeroBadges[] = { + ITEM_POKE_BALL, + ITEM_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_NONE +}; + +static const u16 sShopInventory_OneBadge[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_NONE +}; + +static const u16 sShopInventory_TwoBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_ThreeBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_FourBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_FiveBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_SUPER_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_SixBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPER_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_SUPER_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_SevenBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPER_POTION, + ITEM_MAX_POTION, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_SUPER_REPEL, + ITEM_MAX_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 sShopInventory_EightBadges[] = { + ITEM_POKE_BALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPER_POTION, + ITEM_MAX_POTION, + ITEM_FULL_RESTORE, + ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, + ITEM_REPEL, + ITEM_SUPER_REPEL, + ITEM_MAX_REPEL, + ITEM_POKE_DOLL, + ITEM_NONE +}; + +static const u16 *const sShopInventories[] = +{ + sShopInventory_ZeroBadges, + sShopInventory_OneBadge, + sShopInventory_TwoBadges, + sShopInventory_ThreeBadges, + sShopInventory_FourBadges, + sShopInventory_FiveBadges, + sShopInventory_SixBadges, + sShopInventory_SevenBadges, + sShopInventory_EightBadges +}; +``` + +### Make the file recognize the item definitions +In the same file, add `#include "event_data.h"` at the top of the tile (above `#include "event_object_movement.h"` is a good spot) + +### Make the game load our new item data +Edit the function, `static void SetShopItemsForSale(const u16 *items)`, to the following +```c +static void SetShopItemsForSale(const u16 *items) +{ + u16 i = 0; + u8 badgeCount = GetNumberOfBadges(); + + if (items == NULL) + gMartInfo.itemList = sShopInventories[badgeCount]; + else + gMartInfo.itemList = items; + + gMartInfo.itemCount = 0; + while (gMartInfo.itemList[i]) + { + gMartInfo.itemCount++; + i++; + } +} +``` + +Finally, add the function `GetNumberOfBadges` somewhere above `SetShopItemsForSale` (directly above is fine) +```c +static u8 GetNumberOfBadges(void) +{ + u16 badgeFlag; + u8 count = 0; + + for (badgeFlag = FLAG_BADGE01_GET; badgeFlag < FLAG_BADGE01_GET + NUM_BADGES; badgeFlag++) + { + if (FlagGet(badgeFlag)) + count++; + } + + return count; +} +``` + +### Usage +In any script, replace `pokemart ` with `pokemart 0` to load the items based on the player's badge count. And that's it! \ No newline at end of file