Replace hardcoded flute check with consumability check (#5508)

This commit is contained in:
Bassoonian 2024-10-16 12:07:34 +02:00 committed by GitHub
parent 1cdc91ce53
commit d4387d880c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 5 deletions

View file

@ -18,7 +18,9 @@ struct Item
u8 pluralName[ITEM_NAME_PLURAL_LENGTH]; u8 pluralName[ITEM_NAME_PLURAL_LENGTH];
u8 holdEffect; u8 holdEffect;
u8 holdEffectParam; u8 holdEffectParam;
u8 importance; u8 importance:2;
u8 notConsumed:1;
u8 padding:5;
u8 pocket; u8 pocket;
u8 type; u8 type;
u8 battleUsage; u8 battleUsage;
@ -73,6 +75,7 @@ u32 ItemId_GetHoldEffect(u32 itemId);
u32 ItemId_GetHoldEffectParam(u32 itemId); u32 ItemId_GetHoldEffectParam(u32 itemId);
const u8 *ItemId_GetDescription(u16 itemId); const u8 *ItemId_GetDescription(u16 itemId);
u8 ItemId_GetImportance(u16 itemId); u8 ItemId_GetImportance(u16 itemId);
u8 ItemId_GetConsumability(u16 itemId);
u8 ItemId_GetPocket(u16 itemId); u8 ItemId_GetPocket(u16 itemId);
u8 ItemId_GetType(u16 itemId); u8 ItemId_GetType(u16 itemId);
ItemUseFunc ItemId_GetFieldFunc(u16 itemId); ItemUseFunc ItemId_GetFieldFunc(u16 itemId);

View file

@ -102,6 +102,5 @@ void MoveDeleterForgetMove(void);
void BufferMoveDeleterNicknameAndMove(void); void BufferMoveDeleterNicknameAndMove(void);
void GetNumMovesSelectedMonHas(void); void GetNumMovesSelectedMonHas(void);
void MoveDeleterChooseMoveToForget(void); void MoveDeleterChooseMoveToForget(void);
bool32 IsItemFlute(u16 item);
#endif // GUARD_PARTY_MENU_H #endif // GUARD_PARTY_MENU_H

View file

@ -384,8 +384,8 @@ static void HandleInputChooseAction(u32 battler)
&& !(gAbsentBattlerFlags & (1u << GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) && !(gAbsentBattlerFlags & (1u << GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
// Return item to bag if partner had selected one (except flutes). // Return item to bag if partner had selected one (if consumable).
if (gBattleResources->bufferA[battler][1] == B_ACTION_USE_ITEM && !IsItemFlute(itemId)) if (gBattleResources->bufferA[battler][1] == B_ACTION_USE_ITEM && ItemId_GetConsumability(itemId))
{ {
AddBagItem(itemId, 1); AddBagItem(itemId, 1);
} }

View file

@ -2036,6 +2036,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n" "A glass flute that\n"
"awakens sleeping\n" "awakens sleeping\n"
"Pokémon."), "Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_Medicine, .fieldUseFunc = ItemUseOutOfBattle_Medicine,
@ -2054,6 +2055,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n" "A glass flute that\n"
"snaps Pokémon\n" "snaps Pokémon\n"
"out of confusion."), "out of confusion."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, .fieldUseFunc = ItemUseOutOfBattle_CannotUse,
@ -2072,6 +2074,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n" "A glass flute that\n"
"snaps Pokémon\n" "snaps Pokémon\n"
"out of attraction."), "out of attraction."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, .fieldUseFunc = ItemUseOutOfBattle_CannotUse,
@ -2093,6 +2096,7 @@ const struct Item gItemsInfo[] =
"A glass flute that\n" "A glass flute that\n"
"keeps away wild\n" "keeps away wild\n"
"Pokémon."), "Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute, .fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute,
@ -2109,6 +2113,7 @@ const struct Item gItemsInfo[] =
.description = COMPOUND_STRING( .description = COMPOUND_STRING(
"A glass flute that\n" "A glass flute that\n"
"lures wild Pokémon."), "lures wild Pokémon."),
.notConsumed = TRUE,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute, .fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute,

View file

@ -916,6 +916,11 @@ u8 ItemId_GetImportance(u16 itemId)
return gItemsInfo[SanitizeItemId(itemId)].importance; return gItemsInfo[SanitizeItemId(itemId)].importance;
} }
u8 ItemId_GetConsumability(u16 itemId)
{
return !gItemsInfo[SanitizeItemId(itemId)].notConsumed;
}
u8 ItemId_GetPocket(u16 itemId) u8 ItemId_GetPocket(u16 itemId)
{ {
return gItemsInfo[SanitizeItemId(itemId)].pocket; return gItemsInfo[SanitizeItemId(itemId)].pocket;

View file

@ -4578,7 +4578,7 @@ static bool8 NotUsingHPEVItemOnShedinja(struct Pokemon *mon, u16 item)
return TRUE; return TRUE;
} }
bool32 IsItemFlute(u16 item) static bool32 IsItemFlute(u16 item)
{ {
if (item == ITEM_BLUE_FLUTE || item == ITEM_RED_FLUTE || item == ITEM_YELLOW_FLUTE) if (item == ITEM_BLUE_FLUTE || item == ITEM_RED_FLUTE || item == ITEM_YELLOW_FLUTE)
return TRUE; return TRUE;