Document item_case

This commit is contained in:
GriffinR 2022-10-27 14:36:40 -04:00
parent 7178aa8b99
commit d055ebad83
13 changed files with 1086 additions and 877 deletions

View File

@ -14,7 +14,7 @@ struct Item
u8 holdEffectParam;
const u8 *description;
u8 importance;
u8 exitsBagOnUse;
u8 registrability;
u8 pocket;
u8 type; // unused for balls
ItemUseFunc fieldUseFunc;
@ -69,7 +69,7 @@ ItemUseFunc ItemId_GetFieldFunc(u16 itemId);
u8 ItemId_GetBattleUsage(u16 itemId);
ItemUseFunc ItemId_GetBattleFunc(u16 itemId);
u8 ItemId_GetSecondaryId(u16 itemId);
u16 itemid_get_market_price(u16 itemId);
u16 ItemId_GetPrice(u16 itemId);
void ClearBag(void);
void ClearPCItemSlots(void);
void TrySetObtainedItemQuestLogEvent(u16 itemId);
@ -79,7 +79,7 @@ void SortPocketAndPlaceHMsFirst(struct BagPocket * pocket);
u16 BagGetItemIdByPocketPosition(u8 pocketId, u16 itemId);
u16 BagGetQuantityByPocketPosition(u8 pocketId, u16 itemId);
u16 BagGetQuantityByItemId(u16 item);
bool8 itemid_is_unique(u16 itemId);
u8 ItemId_GetImportance(u16 itemId);
void BagPocketCompaction(struct ItemSlot * slots, u8 capacity);
u16 GetPcItemQuantity(u16 *);
void SetBagPocketsPointers(void);

View File

@ -103,8 +103,8 @@ extern const u8 gText_ItemCantBeHeld[];
extern const u8 gText_TMCase[];
extern const u8 gText_Close[];
extern const u8 gText_TMCaseWillBePutAway[];
extern const u8 gText_FontSize0[];
extern const u8 gText_FontSize2[];
extern const u8 gText_Font0[];
extern const u8 gText_Font2[];
extern const u8 gText_OhNoICantBuyThat[];
extern const u8 gText_HowManyWouldYouLikeToSell[];
extern const u8 gText_ICanPayThisMuch_WouldThatBeOkay[];

View File

