Add misc item data constants

This commit is contained in:
GriffinR 2021-01-19 05:49:20 -05:00
parent de52df5613
commit cf9f8d01c5
5 changed files with 501 additions and 832 deletions

View File

@ -490,6 +490,8 @@
#define ITEM_TO_BERRY(itemId)(((itemId - FIRST_BERRY_INDEX) + 1))
#define FIRST_MAIL_INDEX ITEM_ORANGE_MAIL
#define NUM_TECHNICAL_MACHINES 50
#define NUM_HIDDEN_MACHINES 8
@ -506,6 +508,21 @@
#define GOOD_ROD 1
#define SUPER_ROD 2
// Secondary IDs for bikes
#define MACH_BIKE 0
#define ACRO_BIKE 1
// Item type IDs (used to determine the exit callback)
#define ITEM_USE_MAIL 0
#define ITEM_USE_PARTY_MENU 1
#define ITEM_USE_FIELD 2
#define ITEM_USE_PBLOCK_CASE 3
#define ITEM_USE_BAG_MENU 4 // No exit callback, stays in bag menu
// Item battle usage IDs (only checked to see if nonzero)
#define ITEM_B_USE_MEDICINE 1
#define ITEM_B_USE_OTHER 2
// Check if the item is one that can be used on a Pokemon.
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2)

File diff suppressed because it is too large Load Diff

View File

@ -1721,7 +1721,7 @@ void ItemMenu_UseOutOfBattle(u8 taskId)
if (ItemId_GetFieldFunc(gSpecialVar_ItemId))
{
BagMenu_RemoveSomeWindow();
if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == 1)
if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == ITEM_USE_PARTY_MENU)
BagMenu_PrintThereIsNoPokemon(taskId);
else
{

View File

@ -77,13 +77,13 @@ EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL;
// Below is set TRUE by UseRegisteredKeyItemOnField
#define tUsingRegisteredKeyItem data[3]
// .rodata
// UB here if an item with type ITEM_USE_MAIL or ITEM_USE_BAG_MENU uses SetUpItemUseCallback
// Never occurs in vanilla, but can occur with improperly created items
static const MainCallback sItemUseCallbacks[] =
{
CB2_ShowPartyMenuForItemUse,
CB2_ReturnToField,
NULL,
[ITEM_USE_PARTY_MENU - 1] = CB2_ShowPartyMenuForItemUse,
[ITEM_USE_FIELD - 1] = CB2_ReturnToField,
[ITEM_USE_PBLOCK_CASE - 1] = NULL,
};
static const u8 sClockwiseDirections[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST};
@ -94,13 +94,12 @@ static const struct YesNoFuncTable sUseTMHMYesNoFuncTable =
.noFunc = BagMenu_InitListsMenu,
};
// .text
#define tEnigmaBerryType data[4]
static void SetUpItemUseCallback(u8 taskId)
{
u8 type;
if (gSpecialVar_ItemId == ITEM_ENIGMA_BERRY)
type = gTasks[taskId].data[4] - 1;
type = gTasks[taskId].tEnigmaBerryType - 1;
else
type = ItemId_GetType(gSpecialVar_ItemId) - 1;
if (!InBattlePyramid())
@ -218,9 +217,9 @@ void ItemUseOutOfBattle_Bike(u8 taskId)
static void ItemUseOnFieldCB_Bike(u8 taskId)
{
if (!ItemId_GetSecondaryId(gSpecialVar_ItemId))
if (ItemId_GetSecondaryId(gSpecialVar_ItemId) == MACH_BIKE)
GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE);
else
else // ACRO_BIKE
GetOnOffBike(PLAYER_AVATAR_FLAG_ACRO_BIKE);
ScriptUnfreezeObjectEvents();
ScriptContext2_Disable();
@ -1065,28 +1064,28 @@ void ItemUseOutOfBattle_EnigmaBerry(u8 taskId)
case ITEM_EFFECT_SPDEF_EV:
case ITEM_EFFECT_SPEED_EV:
case ITEM_EFFECT_DEF_EV:
gTasks[taskId].data[4] = 1;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
ItemUseOutOfBattle_Medicine(taskId);
break;
case ITEM_EFFECT_SACRED_ASH:
gTasks[taskId].data[4] = 1;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
ItemUseOutOfBattle_SacredAsh(taskId);
break;
case ITEM_EFFECT_RAISE_LEVEL:
gTasks[taskId].data[4] = 1;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
ItemUseOutOfBattle_RareCandy(taskId);
break;
case ITEM_EFFECT_PP_UP:
case ITEM_EFFECT_PP_MAX:
gTasks[taskId].data[4] = 1;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
ItemUseOutOfBattle_PPUp(taskId);
break;
case ITEM_EFFECT_HEAL_PP:
gTasks[taskId].data[4] = 1;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
ItemUseOutOfBattle_PPRecovery(taskId);
break;
default:
gTasks[taskId].data[4] = 4;
gTasks[taskId].tEnigmaBerryType = ITEM_USE_BAG_MENU;
ItemUseOutOfBattle_CannotUse(taskId);
break;
}

View File

@ -254,7 +254,7 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
sMailRead->parserMultiple = ConvertEasyChatWordsToString;
if (IS_ITEM_MAIL(mail->itemId))
{
sMailRead->mailType = mail->itemId - ITEM_ORANGE_MAIL;
sMailRead->mailType = mail->itemId - FIRST_MAIL_INDEX;
}
else
{
@ -279,10 +279,10 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
default:
sMailRead->animsActive = 0;
break;
case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL:
case ITEM_BEAD_MAIL - FIRST_MAIL_INDEX:
sMailRead->animsActive = 1;
break;
case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL:
case ITEM_DREAM_MAIL - FIRST_MAIL_INDEX:
sMailRead->animsActive = 2;
break;
}