Decomped HasLastUsedMove

This commit is contained in:
AnonymousRandomPerson 2025-09-11 23:39:48 -04:00
parent 9dfaf725cd
commit ffb7ae6716
6 changed files with 21 additions and 41 deletions

View File

@ -1,2 +0,0 @@
#pragma once

View File

@ -1,34 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_02334CAC.inc"
.text
arm_func_start HasLastUsedMove
HasLastUsedMove: ; 0x02334CAC
stmdb sp!, {r3, lr}
mov r3, #0
mov r1, r3
mov r2, #1
b _02334CE8
_02334CC0:
ldrb ip, [r0, r3, lsl #3]
tst ip, #1
movne lr, r2
moveq lr, r1
tst lr, #0xff
beq _02334CE4
tst ip, #0x10
movne r0, #1
ldmneia sp!, {r3, pc}
_02334CE4:
add r3, r3, #1
_02334CE8:
cmp r3, #4
blt _02334CC0
ldrb r0, [r0, #0x20]
tst r0, #0x10
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
ldmia sp!, {r3, pc}
arm_func_end HasLastUsedMove

View File

@ -10,6 +10,7 @@
#define NUM_PICKED_IQ_SKILLS 3
#define MAX_MON_MOVES 4
#define STRUGGLE_MOVE_INDEX 4
#define STAT_MULTIPLIER_THRESHOLD 0.249 // one tick less than 0.25
#define DEFAULT_STAT_STAGE 10

View File

@ -16,5 +16,8 @@ bool8 EntityIsValid__02333FAC(struct entity *entity);
// move: Move pointer
// return: True if it makes sense to use the move, false if it would be redundant given the effects it causes and the effects that the target already has.
bool8 StatusCheckerCheckOnTarget(struct entity *attacker, struct entity *target, struct move *move);
// Determines whether a monster has used any of its moves on this floor.
// This function takes in the monster's move list and checks if any moves have the f_last_used flag set.
bool8 HasLastUsedMove(struct move *moves);
#endif //PMDSKY_MOVE_CHECKS_H

View File

@ -544,7 +544,6 @@ Overlay OVY_29
Object src/overlay_29_023329E8.o
Object asm/overlay_29_02332A0C.o
Object src/move_checks.o
Object asm/overlay_29_02334CAC.o
Object src/weather.o
Object asm/overlay_29_02334D58.o
Object src/overlay_29_023350D8.o

View File

@ -17,7 +17,6 @@
#include "trap.h"
#include "weather.h"
extern bool8 HasLastUsedMove(struct move *moves);
extern bool8 GendersEqualNotGenderless(s16 monster1, s16 monster2);
// https://decomp.me/scratch/TnODN
@ -1783,7 +1782,7 @@ bool8 StatusCheckerCheckOnTarget(struct entity *attacker, struct entity *target,
break;
case MOVE_BLOCK:
case MOVE_MEAN_LOOK:
case MOVE_SPIDER_WEB: // Remove?
case MOVE_SPIDER_WEB:
if (target_data->frozen_class_status.freeze == STATUS_FROZEN_SHADOW_HOLD)
return FALSE;
break;
@ -1822,7 +1821,7 @@ bool8 StatusCheckerCheckOnTarget(struct entity *attacker, struct entity *target,
return FALSE;
break;
case MOVE_FLASH:
case MOVE_KINESIS: // Remove?
case MOVE_KINESIS:
case MOVE_SAND_ATTACK:
if (target_data->stat_modifiers.hit_chance_stages[STAT_STAGE_ACCURACY] < 1)
return FALSE;
@ -1881,7 +1880,7 @@ bool8 StatusCheckerCheckOnTarget(struct entity *attacker, struct entity *target,
break;
case MOVE_COPYCAT:
case MOVE_MIMIC:
case MOVE_SKETCH: // Remove?
case MOVE_SKETCH:
if (!HasLastUsedMove(target_data->moves.moves))
return FALSE;
break;
@ -2007,3 +2006,17 @@ bool8 StatusCheckerCheckOnTarget(struct entity *attacker, struct entity *target,
return TRUE;
}
bool8 HasLastUsedMove(struct move *moves)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (MoveExists(&moves[i]) && moves[i].flags0 & MOVE_FLAG_LAST_USED)
return TRUE;
}
if (moves[STRUGGLE_MOVE_INDEX].flags0 & MOVE_FLAG_LAST_USED)
return TRUE;
return FALSE;
}