@ -1,17 +1,21 @@
#ifndef GUARD_TM_CASE_H
#define GUARD_TM_CASE_H
enum TmCaseType
{
TMCASE_FROMFIELD,
TMCASE_FROMPARTYGIVE,
TMCASE_FROMMARTSELL,
TMCASE_FROMPOKEMONSTORAGEPC,
TMCASE_FROMBATTLE,
TMCASE_NA
// Values for 'type' argument to InitTMCase
enum {
TMCASE_FIELD,
TMCASE_GIVE_PARTY,
TMCASE_SELL,
TMCASE_GIVE_PC,
TMCASE_POKEDUDE,
TMCASE_REOPENING,
};
void InitTMCase(u8 a0, void (* a1)(void), u8 a2);
// Alternative value for 'allowSelectClose' argument to InitTMCase.
// Indicates that the previous value should be preserved
#define TMCASE_KEEP_PREV 0xFF
void InitTMCase(u8 type, void (* exitCallback)(void), bool8 allowSelectClose);
void ResetTMCaseCursorPos(void);
void Pokedude_InitTMCase(void);

View File

@ -684,13 +684,13 @@ static void SetUpListMenuTemplate(void)
static void GetBerryNameAndIndexForMenu(u8 * dest, u16 itemId)
{
StringCopy(gStringVar4, gText_FontSize0);
StringCopy(gStringVar4, gText_Font0);
StringAppend(gStringVar4, gText_NumberClear01);
ConvertIntToDecimalStringN(gStringVar1, itemId - FIRST_BERRY_INDEX + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
StringAppend(gStringVar4, gStringVar1);
CopyItemName(itemId, gStringVar1);
StringAppend(gStringVar4, sText_Space);
StringAppend(gStringVar4, gText_FontSize2);
StringAppend(gStringVar4, gText_Font2);
StringAppend(gStringVar4, gStringVar1);
StringCopy(dest, gStringVar4);
}
@ -1265,7 +1265,7 @@ static void Task_ContextMenu_FromPokemonPC(u8 taskId)
static void Task_ContextMenu_Sell(u8 taskId)
{
s16 * data = gTasks[taskId].data;
if (itemid_get_market_price(gSpecialVar_ItemId) == 0)
if (ItemId_GetPrice(gSpecialVar_ItemId) == 0)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_OhNoICantBuyThat);
@ -1293,7 +1293,7 @@ static void Task_ContextMenu_Sell(u8 taskId)
static void Task_AskSellMultiple(u8 taskId)
{
s16 * data = gTasks[taskId].data;
ConvertIntToDecimalStringN(gStringVar3, itemid_get_market_price(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
ConvertIntToDecimalStringN(gStringVar3, ItemId_GetPrice(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_ICanPayThisMuch_WouldThatBeOkay);
DisplayItemMessageInBerryPouch(taskId, GetDialogBoxFontId(), gStringVar4, Task_SellMultiple_CreateYesNoMenu);
}
@ -1323,7 +1323,7 @@ static void Task_Sell_PrintSelectMultipleUI(u8 taskId)
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
BerryPouchPrint(windowId, FONT_0, gStringVar4, 4, 10, 1, 0, 0xFF, 1);
SellMultiple_UpdateSellPriceDisplay(itemid_get_market_price(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8]);
SellMultiple_UpdateSellPriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8]);
PrintMoneyInWin2();
CreateScrollIndicatorArrows_SellQuantity();
gTasks[taskId].func = Task_Sell_SelectMultiple;
@ -1340,7 +1340,7 @@ static void Task_Sell_SelectMultiple(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE)
{
PrintxQuantityOnWindow(1, data[8], 2);
SellMultiple_UpdateSellPriceDisplay(itemid_get_market_price(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8]);
SellMultiple_UpdateSellPriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8]);
}
else if (JOY_NEW(A_BUTTON))
{
@ -1373,7 +1373,7 @@ static void Task_SellYes(u8 taskId)
PutWindowTilemap(0);
ScheduleBgCopyTilemapToVram(0);
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar3, itemid_get_market_price(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
ConvertIntToDecimalStringN(gStringVar3, ItemId_GetPrice(BagGetItemIdByPocketPosition(POCKET_BERRY_POUCH, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_TurnedOverItemsWorthYen);
DisplayItemMessageInBerryPouch(taskId, FONT_2, gStringVar4, Task_SellBerries_PlaySfxAndRemoveBerries);
}
@ -1383,7 +1383,7 @@ static void Task_SellBerries_PlaySfxAndRemoveBerries(u8 taskId)
s16 * data = gTasks[taskId].data;
PlaySE(SE_SHOP);
RemoveBagItem(gSpecialVar_ItemId, data[8]);
AddMoney(&gSaveBlock1Ptr->money, itemid_get_market_price(gSpecialVar_ItemId) / 2 * data[8]);
AddMoney(&gSaveBlock1Ptr->money, ItemId_GetPrice(gSpecialVar_ItemId) / 2 * data[8]);
RecordItemPurchase(gSpecialVar_ItemId, data[8], 2);
DestroyListMenuTask(data[0], &sStaticCnt.listMenuScrollOffset, &sStaticCnt.listMenuSelectedRow);
SortAndCountBerries();

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ const struct Item gItems[] = {
.description = gItemDescription_{{ item.itemId }},
## endif
.importance = {{ item.importance }},
.exitsBagOnUse = {{ item.exitsBagOnUse }},
.registrability = {{ item.registrability }},
.pocket = {{ item.pocket }},
.type = {{ item.type }},
.fieldUseFunc = {{ item.fieldUseFunc }},

View File

@ -621,12 +621,13 @@ const u8 * ItemId_GetName(u16 itemId)
return gItems[SanitizeItemId(itemId)].name;
}
u16 itemid_get_number(u16 itemId)
// Unused
u16 ItemId_GetId(u16 itemId)
{
return gItems[SanitizeItemId(itemId)].itemId;
}
u16 itemid_get_market_price(u16 itemId)
u16 ItemId_GetPrice(u16 itemId)
{
return gItems[SanitizeItemId(itemId)].price;
}
@ -646,14 +647,15 @@ const u8 * ItemId_GetDescription(u16 itemId)
return gItems[SanitizeItemId(itemId)].description;
}
bool8 itemid_is_unique(u16 itemId)
u8 ItemId_GetImportance(u16 itemId)
{
return gItems[SanitizeItemId(itemId)].importance;
}
u8 itemid_get_x19(u16 itemId)
// Unused
u8 ItemId_GetRegistrability(u16 itemId)
{
return gItems[SanitizeItemId(itemId)].exitsBagOnUse;
return gItems[SanitizeItemId(itemId)].registrability;
}
u8 ItemId_GetPocket(u16 itemId)

View File

@ -714,7 +714,7 @@ static void BagListMenuItemPrintFunc(u8 windowId, u32 itemId, u8 y)
{
bagItemId = BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, itemId);
bagItemQuantity = BagGetQuantityByPocketPosition(gBagMenuState.pocket + 1, itemId);
if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && !itemid_is_unique(bagItemId))
if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && ItemId_GetImportance(bagItemId) == 0)
{
ConvertIntToDecimalStringN(gStringVar1, bagItemQuantity, STR_CONV_MODE_RIGHT_ALIGN, 3);
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
@ -1611,7 +1611,7 @@ static void Task_ItemMenuAction_Give(u8 taskId)
CopyWindowToVram(0, COPYWIN_MAP);
if (!CanWriteMailHere(itemId))
DisplayItemMessageInBag(taskId, FONT_2, gText_CantWriteMailHere, Task_WaitAButtonAndCloseContextMenu);
else if (!itemid_is_unique(itemId))
else if (ItemId_GetImportance(itemId) == 0)
{
if (CalculatePlayerPartyCount() == 0)
{
@ -1717,7 +1717,7 @@ static void Task_ItemContext_FieldGive(u8 taskId)
ItemMenu_SetExitCallback(GoToBerryPouch_Give);
ItemMenu_StartFadeToExitCallback(taskId);
}
else if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && !itemid_is_unique(itemId))
else if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && ItemId_GetImportance(itemId) == 0)
{
Bag_BeginCloseWin0Animation();
gTasks[taskId].func = ItemMenu_StartFadeToExitCallback;
@ -1730,7 +1730,7 @@ static void Task_ItemContext_FieldGive(u8 taskId)
static void GoToTMCase_Give(void)
{
InitTMCase(TMCASE_FROMPARTYGIVE, ReturnToBagMenuFromSubmenu_Give, FALSE);
InitTMCase(TMCASE_GIVE_PARTY, ReturnToBagMenuFromSubmenu_Give, FALSE);
}
static void GoToBerryPouch_Give(void)
@ -1761,7 +1761,7 @@ static void Task_ItemContext_PcBoxGive(u8 taskId)
ItemMenu_SetExitCallback(GoToBerryPouch_PCBox);
ItemMenu_StartFadeToExitCallback(taskId);
}
else if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && !itemid_is_unique(itemId))
else if (gBagMenuState.pocket != POCKET_KEY_ITEMS - 1 && ItemId_GetImportance(itemId) == 0)
{
Bag_BeginCloseWin0Animation();
gTasks[taskId].func = ItemMenu_StartFadeToExitCallback;
@ -1774,7 +1774,7 @@ static void Task_ItemContext_PcBoxGive(u8 taskId)
static void GoToTMCase_PCBox(void)
{
InitTMCase(TMCASE_FROMPOKEMONSTORAGEPC, ReturnToBagMenuFromSubmenu_PCBox, FALSE);
InitTMCase(TMCASE_GIVE_PC, ReturnToBagMenuFromSubmenu_PCBox, FALSE);
}
static void GoToBerryPouch_PCBox(void)
@ -1800,7 +1800,7 @@ static void Task_ItemContext_Sell(u8 taskId)
ItemMenu_SetExitCallback(GoToBerryPouch_Sell);
ItemMenu_StartFadeToExitCallback(taskId);
}
else if (itemid_get_market_price(gSpecialVar_ItemId) == 0)
else if (ItemId_GetPrice(gSpecialVar_ItemId) == 0)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_OhNoICantBuyThat);
@ -1827,7 +1827,7 @@ static void Task_ItemContext_Sell(u8 taskId)
static void GoToTMCase_Sell(void)
{
InitTMCase(TMCASE_FROMMARTSELL, ReturnToBagMenuFromSubmenu_Sell, FALSE);
InitTMCase(TMCASE_SELL, ReturnToBagMenuFromSubmenu_Sell, FALSE);
}
static void GoToBerryPouch_Sell(void)
@ -1843,7 +1843,7 @@ static void ReturnToBagMenuFromSubmenu_Sell(void)
static void Task_PrintSaleConfirmationText(u8 taskId)
{
s16 *data = gTasks[taskId].data;
ConvertIntToDecimalStringN(gStringVar3, itemid_get_market_price(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
ConvertIntToDecimalStringN(gStringVar3, ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_ICanPayThisMuch_WouldThatBeOkay);
DisplayItemMessageInBag(taskId, GetDialogBoxFontId(), gStringVar4, Task_ShowSellYesNoMenu);
}
@ -1873,7 +1873,7 @@ static void Task_InitSaleQuantitySelectInterface(u8 taskId)
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
BagPrintTextOnWindow(r4, FONT_0, gStringVar4, 4, 10, 1, 0, 0xFF, 1);
UpdateSalePriceDisplay(itemid_get_market_price(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]);
UpdateSalePriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]);
BagPrintMoneyAmount();
CreatePocketScrollArrowPair_SellQuantity();
gTasks[taskId].func = Task_SelectQuantityToSell;
@ -1890,7 +1890,7 @@ static void Task_SelectQuantityToSell(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE)
{
UpdateQuantityToTossOrDeposit(data[8], 2);
UpdateSalePriceDisplay(itemid_get_market_price(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]);
UpdateSalePriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]);
}
else if (JOY_NEW(A_BUTTON))
{
@ -1923,7 +1923,7 @@ static void Task_SellItem_Yes(u8 taskId)
PutWindowTilemap(0);
ScheduleBgCopyTilemapToVram(0);
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar3, itemid_get_market_price(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
ConvertIntToDecimalStringN(gStringVar3, ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8], STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_TurnedOverItemsWorthYen);
DisplayItemMessageInBag(taskId, FONT_2, gStringVar4, Task_FinalizeSaleToShop);
}
@ -1933,7 +1933,7 @@ static void Task_FinalizeSaleToShop(u8 taskId)
s16 *data = gTasks[taskId].data;
PlaySE(SE_SHOP);
RemoveBagItem(gSpecialVar_ItemId, data[8]);
AddMoney(&gSaveBlock1Ptr->money, itemid_get_market_price(gSpecialVar_ItemId) / 2 * data[8]);
AddMoney(&gSaveBlock1Ptr->money, ItemId_GetPrice(gSpecialVar_ItemId) / 2 * data[8]);
RecordItemPurchase(gSpecialVar_ItemId, data[8], 2);
DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]);
Pocket_CalculateNItemsAndMaxShowed(gBagMenuState.pocket);

