From e966925e00c5f3c101048f78faa040b3bcb6a447 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sat, 10 May 2025 23:20:27 -0400 Subject: [PATCH] Decomped MonsterHasMiracleEyeStatus --- asm/include/overlay_29_02300618.inc | 1 - asm/overlay_29_02300618.s | 15 --- include/dungeon_logic.h | 22 +++++ include/dungeon_logic_0.h | 27 ------ main.lsf | 3 +- src/dungeon_logic.c | 142 +++++++++++++++++----------- src/dungeon_logic_0.c | 93 ------------------ src/dungeon_logic_1.c | 66 +++++++++++++ 8 files changed, 177 insertions(+), 192 deletions(-) delete mode 100644 asm/include/overlay_29_02300618.inc delete mode 100644 asm/overlay_29_02300618.s delete mode 100644 include/dungeon_logic_0.h delete mode 100644 src/dungeon_logic_0.c create mode 100644 src/dungeon_logic_1.c diff --git a/asm/include/overlay_29_02300618.inc b/asm/include/overlay_29_02300618.inc deleted file mode 100644 index 6f70f09b..00000000 --- a/asm/include/overlay_29_02300618.inc +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/asm/overlay_29_02300618.s b/asm/overlay_29_02300618.s deleted file mode 100644 index de4de9af..00000000 --- a/asm/overlay_29_02300618.s +++ /dev/null @@ -1,15 +0,0 @@ - .include "asm/macros.inc" - .include "overlay_29_02300618.inc" - - .text - - arm_func_start MonsterHasMiracleEyeStatus -MonsterHasMiracleEyeStatus: ; 0x02300618 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xf5] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasMiracleEyeStatus diff --git a/include/dungeon_logic.h b/include/dungeon_logic.h index 33d4e9f7..eeb32cbb 100644 --- a/include/dungeon_logic.h +++ b/include/dungeon_logic.h @@ -3,6 +3,28 @@ #include "dungeon_mode.h" +// Checks if a monster has the sleep, nightmare, or yawning status. Note that this excludes the napping status. +bool8 IsMonsterDrowsy(struct entity *monster); +// Checks if a monster has one of the statuses in the "burn" group, which includes the traditionally non-volatile status conditions (except sleep) in the main series: STATUS_BURN, STATUS_POISONED, STATUS_BADLY_POISONED, STATUS_PARALYSIS, and STATUS_IDENTIFYING. +// STATUS_IDENTIFYING is probably included based on enum status_id? Unless it's handled differently somehow. +bool8 MonsterHasNonvolatileNonsleepStatus(struct entity *monster); +// Checks if a monster has one of the non-self-inflicted statuses in the "freeze" group, which includes status conditions that immobilize the monster: STATUS_FROZEN, STATUS_SHADOW_HOLD, STATUS_WRAPPED, STATUS_PETRIFIED, STATUS_CONSTRICTION, and STATUS_FAMISHED. +bool8 MonsterHasImmobilizingStatus(struct entity *monster); +// Checks if a monster has one of the statuses in the "cringe" group, which includes status conditions that interfere with the monster's ability to attack: STATUS_CRINGE, STATUS_CONFUSED, STATUS_PAUSED, STATUS_COWERING, STATUS_TAUNTED, STATUS_ENCORE, STATUS_INFATUATED, and STATUS_DOUBLE_SPEED. +// STATUS_DOUBLE_SPEED is probably included based on enum status_id? Unless it's handled differently somehow. +bool8 MonsterHasAttackInterferingStatus(struct entity *monster); +// Checks if a monster has one of the non-self-inflicted statuses in the "curse" group, which loosely includes status conditions that interfere with the monster's skills or ability to do things: STATUS_CURSED, STATUS_DECOY, STATUS_GASTRO_ACID, STATUS_HEAL_BLOCK, STATUS_EMBARGO. +bool8 MonsterHasSkillInterferingStatus(struct entity *monster); +// Checks if a monster is afflicted with Leech Seed. +bool8 MonsterHasLeechSeedStatus(struct entity *monster); +// Checks if a monster has the whiffer status. +bool8 MonsterHasWhifferStatus(struct entity *monster); +// Checks if a monster's vision is impaired somehow. This includes the checks in IsBlinded, as well as STATUS_CROSS_EYED and STATUS_DROPEYE. +bool8 IsMonsterVisuallyImpaired(struct entity *monster, bool8 check_held_item); +// Checks if a monster has the muzzled status. +bool8 IsMonsterMuzzled(struct entity *monster); +// Checks if a monster has the Miracle Eye status. +bool8 MonsterHasMiracleEyeStatus(struct entity *monster); // Checks if a monster has any "negative" status conditions. This includes a wide variety of non-self-inflicted statuses that could traditionally be viewed as actual "status conditions", as well as speed being lowered and moves being sealed. // monster: entity pointer // check_held_item: flag for whether to check for the held item (see IsMonsterVisuallyImpaired) diff --git a/include/dungeon_logic_0.h b/include/dungeon_logic_0.h deleted file mode 100644 index 44a17f1e..00000000 --- a/include/dungeon_logic_0.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PMDSKY_DUNGEON_LOGIC_0_H -#define PMDSKY_DUNGEON_LOGIC_0_H - -#include "dungeon_mode.h" - -// Checks if a monster has the sleep, nightmare, or yawning status. Note that this excludes the napping status. -bool8 IsMonsterDrowsy(struct entity *monster); -// Checks if a monster has one of the statuses in the "burn" group, which includes the traditionally non-volatile status conditions (except sleep) in the main series: STATUS_BURN, STATUS_POISONED, STATUS_BADLY_POISONED, STATUS_PARALYSIS, and STATUS_IDENTIFYING. -// STATUS_IDENTIFYING is probably included based on enum status_id? Unless it's handled differently somehow. -bool8 MonsterHasNonvolatileNonsleepStatus(struct entity *monster); -// Checks if a monster has one of the non-self-inflicted statuses in the "freeze" group, which includes status conditions that immobilize the monster: STATUS_FROZEN, STATUS_SHADOW_HOLD, STATUS_WRAPPED, STATUS_PETRIFIED, STATUS_CONSTRICTION, and STATUS_FAMISHED. -bool8 MonsterHasImmobilizingStatus(struct entity *monster); -// Checks if a monster has one of the statuses in the "cringe" group, which includes status conditions that interfere with the monster's ability to attack: STATUS_CRINGE, STATUS_CONFUSED, STATUS_PAUSED, STATUS_COWERING, STATUS_TAUNTED, STATUS_ENCORE, STATUS_INFATUATED, and STATUS_DOUBLE_SPEED. -// STATUS_DOUBLE_SPEED is probably included based on enum status_id? Unless it's handled differently somehow. -bool8 MonsterHasAttackInterferingStatus(struct entity *monster); -// Checks if a monster has one of the non-self-inflicted statuses in the "curse" group, which loosely includes status conditions that interfere with the monster's skills or ability to do things: STATUS_CURSED, STATUS_DECOY, STATUS_GASTRO_ACID, STATUS_HEAL_BLOCK, STATUS_EMBARGO. -bool8 MonsterHasSkillInterferingStatus(struct entity *monster); -// Checks if a monster is afflicted with Leech Seed. -bool8 MonsterHasLeechSeedStatus(struct entity *monster); -// Checks if a monster has the whiffer status. -bool8 MonsterHasWhifferStatus(struct entity *monster); -// Checks if a monster's vision is impaired somehow. This includes the checks in IsBlinded, as well as STATUS_CROSS_EYED and STATUS_DROPEYE. -bool8 IsMonsterVisuallyImpaired(struct entity *monster, bool8 check_held_item); -// Checks if a monster has the muzzled status. -bool8 IsMonsterMuzzled(struct entity *monster); - -#endif //PMDSKY_DUNGEON_LOGIC_0_H diff --git a/main.lsf b/main.lsf index e752e3c9..b01effa0 100644 --- a/main.lsf +++ b/main.lsf @@ -296,9 +296,8 @@ Overlay OVY_29 Object asm/overlay_29_022FF8C8.o Object src/overlay_29_023000E4.o Object asm/overlay_29_02300108.o - Object src/dungeon_logic_0.o - Object asm/overlay_29_02300618.o Object src/dungeon_logic.o + Object src/dungeon_logic_1.o Object asm/overlay_29_023007A8.o Object src/dungeon_capabilities.o Object asm/overlay_29_023008DC.o diff --git a/src/dungeon_logic.c b/src/dungeon_logic.c index c3a38c65..ded660b9 100644 --- a/src/dungeon_logic.c +++ b/src/dungeon_logic.c @@ -1,67 +1,101 @@ #include "dungeon_logic.h" -#include "dungeon_logic_0.h" +#include "dungeon_statuses.h" #include "dungeon_util_static.h" -extern bool8 MonsterHasMiracleEyeStatus(struct entity *monster); - -bool8 MonsterHasNegativeStatus(struct entity *monster, bool8 check_held_item) +bool8 IsMonsterDrowsy(struct entity *monster) { struct monster *pokemon_info = GetEntInfo(monster); - - if (IsMonsterDrowsy(monster)) + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_SLEEP) return TRUE; - if (MonsterHasNonvolatileNonsleepStatus(monster)) + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_NIGHTMARE) return TRUE; - if (MonsterHasImmobilizingStatus(monster)) + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_YAWNING) + return TRUE; + + return FALSE; +} + +bool8 MonsterHasNonvolatileNonsleepStatus(struct entity *monster) +{ + return GetEntInfo(monster)->burn_class_status.burn != STATUS_BURN_NONE; +} + +bool8 MonsterHasImmobilizingStatus(struct entity *monster) +{ + struct monster *pokemon_info = GetEntInfo(monster); + if (pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_WRAP && + pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_INGRAIN && + pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_NONE) + return TRUE; + + return FALSE; +} + +bool8 MonsterHasAttackInterferingStatus(struct entity *monster) +{ + return GetEntInfo(monster)->cringe_class_status.cringe != STATUS_NONE; +} + +bool8 MonsterHasSkillInterferingStatus(struct entity *monster) +{ + struct monster *pokemon_info = GetEntInfo(monster); + if (pokemon_info->curse_class_status.curse == STATUS_CURSE_CURSED) + return TRUE; + + if (pokemon_info->curse_class_status.curse == STATUS_CURSE_DECOY) + return TRUE; + + if (pokemon_info->curse_class_status.curse == STATUS_CURSE_GASTRO_ACID) + return TRUE; + + if (pokemon_info->curse_class_status.curse == STATUS_CURSE_HEAL_BLOCK) + return TRUE; + + if (pokemon_info->curse_class_status.curse == STATUS_CURSE_EMBARGO) + return TRUE; + + return FALSE; +} + +bool8 MonsterHasLeechSeedStatus(struct entity *monster) +{ + return GetEntInfo(monster)->leech_seed_class_status.leech_seed == STATUS_LEECH_SEED_LEECH_SEED; +} + +bool8 MonsterHasWhifferStatus(struct entity *monster) +{ + return GetEntInfo(monster)->sure_shot_class_status.sure_shot == STATUS_SURE_SHOT_WHIFFER; +} + +bool8 IsMonsterVisuallyImpaired(struct entity *monster, bool8 check_held_item) +{ + struct monster *pokemon_info = GetEntInfo(monster); + if (IsBlinded(monster, check_held_item)) + return TRUE; + + if (pokemon_info->blinker_class_status.blinded == STATUS_BLINKER_CROSS_EYED) + return TRUE; + + if (pokemon_info->blinker_class_status.blinded == STATUS_BLINKER_DROPEYE) + return TRUE; + + return FALSE; +} + +bool8 IsMonsterMuzzled(struct entity *monster) +{ + if (GetEntInfo(monster)->muzzled == TRUE) + return TRUE; + + return FALSE; +} + +bool8 MonsterHasMiracleEyeStatus(struct entity *monster) +{ + if (GetEntInfo(monster)->miracle_eye == TRUE) return TRUE; - if (MonsterHasAttackInterferingStatus(monster)) - return TRUE; - - if (MonsterHasSkillInterferingStatus(monster)) - return TRUE; - - if (MonsterHasLeechSeedStatus(monster)) - return TRUE; - - if (MonsterHasWhifferStatus(monster)) - return TRUE; - - if (IsMonsterVisuallyImpaired(monster, check_held_item)) - return TRUE; - - if (IsMonsterMuzzled(monster)) - return TRUE; - - if (MonsterHasMiracleEyeStatus(monster)) - return TRUE; - - if (pokemon_info->exposed) - return TRUE; - - if (pokemon_info->perish_song_turns != 0) - return TRUE; - - for (s32 i = 0; i < MAX_MON_MOVES; i++) - { - bool8 move_exists; - struct move *move = &pokemon_info->moves.moves[i]; - if (move->flags0 & MOVE_FLAG_EXISTS) - move_exists = TRUE; - else - move_exists = FALSE; - - if (move_exists && move->flags2 & MOVE_FLAG_SEALED) - return TRUE; - } - - for (s32 i = 0; i < NUM_SPEED_COUNTERS; i++) - { - if (pokemon_info->speed_down_counters[i] != 0) - return TRUE; - } - return FALSE; } diff --git a/src/dungeon_logic_0.c b/src/dungeon_logic_0.c deleted file mode 100644 index d5d9f393..00000000 --- a/src/dungeon_logic_0.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "dungeon_logic_0.h" -#include "dungeon_statuses.h" -#include "dungeon_util_static.h" - -bool8 IsMonsterDrowsy(struct entity *monster) -{ - struct monster *pokemon_info = GetEntInfo(monster); - if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_SLEEP) - return TRUE; - - if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_NIGHTMARE) - return TRUE; - - if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_YAWNING) - return TRUE; - - return FALSE; -} - -bool8 MonsterHasNonvolatileNonsleepStatus(struct entity *monster) -{ - return GetEntInfo(monster)->burn_class_status.burn != STATUS_BURN_NONE; -} - -bool8 MonsterHasImmobilizingStatus(struct entity *monster) -{ - struct monster *pokemon_info = GetEntInfo(monster); - if (pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_WRAP && - pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_INGRAIN && - pokemon_info->frozen_class_status.freeze != STATUS_FROZEN_NONE) - return TRUE; - - return FALSE; -} - -bool8 MonsterHasAttackInterferingStatus(struct entity *monster) -{ - return GetEntInfo(monster)->cringe_class_status.cringe != STATUS_NONE; -} - -bool8 MonsterHasSkillInterferingStatus(struct entity *monster) -{ - struct monster *pokemon_info = GetEntInfo(monster); - if (pokemon_info->curse_class_status.curse == STATUS_CURSE_CURSED) - return TRUE; - - if (pokemon_info->curse_class_status.curse == STATUS_CURSE_DECOY) - return TRUE; - - if (pokemon_info->curse_class_status.curse == STATUS_CURSE_GASTRO_ACID) - return TRUE; - - if (pokemon_info->curse_class_status.curse == STATUS_CURSE_HEAL_BLOCK) - return TRUE; - - if (pokemon_info->curse_class_status.curse == STATUS_CURSE_EMBARGO) - return TRUE; - - return FALSE; -} - -bool8 MonsterHasLeechSeedStatus(struct entity *monster) -{ - return GetEntInfo(monster)->leech_seed_class_status.leech_seed == STATUS_LEECH_SEED_LEECH_SEED; -} - -bool8 MonsterHasWhifferStatus(struct entity *monster) -{ - return GetEntInfo(monster)->sure_shot_class_status.sure_shot == STATUS_SURE_SHOT_WHIFFER; -} - -bool8 IsMonsterVisuallyImpaired(struct entity *monster, bool8 check_held_item) -{ - struct monster *pokemon_info = GetEntInfo(monster); - if (IsBlinded(monster, check_held_item)) - return TRUE; - - if (pokemon_info->blinker_class_status.blinded == STATUS_BLINKER_CROSS_EYED) - return TRUE; - - if (pokemon_info->blinker_class_status.blinded == STATUS_BLINKER_DROPEYE) - return TRUE; - - return FALSE; -} - -bool8 IsMonsterMuzzled(struct entity *monster) -{ - if (GetEntInfo(monster)->muzzled == 1) - return TRUE; - - return FALSE; -} diff --git a/src/dungeon_logic_1.c b/src/dungeon_logic_1.c new file mode 100644 index 00000000..a74a0a96 --- /dev/null +++ b/src/dungeon_logic_1.c @@ -0,0 +1,66 @@ +#include "dungeon_logic.h" +#include "dungeon_util_static.h" + +// This file cannot be combined with dungeon_logic.c, as this causes all the functions in dungeon_logic.c to be inlined within MonsterHasNegativeStatus. + +bool8 MonsterHasNegativeStatus(struct entity *monster, bool8 check_held_item) +{ + struct monster *pokemon_info = GetEntInfo(monster); + + if (IsMonsterDrowsy(monster)) + return TRUE; + + if (MonsterHasNonvolatileNonsleepStatus(monster)) + return TRUE; + + if (MonsterHasImmobilizingStatus(monster)) + return TRUE; + + if (MonsterHasAttackInterferingStatus(monster)) + return TRUE; + + if (MonsterHasSkillInterferingStatus(monster)) + return TRUE; + + if (MonsterHasLeechSeedStatus(monster)) + return TRUE; + + if (MonsterHasWhifferStatus(monster)) + return TRUE; + + if (IsMonsterVisuallyImpaired(monster, check_held_item)) + return TRUE; + + if (IsMonsterMuzzled(monster)) + return TRUE; + + if (MonsterHasMiracleEyeStatus(monster)) + return TRUE; + + if (pokemon_info->exposed) + return TRUE; + + if (pokemon_info->perish_song_turns != 0) + return TRUE; + + for (s32 i = 0; i < MAX_MON_MOVES; i++) + { + bool8 move_exists; + struct move *move = &pokemon_info->moves.moves[i]; + if (move->flags0 & MOVE_FLAG_EXISTS) + move_exists = TRUE; + else + move_exists = FALSE; + + if (move_exists && move->flags2 & MOVE_FLAG_SEALED) + return TRUE; + } + + for (s32 i = 0; i < NUM_SPEED_COUNTERS; i++) + { + if (pokemon_info->speed_down_counters[i] != 0) + return TRUE; + } + + return FALSE; +}