Decomped GetLeaderIfVisible

This commit is contained in:
AnonymousRandomPerson 2025-11-15 22:54:56 -05:00
parent 045b081c48
commit b74b0f2b7e
6 changed files with 27 additions and 46 deletions

View File

@ -1,4 +0,0 @@
#pragma once
.public CanTargetEntity
.public GetLeader
.public GetTreatmentBetweenMonsters

View File

@ -1,40 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_023082C4.inc"
.text
arm_func_start GetLeaderIfVisible
GetLeaderIfVisible: ; 0x023082C4
stmdb sp!, {r3, r4, r5, lr}
mov r5, r0
ldr r0, [r5, #0xb4]
ldrb r0, [r0, #6]
cmp r0, #0
movne r0, #0
ldmneia sp!, {r3, r4, r5, pc}
bl GetLeader
movs r4, r0
beq _02308338
ldr r0, [r4, #0xb4]
ldrb r0, [r0, #0xd8]
cmp r0, #2
moveq r0, #0
ldmeqia sp!, {r3, r4, r5, pc}
mov r2, #0
mov r0, r5
mov r1, r4
mov r3, r2
bl GetTreatmentBetweenMonsters
cmp r0, #0
movne r0, #0
ldmneia sp!, {r3, r4, r5, pc}
mov r0, r5
mov r1, r4
bl CanTargetEntity
cmp r0, #0
movne r0, r4
ldmneia sp!, {r3, r4, r5, pc}
_02308338:
mov r0, #0
ldmia sp!, {r3, r4, r5, pc}
arm_func_end GetLeaderIfVisible

View File

@ -8,5 +8,7 @@ bool8 EntityIsValid__0230827C(struct entity *entity);
// Checks if the monster should follow the leader. Always returns false for enemy monsters.
// This function may actually be should monster target leader position.
bool8 ShouldMonsterFollowLeader(struct entity *monster);
// For allied monsters, gets the leader monster if they are visible to the ally. Always returns null for enemy monsters.
struct entity* GetLeaderIfVisible(struct entity *monster);
#endif //PMDSKY_DUNGEON_AI_LEADER_H

View File

@ -512,7 +512,6 @@ Overlay OVY_29
Object src/overlay_29_02307EF8.o
Object asm/overlay_29_02307F4C.o
Object src/dungeon_ai_leader.o
Object asm/overlay_29_023082C4.o
Object src/dungeon_ai.o
Object asm/overlay_29_023085DC.o
Object src/overlay_29_02308FBC.o

View File

@ -1,7 +1,11 @@
#include "dungeon_ai_leader.h"
#include "dungeon_ai_targeting_1.h"
#include "dungeon_util_static.h"
#include "dungeon_visibility.h"
#include "main_02058C3C.h"
extern struct entity* GetLeader(void);
bool8 EntityIsValid__0230827C(struct entity *entity)
{
if (entity == NULL)
@ -17,3 +21,24 @@ bool8 ShouldMonsterFollowLeader(struct entity *monster)
return DoesTacticFollowLeader(GetEntInfo(monster)->tactic);
}
struct entity* GetLeaderIfVisible(struct entity *monster)
{
if (GetEntInfo(monster)->is_not_team_member)
return NULL;
struct entity *leader = GetLeader();
if (leader != NULL)
{
if (GetEntInfo(leader)->curse_class_status.curse == STATUS_CURSE_DECOY)
return NULL;
if (GetTreatmentBetweenMonsters(monster, leader, FALSE, FALSE) != TREATMENT_TREAT_AS_ALLY)
return NULL;
if (CanTargetEntity(monster, leader))
return leader;
}
return NULL;
}

View File

@ -51,7 +51,6 @@ struct can_move_in_direction_info
const s32 FACING_DIRECTION_INCREMENTS[] = {0, 1, -1, 2, -2, 3, -3, 4};
extern bool8 ShouldAvoidFirstHit(struct entity *monster, bool8 force_avoid);
extern struct entity* GetLeaderIfVisible(struct entity *monster);
extern bool8 IsAtJunction(struct entity *monster);
bool8 ShouldMonsterRunAwayAndShowEffectOutlawCheck(struct entity *monster, bool8 show_run_away_effect)