Decomped MonsterCannotAttack

This commit is contained in:
AnonymousRandomPerson 2025-06-16 21:47:42 -05:00
parent 7c2e5f5f0b
commit 7e5acbfa54
5 changed files with 46 additions and 51 deletions

View File

@ -1,3 +1,2 @@
#pragma once
.public CheckVariousStatuses
.public ShouldMonsterRunAway

View File

@ -66,51 +66,3 @@ ov29_02300DC0: ; 0x02300DC0
.align 2, 0
_02300DC8: .word ov29_02300D50
arm_func_end ov29_02300DC0
arm_func_start MonsterCannotAttack
MonsterCannotAttack: ; 0x02300DCC
stmdb sp!, {r3, lr}
cmp r1, #0
ldr r2, [r0, #0xb4]
bne _02300DF4
ldrb r1, [r2, #0xbd]
cmp r1, #2
cmpne r1, #4
cmpne r1, #0
movne r0, #1
ldmneia sp!, {r3, pc}
_02300DF4:
ldrb r1, [r2, #0xc4]
cmp r1, #1
moveq r0, #1
ldmeqia sp!, {r3, pc}
cmp r1, #3
moveq r0, #1
ldmeqia sp!, {r3, pc}
cmp r1, #4
moveq r0, #1
ldmeqia sp!, {r3, pc}
cmp r1, #6
moveq r0, #1
ldmeqia sp!, {r3, pc}
ldrb r1, [r2, #0xd0]
cmp r1, #1
moveq r0, #1
ldmeqia sp!, {r3, pc}
cmp r1, #3
moveq r0, #1
ldmeqia sp!, {r3, pc}
cmp r1, #7
moveq r0, #1
ldmeqia sp!, {r3, pc}
ldrb r1, [r2, #0xbf]
cmp r1, #4
moveq r0, #1
ldmeqia sp!, {r3, pc}
bl ShouldMonsterRunAway
cmp r0, #0
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
ldmia sp!, {r3, pc}
arm_func_end MonsterCannotAttack

View File

@ -3,6 +3,7 @@
#include "dungeon_mode.h"
bool8 MonsterCannotAttack(struct entity *pokemon, bool8 skip_sleep);
// Checks if the given monster can move in the specified direction
// Returns false if any monster is standing on the target tile
bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction);

View File

@ -2,6 +2,7 @@
#include "dg_random.h"
#include "direction.h"
#include "dungeon_action.h"
#include "dungeon_logic_3.h"
#include "dungeon_parameters.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_pokemon_attributes_1.h"
@ -14,7 +15,6 @@ const s16 AI_REGULAR_ATTACK_WEIGHTS[5] = { 100, 20, 30, 40, 50 };
extern struct dungeon *DUNGEON_PTR[];
extern bool8 MonsterCannotAttack(struct entity *pokemon, bool8 skip_sleep);
extern u32 ShouldMonsterRunAwayVariation(struct entity *monster, u32 param_2);
extern bool8 IsMonsterCornered(struct entity *monster);
extern bool8 IsChargingTwoTurnMove(struct entity *user, struct move *move);
@ -23,7 +23,7 @@ extern void UpdateAiTargetPos(struct entity *monster);
extern void InitMove(struct move *move, enum move_id move_id);
extern u32 AiConsiderMove(struct ai_possible_move *ai_possible_move, struct entity *monster, struct move *move);
extern bool8 ov29_02338350(struct entity *monster);
extern bool8 TargetRegularAttack(struct entity *pokemon, u32 *target_dir, bool8 check_petrified);
extern bool8 TargetRegularAttack(struct entity *pokemon, u32 *target_dir, bool8 skip_petrified);
extern void SetActionRegularAttack(struct action_data *monster_action, u8 direction);
extern void SetActionStruggle(struct action_data *monster_action, u8 direction);
extern bool8 CanAiUseMove(struct entity *monster, u32 move_index, bool8 extra_checks);

View File

@ -1,4 +1,5 @@
#include "dungeon_logic_3.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_map_access.h"
#include "dungeon_mobility.h"
#include "dungeon_pokemon_attributes_1.h"
@ -9,6 +10,48 @@
static const u8 DIRECTIONAL_BIT_MASKS[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
bool8 MonsterCannotAttack(struct entity *pokemon, bool8 skip_sleep)
{
struct monster *pokemon_info = GetEntInfo(pokemon);
if (!skip_sleep)
{
if (pokemon_info->sleep_class_status.sleep != STATUS_SLEEP_SLEEPLESS &&
pokemon_info->sleep_class_status.sleep != STATUS_SLEEP_YAWNING &&
pokemon_info->sleep_class_status.sleep != STATUS_SLEEP_NONE)
return TRUE;
}
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_FROZEN)
return TRUE;
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_WRAP)
return TRUE;
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_WRAPPED)
return TRUE;
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_PETRIFIED)
return TRUE;
if (pokemon_info->cringe_class_status.cringe == STATUS_CRINGE_CRINGE)
return TRUE;
if (pokemon_info->cringe_class_status.cringe == STATUS_CRINGE_PAUSED)
return TRUE;
if (pokemon_info->cringe_class_status.cringe == STATUS_CRINGE_INFATUATED)
return TRUE;
if (pokemon_info->burn_class_status.burn == STATUS_BURN_PARALYSIS)
return TRUE;
if (ShouldMonsterRunAway(pokemon))
return TRUE;
return FALSE;
}
bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction)
{
struct monster *monster_info = GetEntInfo(monster);