From bd7c07a69821c963cd3698bcb6b738ca453fb492 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 29 Aug 2025 14:39:11 +0200 Subject: [PATCH] dungeon action execution --- include/dungeon_action_execution.h | 8 ++++ include/dungeon_ai_leader.h | 1 - include/dungeon_message.h | 2 + ld_script.ld | 4 +- ...n_8072CF4.c => dungeon_action_execution.c} | 46 ++++++++----------- src/dungeon_engine.c | 14 +++--- src/dungeon_message.c | 10 ++-- src/dungeon_mon_spawn.c | 4 -- sym_ewram.txt | 2 +- 9 files changed, 44 insertions(+), 47 deletions(-) create mode 100644 include/dungeon_action_execution.h rename src/{dungeon_8072CF4.c => dungeon_action_execution.c} (95%) diff --git a/include/dungeon_action_execution.h b/include/dungeon_action_execution.h new file mode 100644 index 000000000..530b579b4 --- /dev/null +++ b/include/dungeon_action_execution.h @@ -0,0 +1,8 @@ +#ifndef GUARD_DUNGEON_ACTION_EXECUTION_H +#define GUARD_DUNGEON_ACTION_EXECUTION_H + +#include "structs/dungeon_entity.h" + +bool8 ExecuteEntityDungeonAction(Entity *entity); + +#endif diff --git a/include/dungeon_ai_leader.h b/include/dungeon_ai_leader.h index 31d468dc2..a66e5804e 100644 --- a/include/dungeon_ai_leader.h +++ b/include/dungeon_ai_leader.h @@ -5,6 +5,5 @@ bool8 TargetLeader(Entity *pokemon); Entity* GetLeaderIfVisible(Entity *pokemon); -bool8 sub_8072CF4(Entity *entity); #endif diff --git a/include/dungeon_message.h b/include/dungeon_message.h index 67ba61848..54e7b1ab0 100644 --- a/include/dungeon_message.h +++ b/include/dungeon_message.h @@ -27,6 +27,8 @@ struct DungeonDialogueStruct const u8 *str; }; +extern bool8 gUnknown_203B434; + void sub_80521D0(void); void sub_8052210(bool8 a0); diff --git a/ld_script.ld b/ld_script.ld index e6f25f580..bca23fe4d 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -244,7 +244,7 @@ SECTIONS { src/dungeon_8071B48.o(.text); src/dungeon_leveling.o(.text); src/dungeon_ai_leader.o(.text); - src/dungeon_8072CF4.o(.text); + src/dungeon_action_execution.o(.text); src/dungeon_ai_items.o(.text); src/dungeon_turn_effects.o(.text); src/code_8075708.o(.text); @@ -629,7 +629,7 @@ SECTIONS { src/dungeon_8071B48.o(.rodata); src/dungeon_leveling.o(.rodata); src/dungeon_ai_leader.o(.rodata); - src/dungeon_8072CF4.o(.rodata); + src/dungeon_action_execution.o(.rodata); src/dungeon_ai_items.o(.rodata); src/dungeon_turn_effects.o(.rodata); src/code_8075708.o(.rodata); diff --git a/src/dungeon_8072CF4.c b/src/dungeon_action_execution.c similarity index 95% rename from src/dungeon_8072CF4.c rename to src/dungeon_action_execution.c index ea20e3078..9a63ef94a 100644 --- a/src/dungeon_8072CF4.c +++ b/src/dungeon_action_execution.c @@ -1,5 +1,6 @@ #include "global.h" #include "globaldata.h" +#include "dungeon_action_execution.h" #include "dungeon_ai_leader.h" #include "dungeon_move_util.h" #include "dungeon_vram.h" @@ -35,12 +36,9 @@ #include "dungeon_turn_effects.h" #include "dungeon_leveling.h" #include "dungeon_cutscene.h" +#include "dungeon_move.h" #include "warp_target.h" -extern u8 gUnknown_202F221; -extern u8 gUnknown_202F222; -extern u8 gUnknown_203B434; - void sub_8075BA4(Entity *param_1, u8 param_2); void sub_804178C(u8 param_1); void nullsub_95(Entity *); @@ -48,15 +46,11 @@ extern void sub_80671A0(Entity *); extern void sub_8067110(Entity *); void HandleUseMoveAIAction(Entity *target); void sub_8041888(u8 param_1); -void sub_807360C(void); void sub_805EFB4(Entity *, u8); void sub_8074FB0(Entity *, u8, DungeonPos *); - void HandlePlaceItemAction(Entity *); void HandlePickUpPlayerAction(Entity *); void sub_8066E14(Entity * ); -void sub_807348C(void); -void sub_80732F0(void); void sub_8066BD4(Entity*); void HandleTalkFieldAction(Entity *); void HandleUseMovePlayerAction(Entity *); @@ -73,14 +67,16 @@ bool8 sub_804AE08(DungeonPos *pos); void HandlePickUpAIAction(Entity *pokemon); void HandleThrowItemAIAction(Entity *pokemon); void HandleEatAIAction(Entity *pokemon); -u32 sub_8075818(Entity *entity); -extern void MarkLastUsedMonMove(Entity *entity, Move *move); -bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, bool32 isLinkedMove, struct Move *move); +u32 sub_8075818(Entity *entity);; EWRAM_DATA u8 gUnknown_202F32C = 0; EWRAM_DATA u8 gUnknown_202F32D = 0; -bool8 sub_8072CF4(Entity *entity) +static void HandleSleepTalk(void); +static void HandleSnore(void); +static void HandleFlashFire(void); + +bool8 ExecuteEntityDungeonAction(Entity *entity) { bool8 bVar4; bool8 bVar5; @@ -92,7 +88,7 @@ bool8 sub_8072CF4(Entity *entity) DungeonPos pos1; sub_804178C(1); - gUnknown_203B434 = 1; + gUnknown_203B434 = TRUE; info = GetEntInfo(entity); info->useHeldItem = FALSE; info->unkF3 = FALSE; @@ -316,10 +312,10 @@ bool8 sub_8072CF4(Entity *entity) LogMessageByIdWithPopupCheckUser(entity,gUnknown_80FD2CC); } } - sub_807360C(); + HandleFlashFire(); if (!sub_8044B84()) { - sub_807348C(); - sub_80732F0(); + HandleSnore(); + HandleSleepTalk(); if (!EntityIsValid(entity)) { return FALSE; } @@ -345,7 +341,7 @@ bool8 sub_8072CF4(Entity *entity) return FALSE; } -void sub_80732F0(void) +static void HandleSleepTalk(void) { s32 index; Entity *entity; @@ -425,7 +421,7 @@ _increase: } } -void sub_807348C(void) +static void HandleSnore(void) { int index; s32 moveIndex; @@ -478,18 +474,14 @@ void sub_807348C(void) } } -void sub_807360C(void) +static void HandleFlashFire(void) { s32 index; - Entity *entity; - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if(EntityIsValid(entity)) - { - if(GetEntInfo(entity)->unk152 != 0) - { + for (index = 0; index < DUNGEON_MAX_POKEMON; index++) { + Entity *entity = gDungeon->activePokemon[index]; + if (EntityIsValid(entity)) { + if (GetEntInfo(entity)->unk152 != 0) { GetEntInfo(entity)->unk152 = 0; UpdateFlashFireBoost(entity, entity); } diff --git a/src/dungeon_engine.c b/src/dungeon_engine.c index cec8ac1c5..77f02d803 100644 --- a/src/dungeon_engine.c +++ b/src/dungeon_engine.c @@ -5,7 +5,7 @@ #include "dungeon_vram.h" #include "dungeon_main.h" #include "constants/dungeon.h" -#include "dungeon_ai_leader.h" +#include "dungeon_action_execution.h" #include "dungeon_ai.h" #include "dungeon_range.h" #include "dungeon_misc.h" @@ -109,7 +109,7 @@ static bool8 RunLeaderTurn(bool8 param_1) gDungeon->noActionInProgress = FALSE; if (IsFloorOver()) break; - sub_8072CF4(entity); + ExecuteEntityDungeonAction(entity); sub_8086AC0(); TryForcedLoss(0); if (IsFloorOver()) @@ -157,7 +157,7 @@ static void sub_8044454(void) if (EntityIsValid(entity)) { EnemyEvolution(entity); RunMonsterAI(entity, 0); - sub_8072CF4(entity); + ExecuteEntityDungeonAction(entity); sub_8086AC0(); TryForcedLoss(0); entityInfo->flags = (entityInfo->flags & ~(MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY)) | MOVEMENT_FLAG_UNK_14; @@ -182,7 +182,7 @@ void sub_80444F4(Entity *pokemon) if ((EntityIsValid(entity)) && (pokemon != entity) && (entityInfo = GetEntInfo(entity), (entityInfo->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY))) { if (IsFloorOver()) break; RunMonsterAI(entity, 0); - sub_8072CF4(entity); + ExecuteEntityDungeonAction(entity); sub_8086AC0(); TryForcedLoss(0); } @@ -233,7 +233,7 @@ static void sub_8044574(void) EnemyEvolution(teamMon); for (j = 0; j < 3; j++) { RunMonsterAI(teamMon, 0); - if (IsFloorOver() || !sub_8072CF4(teamMon)) + if (IsFloorOver() || !ExecuteEntityDungeonAction(teamMon)) break; sub_8086AC0(); TryForcedLoss(0); @@ -290,7 +290,7 @@ static void sub_8044574(void) info->recalculateFollow = TRUE; info->aiAllySkip = FALSE; RunMonsterAI(entity,1); - sub_8072CF4(entity); + ExecuteEntityDungeonAction(entity); sub_8086AC0(); TryForcedLoss(0); EntityIsValid(entity); // Does nothing @@ -349,7 +349,7 @@ static void sub_8044820(void) EnemyEvolution(entity); RunMonsterAI(entity, 0); if (IsFloorOver()) break; - sub_8072CF4(entity); + ExecuteEntityDungeonAction(entity); sub_8086AC0(); TryForcedLoss(0); if (IsFloorOver()) break; diff --git a/src/dungeon_message.c b/src/dungeon_message.c index 7282ff1da..4934b5fbe 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -32,7 +32,7 @@ static EWRAM_DATA Entity *sLastLogMsgEntity = NULL; static UNUSED EWRAM_DATA u8 sUnused = 0; static EWRAM_DATA SpriteOAM sUnknown_202F1F0 = {0}; -EWRAM_INIT u8 gUnknown_203B434 = 1; +EWRAM_INIT bool8 gUnknown_203B434 = TRUE; static bool8 sub_8052DC0(Entity *); static void DisplayMessageAddToLog(Entity *pokemon, const u8 *str, bool8 r2); @@ -45,7 +45,7 @@ void sub_80521D0(void) gDungeon->unk1BDD4.unk1C054[i] = 0; } sLastLogMsgEntity = NULL; - gUnknown_203B434 = 1; + gUnknown_203B434 = TRUE; sub_8052210(FALSE); } @@ -143,11 +143,11 @@ void DisplayDungeonLoggableMessageTrue(Entity *pokemon, const u8 *str) static void DisplayMessageAddToLog(Entity *pokemon, const u8 *str, bool8 r2) { u8 txt[64]; - u32 r7; + bool8 r7; bool32 r8, r9; if (sLastLogMsgEntity != pokemon) { - r7 = 1; + r7 = TRUE; } else { r7 = gUnknown_203B434; @@ -155,7 +155,7 @@ static void DisplayMessageAddToLog(Entity *pokemon, const u8 *str, bool8 r2) r8 = 1; sLastLogMsgEntity = pokemon; - gUnknown_203B434 = 0; + gUnknown_203B434 = FALSE; r9 = FALSE; while (1) { while (1) { diff --git a/src/dungeon_mon_spawn.c b/src/dungeon_mon_spawn.c index eb2a2e58e..b319a3f3b 100644 --- a/src/dungeon_mon_spawn.c +++ b/src/dungeon_mon_spawn.c @@ -51,10 +51,6 @@ extern void sub_80429E8(Entity *r0); extern Entity *sub_804550C(s16 a); extern Entity *sub_80453AC(s16 id); extern void EntityUpdateStatusSprites(Entity *); -extern Entity *sub_80696A8(Entity *a0); -extern void sub_806A898(Entity *entity, bool8 r7, bool8 showRunAwayEffect); -extern void sub_806A6E8(Entity *entity); -void sub_806C264(s32 teamIndex, EntityInfo *entInfo); static s32 CalcSpeciesHPAtLevel(s32 species, s32 level); static s32 CalcSpeciesAtkAtLevel(s32 species, s32 level, s32 categoryIndex); diff --git a/sym_ewram.txt b/sym_ewram.txt index a5518cfb1..97a795918 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -53,7 +53,7 @@ .include "src/dungeon_8067A80.o" .include "src/dungeon_logic.o" .include "src/dungeon_leveling.o" - .include "src/dungeon_8072CF4.o" + .include "src/dungeon_action_execution.o" .include "src/dungeon_ai_items.o" .include "src/code_8075708.o" .space 4