Decomped ShouldMonsterRunAwayAndShowEffect

This commit is contained in:
AnonymousRandomPerson 2025-06-16 22:24:21 -05:00
parent 7e5acbfa54
commit d2b632afc2
19 changed files with 55 additions and 51 deletions

View File

@ -81,7 +81,7 @@
.public SetMonsterActionFields
.public ShouldMonsterFollowLeader
.public ShouldMonsterHeadToStairs
.public ShouldMonsterRunAwayVariation
.public ShouldMonsterRunAwayAndShowEffect
.public sub_0201BD50
.public sub_0201BD80
.public sub_0202760C

View File

@ -177,7 +177,7 @@
.public SetLeaderActionFields
.public SetMonsterActionFields
.public ShouldMonsterRunAway
.public ShouldMonsterRunAwayVariation
.public ShouldMonsterRunAwayAndShowEffect
.public SpawnItem
.public sub_02001AB0
.public sub_02006B70

View File

@ -37,6 +37,6 @@
.public RemoveGroundItem
.public RemoveUsedItem
.public ShouldDisplayEntityWrapper
.public ShouldMonsterRunAwayVariation
.public ShouldMonsterRunAwayAndShowEffect
.public SpawnItem
.public TryTriggerMonsterHouse

View File

@ -1,5 +1,4 @@
#pragma once
.public AbilityIsActive
.public ov29_022E62A8
.public ShouldMonsterRunAway
.public UpdateStateFlags
.public PlayEffectAnimation0x29

View File

@ -33,7 +33,7 @@
.public ov29_02348DD8
.public ov29_02348ECC
.public RemoveGroundItem
.public ShouldMonsterRunAwayVariation
.public ShouldMonsterRunAwayAndShowEffect
.public sub_0200D8AC
.public SubstitutePlaceholderStringTags
.public UseThrowableItem

View File

@ -44,7 +44,7 @@
.public RemoveEmptyItemsInBag
.public RemoveEquivItemNoHole
.public RemoveGroundItem
.public ShouldMonsterRunAwayVariation
.public ShouldMonsterRunAwayAndShowEffect
.public SpawnItemEntity
.public sub_0200D8AC
.public sub_02024FE8

View File

