mirror of
https://github.com/pret/pmd-sky.git
synced 2026-03-21 17:25:15 -05:00
Decomped TryAddTargetToAiTargetList
This commit is contained in:
parent
ec92d0dcbd
commit
92a4e7cfe7
|
|
@ -1,13 +1,10 @@
|
|||
#pragma once
|
||||
.public _s32_div_f
|
||||
.public AbilityIsActiveVeneer
|
||||
.public CanAttackInDirection
|
||||
.public DIRECTIONS_XY
|
||||
.public DUNGEON_PTR
|
||||
.public DungeonRandInt
|
||||
.public GetDirectionTowardsPosition
|
||||
.public GetMoveAccuracyOrAiChance
|
||||
.public GetMoveTypeForMonster
|
||||
.public GetTile
|
||||
.public GetTreatmentBetweenMonsters
|
||||
.public HasHeldItem
|
||||
|
|
@ -15,11 +12,8 @@
|
|||
.public IsBlinded
|
||||
.public IsMonsterSleeping
|
||||
.public MonsterHasNegativeStatus
|
||||
.public _s32_div_f
|
||||
.public ov29_023007DC
|
||||
.public ov29_0230B7D4
|
||||
.public ov29_0230F8D0
|
||||
.public ov29_02333FD0
|
||||
.public AI_CAN_ATTACK_IN_DIRECTION
|
||||
.public AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS
|
||||
.public AI_POTENTIAL_ATTACK_TARGET_WEIGHTS
|
||||
.public AI_POTENTIAL_ATTACK_TARGETS
|
||||
|
|
@ -1,76 +1,8 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "overlay_29_02319FB0.inc"
|
||||
.include "overlay_29_0231A0A4.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start TryAddTargetToAiTargetList
|
||||
TryAddTargetToAiTargetList: ; 0x02319FB0
|
||||
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr}
|
||||
mov r7, r2
|
||||
mov r6, r3
|
||||
ldrsh r3, [r7, #4]
|
||||
ldrsh r2, [r6, #4]
|
||||
mov sb, r0
|
||||
mov r8, r1
|
||||
cmp r3, r2
|
||||
ldreqsh r1, [r7, #6]
|
||||
ldreqsh r0, [r6, #6]
|
||||
ldr r2, [r7, #0xb4]
|
||||
cmpeq r1, r0
|
||||
ldreqb r5, [r2, #0x4c]
|
||||
beq _0231A010
|
||||
and r0, r8, #0xf0
|
||||
cmp r0, #0x30
|
||||
cmpne r0, #0x60
|
||||
cmpne r0, #0x70
|
||||
ldreqb r5, [r2, #0x4c]
|
||||
beq _0231A010
|
||||
add r0, r7, #4
|
||||
add r1, r6, #4
|
||||
bl GetDirectionTowardsPosition
|
||||
mov r5, r0
|
||||
_0231A010:
|
||||
ldr r4, _0231A094 ; =AI_CAN_ATTACK_IN_DIRECTION
|
||||
ldrb r0, [r4, r5]
|
||||
cmp r0, #0
|
||||
movne r0, sb
|
||||
ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
ldrb ip, [sp, #0x24]
|
||||
ldr r3, [sp, #0x20]
|
||||
mov r0, r8
|
||||
mov r1, r7
|
||||
mov r2, r6
|
||||
str ip, [sp]
|
||||
bl IsAiTargetEligible
|
||||
cmp r0, #0
|
||||
beq _0231A08C
|
||||
ldr r2, _0231A098 ; =AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS
|
||||
mov r3, #1
|
||||
ldr r1, [sp, #0x20]
|
||||
mov r0, r7
|
||||
strb r3, [r4, r5]
|
||||
strb r5, [r2, sb]
|
||||
bl GetMoveTypeForMonster
|
||||
mov r3, r0
|
||||
mov r0, r7
|
||||
mov r1, r8
|
||||
mov r2, r6
|
||||
bl WeightMoveWithIqSkills
|
||||
ldr r2, _0231A09C ; =AI_POTENTIAL_ATTACK_TARGET_WEIGHTS
|
||||
ldr r1, _0231A0A0 ; =AI_POTENTIAL_ATTACK_TARGETS
|
||||
str r0, [r2, sb, lsl #2]
|
||||
str r6, [r1, sb, lsl #2]
|
||||
add sb, sb, #1
|
||||
_0231A08C:
|
||||
mov r0, sb
|
||||
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
|
||||
.align 2, 0
|
||||
_0231A094: .word AI_CAN_ATTACK_IN_DIRECTION
|
||||
_0231A098: .word AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS
|
||||
_0231A09C: .word AI_POTENTIAL_ATTACK_TARGET_WEIGHTS
|
||||
_0231A0A0: .word AI_POTENTIAL_ATTACK_TARGETS
|
||||
arm_func_end TryAddTargetToAiTargetList
|
||||
|
||||
arm_func_start IsAiTargetEligible
|
||||
IsAiTargetEligible: ; 0x0231A0A4
|
||||
stmdb sp!, {r4, r5, r6, r7, r8, lr}
|
||||
|
|
@ -23,5 +23,14 @@ struct ai_possible_move
|
|||
u32 AiConsiderMove(struct ai_possible_move *ai_possible_move, struct entity *monster, struct move *move);
|
||||
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
|
||||
bool8 EntityIsValid__02319F8C(struct entity *entity);
|
||||
// Checks if the specified target is eligible to be targeted by the AI and if so adds it to the list of targets. This function also fills an array that seems to contain the directions in which the user should turn to look at each of the targets in the list, as well as a third unknown array.
|
||||
// current_num_targets: Number of existing targets in the list
|
||||
// move_ai_range: Move's AI range field
|
||||
// user: User entity pointer
|
||||
// target: Target entity pointer
|
||||
// move: Move pointer
|
||||
// check_all_conditions: check_all_conditions parameter to pass to IsAiTargetEligible
|
||||
// return: New number of targets in the target list
|
||||
s32 TryAddTargetToAiTargetList(s32 current_num_targets, s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_AI_ATTACK_H
|
||||
|
|
|
|||
2
main.lsf
2
main.lsf
|
|
@ -452,7 +452,7 @@ Overlay OVY_29
|
|||
Object src/dungeon_ai_attack_2.o
|
||||
Object asm/overlay_29_02319880.o
|
||||
Object src/dungeon_ai_attack.o
|
||||
Object asm/overlay_29_02319FB0.o
|
||||
Object asm/overlay_29_0231A0A4.o
|
||||
Object src/dungeon_ai_attack_1.o
|
||||
Object asm/overlay_29_0231A7A0.o
|
||||
Object src/overlay_29_0231A87C.o
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "dg_random.h"
|
||||
#include "dungeon_ai_attack_1.h"
|
||||
#include "dungeon_ai_attack_2.h"
|
||||
#include "dungeon_capabilities_4.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_pokemon_attributes_1.h"
|
||||
#include "dungeon_statuses.h"
|
||||
|
|
@ -21,8 +22,6 @@ extern u8 AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS[NUM_DIRECTIONS];
|
|||
extern s32 AI_POTENTIAL_ATTACK_TARGET_WEIGHTS[NUM_DIRECTIONS];
|
||||
extern struct entity *AI_POTENTIAL_ATTACK_TARGETS[NUM_DIRECTIONS];
|
||||
|
||||
extern bool8 CanAttackInDirection(struct entity *monster, s32 direction);
|
||||
extern s32 TryAddTargetToAiTargetList(s32 current_num_targets, s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions);
|
||||
extern bool8 IsAiTargetEligible(s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions);
|
||||
extern enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move);
|
||||
extern s32 WeightMoveWithIqSkills(struct entity *user, s32 move_ai_range, struct entity *target, enum type_id move_type);
|
||||
|
|
@ -256,3 +255,31 @@ bool8 EntityIsValid__02319F8C(struct entity *entity)
|
|||
|
||||
return entity->type != ENTITY_NOTHING;
|
||||
}
|
||||
|
||||
s32 TryAddTargetToAiTargetList(s32 current_num_targets, s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions)
|
||||
{
|
||||
struct monster *user_data = GetEntInfo(user);
|
||||
|
||||
s32 direction;
|
||||
if (user->pos.x == target->pos.x && user->pos.y == target->pos.y)
|
||||
direction = user_data->action.direction;
|
||||
else if ((move_ai_range & 0xF0) == RANGE_ROOM ||
|
||||
(move_ai_range & 0xF0) == RANGE_FLOOR ||
|
||||
(move_ai_range & 0xF0) == RANGE_USER)
|
||||
direction = user_data->action.direction;
|
||||
else
|
||||
direction = GetDirectionTowardsPosition(&user->pos, &target->pos);
|
||||
|
||||
if (AI_CAN_ATTACK_IN_DIRECTION[direction])
|
||||
return current_num_targets;
|
||||
|
||||
if (IsAiTargetEligible(move_ai_range, user, target, move, check_all_conditions))
|
||||
{
|
||||
AI_CAN_ATTACK_IN_DIRECTION[direction] = TRUE;
|
||||
AI_POTENTIAL_ATTACK_TARGET_DIRECTIONS[current_num_targets] = direction;
|
||||
AI_POTENTIAL_ATTACK_TARGET_WEIGHTS[current_num_targets] = WeightMoveWithIqSkills(user, move_ai_range, target, GetMoveTypeForMonster(user, move));
|
||||
AI_POTENTIAL_ATTACK_TARGETS[current_num_targets] = target;
|
||||
current_num_targets++;
|
||||
}
|
||||
return current_num_targets;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user