Decomped GetDirectionalMobilityType

This commit is contained in:
AnonymousRandomPerson 2025-06-01 00:47:04 -04:00
parent 53abd71c63
commit 09f5f3e062
5 changed files with 39 additions and 50 deletions

View File

@ -2,6 +2,7 @@
.public DIRECTIONS_XY
.public DUNGEON_PTR
.public DungeonRandInt
.public GetDirectionalMobilityType
.public GetMobilityTypeCheckSlipAndFloating
.public GetTile
.public GetTreatmentBetweenMonsters

View File

@ -1,55 +1,8 @@
.include "asm/macros.inc"
.include "overlay_29_02300F30.inc"
.include "overlay_29_02300FCC.inc"
.text
#ifndef JAPAN
arm_func_start GetDirectionalMobilityType
GetDirectionalMobilityType: ; 0x02300F30
stmdb sp!, {r4, r5, r6, lr}
mov r6, r0
mov r5, r1
mov r4, r2
bl IsCurrentTilesetBackground
cmp r0, #0
bne _02300FC4
ldr r0, [r6, #0xb4]
ldrb r0, [r0, #0xef]
cmp r0, #3
moveq r5, #3
beq _02300FC4
mov r0, r6
mov r1, #0x10
bl ItemIsActive__022FF898
cmp r0, #0
movne r5, #3
bne _02300FC4
cmp r5, #3
beq _02300F98
mov r0, r6
mov r1, #0xc
bl IqSkillIsEnabled
cmp r0, #0
movne r5, #2
bne _02300FC4
_02300F98:
mov r0, r6
mov r1, #0xd
bl IqSkillIsEnabled
cmp r0, #0
beq _02300FC4
cmp r4, #0xff
moveq r5, #3
beq _02300FC4
tst r4, #1
movne r5, #2
moveq r5, #3
_02300FC4:
mov r0, r5
ldmia sp!, {r4, r5, r6, pc}
arm_func_end GetDirectionalMobilityType
#endif
arm_func_start ov29_02300FCC
ov29_02300FCC: ; 0x02300FCC
stmdb sp!, {r3, r4, r5, lr}

View File

@ -6,5 +6,15 @@
// 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);
#ifndef JAPAN
// Returns the mobility type of a monster, after accounting for things that could affect it.
// List of checks: Mobile status, Mobile Scarf, All-Terrain Hiker and Absolute Mover.
// If the specified direction is DIR_NONE, direction checks are skipped. If it's not, MOBILITY_INTANGIBLE is only returned if the direction is not diagonal.
// monster: Monster entity pointer
// base_mobility: Base mobility type
// direction: Direction of mobility
// return: Final mobility type
enum mobility_type GetDirectionalMobilityType(struct entity *monster, enum mobility_type base_mobility, u8 direction);
#endif
#endif //PMDSKY_DUNGEON_LOGIC_3_H

View File

@ -331,7 +331,7 @@ Overlay OVY_29
Object src/dungeon_capabilities_2.o
Object asm/overlay_29_02300D00.o
Object src/dungeon_logic_3.o
Object asm/overlay_29_02300F30.o
Object asm/overlay_29_02300FCC.o
Object src/dungeon_ai_targeting.o
Object asm/overlay_29_023016A8.o
Object src/dungeon_ai_targeting_1.o

View File

@ -8,7 +8,6 @@
static const u8 DIRECTIONAL_BIT_MASKS[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
extern enum mobility_type GetDirectionalMobilityType(struct entity* monster, enum mobility_type base_mobility, u8 direction);
extern bool8 IsCurrentTilesetBackground(void);
bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction)
@ -51,3 +50,29 @@ bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction)
return FALSE;
}
#ifndef JAPAN
enum mobility_type GetDirectionalMobilityType(struct entity* monster, enum mobility_type base_mobility, u8 direction)
{
enum mobility_type mobility = base_mobility;
if (!IsCurrentTilesetBackground())
{
if (GetEntInfo(monster)->invisible_class_status.status == STATUS_INVISIBLE_MOBILE)
mobility = MOBILITY_INTANGIBLE;
else if (ItemIsActive__022FF898(monster, ITEM_MOBILE_SCARF))
mobility = MOBILITY_INTANGIBLE;
else if (mobility != MOBILITY_INTANGIBLE && IqSkillIsEnabled(monster, IQ_ALL_TERRAIN_HIKER))
mobility = MOBILITY_HOVERING;
else if (IqSkillIsEnabled(monster, IQ_ABSOLUTE_MOVER)) {
if (direction == 0xFF)
mobility = MOBILITY_INTANGIBLE;
else if (direction & 1)
// Absolute Mover can't break walls diagonally.
mobility = MOBILITY_HOVERING;
else
mobility = MOBILITY_INTANGIBLE;
}
}
return mobility;
}
#endif