From 009df8d7d73592a10b40425dbea1cec6009c8b4c Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sat, 2 Dec 2023 22:09:52 -0800 Subject: [PATCH] document more --- include/constants/dungeon_action.h | 2 ++ src/code_8044CC8.c | 2 +- src/code_8066D04.c | 20 +++++++++--------- src/dungeon_ai_leader.c | 33 +++++++++++++++--------------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/include/constants/dungeon_action.h b/include/constants/dungeon_action.h index 20db553bb..57f68dca6 100644 --- a/include/constants/dungeon_action.h +++ b/include/constants/dungeon_action.h @@ -31,6 +31,7 @@ enum Action ACTION_UNK21 = 0x21, ACTION_EAT_AI = 0x23, ACTION_THROW_ITEM_AI = 0x24, + ACTION_STAIRS = 0x26, ACTION_THROW_STRAIGHT_PLAYER = 0x27, ACTION_USE_LINK_BOX = 0x2C, ACTION_GIVE_UP = 0x2E, @@ -40,6 +41,7 @@ enum Action ACTION_UNSET_MOVE = 0x33, 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_SET_ITEM = 0x3C, ACTION_UNSET_ITEM = 0x3D, diff --git a/src/code_8044CC8.c b/src/code_8044CC8.c index fea195b2e..1c8d3b1d2 100644 --- a/src/code_8044CC8.c +++ b/src/code_8044CC8.c @@ -233,7 +233,7 @@ void sub_8044FF0(u16 param_1) } } -bool8 IsNotAttacking(Entity *param_1, u8 param_2) +bool8 IsNotAttacking(Entity *param_1, bool8 param_2) { EntityInfo *info; u16 *action; diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 4e0e5c7b6..c9d1e43af 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -55,8 +55,8 @@ void sub_806675C(Entity *param_1, bool8 param_2) for(index = 0; index < INVENTORY_SIZE; index++) { itemPtr = &gTeamInventoryRef->teamItems[index]; - if (((itemPtr->flags & ITEM_FLAG_EXISTS) != 0) && ((itemPtr->flags & ITEM_FLAG_SET) != 0)) { - if ((itemPtr->flags & ITEM_FLAG_STICKY) != 0) { + if (((itemPtr->flags & ITEM_FLAG_EXISTS)) && ((itemPtr->flags & ITEM_FLAG_SET))) { + if ((itemPtr->flags & ITEM_FLAG_STICKY)) { sub_8045BF8(gUnknown_202DE58,itemPtr); SendMessage(param_1,*gUnknown_80F8C7C); return; @@ -71,7 +71,7 @@ void sub_806675C(Entity *param_1, bool8 param_2) SendMessage(param_1,*gUnknown_80F8D04); } else { - if (GetItemCategory(item->id) == 0) { + if (GetItemCategory(item->id) == CATEGORY_THROWN_LINE) { SendMessage(param_1,*gUnknown_80F8CE4); } else @@ -141,8 +141,8 @@ void sub_80668D0(Entity *param_1) else { SetMessageArgument(gUnknown_202DFE8,entity,0); - if (((info2->heldItem).flags & ITEM_FLAG_EXISTS) != 0) { - if (((info2->heldItem).flags & ITEM_FLAG_STICKY) != 0) { + if (((info2->heldItem).flags & ITEM_FLAG_EXISTS)) { + if (((info2->heldItem).flags & ITEM_FLAG_STICKY)) { sub_8045BF8(gUnknown_202DEA8,&info2->heldItem); SendMessage(param_1,*gUnknown_80F8C40); return; @@ -184,7 +184,7 @@ void sub_80668D0(Entity *param_1) sub_807D148(param_1,entity,0,0); } if (!info2->isTeamLeader) { - info2->flags = info2->flags | 0x4000; + info2->flags = info2->flags | MOVEMENT_FLAG_UNK_14; } sub_807AB38(param_1,gDungeon->unk3A08); } @@ -229,7 +229,7 @@ void sub_8066AC0(Entity *param_1) sub_807D148(param_1,entity,0,0); } if (!info2->isTeamLeader) { - info2->flags = info2->flags | 0x4000; + info2->flags = info2->flags | MOVEMENT_FLAG_UNK_14; } sub_807AB38(param_1,gDungeon->unk3A08); } @@ -275,7 +275,7 @@ void sub_8066BD4(Entity *param_1) sub_807D148(param_1,entity,0,0); } if (!info2->isTeamLeader) { - info2->flags = info2->flags | 0x4000; + info2->flags = info2->flags | MOVEMENT_FLAG_UNK_14; } sub_807AB38(param_1,gDungeon->unk3A08); } @@ -312,9 +312,9 @@ void sub_8066D04(Entity *param_1) } else { tile = GetTile(entity->pos.x, entity->pos.y); - if ((tile->terrainType & 0x200) == 0) + if (!(tile->terrainType & TERRAIN_TYPE_STAIRS)) { - if(((tile->terrainType & 3) == 1) && + if(((tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_NORMAL) && (tile->object == NULL)) { item->flags &= ~(ITEM_FLAG_SET); sub_8045BF8(gUnknown_202DE58,item); diff --git a/src/dungeon_ai_leader.c b/src/dungeon_ai_leader.c index 128cf1e1a..45eeb9936 100644 --- a/src/dungeon_ai_leader.c +++ b/src/dungeon_ai_leader.c @@ -23,21 +23,22 @@ #include "code_8077274_1.h" extern u8 gUnknown_202F221; -extern u8 gUnknown_202F32D; extern u8 gUnknown_202F222; extern u8 gUnknown_202F32C; -extern u8 *gUnknown_80FA5B4[]; +extern u8 gUnknown_202F32D; +extern u8 gUnknown_203B434; extern u8 gAvailablePokemonNames[]; + +extern u8 *gUnknown_80FA5B4[]; extern u8 *gUnknown_80FE478[]; extern u8 *gUnknown_80FD2CC[]; extern u8 gUnknown_80F58F4[NUM_DUNGEON_ACTIONS][2]; -extern u8 gUnknown_203B434; extern u8 *gUnknown_80FE6D4[]; void sub_8075BA4(Entity *param_1, u8 param_2); void sub_804178C(u8 param_1); void nullsub_95(Entity *); -bool8 IsNotAttacking(Entity *, s32); +bool8 IsNotAttacking(Entity *, bool8); extern void sub_80671A0(Entity *); extern void sub_8067110(Entity *); void sub_807CABC(Entity *target); @@ -64,8 +65,8 @@ void sub_80668D0(Entity *); void sub_8066AC0(Entity *); void sub_8066CF0(Entity *); void sub_8066FA4(Entity *); -void sub_806675C(Entity *,u32); -void sub_806684C(Entity *,u32); +void sub_806675C(Entity *,bool8); +void sub_806684C(Entity *,bool8); void sub_807FE9C(Entity *,Position *,u32,u32); extern u8 sub_8044B28(void); extern u8 UseAttack(Entity *); @@ -126,7 +127,7 @@ bool8 sub_8072CF4(Entity *entity) info->useHeldItem = FALSE; info->fillF3 = 0; gDungeon->unkB8 = entity; - if ((gUnknown_80F58F4)[(info->action).action][0] != 0) { + if (gUnknown_80F58F4[(info->action).action][0] != 0) { if (info->isTeamLeader) { sub_805EFB4(entity,gUnknown_80F58F4[(info->action).action][1]); } @@ -134,7 +135,7 @@ bool8 sub_8072CF4(Entity *entity) sub_8075BA4(entity,gUnknown_80F58F4[(info->action).action][1]); } } - if ((CannotAttack(entity,0)) && (IsCharging(entity,1))) { + if ((CannotAttack(entity, FALSE)) && (IsCharging(entity, TRUE))) { sub_8079764(entity); } @@ -142,10 +143,10 @@ bool8 sub_8072CF4(Entity *entity) { move = &info->moves[index]; if ((move->moveFlags & MOVE_FLAG_EXISTS)) { - move->moveFlags2 &= 0xfb; + move->moveFlags2 &= ~(MOVE_FLAG2_UNK4); } } - if (!IsNotAttacking(entity,0)) { + if (!IsNotAttacking(entity, FALSE)) { if (UseAttack(entity)) { if (sub_8044B28()) { return FALSE; @@ -198,7 +199,7 @@ bool8 sub_8072CF4(Entity *entity) bVar5 = FALSE; pos1.x = (entity->pos).x + gAdjacentTileOffsets[(info->action).direction].x; pos1.y = (entity->pos).y + gAdjacentTileOffsets[(info->action).direction].y; - if (((info->flags & 0x8000) == 0) && + if ((!(info->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY)) && (!CanMoveInDirection(entity,(info->action).direction))) { bVar5 = TRUE; } @@ -225,7 +226,7 @@ bool8 sub_8072CF4(Entity *entity) case ACTION_USE_MOVE_AI: sub_807CABC(entity); break; - case 0x26: // ACTION_STAIRS?? + case ACTION_STAIRS: if ((gDungeon->dungeonLocation.id == DUNGEON_METEOR_CAVE) && (!gDungeon->deoxysDefeat)) { SendMessage(entity,*gUnknown_80FA5B4); // It's impossible to go down the stairs now! } @@ -256,14 +257,14 @@ bool8 sub_8072CF4(Entity *entity) case 0x3e: sub_8066BD4(entity); // ITEM_SWITCH_TOOLBOX (When you switch item in Toolbox) break; - case 0x38: - sub_8066CF0(entity); // ACTION_USE_HELD_ITEM + case ACTION_USE_ITEM: + sub_8066CF0(entity); break; case ACTION_SET_ITEM: - sub_806675C(entity,1); + sub_806675C(entity, TRUE); break; case ACTION_UNSET_ITEM: - sub_806684C(entity,1); + sub_806684C(entity, TRUE); break; case 0x3b: gDungeon->unkBC = gDungeon->teamPokemon[(info->action).unk4[0].actionUseIndex];