View File

@ -457,7 +457,7 @@ void FieldUseFunc_TmCase(u8 taskId)
static void InitTMCaseFromBag(void)
{
InitTMCase(0, CB2_BagMenuFromStartMenu, 0);
InitTMCase(TMCASE_FIELD, CB2_BagMenuFromStartMenu, FALSE);
}
static void Task_InitTMCaseFromField(u8 taskId)
@ -466,7 +466,7 @@ static void Task_InitTMCaseFromField(u8 taskId)
{
CleanupOverworldWindowsAndTilemaps();
SetFieldCallback2ForItemUse();
InitTMCase(0, CB2_ReturnToField, 1);
InitTMCase(TMCASE_FIELD, CB2_ReturnToField, TRUE);
DestroyTask(taskId);
}
}

View File

@ -4258,7 +4258,7 @@ static void CB2_ReturnToBagMenu(void)
static void CB2_ReturnToTMCaseMenu(void)
{
InitTMCase(TMCASE_NA, NULL, 0xFF);
InitTMCase(TMCASE_REOPENING, NULL, TMCASE_KEEP_PREV);
}
static void CB2_ReturnToBerryPouchMenu(void)

View File

@ -614,7 +614,7 @@ static void BuyMenuPrintPriceInList(u8 windowId, u32 item, u8 y)
if (item != INDEX_CANCEL)
{
ConvertIntToDecimalStringN(gStringVar1, itemid_get_market_price(item), 0, 4);
ConvertIntToDecimalStringN(gStringVar1, ItemId_GetPrice(item), 0, 4);
x = 4 - StringLength(gStringVar1);
loc = gStringVar4;
while (x-- != 0)
@ -902,7 +902,7 @@ static void Task_BuyMenu(u8 taskId)
BuyMenuRemoveScrollIndicatorArrows();
BuyMenuPrintCursor(tListTaskId, 2);
RecolorItemDescriptionBox(1);
gShopData.itemPrice = itemid_get_market_price(itemId);
gShopData.itemPrice = ItemId_GetPrice(itemId);
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, gShopData.itemPrice))
{
BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList);
@ -931,7 +931,7 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
BuyMenuQuantityBoxNormalBorder(3, 0);
BuyMenuPrintItemQuantityAndPrice(taskId);
ScheduleBgCopyTilemapToVram(0);
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / itemid_get_market_price(tItemId);
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / ItemId_GetPrice(tItemId);
if (maxQuantity > 99)
gShopData.maxQuantity = 99;
else
@ -949,7 +949,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&tItemCount, gShopData.maxQuantity) == TRUE)
{
gShopData.itemPrice = itemid_get_market_price(tItemId) * tItemCount;
gShopData.itemPrice = ItemId_GetPrice(tItemId) * tItemCount;
BuyMenuPrintItemQuantityAndPrice(taskId);
}
else
@ -1102,7 +1102,7 @@ void RecordItemPurchase(u16 item, u16 quantity, u8 a2)
if (history->unk0 < 999999)
{
history->unk0 += (itemid_get_market_price(item) >> (a2 - 1)) * quantity;
history->unk0 += (ItemId_GetPrice(item) >> (a2 - 1)) * quantity;
if (history->unk0 > 999999)
history->unk0 = 999999;
}

View File

@ -207,8 +207,8 @@ const u8 gText_PokeFluteAwakenedMon[] = _("The POKé FLUTE awakened sleeping\nPO
const u8 gText_TMCase[] = _("TM CASE");
const u8 gText_Close[] = _("CLOSE");
const u8 gText_TMCaseWillBePutAway[] = _("The TM CASE will be\nput away.");
const u8 gText_FontSize0[] = _("{FONT_0}");
const u8 gText_FontSize2[] = _("{FONT_2}");
const u8 gText_Font0[] = _("{FONT_0}");
const u8 gText_Font2[] = _("{FONT_2}");
const u8 gText_EmptySpace[] = _(" ");
const u8 gText_BerryPouch[] = _("BERRY POUCH");
const u8 gText_TheBerryPouchWillBePutAway[] = _("The BERRY POUCH will be\nput away.");

File diff suppressed because it is too large Load Diff