@ -2792,12 +2792,12 @@ _01FFA37C:
_01FFA38C: .word ov29_02353530
arm_func_end sub_01FF9F80
arm_func_start ShouldMonsterRunAwayVariationOutlawCheck
ShouldMonsterRunAwayVariationOutlawCheck: ; 0x01FFA390
arm_func_start ShouldMonsterRunAwayAndShowEffectOutlawCheck
ShouldMonsterRunAwayAndShowEffectOutlawCheck: ; 0x01FFA390
stmdb sp!, {r3, r4, r5, lr}
mov r4, #0
mov r5, r0
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
movne r4, #1
bne _01FFA3BC
@ -2808,7 +2808,7 @@ ShouldMonsterRunAwayVariationOutlawCheck: ; 0x01FFA390
_01FFA3BC:
mov r0, r4
ldmia sp!, {r3, r4, r5, pc}
arm_func_end ShouldMonsterRunAwayVariationOutlawCheck
arm_func_end ShouldMonsterRunAwayAndShowEffectOutlawCheck
arm_func_start AiMovement
AiMovement: ; 0x01FFA3C4
@ -2894,7 +2894,7 @@ _01FFA494:
_01FFA4D4:
ldr r1, [sp]
mov r0, r4
bl ShouldMonsterRunAwayVariationOutlawCheck
bl ShouldMonsterRunAwayAndShowEffectOutlawCheck
cmp r0, #0
beq _01FFA9A8
ldr sb, [r4, #0xb4]
@ -3775,7 +3775,7 @@ _01FFB16C:
movne sl, #5
mov r0, r4
moveq sl, #3
bl ShouldMonsterRunAwayVariationOutlawCheck
bl ShouldMonsterRunAwayAndShowEffectOutlawCheck
cmp r0, #0
ldreqb r0, [sb, #0x7f]
mov r8, #1
@ -4169,7 +4169,7 @@ ChooseAiMove: ; 0x01FFB658
bne _01FFBD0C
mov r0, sl
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
bne _01FFBD0C
ldr r0, [sl, #0xb4]

View File

@ -3516,8 +3516,8 @@ ov29_022E6260: ; 0x022E6260
ldmia sp!, {r4, pc}
arm_func_end ov29_022E6260
arm_func_start ov29_022E62A8
ov29_022E62A8: ; 0x022E62A8
arm_func_start PlayEffectAnimation0x29
PlayEffectAnimation0x29: ; 0x022E62A8
stmdb sp!, {r4, lr}
sub sp, sp, #0x10
mov r4, r0
@ -3536,7 +3536,7 @@ ov29_022E62A8: ; 0x022E62A8
bl PlayEffectAnimationEntity
add sp, sp, #0x10
ldmia sp!, {r4, pc}
arm_func_end ov29_022E62A8
arm_func_end PlayEffectAnimation0x29
arm_func_start ov29_022E62F0
ov29_022E62F0: ; 0x022E62F0

View File

@ -814,7 +814,7 @@ _022F0F58:
_022F0FAC:
bl GetLeader
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
bne _022F1000
mov r0, #0xa
@ -1545,7 +1545,7 @@ _022F19DC:
_022F1A64:
mov r0, r6
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
beq _022F1AA0
ldr r1, _022F1DF4 ; =0x00000B9A
@ -2648,7 +2648,7 @@ _022F2A00:
beq _022F2A70
bl GetLeader
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
bne _022F2A70
mov r0, #4

View File

@ -242,7 +242,7 @@ _022F5578:
_022F55B8:
mov r0, sb
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
beq _022F55E8
ldr r1, _022F5984 ; =0x00000BBE

View File

@ -1,26 +1,10 @@
.include "asm/macros.inc"
.include "overlay_29_023016A8.inc"
.include "overlay_29_023016D8.inc"
.text
arm_func_start ShouldMonsterRunAwayVariation
ShouldMonsterRunAwayVariation: ; 0x023016A8
stmdb sp!, {r3, r4, r5, lr}
mov r5, r0
mov r4, r1
bl ShouldMonsterRunAway
cmp r0, #0
moveq r0, #0
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r5
mov r1, r4
bl ov29_023016D8
mov r0, #1
ldmia sp!, {r3, r4, r5, pc}
arm_func_end ShouldMonsterRunAwayVariation
arm_func_start ov29_023016D8
ov29_023016D8: ; 0x023016D8
arm_func_start DisplayRunAwayIfTriggered
DisplayRunAwayIfTriggered: ; 0x023016D8
stmdb sp!, {r4, r5, r6, lr}
mov r6, r0
ldr r4, [r6, #0xb4]
@ -51,8 +35,8 @@ ov29_023016D8: ; 0x023016D8
cmpne r0, #0
ldmeqia sp!, {r4, r5, r6, pc}
mov r0, r6
bl ov29_022E62A8
bl PlayEffectAnimation0x29
ldmia sp!, {r4, r5, r6, pc}
.align 2, 0
_02301758: .word 0x000003E7
arm_func_end ov29_023016D8
arm_func_end DisplayRunAwayIfTriggered

View File

@ -86,7 +86,7 @@ _0230F22C:
beq _0230F624
mov r0, r8
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
beq _0230F274
mov r1, r4

View File

@ -469,7 +469,7 @@ TryLeaderItemPickUp: ; 0x02345058
b _02345508
_02345108:
mov r1, #1
bl ShouldMonsterRunAwayVariation
bl ShouldMonsterRunAwayAndShowEffect
cmp r0, #0
beq _0234515C
cmp sb, #0

View File

@ -6,5 +6,10 @@
// Checks if a monster should run away from other monsters
// return: True if the monster should run away, false otherwise
bool8 ShouldMonsterRunAway(struct entity *monster);
// Calls ShouldMonsterRunAway and returns its result. It also calls DisplayRunAwayIfTriggered if the result was true.
// monster: Entity pointer
// show_run_away_effect: Boolean value. If true, display a visual "poof" effect if the Run Away ability caused the monster to run away.
// return: Result of the call to ShouldMonsterRunAway
bool8 ShouldMonsterRunAwayAndShowEffect(struct entity *monster, bool8 show_run_away_effect);
#endif //PMDSKY_DUNGEON_AI_TARGETING_H

View File

@ -3,6 +3,10 @@
#include "dungeon_mode.h"
// Returns false if the entity has any of these conditions: sleep, nightmare, napping, frozen, wrapped/wrapping, petrified, cringe, paused, infatuated, paralysis. Also returns false if ShouldMonsterRunAway returns true.
// pokemon: Entity pointer
// skip_sleep: If true, ignore sleep conditions (sleep, nightmare, napping) when checking if the entity cannot attack.
// return: bool
bool8 MonsterCannotAttack(struct entity *pokemon, bool8 skip_sleep);
// Checks if the given monster can move in the specified direction
// Returns false if any monster is standing on the target tile

View File

@ -347,7 +347,7 @@ Overlay OVY_29
Object src/dungeon_logic_3.o
Object asm/overlay_29_02300FCC.o
Object src/dungeon_ai_targeting.o
Object asm/overlay_29_023016A8.o
Object asm/overlay_29_023016D8.o
Object src/dungeon_ai_targeting_1.o
Object asm/overlay_29_rodata_023527C0.o
Object asm/overlay_29_023018AC.o

View File

@ -2,6 +2,7 @@
#include "dg_random.h"
#include "direction.h"
#include "dungeon_action.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_logic_3.h"
#include "dungeon_parameters.h"
#include "dungeon_pokemon_attributes.h"
@ -15,7 +16,6 @@ const s16 AI_REGULAR_ATTACK_WEIGHTS[5] = { 100, 20, 30, 40, 50 };
extern struct dungeon *DUNGEON_PTR[];
extern u32 ShouldMonsterRunAwayVariation(struct entity *monster, u32 param_2);
extern bool8 IsMonsterCornered(struct entity *monster);
extern bool8 IsChargingTwoTurnMove(struct entity *user, struct move *move);
extern void SetActionUseMoveAi(struct action_data *monster_action, s16 move_index, u8 direction);
@ -38,7 +38,7 @@ void ChooseAiMove(struct entity *monster)
if (!AreMovesEnabled(DUNGEON_PTR[0]->gen_info.fixed_room_id) ||
MonsterCannotAttack(monster, FALSE) ||
ShouldMonsterRunAwayVariation(monster, TRUE) ||
ShouldMonsterRunAwayAndShowEffect(monster, TRUE) ||
GetEntInfo(monster)->monster_behavior == BEHAVIOR_FLEEING_OUTLAW && IsMonsterCornered(monster) ||
IsTacticSet(monster, TACTIC_KEEP_YOUR_DISTANCE) ||
(pokemon_info->cringe_class_status.cringe == STATUS_CRINGE_CONFUSED && DungeonRandOutcome__022EAB20(AI_CONFUSED_NO_ATTACK_CHANCE)))

View File

@ -4,6 +4,8 @@
#include "dungeon_util_static.h"
#include "overlay_29_023000E4.h"
extern void DisplayRunAwayIfTriggered(struct entity *monster, bool8 show_run_away_effect);
bool8 ShouldMonsterRunAway(struct entity *monster)
{
if (!EntityIsValid__023000E4(monster))
@ -42,3 +44,14 @@ bool8 ShouldMonsterRunAway(struct entity *monster)
}
return FALSE;
}
bool8 ShouldMonsterRunAwayAndShowEffect(struct entity *monster, bool8 show_run_away_effect)
{
if (ShouldMonsterRunAway(monster))
{
DisplayRunAwayIfTriggered(monster, show_run_away_effect);
return TRUE;
}
return FALSE;
}

View File

@ -1,4 +1,5 @@
#include "overlay_31_02382820.h"
#include "dungeon_ai_targeting.h"
#include "number_util.h"
extern struct dungeon* DUNGEON_PTR[];
@ -36,7 +37,6 @@ extern u8* AllocateTemp1024ByteBufferFromPool(void);
extern struct Window* GetWindow(struct Window*);
extern s32 sub_020265A8(u8*); // Measures the text's width in pixels
extern u32 ShouldMonsterRunAwayVariation(struct entity*, u32);
extern u32 Arm9LoadUnkFieldNa0x2029EC8(u32, u8*);
extern u8 CreateParentMenuFromStringIds(u32*, u32, struct struct_2*, u32*);
extern u8 CreateTextBox(u32*, void (*fun)(struct Window*));
@ -44,7 +44,6 @@ extern u32 IsParentMenuActive(s8);
extern u32 sub_0202AB80(s8);
extern void Arm9StoreUnkFieldNa0x2029ED8(u32, u8);
extern u32 GetPressedButtons(u32, u16*);
extern u32 ShouldMonsterRunAwayVariation(struct entity*, u32);
extern void sub_0202AB94(s8, u32);
extern void sub_0202B030(s8);
extern void sub_0202F954(s8);
@ -173,7 +172,7 @@ u32 ov31_02382B54(void)
OVERLAY31_UNKNOWN_POINTER__NA_238A260[0]->b[i] = 0;
}
leader = GetLeader();
if (ShouldMonsterRunAwayVariation(leader, 1)) {
if (ShouldMonsterRunAwayAndShowEffect(leader, 1)) {
OVERLAY31_UNKNOWN_POINTER__NA_238A260[0]->b[0] = 3;
OVERLAY31_UNKNOWN_POINTER__NA_238A260[0]->b[1] = 3;
OVERLAY31_UNKNOWN_POINTER__NA_238A260[0]->b[2] = 3;
@ -201,7 +200,7 @@ u32 ov31_02382B54(void)
struct entity* leader = GetLeader();
if (ShouldMonsterRunAwayVariation(leader, 1))
if (ShouldMonsterRunAwayAndShowEffect(leader, 1))
break;
sub_0202AB94(OVERLAY31_UNKNOWN_POINTER__NA_238A260[0]->f[0], 0);