diff --git a/include/code_801B3C0.h b/include/code_801B3C0.h index 76ad0b429..aff5cacfc 100644 --- a/include/code_801B3C0.h +++ b/include/code_801B3C0.h @@ -21,8 +21,8 @@ typedef struct unkStruct_203B230 MenuInputStructSub unk88; } unkStruct_203B230; -bool8 sub_801B3C0(Item *item); +bool8 InitItemDescriptionWindow(Item *item); u32 sub_801B410(void); -void sub_801B450(void); +void FreeItemDescriptionWindow(void); #endif // GUARD_CODE_801B3C0_H diff --git a/include/constants/dungeon_action.h b/include/constants/dungeon_action.h index d01f17a83..fcc22457f 100644 --- a/include/constants/dungeon_action.h +++ b/include/constants/dungeon_action.h @@ -16,6 +16,7 @@ enum DungeonAction ACTION_THROW_ITEM_PLAYER = 0xB, ACTION_SHOW_INFO = 0xC, ACTION_EAT_BERRY_SEED_DRINK = 0xD, + ACTION_UNK10 = 0x10, ACTION_USE_TM = 0x12, ACTION_TALK_FIELD = 0x13, // Talking to another Pokémon by facing them and interacting. ACTION_USE_MOVE_PLAYER = 0x14, @@ -43,12 +44,15 @@ enum DungeonAction ACTION_USE_ORB = 0x31, ACTION_REGULAR_ATTACK = 0x32, ACTION_UNSET_MOVE = 0x33, + ACTION_UNK35 = 0x35, ACTION_GIVE_ITEM = 0x36, ACTION_TAKE_ITEM = 0x37, ACTION_USE_ITEM = 0x38, ACTION_SECOND_THOUGHTS = 0x39, // Happens with invalid actions, like attempting to eat a non-consumable item. + ACTION_UNK3A = 0x3A, ACTION_SET_ITEM = 0x3C, ACTION_UNSET_ITEM = 0x3D, + ACTION_UNK3E = 0x3E, ACTION_PICK_UP_AI = 0x3F, ACTION_THROW_ARC_PLAYER = 0x41, // Throwing Gravelerocks and Geo Pebbles. NUM_DUNGEON_ACTIONS diff --git a/include/dungeon_items.h b/include/dungeon_items.h index 288a1147b..f1bafd243 100644 --- a/include/dungeon_items.h +++ b/include/dungeon_items.h @@ -2,9 +2,33 @@ #define GUARD_DUNGEON_ITEMS_H #include "structs/dungeon_entity.h" +#include "structs/str_position.h" +#include "structs/str_items.h" +void sub_8045BF8(u8 *buffer, Item *item); +void sub_8045C08(u8 *buffer, Item *item); +void sub_8045C18(u8 *buffer, Item *item); +#define FORCE_STICKY_RANDOM 0 +#define FORCE_STICKY_ALWAYS 1 +#define FORCE_STICKY_NEVER 2 +void CreateItemWithStickyChance(Item *item, u8 itemID, u32 forceSticky); +void CreateFloorItems(void); +void PickUpItemFromPos(struct DungeonPos *pos, bool8 printMsg); +bool8 sub_80460F8(DungeonPos *pos, Item *item, bool8 a2); +bool8 sub_80461C8(DungeonPos *pos, bool8 a2); +bool8 sub_80462AC(Entity * entity, u8 hallucinating, u8 a2, u8 a3, u8 a4); +const u8 *sub_80464AC(Item *item); +void sub_80464C8(Entity *entity, DungeonPos *pos, Item *item); +void sub_804652C(Entity *entity1, Entity *entity2, Item *item, bool8 a3, DungeonPos *pos); +void sub_8046860(Entity *entity, DungeonPos *pos, Item *item, s32 a4); +void sub_804687C(Entity *entity, DungeonPos *pos1, DungeonPos *pos2, Item *item, s32 count); bool8 HasHeldItem(Entity *pokemon, u8 id); -void sub_8046CE4(Item *item, s32 param_2); void sub_8046D20(void); +bool8 sub_8046F00(Item *item); +void ClearAllItemsWithFlag(s32 itemFlag); +void AllItemsToPlainSeed(void); +bool8 PlayerHasItemWithFlag(s32 itemFlag); +void CleanUpInventoryItems(void); +void ClearUnpaidFlagFromAllItems(void); #endif diff --git a/include/dungeon_menu_items.h b/include/dungeon_menu_items.h index ee8424def..f5dbe9975 100644 --- a/include/dungeon_menu_items.h +++ b/include/dungeon_menu_items.h @@ -6,6 +6,6 @@ bool8 sub_805FD3C(struct UnkMenuBitsStruct *a0); bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); -void sub_8060D24(UNUSED ActionContainer *a0); +void DungeonShowItemDescription(UNUSED ActionContainer *a0); #endif diff --git a/include/items.h b/include/items.h index 933aa5920..67c11f8c2 100644 --- a/include/items.h +++ b/include/items.h @@ -14,7 +14,7 @@ TeamInventory *GetMoneyItemsInfo(void); void InitializeMoneyItems(void); s32 GetNumberOfFilledInventorySlots(void); bool8 IsThrowableItem(u8 id); -void xxx_init_itemslot_8090A8C(Item *param_1,u8 id,u8 param_3); +void ItemIdToSlot(Item *param_1,u8 id,u8 param_3); void xxx_init_helditem_8090B08(BulkItem *param_1,u8 id); void HeldItemToSlot(Item *param_1, BulkItem *param_2); void SlotToHeldItem(BulkItem *held, Item *slot); diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 845800a51..fe016e4ca 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -127,7 +127,7 @@ typedef struct FloorProperties u8 kecleonShopChance; // Percentage chance 0-100% u8 monsterHouseChance; // Percentage chance 0-100% u8 mazeRoomChance; // Percentage chance 0-100% - u8 unkA; + u8 itemStickyChance; // Percentage chance 0-100% bool8 allowDeadEnds; u8 secondaryStructuresBudget; // Maximum number of secondary structures that can be generated u8 roomFlags; // See ROOM_FLAG_ @@ -146,11 +146,19 @@ typedef struct FloorProperties u8 unk1A; } FloorProperties; -typedef struct UnkDungeonGlobal_unk1C590 +enum { + ITEM_SPAWN_NORMAL, + ITEM_SPAWN_IN_SHOP, + ITEM_SPAWN_IN_MONSTER_HOUSE, + ITEM_SPAWN_WALL, // ? + ITEM_SPAWN_TYPES_COUNT +}; + +typedef struct ItemSpawns { s16 categoryValues[NUM_ITEM_CATEGORIES]; s16 itemValues[NUMBER_OF_ITEM_IDS]; -} UnkDungeonGlobal_unk1C590; +} ItemSpawns; typedef struct UnkDungeonGlobal_unk1CD98 { @@ -252,7 +260,7 @@ typedef struct unkDungeon644 /* 0x14 */ bool8 canRecruit; /* 0x15 */ u8 unk15; /* 0x16 */ u8 unk16; - /* 0x17 */ u8 unk17; + /* 0x17 */ bool8 hasInventory; /* 0x18 */ u8 unk18; /* 0x19 */ u8 unk19; /* 0x1A */ u8 fill1A[2]; @@ -480,8 +488,8 @@ typedef struct Dungeon /* 0x1BDD4 */ struct UnkStructDungeon1BDD4 unk1BDD4; /* 0x1BE14 */ struct MessageLogString messageLogStrings[MESSAGE_LOG_STRINGS_COUNT]; /* 0x1C570 */ DungeonLocation unk1C570; - /* 0x1C574 */ FloorProperties unk1C574; - /* 0x1C590 */ UnkDungeonGlobal_unk1C590 unk1C590[4]; + /* 0x1C574 */ FloorProperties floorProperties; + /* 0x1C590 */ ItemSpawns itemSpawns[ITEM_SPAWN_TYPES_COUNT]; u16 unk1CD70[20]; UnkDungeonGlobal_unk1CD98 unk1CD98[32]; UnkDungeonGlobal_unk1CE98_sub unk1CE98; // TODO: not sure how large this is diff --git a/src/code_801B3C0.c b/src/code_801B3C0.c index 1ea71f135..e803f8184 100644 --- a/src/code_801B3C0.c +++ b/src/code_801B3C0.c @@ -19,7 +19,7 @@ static void sub_801B480(void); static void sub_801B51C(void); static void sub_801B590(void); -bool8 sub_801B3C0(Item *item) +bool8 InitItemDescriptionWindow(Item *item) { ResetSprites(TRUE); sUnknown_203B230 = MemoryAlloc(sizeof(unkStruct_203B230),8); @@ -52,7 +52,7 @@ u32 sub_801B410(void) return 0; } -void sub_801B450(void) +void FreeItemDescriptionWindow(void) { if (sUnknown_203B230 != NULL) { MemoryFree(sUnknown_203B230); diff --git a/src/code_801B60C.c b/src/code_801B60C.c index f44ba2fa0..ae88c5fd0 100644 --- a/src/code_801B60C.c +++ b/src/code_801B60C.c @@ -244,7 +244,7 @@ store: sub_8012D60(&sUnknown_203B234->unk28, sUnknown_203B234->unkCC, 0, 0, sUnknown_203B234->menuAction, 2); break; case 11: - sub_801B3C0(&sUnknown_203B234->unk20); + InitItemDescriptionWindow(&sUnknown_203B234->unk20); break; case 12: sub_801A9E0(); @@ -470,7 +470,7 @@ static void sub_801BEAC(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); sub_801B748(9); case 0: case 1: diff --git a/src/code_80227B8.c b/src/code_80227B8.c index 3bd8dd8f0..6f584aeb3 100644 --- a/src/code_80227B8.c +++ b/src/code_80227B8.c @@ -159,7 +159,7 @@ static void sub_8022A10(void) sub_8012D60(&sUnknown_203B294->unkA4, sUnknown_80DC584, 0, 0, 3, 1); break; case 4: - sub_801B3C0(&sUnknown_203B294->item); + InitItemDescriptionWindow(&sUnknown_203B294->item); break; case 5: CreateDialogueBoxAndPortrait(sDoesNotAppearHungry, 0, 0, 0x301); @@ -446,7 +446,7 @@ static void sub_80230E8(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); sub_8022924(1); case 1: case 0: diff --git a/src/code_803D110.c b/src/code_803D110.c index 95e2d54d0..762afb0d9 100644 --- a/src/code_803D110.c +++ b/src/code_803D110.c @@ -93,7 +93,7 @@ void sub_803D4D0(void) gDungeon->unk1CEC8 = GetDungeonFloorCount(gDungeon->unk644.dungeonLocation.id); gDungeon->unk14 = sub_80902C8(gDungeon->unk644.dungeonLocation.id); - gDungeon->unk1C574 = ((struct UnkDataFileStruct *)(file->data))->unk4[strPtr->unk0]; + gDungeon->floorProperties = ((struct UnkDataFileStruct *)(file->data))->unk4[strPtr->unk0]; for (i = 0; i < 20; i++) { gDungeon->unk1CD70[i] = ((struct UnkDataFileStruct *)(file->data))->unk10[strPtr->unk4][i]; @@ -127,12 +127,12 @@ void sub_803D4D0(void) arrId = 0; for (j = 0; j < NUM_ITEM_CATEGORIES; j++) { - gDungeon->unk1C590[i].categoryValues[arrId] = spArray[arrId]; + gDungeon->itemSpawns[i].categoryValues[arrId] = spArray[arrId]; arrId++; } for (j = 0; j < NUMBER_OF_ITEM_IDS; j++) { - gDungeon->unk1C590[i].itemValues[j] = spArray[arrId]; + gDungeon->itemSpawns[i].itemValues[j] = spArray[arrId]; arrId++; } } @@ -152,28 +152,28 @@ u8 sub_803D6FC(void) return 16; } -u8 sub_803D73C(s32 a0) +u8 GetRandomFloorItem(s32 spawnType) { s32 i; s32 rand = DungeonRandInt(10000); u8 category = NUM_ITEM_CATEGORIES; for (i = 0; i < NUM_ITEM_CATEGORIES; i++) { - if (gDungeon->unk1C590[a0].categoryValues[i] != 0 && gDungeon->unk1C590[a0].categoryValues[i] >= rand) { + if (gDungeon->itemSpawns[spawnType].categoryValues[i] != 0 && gDungeon->itemSpawns[spawnType].categoryValues[i] >= rand) { category = i; break; } } if (category == NUM_ITEM_CATEGORIES) - return 105; + return ITEM_POKE; rand = DungeonRandInt(10000); for (i = 0; i < NUMBER_OF_ITEM_IDS; i++) { - if (gDungeon->unk1C590[a0].itemValues[i] != 0 && GetItemCategory(i) == category && gDungeon->unk1C590[a0].itemValues[i] >= rand) { + if (gDungeon->itemSpawns[spawnType].itemValues[i] != 0 && GetItemCategory(i) == category && gDungeon->itemSpawns[spawnType].itemValues[i] >= rand) { return i; } } - return 105; + return ITEM_POKE; } s32 sub_803D808(UnkDungeonGlobal_unk1CD98 *strPtr, s32 id) diff --git a/src/code_803E724.c b/src/code_803E724.c index 8807f6e81..64a70a270 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -694,7 +694,7 @@ void sub_803F27C(bool8 a0) gUnknown_202EDFC = 0xFFFF; if (!a0) { - strPtr->visibilityRange = gDungeon->unk1C574.unk16 & 3; + strPtr->visibilityRange = gDungeon->floorProperties.unk16 & 3; if (strPtr->visibilityRange == 0) { strPtr->unk1820C = 1; } diff --git a/src/code_8042B34.c b/src/code_8042B34.c index f72c581b4..b946e8a4b 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -41,6 +41,7 @@ #include "dungeon_serializer.h" #include "dungeon_config.h" #include "dungeon_map.h" +#include "dungeon_items.h" extern void sub_800EE5C(s32); extern void sub_800EF64(void); @@ -263,10 +264,8 @@ extern void sub_803E250(void); extern void sub_803E830(void); extern void sub_803E214(void); extern void nullsub_56(void); -extern void sub_8047104(void); extern void sub_8068F28(void); extern void sub_806C1D8(void); -extern void sub_804700C(void); extern void IncrementThievingSuccesses(void); extern void sub_803E13C(void); extern void sub_80841EC(void); @@ -313,7 +312,6 @@ extern void sub_806B168(void); extern void sub_806B6C4(void); extern void sub_806A338(void); extern void sub_8051E3C(void); -extern void sub_8045CB0(void); extern void sub_807FA18(void); extern void sub_806A974(void); extern void sub_806CF60(void); @@ -327,7 +325,6 @@ extern void sub_803EAF0(u32, u32); extern void sub_806A914(bool8 a0, bool8 a1, bool8 showRunAwayEffect); extern void sub_803F4A0(Entity *a0); extern void sub_8083AB0(s16 param_0, Entity * target, Entity * entity); -extern void sub_8046F84(s32 itemFlag); extern bool8 sub_8083C50(void); extern void sub_8068FE0(Entity *, u32, Entity *r2); extern void ResetMonEntityData(EntityInfo *, u32); @@ -405,7 +402,7 @@ void RunDungeon(UnkStruct_RunDungeon *r8) gDungeon->unk644.unk16 = r8->unkC; gDungeon->unk644.canRecruit = r8->unkA; gDungeon->unk644.unk15 = r8->unkB; - gDungeon->unk644.unk17 = r8->unkD; + gDungeon->unk644.hasInventory = r8->unkD; gDungeon->unk644.unk19 = r8->unkE; StopDungeonBGM(); sub_803D4AC(); @@ -562,9 +559,9 @@ void RunDungeon(UnkStruct_RunDungeon *r8) gDungeon->unk644.unk40 = 99; gDungeon->unk644.unk42 = 99; gDungeon->weather.weather = 0; - gDungeon->tileset = gDungeon->unk1C574.unk2; - gDungeon->unk3A10 = gDungeon->unk1C574.unk3; - gDungeon->fixedRoomNumber = gDungeon->unk1C574.unk12; + gDungeon->tileset = gDungeon->floorProperties.unk2; + gDungeon->unk3A10 = gDungeon->floorProperties.unk3; + gDungeon->fixedRoomNumber = gDungeon->floorProperties.unk12; sub_807E5E4(0); sub_80842F0(); } @@ -618,7 +615,7 @@ void RunDungeon(UnkStruct_RunDungeon *r8) gDungeon->unk17B40 = 0; if (!r6) { sub_807FA18(); - sub_8045CB0(); + CreateFloorItems(); gDungeon->unk644.unk50 = gDungeon->unk644.unk48; gDungeon->unk644.unk4C = 0; sub_8051E3C(); @@ -793,13 +790,13 @@ void RunDungeon(UnkStruct_RunDungeon *r8) SaveDungeonState(gSerializedData_203B41C, 0x4800); } else { - sub_8046F84(ITEM_FLAG_IN_SHOP); + ClearAllItemsWithFlag(ITEM_FLAG_IN_SHOP); } sub_806C1D8(); if (gDungeon->unk644.unk10 == 1) { if (gDungeon->unk644.unk2A != 0) { - sub_804700C(); + AllItemsToPlainSeed(); } check = TRUE; } @@ -915,7 +912,7 @@ void RunDungeon(UnkStruct_RunDungeon *r8) nullsub_56(); CloseDungeonMapFile(); if (r8->unk7C == 1 || r8->unk7C == 4 || r8->unk7C == 2) { - sub_8047104(); + CleanUpInventoryItems(); } if (r8->unk7C == 1 || r8->unk7C == -2 || r8->unk7C == 4 || r8->unk7C == -1 || r8->unk7C == 2) { if (r8->unk7C == 1 || r8->unk7C == 4 || r8->unk7C == 2) { @@ -1023,7 +1020,7 @@ void sub_8043D60(void) } } - sub_8046F84(ITEM_FLAG_IN_SHOP); + ClearAllItemsWithFlag(ITEM_FLAG_IN_SHOP); } bool8 sub_8043ED0(bool8 a0) diff --git a/src/code_8045A00.c b/src/code_8045A00.c index cc9756af5..a4ffb2d67 100644 --- a/src/code_8045A00.c +++ b/src/code_8045A00.c @@ -12,14 +12,10 @@ #include "dungeon_ai_targeting.h" #include "string_format.h" #include "items.h" +#include "trap.h" #include "status_checks_1.h" #include "structs/map.h" #include "structs/str_dungeon.h" -#include "trap.h" -#include "math.h" -#include "code_80450F8.h" -#include "dungeon_util.h" -#include "structs/str_item_text.h" void sub_8045BF8(u8 *, Item *); @@ -87,8 +83,3 @@ void SubstitutePlaceholderStringTags(u8 *buffer, Entity *entity, u32 param_3) break; } } - -// FILE SPLIT HERE - - -// diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 3b60aa4e2..083ff0bea 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -92,19 +92,15 @@ extern Item *sub_8044D90(Entity *, s32, u32); void sub_8045BF8(u8 *, Item *); u8 sub_8048D50(); void SetActionUnusableInDungeonSubMenu(u16 param_1); -u8 * sub_80464AC(); void AddActionToDungeonSubMenu(u16 param_1, u8 param_2); void sub_8044DF0(); void sub_8042208(Entity *pokemon, u8 r1); void sub_803E708(); void sub_80479B8(); -u8 sub_80460F8(DungeonPos *, Item *, u32); extern void sub_807AB38(Entity *, u32); extern Entity * sub_8044DA4(Entity *param_1,int param_2); extern void sub_806A6E8(Entity *); extern void sub_8044DF0(Entity *, u32, u32); -extern void sub_8045DB4(DungeonPos *, u32); -extern bool8 sub_80461C8(DungeonPos *, u32); extern bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s32 arg_0); extern bool8 sub_8044B28(void); Entity *sub_806773C(Entity *entity); @@ -119,7 +115,7 @@ extern Entity * sub_80696A8(Entity *target); void HandlePickUpPlayerAction(Entity *entity) { GetEntInfo(entity)->action.actionParameters[0].actionUseIndex = 1; - sub_8045DB4(&entity->pos,0); + PickUpItemFromPos(&entity->pos,0); } void HandleSetItemAction(Entity *param_1, bool8 param_2) diff --git a/src/code_8069E0C.c b/src/code_8069E0C.c index d24ddd72a..adf13948b 100644 --- a/src/code_8069E0C.c +++ b/src/code_8069E0C.c @@ -66,7 +66,7 @@ extern DungeonPos gUnknown_202EE0C; extern void sub_803F4A0(Entity *a0); extern bool8 sub_80860A8(u8 id); extern u8 gUnknown_202F32C; -extern u8 sub_803D73C(s32 a0); +extern u8 GetRandomFloorItem(s32 a0); extern void DeletePokemonDungeonSprite(s32 id); extern void sub_80429E8(Entity *r0); extern s32 sub_803DA20(s32 param_1); @@ -1407,9 +1407,9 @@ bool8 sub_806B8CC(s16 _species, s32 x, s32 y, PokemonStruct2 *monPtr, Entity **a && (entityInfo->abilities[0] == ABILITY_PICKUP || entityInfo->abilities[1] == ABILITY_PICKUP) && !ItemExists(&entityInfo->heldItem)) { - u32 pickUpItem = sub_803D73C(0); + u32 pickUpItem = GetRandomFloorItem(0); if (pickUpItem != ITEM_POKE) { - xxx_init_itemslot_8090A8C(&entityInfo->heldItem, pickUpItem, 0); + ItemIdToSlot(&entityInfo->heldItem, pickUpItem, 0); entityInfo->unkF3 = TRUE; } } diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 0810e0ac0..34f4bc571 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -282,7 +282,6 @@ extern void sub_806A390(Entity *r0); extern void sub_806F63C(Entity *r0); extern void sub_8078084(Entity * pokemon); extern void sub_800DBBC(void); -extern void sub_8045C28(Item *Item, u8 itemID, u32 param_3); extern void sub_80464C8(Entity *, DungeonPos *, Item *); extern bool8 DoEnemiesEvolveWhenKOed(u8 dungeon); extern bool8 sub_806FA5C(Entity *, Entity *, struct unkStruct_8069D4C *); @@ -869,7 +868,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc if (reviverSeed != NULL) { sub_8042148(target); - sub_8045C28(reviverSeed, ITEM_PLAIN_SEED, 2); + CreateItemWithStickyChance(reviverSeed, ITEM_PLAIN_SEED, FORCE_STICKY_NEVER); target->unk22 = 0; targetData->HP = targetData->maxHPStat; targetData->unk158 = 0; diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index fa2eb2d7d..d2e6eb8a3 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -42,7 +42,6 @@ extern void sub_8067110(Entity *); extern void sub_80671A0(Entity *); extern void sub_8073D14(Entity *); extern void sub_8045BF8(u8 *, Item *); -extern bool8 sub_80461C8(DungeonPos *, u32); extern void sub_805229C(void); extern void sub_807E8F0(Entity *); extern void sub_80444F4(Entity *pokemon); @@ -156,7 +155,7 @@ void sub_8073D14(Entity *entity) Item *carriedItems[INVENTORY_SIZE + 1]; // plus held s32 newQuantity; - if (gDungeon->unk644.unk17 && !_entityInfo->isNotTeamMember) { + if (gDungeon->unk644.hasInventory && !_entityInfo->isNotTeamMember) { for (i = 0; i < INVENTORY_SIZE; i++) { carriedItems[i] = &gTeamInventoryRef->teamItems[i]; inventoryIds[i] = i; diff --git a/src/debug_menu2.c b/src/debug_menu2.c index af32641b8..3a2fe7eff 100644 --- a/src/debug_menu2.c +++ b/src/debug_menu2.c @@ -128,8 +128,8 @@ static void sub_803A5A0(void) sub_803A690(); break; case 4: - xxx_init_itemslot_8090A8C(&item, sUnknown_203B3F0->id, 0); - sub_801B3C0(&item); + ItemIdToSlot(&item, sUnknown_203B3F0->id, 0); + InitItemDescriptionWindow(&item); break; case 5: break; @@ -239,7 +239,7 @@ static void sub_803A86C(void) break; case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); sub_803A504(1); break; } diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c index 6b41e2580..6eba3934a 100644 --- a/src/dungeon_cutscenes.c +++ b/src/dungeon_cutscenes.c @@ -388,10 +388,7 @@ extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); extern void sub_807EAA0(u32, u32); extern void sub_8072008(Entity *, Entity *, s16, u32, u32); extern void sub_8085374(void); -extern void sub_8045C28(Item *, u8 , u8 *); -extern void sub_8046860(Entity *, DungeonPos *, Item *, u32); -extern u32 sub_803D73C(u32); -extern void sub_80460F8(DungeonPos *, Item *, u8); +extern u32 GetRandomFloorItem(u32); extern u8 sub_8044B28(void); extern bool8 sub_8085B80(struct_8085B80 *); @@ -3548,7 +3545,7 @@ void sub_808AE54(u8 param_1,u8 param_2,DungeonPos *param_3) if (!sub_8098100(0x22) && (param_2 == 0x2E) && (param_1 == 0x17)) { sub_808B1CC(ITEM_NOTHING); if (!sub_8098100(0x1d)) { - xxx_init_itemslot_8090A8C(&item,ITEM_ROCK_PART,0); + ItemIdToSlot(&item,ITEM_ROCK_PART,0); sub_80464C8(GetLeader(),param_3,&item); DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); // Something fell from Regirock's body @@ -3571,7 +3568,7 @@ void sub_808AEC8(u8 param_1,u8 param_2,DungeonPos *param_3) if (!sub_8098100(0x22) && (param_2 == 0x2F) && (param_1 == 0x18)) { sub_808B1CC(ITEM_NOTHING); if (!sub_8098100(0x1d)) { - xxx_init_itemslot_8090A8C(&item,ITEM_ICE_PART,0); + ItemIdToSlot(&item,ITEM_ICE_PART,0); sub_80464C8(GetLeader(),param_3,&item); DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); // Something fell from Regice's body @@ -3593,7 +3590,7 @@ void sub_808AF3C(u8 param_1,u8 param_2,DungeonPos *param_3) if (!sub_8098100(0x22) && (param_2 == 0x30) && (param_1 == 0x19)) { sub_808B1CC(ITEM_NOTHING); if (!sub_8098100(0x1d)) { - xxx_init_itemslot_8090A8C(&item,ITEM_STEEL_PART,0); + ItemIdToSlot(&item,ITEM_STEEL_PART,0); sub_80464C8(GetLeader(),param_3, &item); DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); // Something fell from Registeel's body @@ -3716,7 +3713,7 @@ void sub_808B1CC(u8 itemID) tile->terrainType = tile->terrainType | TERRAIN_TYPE_STAIRS; if (((itemID != ITEM_NOTHING) && (sub_80860A8(itemID) == 0)) && (sub_80860A8(ITEM_MUSIC_BOX) == 0)) { - xxx_init_itemslot_8090A8C(&item,itemID,0); + ItemIdToSlot(&item,itemID,0); pos.y--; sub_80460F8(&pos,&item,1); } @@ -3925,7 +3922,7 @@ void JirachiWish(void) { for(index = 0; index < 9; index++) { - sub_8045C28(&moneyItems[index], ITEM_POKE, 0); + CreateItemWithStickyChance(&moneyItems[index], ITEM_POKE, 0); } pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); @@ -3950,7 +3947,7 @@ void JirachiWish(void) { for(index = 0; index < 9; index++) { - sub_8045C28(&items[index], sub_803D73C(0),0); + CreateItemWithStickyChance(&items[index], GetRandomFloorItem(0),0); } pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); @@ -4006,7 +4003,7 @@ void JirachiWish(void) for(index = 0; index < 4; index++) { - sub_8045C28(&strengthItems[index],gUnknown_81074FC[DungeonRandInt(8)],0); + CreateItemWithStickyChance(&strengthItems[index],gUnknown_81074FC[DungeonRandInt(8)],0); } pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); diff --git a/src/dungeon_generation.c b/src/dungeon_generation.c index bddd4608d..02d76ddcb 100644 --- a/src/dungeon_generation.c +++ b/src/dungeon_generation.c @@ -171,7 +171,7 @@ void GenerateFloor(void) s32 x, y; s32 spawnAttempts; bool8 secondaryGen = FALSE; - FloorProperties *floorProps = &gDungeon->unk1C574; + FloorProperties *floorProps = &gDungeon->floorProperties; gDungeon->unk13568 = OpenFileAndGetFileDataPtr(gUnknown_80F6DCC, &gDungeonFileArchive); sHasKecleonShop = FALSE; @@ -6094,10 +6094,10 @@ static void sub_805193C(u8 itemId, s32 x, s32 y, s32 quantity, u32 itemFlags) DungeonPos pos = {x, y}; if (sub_805210C(itemId)) { - xxx_init_itemslot_8090A8C(&item, ITEM_LINK_CABLE, 0); + ItemIdToSlot(&item, ITEM_LINK_CABLE, 0); } else { - xxx_init_itemslot_8090A8C(&item, itemId, 0); + ItemIdToSlot(&item, itemId, 0); } item.flags |= itemFlags; diff --git a/src/dungeon_items.c b/src/dungeon_items.c index 19df08df7..e7892e579 100644 --- a/src/dungeon_items.c +++ b/src/dungeon_items.c @@ -59,6 +59,7 @@ extern void sub_804178C(u32); extern void sub_804219C(PixelPos *pos); extern void DungeonRunFrameActions(u32); extern bool8 sub_8045888(Entity *); +extern u32 GetRandomFloorItem(u32); static void MusicBoxCreation(void); static u8 sub_8046D70(void); @@ -67,12 +68,8 @@ extern SpriteOAM gUnknown_202EDC0; extern u8 gUnknown_203B420[]; extern u8 gUnknown_203B428[]; -void sub_8046734(Entity *entity, DungeonPos *pos); -void sub_804687C(Entity *entity, DungeonPos *pos1, DungeonPos *pos2, Item *item, s32 a4); -void sub_804652C(Entity *entity1, Entity *entity2, Item *item, bool8 a3, DungeonPos *pos); -bool8 sub_80461C8(DungeonPos *, bool8); -extern u32 sub_803D73C(u32); -bool8 sub_80460F8(DungeonPos *, Item *, bool8); +static void sub_8046734(Entity *entity, DungeonPos *pos); +static void sub_8046CE4(Item *item,s32 param_2); void sub_8045BF8(u8 *buffer, Item *item) { @@ -89,38 +86,39 @@ void sub_8045C18(u8 *buffer, Item *item) sub_8090E14(buffer, item, &gUnknown_80F6990); } -void sub_8045C28(Item *item, u8 itemID, u32 param_3) +void CreateItemWithStickyChance(Item *item, u8 itemID, u32 forceSticky) { bool8 stickyFlag; - xxx_init_itemslot_8090A8C(item,itemID,0); + ItemIdToSlot(item, itemID, FALSE); stickyFlag = FALSE; if (IsNotSpecialItem(itemID)) { - if (param_3 == 0) { - if (DungeonRandInt(100) < gDungeon->unk1C574.unkA) + if (forceSticky == FORCE_STICKY_RANDOM) { + if (DungeonRandInt(100) < gDungeon->floorProperties.itemStickyChance) stickyFlag = TRUE; else stickyFlag = FALSE; } - else if (param_3 == 1) { + else if (forceSticky == FORCE_STICKY_ALWAYS) { stickyFlag = TRUE; } } + if (stickyFlag) { item->flags |= ITEM_FLAG_STICKY; } if (GetItemCategory(itemID) == CATEGORY_POKE) { - sub_8046CE4(item, gDungeon->unk1C574.unk17 * 40); + sub_8046CE4(item, gDungeon->floorProperties.unk17 * 40); } } -void sub_8045CB0(void) +void CreateFloorItems(void) { u8 itemID; s32 yCounter, xCounter; const Tile *tile; - u32 uVar5; + s32 spawnType; Item item; u32 flag; s32 x = DungeonRandInt(DUNGEON_MAX_SIZE_X); @@ -141,7 +139,7 @@ void sub_8045CB0(void) } tile = GetTile(x,y); - if (!(tile->terrainType & TERRAIN_TYPE_STAIRS) && (tile->spawnOrVisibilityFlags & 2)) { + if (!(tile->terrainType & TERRAIN_TYPE_STAIRS) && (tile->spawnOrVisibilityFlags & SPAWN_FLAG_ITEM)) { DungeonPos pos; bool8 shopFlag = FALSE; pos.x = x; @@ -149,22 +147,22 @@ void sub_8045CB0(void) if (tile->terrainType & TERRAIN_TYPE_SHOP) { shopFlag = TRUE; - uVar5 = 1; + spawnType = ITEM_SPAWN_IN_SHOP; } else { if (GetTerrainType(tile) == TERRAIN_TYPE_WALL) { - uVar5 = 3; + spawnType = ITEM_SPAWN_WALL; } else { - uVar5 = (tile->terrainType & TERRAIN_TYPE_IN_MONSTER_HOUSE) ? 2 : 0; + spawnType = (tile->terrainType & TERRAIN_TYPE_IN_MONSTER_HOUSE) ? ITEM_SPAWN_IN_MONSTER_HOUSE : ITEM_SPAWN_NORMAL; } } - itemID = sub_803D73C(uVar5); + itemID = GetRandomFloorItem(spawnType); if (!CanSellItem(itemID)) { - shopFlag = 0; + shopFlag = FALSE; } - sub_8045C28(&item,itemID,0); + CreateItemWithStickyChance(&item,itemID,FORCE_STICKY_RANDOM); if (shopFlag) { item.flags |= flag; } @@ -174,7 +172,7 @@ void sub_8045CB0(void) } } -void sub_8045DB4(struct DungeonPos *pos, bool8 printMsg) +void PickUpItemFromPos(struct DungeonPos *pos, bool8 printMsg) { Item *tileItem; int inventoryIds[INVENTORY_SIZE + 1]; @@ -216,7 +214,7 @@ void sub_8045DB4(struct DungeonPos *pos, bool8 printMsg) } else { s32 i, maxItems; - if (gDungeon->unk644.unk17 != 0) { + if (gDungeon->unk644.hasInventory) { for (i = 0; i < INVENTORY_SIZE; i++) { inventoryItems[i] = &gTeamInventoryRef->teamItems[i]; inventoryIds[i] = i; @@ -393,12 +391,12 @@ bool8 sub_80461C8(DungeonPos *pos, bool8 a2) return TRUE; } -s32 sub_8046298(Item *item) +static s32 GetItemIconId(Item *item) { return gItemParametersData[item->id].icon; } -bool8 sub_80462AC(Entity * entity, u8 a1, u8 a2, u8 a3, u8 a4) +bool8 sub_80462AC(Entity * entity, u8 hallucinating, u8 a2, u8 a3, u8 a4) { s32 x, y, y2; s32 objMode = 0; @@ -428,12 +426,12 @@ bool8 sub_80462AC(Entity * entity, u8 a1, u8 a2, u8 a3, u8 a4) s32 tileNum; SpriteSetMatrixNum(&gUnknown_202EDC0, 0); - if (a1) { + if (hallucinating) { tileNum = 0x17; SpriteSetPalNum(&gUnknown_202EDC0, 10); } else { - tileNum = sub_8046298(entity->axObj.info.item); + tileNum = GetItemIconId(entity->axObj.info.item); if (a3 != 0xFF && tileNum == 0) { tileNum = gUnknown_203B420[a3]; SpriteSetMatrixNum(&gUnknown_202EDC0, gUnknown_203B428[a3] * 8); @@ -560,7 +558,7 @@ void sub_804652C(Entity *entity1, Entity *entity2, Item *item, bool8 a3, Dungeon } } -void sub_8046734(Entity *entity, DungeonPos *pos) +static void sub_8046734(Entity *entity, DungeonPos *pos) { PixelPos posPixel; PixelPos calcPixelPos; @@ -737,7 +735,7 @@ bool8 HasHeldItem(Entity *pokemon, u8 id) return TRUE; } -void sub_8046CE4(Item *item,s32 param_2) +static void sub_8046CE4(Item *item,s32 param_2) { s32 i; s32 rand = DungeonRandInt(100); @@ -768,7 +766,7 @@ void sub_8046D20(void) } } -u8 sub_8046D70(void) +static u8 sub_8046D70(void) { if (gDungeon->unk644.unk46) return 0; @@ -776,7 +774,7 @@ u8 sub_8046D70(void) return 0; } -void MusicBoxCreation(void) +static void MusicBoxCreation(void) { bool8 musicBoxOnce; bool8 createMusicBox; @@ -816,7 +814,7 @@ void MusicBoxCreation(void) ZeroOutItem(&gTeamInventoryRef->teamItems[indexes[2]]); // init the music box - xxx_init_itemslot_8090A8C(&gTeamInventoryRef->teamItems[indexes[0]], ITEM_MUSIC_BOX, 0); + ItemIdToSlot(&gTeamInventoryRef->teamItems[indexes[0]], ITEM_MUSIC_BOX, 0); } } while (musicBoxOnce); @@ -871,7 +869,7 @@ bool8 sub_8046F00(Item *item) return TRUE; } -void sub_8046F84(s32 itemFlag) +void ClearAllItemsWithFlag(s32 itemFlag) { s32 i; @@ -895,7 +893,7 @@ void sub_8046F84(s32 itemFlag) } } -void sub_804700C(void) +void AllItemsToPlainSeed(void) { s32 i; @@ -903,7 +901,7 @@ void sub_804700C(void) { Item *item = &gTeamInventoryRef->teamItems[i]; if ((item->flags & ITEM_FLAG_EXISTS)) { - xxx_init_itemslot_8090A8C(item, ITEM_PLAIN_SEED, 0); + ItemIdToSlot(item, ITEM_PLAIN_SEED, FALSE); } } FillInventoryGaps(); @@ -914,13 +912,13 @@ void sub_804700C(void) EntityInfo *entityInfo = GetEntInfo(entity); Item *item = &entityInfo->heldItem; if ((item->flags & ITEM_FLAG_EXISTS)) { - xxx_init_itemslot_8090A8C(item, ITEM_PLAIN_SEED, 0); + ItemIdToSlot(item, ITEM_PLAIN_SEED, FALSE); } } } } -bool8 sub_8047084(s32 itemFlag) +bool8 PlayerHasItemWithFlag(s32 itemFlag) { s32 i; @@ -946,7 +944,7 @@ bool8 sub_8047084(s32 itemFlag) return FALSE; } -void sub_8047104(void) +void CleanUpInventoryItems(void) { s32 i; @@ -965,7 +963,7 @@ void sub_8047104(void) FillInventoryGaps(); } -void sub_8047158(void) +void ClearUnpaidFlagFromAllItems(void) { s32 i; diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 10afb73a9..0bfc8ab63 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -68,16 +68,14 @@ extern void PlayDungeonStartButtonSE(void); extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); extern void sub_806A6E8(Entity *); -extern bool8 sub_8047084(s32 itemFlag); extern void HandleTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); -extern void sub_8045DB4(DungeonPos *, u32); bool8 sub_807EF48(void); void sub_806A2BC(Entity *a0, u8 a1); bool8 sub_80701A4(Entity *a0); void sub_803E708(s32 a0, s32 a1); void sub_8075680(u32); void sub_8094C88(void); -void sub_8047158(void); +void ClearUnpaidFlagFromAllItems(void); void sub_806A914(u8 a0, u8 a1, u8 a2); void SetLeaderActionToNothing(u8 a0); u16 GetLeaderActionId(void); @@ -584,7 +582,7 @@ void DungeonHandlePlayerInput(void) } else { DungeonRunFrameActions(0xF); - sub_8047158(); + ClearUnpaidFlagFromAllItems(); ShowMainMenu((r6.a0_16 == 0), r6.a0_24); ResetRepeatTimers(); ResetUnusedInputStruct(); @@ -1047,7 +1045,7 @@ void sub_805EE30(void) case ENTITY_ITEM: { Item *item = GetItemData(tileObject); if (!(item->flags & ITEM_FLAG_IN_SHOP)) { - sub_8045DB4(&leader->pos, 1); + PickUpItemFromPos(&leader->pos, 1); } else { gDungeon->unk5C0 = 4; @@ -1111,7 +1109,7 @@ void sub_805F02C(void) if (r8->isTeamLeader) { DisplayDungeonLoggableMessageTrue(r7, gUnknown_80F9BD8); } - else if (sub_8047084(ITEM_FLAG_IN_SHOP) || sub_807EF48()) { + else if (PlayerHasItemWithFlag(ITEM_FLAG_IN_SHOP) || sub_807EF48()) { DisplayDungeonLoggableMessageTrue(r7, gUnknown_80F9C08); } else if (gDungeon->unk644.unk2A) { @@ -1204,7 +1202,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) while (1) { if (r10 < 0) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); gTeamMenuChosenId = -1; PrintOnMainMenu(printAll); sub_806A2BC(GetLeader(), 0); @@ -1242,7 +1240,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) if (chosenOption == MAIN_MENU_ITEMS) { u16 action; - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); var_34.a0_8 = 0; var_34.a0_16 = 1; var_34.a0_24 = 0; @@ -1251,75 +1249,75 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) r10 = -1; } if (sub_805FD3C(&var_34) && ShowDungeonItemsMenu(GetLeader(), &var_34)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } action = GetLeaderActionId(); - if (action == 12) { + if (action == ACTION_SHOW_INFO) { sub_8044D90(GetLeader(), 0, 12)->flags |= ITEM_FLAG_UNPAID; - sub_8060D24(GetLeaderActionContainer()); - SetLeaderActionToNothing(1); + DungeonShowItemDescription(GetLeaderActionContainer()); + SetLeaderActionToNothing(TRUE); } - else if (action == 53) { + else if (action == ACTION_UNK35) { item = sub_8044D90(GetLeader(), 0, 13); if (!sub_8048A68(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } - else if (action == 16) { + else if (action == ACTION_UNK10) { item = sub_8044D90(GetLeader(), 0, 14); if (!sub_8048950(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } - else if (action == 44) { + else if (action == ACTION_USE_LINK_BOX) { item = sub_8044D90(GetLeader(), 0, 15); if (!sub_8048B9C(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } - else if (action == 60) { + else if (action == ACTION_SET_ITEM) { HandleSetItemAction(GetLeader(), TRUE); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); sub_803E708(0x50, 0x4D); sub_8052210(0); break; } - else if (action == 61) { + else if (action == ACTION_UNSET_ITEM) { HandleUnsetItemAction(GetLeader(), TRUE); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); sub_803E708(0x50, 0x4D); sub_8052210(0); break; } - if (GetLeaderActionId() != 0) + if (GetLeaderActionId() != ACTION_NOTHING) break; } else if (chosenOption == MAIN_MENU_TEAM) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); if (ShowDungeonTeamMenu(GetLeader())) { r10 = -1; } if (GetLeaderActionId() == ACTION_CHECK_SUMMARY) { ShowDungeonSummaryOrIQMenu(GetLeaderActionContainer(), FALSE); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } else if (GetLeaderActionId() == ACTION_TALK_MENU) { sub_806752C(GetLeaderActionContainer()); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } else if (GetLeaderActionId() == 0x34) { sub_8067768(GetLeaderActionContainer()); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } else if (GetLeaderActionId() == ACTION_CHANGE_TACTICS) { ShowDungeonTacticsMenu(GetLeaderActionContainer()); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } else if (GetLeaderActionId() == ACTION_VIEW_IQ) { ShowDungeonSummaryOrIQMenu(GetLeaderActionContainer(), TRUE); - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } else if (GetLeaderActionId() == ACTION_CHECK_MOVES) { s32 i, count; @@ -1349,7 +1347,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) Entity *currEntity; currMonId = 0; - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; if (EntityIsValid(teamMon)) { @@ -1452,7 +1450,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) if (GetEntityType(tileObject) == ENTITY_ITEM) { u16 action; - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); var_30.a0_8 = 0; var_30.a0_16 = 1; var_30.a0_24 = 1; @@ -1462,45 +1460,45 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) ASM_MATCH_TRICK(leader); } if (sub_805FD3C(&var_30) && ShowDungeonItemsMenu(GetLeader(), &var_30)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } action = GetLeaderActionId(); if (action == 0xC) { sub_8044D90(GetLeader(), 0, 0x10)->flags |= ITEM_FLAG_UNPAID; - sub_8060D24(GetLeaderActionContainer()); - SetLeaderActionToNothing(1); + DungeonShowItemDescription(GetLeaderActionContainer()); + SetLeaderActionToNothing(TRUE); } else if (action == 0x35) { item = sub_8044D90(GetLeader(), 0, 0x11); if (!sub_8048A68(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } else if (action == 0x10) { item = sub_8044D90(GetLeader(), 0, 0x12); if (!sub_8048950(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } else if (action == 0x2C) { item = sub_8044D90(GetLeader(), 0, 0x13); if (!sub_8048B9C(GetLeader(), item)) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); } } if (GetLeaderActionId() != 0) break; } else if (GetEntityType(tileObject) == ENTITY_TRAP) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); ShowDungeonTileMenu(GetLeader()); if (GetLeaderActionId() != 0) break; } } else if (tile->terrainType & TERRAIN_TYPE_STAIRS) { - SetLeaderActionToNothing(1); + SetLeaderActionToNothing(TRUE); ShowDungeonStairsMenu(GetLeader()); if (GetLeaderActionId() != 0) break; diff --git a/src/dungeon_menu_items.c b/src/dungeon_menu_items.c index e38732557..b5a3242eb 100644 --- a/src/dungeon_menu_items.c +++ b/src/dungeon_menu_items.c @@ -36,7 +36,6 @@ extern void PlayDungeonConfirmationSE(void); extern void sub_806A2BC(Entity *a0, u8 a1); extern void SetLeaderActionToNothing(u8 a0); extern void sub_803E708(s32 a0, s32 a1); -extern void sub_8047158(void); extern Item *sub_8044D90(Entity *, s32, u32); extern bool8 sub_8070F14(Entity * pokemon, s32 direction); bool8 sub_805EC2C(Entity *a0, s32 x, s32 y); @@ -235,7 +234,7 @@ bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1) s16 arr[10]; PlaySoundEffect(0x132); - sub_8047158(); + ClearUnpaidFlagFromAllItems(); ConvertMoneyItemToMoney(); sUnknown_202F240 = 0; r3 = sub_8060D64(arr, var_30, var_34, var_28, a0); @@ -611,10 +610,10 @@ static void sub_8060900(Entity *a0) gDungeonSubMenuItemsCount = 0; if (sUnknownActionUnk4.actionUseIndex < 144) { if (sUnknownActionUnk4.actionUseIndex == 128) { - AddActionToDungeonSubMenu(9, item->id); + AddActionToDungeonSubMenu(ACTION_PICK_UP_PLAYER, item->id); if (GetItemCategory(item->id) != CATEGORY_POKE) { bool32 r2 = 0; - if (gDungeon->unk644.unk17 != 0) { + if (gDungeon->unk644.hasInventory) { if (gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].flags & ITEM_FLAG_EXISTS) { r2 = TRUE; } @@ -628,7 +627,7 @@ static void sub_8060900(Entity *a0) } } } - if (sUnknownActionUnk4.actionUseIndex == 128 && gDungeon->unk644.unk17 != 0) { + if (sUnknownActionUnk4.actionUseIndex == 128 && gDungeon->unk644.hasInventory) { AddActionToDungeonSubMenu(10, item->id); } val_sub8044DC8 = sub_8044DC8(item); @@ -648,10 +647,10 @@ static void sub_8060900(Entity *a0) s32 i; if (ItemSet(item)) { - AddActionToDungeonSubMenu(0x3D, item->id); + AddActionToDungeonSubMenu(ACTION_UNSET_ITEM, item->id); } else { - AddActionToDungeonSubMenu(0x3C, item->id); + AddActionToDungeonSubMenu(ACTION_SET_ITEM, item->id); } for (i = 0; i < INVENTORY_SIZE; i++) { @@ -659,8 +658,8 @@ static void sub_8060900(Entity *a0) && ItemSet(&gTeamInventoryRef->teamItems[i]) && ItemSticky(&gTeamInventoryRef->teamItems[i])) { - SetActionUnusableInDungeonSubMenu(0x3C); - SetActionUnusableInDungeonSubMenu(0x3D); + SetActionUnusableInDungeonSubMenu(ACTION_SET_ITEM); + SetActionUnusableInDungeonSubMenu(ACTION_UNSET_ITEM); break; } } @@ -688,7 +687,7 @@ static void sub_8060900(Entity *a0) } } } - else if (gDungeon->unk644.unk17) { + else if (gDungeon->unk644.hasInventory) { if (gTeamInventoryRef->teamItems[INVENTORY_SIZE - 1].flags & ITEM_FLAG_EXISTS) { AddActionToDungeonSubMenu(0x3E, item->id); } @@ -705,10 +704,10 @@ static void sub_8060900(Entity *a0) if (sUnknownActionUnk4.actionUseIndex <= 20) { Entity *tileEntity = GetTile(a0->pos.x, a0->pos.y)->object; if (tileEntity == NULL) { - AddActionToDungeonSubMenu(8, item->id); + AddActionToDungeonSubMenu(ACTION_PLACE_ITEM, item->id); } else if (GetEntityType(tileEntity) == ENTITY_ITEM) { - AddActionToDungeonSubMenu(0x3A, item->id); + AddActionToDungeonSubMenu(ACTION_UNK3A, item->id); } } @@ -749,17 +748,17 @@ static void sub_8060900(Entity *a0) if (GetItemCategory(item->id) == CATEGORY_TMS_HMS) r5 = TRUE; if (GetItemCategory(item->id) == CATEGORY_ORBS) r5 = TRUE; - if (gDungeon->unk644.unk17) { + if (gDungeon->unk644.hasInventory) { if (r4) { - AddActionToDungeonSubMenu(0x3E, item->id); + AddActionToDungeonSubMenu(ACTION_UNK3E, item->id); } else { - AddActionToDungeonSubMenu(0x37, item->id); + AddActionToDungeonSubMenu(ACTION_TAKE_ITEM, item->id); } if (r6) { - SetActionUnusableInDungeonSubMenu(0x37); - SetActionUnusableInDungeonSubMenu(0x3E); + SetActionUnusableInDungeonSubMenu(ACTION_TAKE_ITEM); + SetActionUnusableInDungeonSubMenu(ACTION_UNK3E); } } @@ -797,17 +796,17 @@ static void ChosenSubMenuToAction(ActionContainer *a0) a0->actionParameters[1].itemPos.y = 0; } -void sub_8060D24(UNUSED ActionContainer *a0) +void DungeonShowItemDescription(UNUSED ActionContainer *a0) { Item *item = sub_8044D90(GetLeader(), 0, 0xB); DungeonShowWindows(NULL, 0); - sub_801B3C0(item); + InitItemDescriptionWindow(item); do { DungeonRunFrameActions(0x16); } while (sub_801B410() == 0); - sub_801B450(); + FreeItemDescriptionWindow(); sub_803EAF0(0, NULL); } @@ -816,7 +815,7 @@ static s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4) s32 i; s32 count = 0; - if (gDungeon->unk644.unk17 && !a1) { + if (gDungeon->unk644.hasInventory && !a1) { if (gTeamInventoryRef->teamItems[0].flags & ITEM_FLAG_EXISTS) { a0[count++] = 0; } diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index 451b71063..f6ff6d6e5 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -55,9 +55,7 @@ extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); extern void PlayDungeonCursorSE(u8 param_1); extern void sub_806A6E8(Entity *); -extern bool8 sub_8047084(s32 itemFlag); extern void HandleTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); -extern void sub_8045DB4(DungeonPos *, u32); bool8 sub_807EF48(void); void sub_806A2BC(Entity *a0, u8 a1); bool8 sub_805E874(void); @@ -70,7 +68,6 @@ void ShowDungeonOthersMenu(void); void sub_8075680(u32); void sub_8094C88(void); void sub_8040A84(void); -void sub_8047158(void); void sub_806A914(u8 a0, u8 a1, u8 a2); void SetLeaderActionToNothing(u8 a0); u16 GetLeaderActionId(void); @@ -86,7 +83,7 @@ bool8 sub_805EF60(Entity *a0, EntityInfo *a1); bool8 sub_8070F80(Entity * pokemon, s32 direction); void PrintOnMainMenu(bool8 printAll); bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); -void sub_8060D24(UNUSED ActionContainer *a0); +void DungeonShowItemDescription(UNUSED ActionContainer *a0); bool8 ShowDungeonTeamMenu(Entity *a0); void ActionShowMoveInfo(ActionContainer *a0); void ActionToggleMoveUsableForAi(ActionContainer *a0); @@ -201,7 +198,7 @@ bool8 ShowDungeonTeamMenu(Entity *a0) } } - if (!gDungeon->unk644.unk17) { + if (!gDungeon->unk644.hasInventory) { windows.id[0].type = WINDOW_TYPE_NORMAL; windows.id[0].pos.y++; } diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index 9220cc7a8..6d5ff8b7a 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -202,7 +202,7 @@ void sub_8027274(void) break; case 0xd: HeldItemToSlot(&slot, &sUnknown_203B2BC->itemToGive); - sub_801B3C0(&slot); + InitItemDescriptionWindow(&slot); break; case 0xe: unk_CopyMoves4To8(sUnknown_203B2BC->moves,sUnknown_203B2BC->pokeStruct->moves); @@ -625,7 +625,7 @@ void sub_8027C84() { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); SetFriendAreaActionMenuState(0xB); case 0: case 1: diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index 6797e99ff..aad9ac460 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -219,7 +219,7 @@ void sub_8025518(void) break; case FRIEND_LIST_MENU_STATE_INFO: HeldItemToSlot(&item, &gUnknown_203B2B4->item1); - sub_801B3C0(&item); + InitItemDescriptionWindow(&item); break; case FRIEND_LIST_MENU_STATE_ITEM_GIVEN: gUnknown_203B2B4->fallbackState = 2; @@ -560,7 +560,7 @@ void sub_8025D90(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); SetFriendListMenuState(0xC); case 0: case 1: diff --git a/src/friend_rescue.c b/src/friend_rescue.c index 0f02fb76a..75426d02e 100644 --- a/src/friend_rescue.c +++ b/src/friend_rescue.c @@ -693,7 +693,7 @@ void CleanFriendRescueMenu(void) sub_802F2C0(); sub_8030DE4(); sub_802453C(); - sub_801B450(); + FreeItemDescriptionWindow(); } } @@ -2470,7 +2470,7 @@ void sub_8034B88(void) RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&gUnknown_203B33C->item); + InitItemDescriptionWindow(&gUnknown_203B33C->item); SetFriendRescueMenuState(0x61); break; } @@ -2482,7 +2482,7 @@ void sub_8034C38(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); ResetUnusedInputStruct(); ShowWindows(&gUnknown_203B33C->unk3BC, TRUE, TRUE); sub_801CB5C(TRUE); @@ -2519,7 +2519,7 @@ void sub_8034C98(void) RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&gUnknown_203B33C->item); + InitItemDescriptionWindow(&gUnknown_203B33C->item); SetFriendRescueMenuState(0x61); break; case 5: diff --git a/src/items.c b/src/items.c index 69349b080..4f6ed3ce2 100644 --- a/src/items.c +++ b/src/items.c @@ -98,33 +98,32 @@ bool8 IsThrowableItem(u8 id) return TRUE; } -void xxx_init_itemslot_8090A8C(Item *slot, u8 id, u8 param_3) +void ItemIdToSlot(Item *slot, u8 id, u8 makeSticky) { - u32 uVar3; - u32 uVar4; + if (id != ITEM_NOTHING) { + slot->flags = ITEM_FLAG_EXISTS; + slot->id = id; + if (IsThrowableItem(id)) { + s32 min = GetSpawnAmountRange(id, MIN_SPAWN_AMOUNT); + s32 max = GetSpawnAmountRange(id, MAX_SPAWN_AMOUNT); + slot->quantity = RandRange(min, max); + } + else if (GetItemCategory(id) == CATEGORY_POKE) { + slot->quantity = 1; + } + else { + slot->quantity = 0; + } - if (id != ITEM_NOTHING) { - slot->flags = ITEM_FLAG_EXISTS; - slot->id = id; - if (IsThrowableItem(id)) { - uVar3 = GetSpawnAmountRange(id, MIN_SPAWN_AMOUNT); - uVar4 = GetSpawnAmountRange(id, MAX_SPAWN_AMOUNT); - slot->quantity = RandRange(uVar3, uVar4); + if (makeSticky) { + slot->flags |= ITEM_FLAG_STICKY; + } } - else if (GetItemCategory(id) == CATEGORY_POKE) - slot->quantity = 1; - else + else { + slot->flags = 0; + slot->id = ITEM_NOTHING; slot->quantity = 0; - - if (param_3 != 0) - slot->flags |= ITEM_FLAG_STICKY; - - } - else { - slot->flags = 0; - slot->id = ITEM_NOTHING; - slot->quantity = 0; - } + } } void xxx_init_helditem_8090B08(BulkItem *held, u8 id) @@ -299,7 +298,7 @@ void BufferItemName(u8* dest, u8 id, struct unkStruct_8090F58* a2) Item unkItem; strncpy(acStack104, gItemParametersData[id].name, 80); - xxx_init_itemslot_8090A8C(&unkItem, id, 0); + ItemIdToSlot(&unkItem, id, 0); unkItem.quantity = 1; sub_8090F58(dest, acStack104, &unkItem, a2); } @@ -548,7 +547,7 @@ void ClearItemSlotAt(u32 index) bool8 sub_809124C(u8 id, u8 param_3) { Item temp; - xxx_init_itemslot_8090A8C(&temp, id, param_3); + ItemIdToSlot(&temp, id, param_3); return AddItemToInventory(&temp); } @@ -1201,7 +1200,7 @@ u8 sub_8091E94(s32 a0, s32 a1, s32 a2) { s32 id, i, arrId; u8 foundCategory, ret; - struct UnkDungeonGlobal_unk1C590 data; + struct ItemSpawns data; s16 rawArray[NUM_ITEM_CATEGORIES + NUMBER_OF_ITEM_IDS]; const u16 *ptr = gUnknown_8108E58[a0 - 1]; diff --git a/src/kangaskhan_storage1.c b/src/kangaskhan_storage1.c index a5b6cfa36..76b2e6515 100644 --- a/src/kangaskhan_storage1.c +++ b/src/kangaskhan_storage1.c @@ -323,7 +323,7 @@ static void sub_8016FF8(void) break; case 16: case 26: - sub_801B3C0(&gKangaskhanStorageWork->storedItem); + InitItemDescriptionWindow(&gKangaskhanStorageWork->storedItem); break; case 27: sub_80177F8(); @@ -669,14 +669,14 @@ static void sub_8017B88(void) UpdateKangaskhanStorageState(28); else { gKangaskhanStorageWork->id = sub_801CB24(); - xxx_init_itemslot_8090A8C(&gKangaskhanStorageWork->storedItem, gKangaskhanStorageWork->id, 0); + ItemIdToSlot(&gKangaskhanStorageWork->storedItem, gKangaskhanStorageWork->id, 0); gKangaskhanStorageWork->storedItem.quantity = 1; UpdateKangaskhanStorageState(25); } break; case 4: gKangaskhanStorageWork->id = sub_801CB24(); - xxx_init_itemslot_8090A8C(&gKangaskhanStorageWork->storedItem, gKangaskhanStorageWork->id, 0); + ItemIdToSlot(&gKangaskhanStorageWork->storedItem, gKangaskhanStorageWork->id, 0); gKangaskhanStorageWork->storedItem.quantity = 1; UpdateKangaskhanStorageState(26); break; @@ -785,7 +785,7 @@ static void sub_8017DC0(void) break; case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateKangaskhanStorageState(14); break; } @@ -800,7 +800,7 @@ static void sub_8017DDC(void) break; case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateKangaskhanStorageState(23); break; } diff --git a/src/kangaskhan_storage2.c b/src/kangaskhan_storage2.c index 031183c8d..ca026110f 100644 --- a/src/kangaskhan_storage2.c +++ b/src/kangaskhan_storage2.c @@ -168,7 +168,7 @@ static void sub_8018100(void) sub_8012D60(&sUnknown_203B20C->unk70, sUnknown_203B20C->unk20, 0, sUnknown_203B20C->unk60, sUnknown_203B20C->menuAction2, 2); break; case 7: - sub_801B3C0(&sUnknown_203B20C->item); + InitItemDescriptionWindow(&sUnknown_203B20C->item); break; case 10: sub_801C8C4(1, 3, 0, 10); @@ -202,7 +202,7 @@ static void sub_8018100(void) sub_8012D60(&sUnknown_203B20C->unk70, sUnknown_203B20C->unk20, 0, sUnknown_203B20C->unk60, sUnknown_203B20C->menuAction3, 2); break; case 14: - sub_801B3C0(&sUnknown_203B20C->item); + InitItemDescriptionWindow(&sUnknown_203B20C->item); break; case KANGASKHAN_STORAGE_2_INIT: default: @@ -447,14 +447,14 @@ static void sub_80186F8(void) } else { sUnknown_203B20C->id = sub_801CB24(); - xxx_init_itemslot_8090A8C(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0); + ItemIdToSlot(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0); sUnknown_203B20C->item.quantity = 1; UpdateKangaskhanStorage2State(13); } break; case 4: sUnknown_203B20C->id = sub_801CB24(); - xxx_init_itemslot_8090A8C(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0); + ItemIdToSlot(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0); sUnknown_203B20C->item.quantity = 1; UpdateKangaskhanStorage2State(14); break; @@ -606,7 +606,7 @@ static void sub_8018AC8(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateKangaskhanStorage2State(5); break; case 0: @@ -621,7 +621,7 @@ static void sub_8018AE4(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateKangaskhanStorage2State(11); break; case 0: diff --git a/src/kecleon_bros1.c b/src/kecleon_bros1.c index bc56a7c83..2d6f440f6 100644 --- a/src/kecleon_bros1.c +++ b/src/kecleon_bros1.c @@ -394,7 +394,7 @@ static void UpdateKecleonStoreDialogue(void) break; case KECLEON_STORE_BUY_ITEM_INFO: case KECLEON_STORE_SELL_ITEM_INFO: - sub_801B3C0(&sKecleonBrosWork1->soldItem); + InitItemDescriptionWindow(&sKecleonBrosWork1->soldItem); break; case KECLEON_STORE_SELL_ITEM_RECEIPT: if (GetNumberOfFilledInventorySlots() == 0 || gTeamInventoryRef->teamMoney >= MAX_TEAM_MONEY) { @@ -699,7 +699,7 @@ static void sub_80199CC(void) item = GetKecleonWareItem(sKecleonBrosWork1->wareShopItemIndex); } - xxx_init_itemslot_8090A8C(&sKecleonBrosWork1->soldItem, item->id, 0); + ItemIdToSlot(&sKecleonBrosWork1->soldItem, item->id, 0); sKecleonBrosWork1->soldItem.quantity = item->quantity; sKecleonBrosWork1->itemSellPrice = GetStackBuyPrice(&sKecleonBrosWork1->soldItem); SetKecleonBrosState(20); @@ -714,7 +714,7 @@ static void sub_80199CC(void) item = GetKecleonWareItem(sKecleonBrosWork1->wareShopItemIndex); } - xxx_init_itemslot_8090A8C(&sKecleonBrosWork1->soldItem, item->id, 0); + ItemIdToSlot(&sKecleonBrosWork1->soldItem, item->id, 0); sKecleonBrosWork1->soldItem.quantity = item->quantity; sKecleonBrosWork1->itemSellPrice = GetStackBuyPrice(&sKecleonBrosWork1->soldItem); SetKecleonBrosState(KECLEON_STORE_BUY_ITEM_INFO); @@ -831,7 +831,7 @@ static void sub_8019D30(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); SetKecleonBrosState(19); break; case 0: @@ -845,7 +845,7 @@ static void sub_8019D4C(void) switch (sub_801B410()) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); SetKecleonBrosState(27); break; case 0: diff --git a/src/luminous_cave.c b/src/luminous_cave.c index 3f381d91e..ba628e768 100644 --- a/src/luminous_cave.c +++ b/src/luminous_cave.c @@ -268,7 +268,7 @@ static void UpdateLuminousCaveDialogue(void) break; case 9: case 14: - sub_801B3C0(&sLuminousCaveWork->chosenItem); + InitItemDescriptionWindow(&sLuminousCaveWork->chosenItem); break; case LUMINOUS_CAVE_LACK_WHAT_NEEDED: sLuminousCaveWork->fallbackState = LUMINOUS_CAVE_GIVE_ITEM_1; @@ -671,7 +671,7 @@ static void sub_80251CC(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateLuminousCaveState(0x7); break; case 0: @@ -686,7 +686,7 @@ static void sub_80251E8(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); UpdateLuminousCaveState(0xC); break; case 0: diff --git a/src/move_actions.c b/src/move_actions.c index 1a797a308..1047ef507 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -116,9 +116,7 @@ void sub_8075900(Entity *pokemon, u8 r1); extern u8 sub_8044B28(void); extern void sub_807EC28(bool8); extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void sub_804652C(Entity *, Entity *, Item *, u32, DungeonPos *); extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); -extern void sub_8045C28(Item *, u8 , u8); static void sub_805A7D4(Entity *, Entity *, Item *, DungeonPos *); extern void MudWaterSportEffect(u32); extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); @@ -2391,7 +2389,7 @@ bool8 PayDayMoveAction(Entity *pokemon, Entity *target, Move *move, u32 param_4) if (!EntityIsValid(target)) { pos.x = 0; pos.y = 0; - sub_8045C28(&item,ITEM_POKE,2); + CreateItemWithStickyChance(&item,ITEM_POKE,2); sub_805A7D4(pokemon,target,&item,&pos); } } diff --git a/src/party_list_menu.c b/src/party_list_menu.c index d8a525d4d..9b85d90d2 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -229,7 +229,7 @@ void HandlePartyListMenuCallback(void) break; case 0x15: HeldItemToSlot(&item,&sUnknown_203B2B8->item1); - sub_801B3C0(&item); + InitItemDescriptionWindow(&item); break; case PARTY_LIST_STATE_MOVES: unk_CopyMoves4To8(sUnknown_203B2B8->moves,sUnknown_203B2B8->pokeStruct->moves); @@ -699,7 +699,7 @@ void sub_8026CF0(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); SetPartyListMenuState(PARTY_LIST_STATE_GIVE_ITEM_1); break; case 0: diff --git a/src/status_actions.c b/src/status_actions.c index de33f439a..1f714d7de 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -36,8 +36,7 @@ extern void sub_807F43C(Entity *, Entity *); extern void HandleOneRoomOrb(Entity *, Entity *); -extern u32 sub_803D73C(u32); -extern void sub_8045C28(Item *, u8 , u8); +extern u32 GetRandomFloorItem(u32); extern void sub_80464C8(Entity *, DungeonPos *, Item *); extern void sub_8068FE0(Entity *, u32, Entity *r2); extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); @@ -524,13 +523,13 @@ bool8 RecycleMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param { Item *item = &gTeamInventoryRef->teamItems[i]; if (item->id == ITEM_TM_USED_TM) { - xxx_init_itemslot_8090A8C(item, item->quantity + 0x7d,0); + ItemIdToSlot(item, item->quantity + 0x7d,0); isTMRecycled = TRUE; } } } if (ItemExists(&entityInfo->heldItem) && (entityInfo->heldItem.id == ITEM_TM_USED_TM)) { - xxx_init_itemslot_8090A8C(&entityInfo->heldItem,entityInfo->heldItem.quantity + 0x7D,0); + ItemIdToSlot(&entityInfo->heldItem,entityInfo->heldItem.quantity + 0x7D,0); isTMRecycled = TRUE; } } @@ -1133,7 +1132,7 @@ bool8 ItemizeOrbAction(Entity *pokemon, Entity *target, Move *move, s32 param_4) else { target->isVisible = FALSE; - sub_8045C28(&stack, sub_803D73C(0), 0); + CreateItemWithStickyChance(&stack, GetRandomFloorItem(0), 0); sub_80464C8(pokemon, &posStruct, &stack); sub_8068FE0(target, 0x218, pokemon); return TRUE; diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index a3daad4eb..5455bd5b6 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -411,7 +411,7 @@ void CleanThankYouMailPelipper(void) MemoryFree(sUnknown_203B2C4); sUnknown_203B2C4 = NULL; sub_8030DE4(); - sub_801B450(); + FreeItemDescriptionWindow(); sub_803084C(); sub_801CBB8(); sub_80155F0(); @@ -663,7 +663,7 @@ void sub_802A28C(void) RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&sUnknown_203B2C4->unk41C); + InitItemDescriptionWindow(&sUnknown_203B2C4->unk41C); SetThankYouMailMenuState(SHOW_ITEM_TO_SEND_INFO); break; } @@ -675,7 +675,7 @@ void sub_802A33C(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); ResetUnusedInputStruct(); ShowWindows(&sUnknown_203B2C4->unk3BC, TRUE, TRUE); sub_801CB5C(TRUE); @@ -714,7 +714,7 @@ void sub_802A39C(void) RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&sUnknown_203B2C4->unk41C); + InitItemDescriptionWindow(&sUnknown_203B2C4->unk41C); SetThankYouMailMenuState(SHOW_ITEM_TO_SEND_INFO); break; case CANCEL_ACTION: diff --git a/src/trade_items_menu.c b/src/trade_items_menu.c index 47d528bbc..fc9804dd8 100644 --- a/src/trade_items_menu.c +++ b/src/trade_items_menu.c @@ -179,7 +179,7 @@ void sub_80365AC(void) RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk1E4); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&sTradeItemsMenu->itemToSend); + InitItemDescriptionWindow(&sTradeItemsMenu->itemToSend); SetTradeItemMenu(TRADE_ITEMS_ITEM_INFO); break; } @@ -203,7 +203,7 @@ void sub_8036674(void) RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk1E4); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_801B3C0(&sTradeItemsMenu->itemToSend); + InitItemDescriptionWindow(&sTradeItemsMenu->itemToSend); SetTradeItemMenu(TRADE_ITEMS_ITEM_INFO); break; case 7: @@ -222,7 +222,7 @@ void sub_8036728(void) { case 2: case 3: - sub_801B450(); + FreeItemDescriptionWindow(); ResetUnusedInputStruct(); ShowWindows(&sTradeItemsMenu->unk1E4, TRUE, TRUE); sub_801CB5C(TRUE); diff --git a/src/trap.c b/src/trap.c index 036f18b2a..35624f6ad 100644 --- a/src/trap.c +++ b/src/trap.c @@ -57,16 +57,13 @@ extern u32 gUnknown_8106A4C; extern u32 gUnknown_8106A50; void sub_806A9B4(Entity *, u32); -void sub_80461C8(DungeonPos *, u32); void ShowDungeonMapAtPos(s32, s32); s16 sub_803D970(u32); bool8 sub_806AA0C(s32, s32); void sub_80421EC(DungeonPos *, u32); -extern void sub_804687C(Entity *, DungeonPos *, DungeonPos *, Item *, u32); bool8 sub_8045888(Entity *); u8 GetFloorType(void); void sub_8068FE0(Entity *, u32, Entity *); -void sub_8045C28(Item *, u8 , u8); void sub_8045BF8(u8 *, Item *); void DealDamageToEntity(Entity *,s16,u32,u32); void sub_806F480(Entity *, u32); @@ -503,7 +500,7 @@ void HandleGrimyTrap(Entity *pokemon, Entity *target) if (((GetItemCategory(itemStack[index]->id) == CATEGORY_FOOD_GUMMIES) && (itemStack[index]->id != ITEM_GRIMY_FOOD)) && (DungeonRandInt(100) < gGrimyTrapActivateChance)) { badFoodCount++; - sub_8045C28(itemStack[index], ITEM_GRIMY_FOOD, 2); + CreateItemWithStickyChance(itemStack[index], ITEM_GRIMY_FOOD, 2); } } if (badFoodCount == 1) { diff --git a/src/weather.c b/src/weather.c index 1a5976f7f..80069ab39 100644 --- a/src/weather.c +++ b/src/weather.c @@ -24,7 +24,7 @@ u8 GetApparentWeather(Entity *pokemon) void sub_807E5AC(void) { u8 weather; - weather = gDungeon->unk1C574.unk4; + weather = gDungeon->floorProperties.unk4; if(weather == WEATHER_COUNT) weather = DungeonRandInt(WEATHER_COUNT); sub_807E5E4(weather); diff --git a/src/wonder_mail_main_menu.c b/src/wonder_mail_main_menu.c index 5cec3e8e2..bbfd2148e 100644 --- a/src/wonder_mail_main_menu.c +++ b/src/wonder_mail_main_menu.c @@ -168,7 +168,7 @@ void CleanWonderMailMenu(void) MemoryFree(gUnknown_203B3E8); gUnknown_203B3E8 = NULL; sub_8030DE4(); // Frees 203B324 - sub_801B450(); // Frees 203B230 + FreeItemDescriptionWindow(); // Frees 203B230 sub_803084C(); // Frees 203B320 sub_801CBB8(); // Frees 203B244 sub_80155F0(); // Frees 203B1FC