Created Shop Items By Badge Count (markdown)

ghoulslash 2020-06-20 14:42:46 -06:00
parent 7dc1ba1598
commit ecd2e055e9
1 changed files with 223 additions and 0 deletions

@ -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 <itemList>` with `pokemart 0` to load the items based on the player's badge count. And that's it!