mirror of
https://github.com/pret/pmd-sky.git
synced 2026-09-30 14:18:10 -05:00
Decomped FindDirectionOfAdjacentMonsterWithItem
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
.public DIRECTIONS_XY
|
||||
.public EntityIsValid__0230F008
|
||||
.public GetTile
|
||||
.public IsMonster__0230F980
|
||||
.public ItemIsActive__0230F810
|
||||
@@ -1,56 +0,0 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "overlay_29_0230F8D0.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start ov29_0230F8D0
|
||||
ov29_0230F8D0: ; 0x0230F8D0
|
||||
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr}
|
||||
mov r8, r0
|
||||
mov r7, r1
|
||||
bl EntityIsValid__0230F008
|
||||
cmp r0, #0
|
||||
moveq r0, #0xff
|
||||
ldmeqia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
ldr r0, [r8, #0xb4]
|
||||
mov r5, #0
|
||||
ldrb r6, [r0, #0x4c]
|
||||
ldr r4, _0230F97C ; =DIRECTIONS_XY
|
||||
b _0230F96C
|
||||
_0230F900:
|
||||
mov r1, r6, lsl #2
|
||||
add r0, r4, r6, lsl #2
|
||||
ldrsh ip, [r8, #4]
|
||||
ldrsh r3, [r4, r1]
|
||||
ldrsh r2, [r8, #6]
|
||||
ldrsh r1, [r0, #2]
|
||||
add r0, ip, r3
|
||||
add r1, r2, r1
|
||||
bl GetTile
|
||||
ldr sb, [r0, #0xc]
|
||||
cmp sb, #0
|
||||
beq _0230F958
|
||||
mov r0, sb
|
||||
bl IsMonster__0230F980
|
||||
cmp r0, #0
|
||||
beq _0230F958
|
||||
mov r0, sb
|
||||
mov r1, r7
|
||||
bl ItemIsActive__0230F810
|
||||
cmp r0, #0
|
||||
movne r0, r6
|
||||
ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
_0230F958:
|
||||
add r0, r6, #1
|
||||
and r0, r0, #0xff
|
||||
add r1, r5, #1
|
||||
and r6, r0, #7
|
||||
and r5, r1, #0xff
|
||||
_0230F96C:
|
||||
cmp r5, #8
|
||||
blo _0230F900
|
||||
mov r0, #0xff
|
||||
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
.align 2, 0
|
||||
_0230F97C: .word DIRECTIONS_XY
|
||||
arm_func_end ov29_0230F8D0
|
||||
@@ -5,5 +5,8 @@
|
||||
|
||||
// Checks if a monster is a team member under the effects of a certain exclusive item effect.
|
||||
bool8 ExclusiveItemEffectIsActive__0230F8AC(struct entity *entity, enum exclusive_item_effect_id effect_id);
|
||||
u8 FindDirectionOfAdjacentMonsterWithItem(struct entity *pokemon, enum item_id item_id);
|
||||
// Checks if an entity is a monster (entity type 1).
|
||||
bool8 IsMonster__0230F980(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_OVERLAY_29_0230F8AC_H
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef PMDSKY_OVERLAY_29_0230F980_H
|
||||
#define PMDSKY_OVERLAY_29_0230F980_H
|
||||
|
||||
#include "dungeon_mode.h"
|
||||
|
||||
// Checks if an entity is a monster (entity type 1).
|
||||
bool8 IsMonster__0230F980(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_OVERLAY_29_0230F980_H
|
||||
2
main.lsf
2
main.lsf
@@ -496,8 +496,6 @@ Overlay OVY_29
|
||||
Object src/overlay_29_0230F810.o
|
||||
Object asm/overlay_29_0230F840.o
|
||||
Object src/overlay_29_0230F8AC.o
|
||||
Object asm/overlay_29_0230F8D0.o
|
||||
Object src/overlay_29_0230F980.o
|
||||
Object asm/overlay_29_0230F9A4.o
|
||||
Object src/overlay_29_02311010.o
|
||||
Object asm/overlay_29_02311088.o
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "moves_2.h"
|
||||
#include "moves_3.h"
|
||||
#include "moves_4.h"
|
||||
#include "overlay_29_0230F8AC.h"
|
||||
#include "overlay_29_0231ACAC.h"
|
||||
#include "position_util.h"
|
||||
|
||||
@@ -33,8 +34,6 @@ s32 AI_POTENTIAL_ATTACK_TARGET_WEIGHTS[NUM_DIRECTIONS] = {0};
|
||||
struct entity *AI_POTENTIAL_ATTACK_TARGETS[NUM_DIRECTIONS] = {0};
|
||||
#endif
|
||||
|
||||
extern enum direction_id ov29_0230F8D0(struct entity *pokemon, s32);
|
||||
|
||||
void ResetAiCanAttackInDirection()
|
||||
{
|
||||
for (s32 i = 0; i < NUM_DIRECTIONS; i++)
|
||||
@@ -945,10 +944,10 @@ bool8 TargetRegularAttack(struct entity *pokemon, u32 *target_dir, bool8 skip_pe
|
||||
face_turn_limit = 1;
|
||||
else
|
||||
{
|
||||
enum direction_id ov29_0230F8D0_result = ov29_0230F8D0(pokemon, 15);
|
||||
u8 gaggle_specs_direction = FindDirectionOfAdjacentMonsterWithItem(pokemon, ITEM_GAGGLE_SPECS);
|
||||
face_turn_limit = 8;
|
||||
if (ov29_0230F8D0_result != 0xFF)
|
||||
direction = ov29_0230F8D0_result;
|
||||
if (gaggle_specs_direction != DIR_NONE_UNSIGNED)
|
||||
direction = gaggle_specs_direction;
|
||||
}
|
||||
|
||||
s32 potential_attack_target_directions[NUM_DIRECTIONS];
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "overlay_29_0230F8AC.h"
|
||||
#include "dungeon_ai_items_1.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_util_static.h"
|
||||
#include "exclusive_item.h"
|
||||
#include "overlay_29_0230F810.h"
|
||||
|
||||
bool8 ExclusiveItemEffectIsActive__0230F8AC(struct entity *entity, enum exclusive_item_effect_id effect_id)
|
||||
{
|
||||
@@ -10,3 +14,28 @@ bool8 ExclusiveItemEffectIsActive__0230F8AC(struct entity *entity, enum exclusiv
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 FindDirectionOfAdjacentMonsterWithItem(struct entity *pokemon, enum item_id item_id)
|
||||
{
|
||||
if (!EntityIsValid__0230F008(pokemon))
|
||||
return DIR_NONE_UNSIGNED;
|
||||
|
||||
u8 i = 0;
|
||||
u8 direction = GetEntInfo(pokemon)->action.direction;
|
||||
for (; i < NUM_DIRECTIONS; i++, direction = (u8)(direction + 1) & DIRECTION_MASK)
|
||||
{
|
||||
struct entity *monster_in_direction = GetTile(pokemon->pos.x + DIRECTIONS_XY[direction].x, pokemon->pos.y + DIRECTIONS_XY[direction].y)->monster;
|
||||
if (monster_in_direction != NULL && IsMonster__0230F980(monster_in_direction) && ItemIsActive__0230F810(monster_in_direction, item_id))
|
||||
return direction;
|
||||
}
|
||||
|
||||
return DIR_NONE_UNSIGNED;
|
||||
}
|
||||
|
||||
bool8 IsMonster__0230F980(struct entity *entity)
|
||||
{
|
||||
if (entity == NULL)
|
||||
return FALSE;
|
||||
|
||||
return GetEntityType(entity) == ENTITY_MONSTER;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "overlay_29_0230F980.h"
|
||||
#include "dungeon_util_static.h"
|
||||
|
||||
bool8 IsMonster__0230F980(struct entity *entity)
|
||||
{
|
||||
if (entity == NULL)
|
||||
return FALSE;
|
||||
|
||||
return GetEntityType(entity) == ENTITY_MONSTER;
|
||||
}
|
||||
Reference in New Issue
Block a user