mirror of
https://github.com/pret/pmd-sky.git
synced 2026-04-25 15:42:34 -05:00
Decomped IsAtJunction
This commit is contained in:
parent
a5882c3d58
commit
a47a2cad7e
|
|
@ -1,10 +0,0 @@
|
|||
#pragma once
|
||||
.public DUNGEON_PTR
|
||||
.public DungeonRandInt
|
||||
.public GetDirectionalMobilityType
|
||||
.public GetMobilityTypeCheckSlipAndFloating
|
||||
.public GetTile
|
||||
.public IqSkillIsEnabled
|
||||
.public IsCurrentTilesetBackground
|
||||
.public ItemIsActive__022FF898
|
||||
.public SECONDARY_TERRAIN_TYPES
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "overlay_29_02301498.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start IsAtJunction
|
||||
IsAtJunction: ; 0x02301498
|
||||
#ifdef JAPAN
|
||||
#define OV29_02301498_OFFSET -4
|
||||
#else
|
||||
#define OV29_02301498_OFFSET 0
|
||||
#endif
|
||||
stmdb sp!, {r3, r4, r5, lr}
|
||||
mov r5, r0
|
||||
ldr r1, [r5, #0xb4]
|
||||
ldrsh r1, [r1, #2]
|
||||
bl GetMobilityTypeCheckSlipAndFloating
|
||||
#ifdef JAPAN
|
||||
mov r4, r0
|
||||
bl IsCurrentTilesetBackground
|
||||
cmp r0, #0
|
||||
bne _02302A30_JP
|
||||
ldr r0, [r5, #0xb4]
|
||||
ldrb r0, [r0, #0xef]
|
||||
cmp r0, #3
|
||||
moveq r4, #3
|
||||
beq _02302A30_JP
|
||||
mov r0, r5
|
||||
mov r1, #0x10
|
||||
bl ItemIsActive__022FF898
|
||||
cmp r0, #0
|
||||
movne r4, #3
|
||||
bne _02302A30_JP
|
||||
mov r0, r5
|
||||
mov r1, #0xc
|
||||
bl IqSkillIsEnabled
|
||||
cmp r0, #0
|
||||
movne r4, #2
|
||||
bne _02302A30_JP
|
||||
mov r0, r5
|
||||
mov r1, #0xd
|
||||
bl IqSkillIsEnabled
|
||||
cmp r0, #0
|
||||
movne r4, #3
|
||||
_02302A30_JP:
|
||||
#else
|
||||
mov r1, r0
|
||||
mov r0, r5
|
||||
mov r2, #0xff
|
||||
bl GetDirectionalMobilityType
|
||||
mov r4, r0
|
||||
#endif
|
||||
cmp r4, #3
|
||||
bne _023014FC
|
||||
ldr r4, [r5, #0xb4]
|
||||
mov r0, #0x64
|
||||
bl DungeonRandInt
|
||||
add r1, r4, #0x200
|
||||
ldrsh r2, [r1, #0x12 + OV29_02301498_OFFSET]
|
||||
add r0, r2, r0
|
||||
strh r0, [r1, #0x12 + OV29_02301498_OFFSET]
|
||||
ldrsh r0, [r1, #0x12 + OV29_02301498_OFFSET]
|
||||
cmp r0, #0xc8
|
||||
mov r0, #0
|
||||
strgeh r0, [r1, #0x12 + OV29_02301498_OFFSET]
|
||||
movge r0, #1
|
||||
ldmia sp!, {r3, r4, r5, pc}
|
||||
_023014FC:
|
||||
ldr r0, _0230158C ; =DUNGEON_PTR
|
||||
ldr r1, _02301590 ; =SECONDARY_TERRAIN_TYPES
|
||||
ldr r0, [r0]
|
||||
add r0, r0, #0x4000
|
||||
#ifdef JAPAN
|
||||
ldrsh r0, [r0, #0x30]
|
||||
#else
|
||||
ldrsh r0, [r0, #0xd4]
|
||||
#endif
|
||||
ldrb r0, [r1, r0]
|
||||
cmp r0, #1
|
||||
cmpeq r4, #1
|
||||
bne _02301534
|
||||
mov r0, r5
|
||||
mov r1, #0x14
|
||||
bl IqSkillIsEnabled
|
||||
cmp r0, #0
|
||||
movne r4, #0
|
||||
_02301534:
|
||||
ldrsh r0, [r5, #4]
|
||||
ldrsh r1, [r5, #6]
|
||||
bl GetTile
|
||||
add r0, r0, r4
|
||||
ldrb r0, [r0, #8]
|
||||
cmp r0, #0x54
|
||||
moveq r0, #1
|
||||
ldmeqia sp!, {r3, r4, r5, pc}
|
||||
cmp r0, #0x51
|
||||
moveq r0, #1
|
||||
ldmeqia sp!, {r3, r4, r5, pc}
|
||||
cmp r0, #0x45
|
||||
moveq r0, #1
|
||||
ldmeqia sp!, {r3, r4, r5, pc}
|
||||
cmp r0, #0x15
|
||||
moveq r0, #1
|
||||
ldmeqia sp!, {r3, r4, r5, pc}
|
||||
cmp r0, #0x55
|
||||
moveq r0, #1
|
||||
movne r0, #0
|
||||
and r0, r0, #0xff
|
||||
ldmia sp!, {r3, r4, r5, pc}
|
||||
.align 2, 0
|
||||
_0230158C: .word DUNGEON_PTR
|
||||
_02301590: .word SECONDARY_TERRAIN_TYPES
|
||||
arm_func_end IsAtJunction
|
||||
|
|
@ -18,5 +18,7 @@ bool8 CanAttackInDirection(struct entity *monster, s32 direction);
|
|||
// out_monster_in_target_position: [output] True if movement was not possible because there was another monster on the target tile, false otherwise.
|
||||
// return: True if the monster can move in the specified direction, false otherwise.
|
||||
bool8 CanAiMonsterMoveInDirection(struct entity *monster, s32 direction, bool8 *out_monster_in_target_position);
|
||||
// Checks if the tile the given monster is on is considered a junction for the purposes of AI movement. This is affected by what types of terrain the monster can cross.
|
||||
bool8 IsAtJunction(struct entity *monster);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_CAPABILITIES_4_H
|
||||
|
|
|
|||
|
|
@ -649,8 +649,8 @@ struct monster {
|
|||
u8 field_0x20f;
|
||||
u8 hp_fractional; // 0x210: 200 * fractional_part(HP)
|
||||
u8 field_0x211;
|
||||
u8 field_0x212;
|
||||
u8 field_0x213;
|
||||
// 0x212: When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
|
||||
s16 mobile_turn_timer;
|
||||
// 0x214: Somehow related to gaining exp through a joy ribbon. Set to 0 after
|
||||
// gaining or losing a level. Also checked and set to 0 when an enemy evolves.
|
||||
// Maybe for a specific scenario of leveling up with exp from a joy ribbon?
|
||||
|
|
|
|||
1
main.lsf
1
main.lsf
|
|
@ -480,7 +480,6 @@ Overlay OVY_29
|
|||
Object src/dungeon_capabilities_3.o
|
||||
Object asm/overlay_29_02300FCC.o
|
||||
Object src/dungeon_capabilities_4.o
|
||||
Object asm/overlay_29_02301498.o
|
||||
Object src/dungeon_ai_targeting.o
|
||||
Object asm/overlay_29_023016D8.o
|
||||
Object src/dungeon_ai_targeting_1.o
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "dungeon_action.h"
|
||||
#include "dungeon_ai_itcm.h"
|
||||
#include "dungeon_ai_items.h"
|
||||
#include "dungeon_ai_movement.h"
|
||||
#include "dungeon_capabilities_1.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_pokemon_attributes_1.h"
|
||||
|
|
@ -26,7 +27,6 @@
|
|||
extern void EndFrozenClassStatus(struct entity *user, struct entity *target, bool8 log);
|
||||
extern void SubstitutePlaceholderStringTags(u8 *string_id, struct entity *entity, u32 param_3);
|
||||
extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id);
|
||||
extern void AiMovement(struct entity *monster, bool8 show_run_away_effect);
|
||||
|
||||
void RunMonsterAi(struct entity *monster, u32 unused)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ struct can_move_in_direction_info
|
|||
|
||||
const s32 FACING_DIRECTION_INCREMENTS[] = {0, 1, -1, 2, -2, 3, -3, 4};
|
||||
|
||||
extern bool8 IsAtJunction(struct entity *monster);
|
||||
|
||||
bool8 ShouldMonsterRunAwayAndShowEffectOutlawCheck(struct entity *monster, bool8 show_run_away_effect)
|
||||
{
|
||||
bool8 should_run_away = FALSE;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "dungeon_capabilities_4.h"
|
||||
#include "dg_random.h"
|
||||
#include "direction.h"
|
||||
#include "directional_bit_masks.h"
|
||||
#include "dungeon.h"
|
||||
|
|
@ -173,3 +174,68 @@ bool8 CanAiMonsterMoveInDirection(struct entity *monster, s32 direction, bool8 *
|
|||
*out_monster_in_target_position = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 IsAtJunction(struct entity *monster)
|
||||
{
|
||||
enum mobility_type mobility = GetMobilityTypeCheckSlipAndFloating(monster, GetEntInfo(monster)->id);
|
||||
|
||||
#ifdef JAPAN
|
||||
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 (IqSkillIsEnabled(monster, IQ_ALL_TERRAIN_HIKER))
|
||||
// BUG: If a Pokémon can normally move through walls, All-Terrain Hiker will block them from moving through walls.
|
||||
// This bug is fixed in the NA/EU versions.
|
||||
mobility = MOBILITY_HOVERING;
|
||||
else if (IqSkillIsEnabled(monster, IQ_ABSOLUTE_MOVER)) {
|
||||
mobility = MOBILITY_INTANGIBLE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
mobility = GetDirectionalMobilityType(monster, mobility, DIR_NONE_UNSIGNED);
|
||||
#endif
|
||||
|
||||
if (mobility == MOBILITY_INTANGIBLE)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(monster);
|
||||
pokemon_info->mobile_turn_timer += DungeonRandInt(100);
|
||||
if (pokemon_info->mobile_turn_timer < 200)
|
||||
return FALSE;
|
||||
|
||||
pokemon_info->mobile_turn_timer = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const struct tile *map_tile;
|
||||
if (SECONDARY_TERRAIN_TYPES[DUNGEON_PTR[0]->gen_info.tileset_id] == SECONDARY_TERRAIN_LAVA &&
|
||||
mobility == MOBILITY_SECONDARY &&
|
||||
IqSkillIsEnabled(monster, IQ_LAVA_EVADER))
|
||||
mobility = MOBILITY_NORMAL;
|
||||
|
||||
map_tile = GetTile(monster->pos.x, monster->pos.y);
|
||||
u8 walkable_neighbor_flags = map_tile->walkable_neighbor_flags[mobility];
|
||||
/*
|
||||
Check for configurations of open tiles that are considered junctions; i.e., shaped like a 'T' or '+'.
|
||||
X=Wall, O=Open
|
||||
|
||||
0x54 0x51 0x45 0x15 0x55
|
||||
XOX XOX XXX XOX XOX
|
||||
OOO OOX OOO XOO OOO
|
||||
XXX XOX XOX XOX XOX
|
||||
*/
|
||||
if (walkable_neighbor_flags == 0x54)
|
||||
return TRUE;
|
||||
if (walkable_neighbor_flags == 0x51)
|
||||
return TRUE;
|
||||
if (walkable_neighbor_flags == 0x45)
|
||||
return TRUE;
|
||||
if (walkable_neighbor_flags == 0x15)
|
||||
return TRUE;
|
||||
if (walkable_neighbor_flags == 0x55)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user