Decomped MonsterHasQuarterHp

This commit is contained in:
AnonymousRandomPerson 2025-09-07 23:59:07 -04:00
parent 05b8ef6f6a
commit c79608481d
7 changed files with 22 additions and 30 deletions

View File

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

View File

@ -32,7 +32,7 @@
.public ov10_022C6322
.public ov29_022E576C
.public ov29_0230040C
.public ov29_023007DC
.public MonsterHasQuarterHp
.public ov29_02304A48
.public ov29_0230D088
.public ov29_0234B034

View File

@ -19,23 +19,3 @@ IsMonsterSleeping: ; 0x023007A8
and r0, r0, #0xff
bx lr
arm_func_end IsMonsterSleeping
arm_func_start ov29_023007DC
ov29_023007DC: ; 0x023007DC
ldr r3, [r0, #0xb4]
ldr r0, _02300814 ; =0x000003E7
ldrsh r2, [r3, #0x12]
ldrsh r1, [r3, #0x16]
add r2, r2, r1
cmp r2, r0
movgt r2, r0
mov r0, r2, asr #1
ldrsh r1, [r3, #0x10]
add r0, r2, r0, lsr #30
cmp r1, r0, asr #2
movle r0, #1
movgt r0, #0
bx lr
.align 2, 0
_02300814: .word 0x000003E7
arm_func_end ov29_023007DC

View File

@ -3,6 +3,8 @@
#include "dungeon_mode.h"
// 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:
// blinded (checked only if blind_check == true),
// asleep, frozen, paused, infatuated, wrapping, wrapped, biding, petrified, or terrified.

View File

@ -2,6 +2,7 @@
#include "dg_random.h"
#include "dungeon_ai_attack_1.h"
#include "dungeon_ai_targeting_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_capabilities_4.h"
#include "dungeon_logic.h"
#include "dungeon_logic_4.h"
@ -26,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 ov29_023007DC(struct entity *entity);
extern bool8 IsMonsterSleeping(struct entity *monster);
extern u8 GetMoveAccuracyOrAiChance(struct move *move, u32 which);
@ -854,7 +854,7 @@ bool8 IsAiTargetEligible(s32 move_ai_range, struct entity *user, struct entity *
}
else if ((move_ai_range & 0xF00) == AI_CONDITION_HP_25)
{
if (!ov29_023007DC(target))
if (!MonsterHasQuarterHp(target))
return FALSE;
}
else if ((move_ai_range & 0xF00) == AI_CONDITION_STATUS)
@ -880,10 +880,10 @@ bool8 IsAiTargetEligible(s32 move_ai_range, struct entity *user, struct entity *
{
if (move->id == MOVE_HEALING_WISH || move->id == MOVE_LUNAR_DANCE)
{
if (!MonsterHasNegativeStatus(target, TRUE) && !ov29_023007DC(target))
if (!MonsterHasNegativeStatus(target, TRUE) && !MonsterHasQuarterHp(target))
return FALSE;
}
else if (!MonsterHasNegativeStatus(target, TRUE) && !ov29_023007DC(target))
else if (!MonsterHasNegativeStatus(target, TRUE) && !MonsterHasQuarterHp(target))
return FALSE;
}
}

View File

@ -1,8 +1,19 @@
#include "dungeon_capabilities.h"
#include "dungeon_capabilities_2.h"
#include "dungeon_statuses.h"
#include "dungeon_util_static.h"
extern bool8 CheckVariousStatuses(struct entity *entity);
bool8 MonsterHasQuarterHp(struct entity *monster)
{
struct monster *entity_data = GetEntInfo(monster);
s32 max_hp = entity_data->max_hp_stat + entity_data->max_hp_boost;
if (max_hp > 999)
max_hp = 999;
if (entity_data->hp <= max_hp / 4)
return TRUE;
return FALSE;
}
bool8 CheckVariousStatuses2(struct entity *entity, bool8 blind_check)
{

View File

@ -1,4 +1,5 @@
#include "move_checks.h"
#include "dungeon_capabilities.h"
#include "dungeon_logic.h"
#include "dungeon_logic_3.h"
#include "dungeon_logic_4.h"
@ -15,7 +16,6 @@
#include "trap.h"
#include "weather.h"
extern bool8 ov29_023007DC(struct entity *entity);
extern bool8 IsThawingMove(struct move *move);
extern bool8 IsMonsterSleeping(struct entity* monster);
extern bool8 HasLastUsedMove(struct move *moves);
@ -203,7 +203,7 @@ bool8 StatusCheckerCheck(struct entity *attacker, struct move *move)
return FALSE;
break;
case MOVE_REST:
if (!ov29_023007DC(attacker) && !MonsterHasNegativeStatus(attacker, FALSE))
if (!MonsterHasQuarterHp(attacker) && !MonsterHasNegativeStatus(attacker, FALSE))
return FALSE;
break;
case MOVE_DIVE:
@ -1174,7 +1174,7 @@ _02333990:
mov r0, #0
ldmia sp!, {r3, r4, r5, r6, r7, pc}
_023339B0:
bl ov29_023007DC
bl MonsterHasQuarterHp
cmp r0, #0
bne _02333F90
mov r0, r4