Skip to content

Commit

Permalink
Replace hardcoded flute check with consumability check (#5508)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian authored Oct 16, 2024
1 parent 1cdc91c commit d4387d8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion include/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ struct Item
u8 pluralName[ITEM_NAME_PLURAL_LENGTH];
u8 holdEffect;
u8 holdEffectParam;
u8 importance;
u8 importance:2;
u8 notConsumed:1;
u8 padding:5;
u8 pocket;
u8 type;
u8 battleUsage;
Expand Down Expand Up @@ -73,6 +75,7 @@ u32 ItemId_GetHoldEffect(u32 itemId);
u32 ItemId_GetHoldEffectParam(u32 itemId);
const u8 *ItemId_GetDescription(u16 itemId);
u8 ItemId_GetImportance(u16 itemId);
u8 ItemId_GetConsumability(u16 itemId);
u8 ItemId_GetPocket(u16 itemId);
u8 ItemId_GetType(u16 itemId);
ItemUseFunc ItemId_GetFieldFunc(u16 itemId);
Expand Down
1 change: 0 additions & 1 deletion include/party_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,5 @@ void MoveDeleterForgetMove(void);
void BufferMoveDeleterNicknameAndMove(void);
void GetNumMovesSelectedMonHas(void);
void MoveDeleterChooseMoveToForget(void);
bool32 IsItemFlute(u16 item);

#endif // GUARD_PARTY_MENU_H
4 changes: 2 additions & 2 deletions src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ static void HandleInputChooseAction(u32 battler)
&& !(gAbsentBattlerFlags & (1u << GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
// Return item to bag if partner had selected one (except flutes).
if (gBattleResources->bufferA[battler][1] == B_ACTION_USE_ITEM && !IsItemFlute(itemId))
// Return item to bag if partner had selected one (if consumable).
if (gBattleResources->bufferA[battler][1] == B_ACTION_USE_ITEM && ItemId_GetConsumability(itemId))
{
AddBagItem(itemId, 1);
}
Expand Down
5 changes: 5 additions & 0 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n"
"awakens sleeping\n"
"Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Medicine,
Expand All @@ -2054,6 +2055,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n"
"snaps Pokémon\n"
"out of confusion."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
Expand All @@ -2072,6 +2074,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n"
"snaps Pokémon\n"
"out of attraction."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
Expand All @@ -2093,6 +2096,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n"
"keeps away wild\n"
"Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute,
Expand All @@ -2109,6 +2113,7 @@ const struct Item gItemsInfo[] =
.description = COMPOUND_STRING(
"A glass flute that\n"
"lures wild Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute,
Expand Down
5 changes: 5 additions & 0 deletions src/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,11 @@ u8 ItemId_GetImportance(u16 itemId)
return gItemsInfo[SanitizeItemId(itemId)].importance;
}

u8 ItemId_GetConsumability(u16 itemId)
{
return !gItemsInfo[SanitizeItemId(itemId)].notConsumed;
}

u8 ItemId_GetPocket(u16 itemId)
{
return gItemsInfo[SanitizeItemId(itemId)].pocket;
Expand Down
2 changes: 1 addition & 1 deletion src/party_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4578,7 +4578,7 @@ static bool8 NotUsingHPEVItemOnShedinja(struct Pokemon *mon, u16 item)
return TRUE;
}

bool32 IsItemFlute(u16 item)
static bool32 IsItemFlute(u16 item)
{
if (item == ITEM_BLUE_FLUTE || item == ITEM_RED_FLUTE || item == ITEM_YELLOW_FLUTE)
return TRUE;
Expand Down

0 comments on commit d4387d8

Please sign in to comment.