mirror of
https://github.com/pret/pmd-sky.git
synced 2026-09-30 14:18:10 -05:00
Decomped IsAdjacentToEnemy
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
.public DUNGEON_PTR
|
||||
.public DetermineAllMonsterShadow
|
||||
.public DetermineTileWalkableNeighbors
|
||||
.public DIRECTIONS_XY
|
||||
.public DUNGEON_PTR
|
||||
.public EAT_ITEM_EFFECT_IGNORE_LIST
|
||||
.public EnsureCanStandCurrentTile
|
||||
.public EntityIsValid__0231EDD8
|
||||
@@ -10,11 +9,13 @@
|
||||
.public GetMoveCategory
|
||||
.public GetTile
|
||||
.public GetTileSafe
|
||||
.public GetTreatmentBetweenMonsters
|
||||
.public InitMove
|
||||
.public IsFullFloorFixedRoom
|
||||
.public IsItemValidVeneer
|
||||
.public LogMessageByIdWithPopupCheckUser
|
||||
.public StairsAlwaysReachable
|
||||
.public UpdateMinimap
|
||||
.public UpdateTrapsVisibility
|
||||
.public ov29_022E0378
|
||||
.public ov29_022EA370
|
||||
.public ov29_022F9C74
|
||||
@@ -22,6 +23,3 @@
|
||||
.public ov29_0233665C
|
||||
.public ov29_0233785C
|
||||
.public ov29_0233FB1C
|
||||
.public StairsAlwaysReachable
|
||||
.public UpdateMinimap
|
||||
.public UpdateTrapsVisibility
|
||||
@@ -1,56 +1,8 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "overlay_29_0231E8F0.inc"
|
||||
.include "overlay_29_0231E990.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start IsAdjacentToEnemy
|
||||
IsAdjacentToEnemy: ; 0x0231E8F0
|
||||
stmdb sp!, {r4, r5, r6, r7, r8, sb, sl, lr}
|
||||
mov r5, #0
|
||||
mov sl, #1
|
||||
mov r6, r0
|
||||
mov sb, r5
|
||||
mov r8, r5
|
||||
mov r7, sl
|
||||
ldr r4, _0231E98C ; =DIRECTIONS_XY
|
||||
b _0231E97C
|
||||
_0231E914:
|
||||
mov r1, r5, lsl #2
|
||||
add r0, r4, r5, lsl #2
|
||||
ldrsh ip, [r6, #4]
|
||||
ldrsh r3, [r4, r1]
|
||||
ldrsh r2, [r6, #6]
|
||||
ldrsh r1, [r0, #2]
|
||||
add r0, ip, r3
|
||||
add r1, r2, r1
|
||||
bl GetTile
|
||||
ldr r1, [r0, #0xc]
|
||||
cmp r1, #0
|
||||
beq _0231E978
|
||||
ldr r0, [r1]
|
||||
cmp r0, #0
|
||||
moveq r0, sl
|
||||
movne r0, sb
|
||||
cmp r0, #1
|
||||
beq _0231E978
|
||||
mov r0, r6
|
||||
mov r2, r8
|
||||
mov r3, r7
|
||||
bl GetTreatmentBetweenMonsters
|
||||
cmp r0, #1
|
||||
moveq r0, #1
|
||||
ldmeqia sp!, {r4, r5, r6, r7, r8, sb, sl, pc}
|
||||
_0231E978:
|
||||
add r5, r5, #1
|
||||
_0231E97C:
|
||||
cmp r5, #8
|
||||
blt _0231E914
|
||||
mov r0, #0
|
||||
ldmia sp!, {r4, r5, r6, r7, r8, sb, sl, pc}
|
||||
.align 2, 0
|
||||
_0231E98C: .word DIRECTIONS_XY
|
||||
arm_func_end IsAdjacentToEnemy
|
||||
|
||||
arm_func_start ShouldTryEatItem
|
||||
ShouldTryEatItem: ; 0x0231E990
|
||||
stmdb sp!, {r4, lr}
|
||||
@@ -4,5 +4,6 @@
|
||||
#include "dungeon_mode.h"
|
||||
|
||||
u32 GetAiUseItemProbability(struct entity *item_consumer, struct item *item, u32 flags);
|
||||
bool8 IsAdjacentToEnemy(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_AI_ITEM_WEIGHT_H
|
||||
|
||||
2
main.lsf
2
main.lsf
@@ -373,7 +373,7 @@ Overlay OVY_29
|
||||
Object src/overlay_29_0231CBC8.o
|
||||
Object asm/overlay_29_0231CBEC.o
|
||||
Object src/dungeon_ai_item_weight.o
|
||||
Object asm/overlay_29_0231E8F0.o
|
||||
Object asm/overlay_29_0231E990.o
|
||||
Object src/overlay_29_0231EDD8.o
|
||||
Object asm/overlay_29_0231EDFC.o
|
||||
Object src/overlay_29_0231F570.o
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#include "dungeon_ai_item_weight.h"
|
||||
#include "dungeon_ai_targeting_1.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_pokemon_attributes_1.h"
|
||||
#include "dungeon_statuses.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_util_static.h"
|
||||
#include "main_02054BE0.h"
|
||||
#include "number_util.h"
|
||||
#include "targeting.h"
|
||||
#include "util.h"
|
||||
|
||||
extern bool8 IsAdjacentToEnemy(struct entity *entity);
|
||||
extern u8 GetMaxPpWrapper(struct move *move);
|
||||
extern bool8 MonsterHasNegativeStatus(struct entity *monster, bool8 check_held_item);
|
||||
extern enum mobility_type GetMobilityType(s16 monster_id);
|
||||
@@ -368,3 +371,18 @@ u32 GetAiUseItemProbability(struct entity *item_consumer, struct item *item, u32
|
||||
}
|
||||
return item_weight;
|
||||
}
|
||||
|
||||
bool8 IsAdjacentToEnemy(struct entity *entity)
|
||||
{
|
||||
for (s32 direction = 0; direction < NUM_DIRECTIONS; direction++)
|
||||
{
|
||||
struct tile *map_tile = GetTile(entity->pos.x + DIRECTIONS_XY[direction].x, entity->pos.y + DIRECTIONS_XY[direction].y);
|
||||
if (map_tile->monster != NULL)
|
||||
{
|
||||
s32 no_pokemon = map_tile->monster->type == ENTITY_NOTHING;
|
||||
if (no_pokemon != TRUE && GetTreatmentBetweenMonsters(entity, map_tile->monster, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user