From 3f6b99b4defab8643c3b4cd1199b83ff7d66c7c8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 30 Mar 2025 19:28:50 +0200 Subject: [PATCH] split dungeon item action --- data/data_80F59C8_7.s | 7 ---- ld_script.txt | 6 ++- src/code_8046CE4.c | 39 +++++++++++++++++++ src/{code_8048480.c => dungeon_item_action.c} | 31 +-------------- 4 files changed, 44 insertions(+), 39 deletions(-) delete mode 100644 data/data_80F59C8_7.s create mode 100644 src/code_8046CE4.c rename src/{code_8048480.c => dungeon_item_action.c} (97%) diff --git a/data/data_80F59C8_7.s b/data/data_80F59C8_7.s deleted file mode 100644 index fd19b376b..000000000 --- a/data/data_80F59C8_7.s +++ /dev/null @@ -1,7 +0,0 @@ -#include "constants/status.h" -.section .rodata - -.align 2,0 -.string "pksdir0" -.align 2,0 -.string "pksdir0" diff --git a/ld_script.txt b/ld_script.txt index 261259f2f..0ef3b5e41 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -209,7 +209,8 @@ SECTIONS { src/dungeon_util.o(.text); src/dungeon_items.o(.text); asm/code_8046CE4.o(.text); - src/code_8048480.o(.text); + src/code_8046CE4.o(.text); + src/dungeon_item_action.o(.text); src/dungeon_ai_item_weight.o(.text); src/dungeon_map_access.o(.text); src/dungeon_generation.o(.text); @@ -546,7 +547,8 @@ SECTIONS { data/pksdir_1.o(.rodata); src/dungeon_util.o(.text); src/dungeon_items.o(.rodata); - data/data_80F59C8_7.o(.rodata); + src/code_8046CE4.o(.rodata); + src/dungeon_item_action.o(.rodata); src/dungeon_ai_item_weight.o(.rodata); src/dungeon_map_access.o(.rodata); src/dungeon_generation.o(.rodata); diff --git a/src/code_8046CE4.c b/src/code_8046CE4.c new file mode 100644 index 000000000..b855cede3 --- /dev/null +++ b/src/code_8046CE4.c @@ -0,0 +1,39 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_random.h" +#include "dungeon_util.h" +#include "dungeon_items.h" +#include "dungeon_config.h" +#include "structs/dungeon_entity.h" + +// Decompile code_8046CE4.s from bottom instead of top and put functions before sub_8047930 + +bool8 sub_8047930(Entity *pokemon, Entity *target) +{ + bool8 flag; + + if (((GetEntInfo(target)->shopkeeper == TRUE) || + (GetEntInfo(target)->monsterBehavior == BEHAVIOR_DIGLETT)) || (GetEntInfo(target)->monsterBehavior == BEHAVIOR_RESCUE_TARGET)) { + return FALSE; + } + else { + if(DungeonRandInt(100) < gUnknownDungeonChance) + flag = TRUE; + else + flag = FALSE; + if (GetEntityType(pokemon) == ENTITY_MONSTER) { + if (HasHeldItem(pokemon, ITEM_WHIFF_SPECS)) { + flag = FALSE; + } + else { + if (HasHeldItem(pokemon, ITEM_LOCKON_SPECS)) { + flag = TRUE; + } + } + } + if ((GetEntityType(target) == ENTITY_MONSTER) && (HasHeldItem(target, ITEM_DODGE_SCARF))) { + flag = FALSE; + } + } + return flag; +} diff --git a/src/code_8048480.c b/src/dungeon_item_action.c similarity index 97% rename from src/code_8048480.c rename to src/dungeon_item_action.c index 350d83f85..543816857 100644 --- a/src/code_8048480.c +++ b/src/dungeon_item_action.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "code_803E668.h" #include "code_8041AD0.h" #include "dungeon_message.h" @@ -129,36 +130,6 @@ extern void sub_80464C8(Entity *, DungeonPos *, Item *); extern void sub_806A6E8(Entity *); extern void sub_8042390(Entity *, Item *); -bool8 sub_8047930(Entity *pokemon, Entity *target) -{ - bool8 flag; - - if (((GetEntInfo(target)->shopkeeper == TRUE) || - (GetEntInfo(target)->monsterBehavior == BEHAVIOR_DIGLETT)) || (GetEntInfo(target)->monsterBehavior == BEHAVIOR_RESCUE_TARGET)) { - return FALSE; - } - else { - if(DungeonRandInt(100) < gUnknownDungeonChance) - flag = TRUE; - else - flag = FALSE; - if (GetEntityType(pokemon) == ENTITY_MONSTER) { - if (HasHeldItem(pokemon, ITEM_WHIFF_SPECS)) { - flag = FALSE; - } - else { - if (HasHeldItem(pokemon, ITEM_LOCKON_SPECS)) { - flag = TRUE; - } - } - } - if ((GetEntityType(target) == ENTITY_MONSTER) && (HasHeldItem(target, ITEM_DODGE_SCARF))) { - flag = FALSE; - } - } - return flag; -} - void sub_80479B8(char param_1, char param_2, u8 param_3, Entity *pokemon, Entity *target, Item *item) { EntityInfo *info;