Decomped IsMonsterSleeping

This commit is contained in:
AnonymousRandomPerson 2025-09-11 23:24:47 -04:00
parent e2cafe7dee
commit 9dfaf725cd
8 changed files with 26 additions and 34 deletions

View File

@ -1 +0,0 @@
#pragma once

View File

@ -1,21 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_023007A8.inc"
.text
arm_func_start IsMonsterSleeping
IsMonsterSleeping: ; 0x023007A8
ldr r0, [r0, #0xb4]
ldrb r0, [r0, #0xbd]
cmp r0, #1
moveq r0, #1
bxeq lr
cmp r0, #5
moveq r0, #1
bxeq lr
cmp r0, #3
moveq r0, #1
movne r0, #0
and r0, r0, #0xff
bx lr
arm_func_end IsMonsterSleeping

View File

@ -3,6 +3,8 @@
#include "dungeon_mode.h"
// Checks if a monster has the sleep, nightmare, or napping status.
bool8 IsMonsterSleeping(struct entity *monster);
// Checks if a monster has a quarter or less HP remaining.
bool8 MonsterHasQuarterHp(struct entity *monster);
// Returns false if none of these conditions holds for the given entity:

View File

@ -409,7 +409,6 @@ Overlay OVY_29
Object asm/overlay_29_0230027C.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
Object src/dungeon_capabilities_1.o

View File

@ -27,7 +27,6 @@ extern struct entity *AI_POTENTIAL_ATTACK_TARGETS[NUM_DIRECTIONS];
extern enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move);
extern s32 WeightMoveWithIqSkills(struct entity *user, s32 move_ai_range, struct entity *target, enum type_id move_type);
extern bool8 IsMonsterSleeping(struct entity *monster);
extern u8 GetMoveAccuracyOrAiChance(struct move *move, u32 which);
void ResetAiCanAttackInDirection()

View File

@ -3,6 +3,20 @@
#include "dungeon_statuses.h"
#include "dungeon_util_static.h"
bool8 IsMonsterSleeping(struct entity *monster)
{
if (GetEntInfo(monster)->sleep_class_status.sleep == STATUS_SLEEP_SLEEP)
return TRUE;
if (GetEntInfo(monster)->sleep_class_status.sleep == STATUS_SLEEP_NAPPING)
return TRUE;
if (GetEntInfo(monster)->sleep_class_status.sleep == STATUS_SLEEP_NIGHTMARE)
return TRUE;
return FALSE;
}
bool8 MonsterHasQuarterHp(struct entity *monster)
{
struct monster *entity_data = GetEntInfo(monster);

View File

@ -17,7 +17,6 @@
#include "trap.h"
#include "weather.h"
extern bool8 IsMonsterSleeping(struct entity* monster);
extern bool8 HasLastUsedMove(struct move *moves);
extern bool8 GendersEqualNotGenderless(s16 monster1, s16 monster2);

View File

@ -215,15 +215,16 @@ asm {function_header}
# Otherwise, make a new set of files.
if merge_prev_file:
header_file_path = os.path.join(HEADER_FOLDER, f'{merge_prev_file}.h')
with open(header_file_path, 'r') as header_file:
header_lines = header_file.readlines()
for i, line in reversed(list(enumerate(header_lines))):
if line != '\n' and not line.startswith('#'):
header_lines[i] += f'{function_header};\n'
break
print('Updating', header_file_path)
with open(header_file_path, 'w') as header_file:
header_file.writelines(header_lines)
if os.path.exists(header_file_path):
with open(header_file_path, 'r') as header_file:
header_lines = header_file.readlines()
for i, line in reversed(list(enumerate(header_lines))):
if line != '\n' and not line.startswith('#'):
header_lines[i] += f'{function_header};\n'
break
print('Updating', header_file_path)
with open(header_file_path, 'w') as header_file:
header_file.writelines(header_lines)
src_file_path = os.path.join(SRC_FOLDER, f'{merge_prev_file}.c')
print('Updating', src_file_path)