Decomped GetMoveTypeForMonster

This commit is contained in:
AnonymousRandomPerson 2025-09-12 23:58:17 -04:00
parent 843b11398f
commit c742a852ad
11 changed files with 85 additions and 82 deletions

View File

@ -1,20 +1,13 @@
#pragma once
.public AbilityIsActive
.public CanLearnIqSkill
.public CanSeeTarget
.public DisableIqSkill
.public DUNGEON_PTR
.public DisableIqSkill
.public EnableIqSkill
.public EntityIsValid__023000E4
.public GetEntityNaturalGiftInfo
.public GetEntityWeatherBallType
.public GetMoveBasePower
.public GetMoveType
.public GetPerformanceFlagWithChecks
.public GetSpeciesIqSkill
.public IqSkillFlagTest
.public IsRegularAttackOrProjectile
.public ItemIsActive__022FF898
.public MIN_IQ_EXCLUSIVE_MOVE_USER
.public MIN_IQ_ITEM_MASTER
.public ov29_022FBDE0

View File

@ -0,0 +1,3 @@
#pragma once
.public GetMoveBasePower
.public ItemIsActive__022FF898

View File

@ -217,74 +217,3 @@ _02302268:
.align 2, 0
_02302278: .word DUNGEON_PTR
arm_func_end ov29_02302200
arm_func_start GetMoveTypeForMonster
GetMoveTypeForMonster: ; 0x0230227C
stmdb sp!, {r3, r4, r5, lr}
mov r4, r1
mov r5, r0
ldrh r0, [r4, #4]
bl IsRegularAttackOrProjectile
cmp r0, #0
bne _023022C0
mov r0, r5
bl EntityIsValid__023000E4
cmp r0, #0
beq _023022C0
mov r0, r5
mov r1, #0x6b
bl AbilityIsActive
cmp r0, #0
movne r0, #1
ldmneia sp!, {r3, r4, r5, pc}
_023022C0:
ldrh r1, [r4, #4]
cmp r1, #0x144
ldreq r0, [r5, #0xb4]
ldreqb r0, [r0, #0x46]
ldmeqia sp!, {r3, r4, r5, pc}
ldr r0, _02302318 ; =0x000001D7
cmp r1, r0
bne _023022F4
mov r0, r5
bl GetEntityNaturalGiftInfo
cmp r0, #0
ldrneb r0, [r0, #2]
ldmneia sp!, {r3, r4, r5, pc}
_023022F4:
ldrh r0, [r4, #4]
cmp r0, #0x1f
bne _0230230C
mov r0, r5
bl GetEntityWeatherBallType
ldmia sp!, {r3, r4, r5, pc}
_0230230C:
mov r0, r4
bl GetMoveType
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
_02302318: .word 0x000001D7
arm_func_end GetMoveTypeForMonster
arm_func_start GetMovePower
GetMovePower: ; 0x0230231C
stmdb sp!, {r3, r4, r5, lr}
ldrh r2, [r1, #4]
mov r5, r0
ldrb r4, [r1, #7]
cmp r2, #0x144
ldreq r0, [r5, #0xb4]
ldreqsh r0, [r0, #0x44]
addeq r0, r4, r0
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r1
bl GetMoveBasePower
add r4, r4, r0
mov r0, r5
mov r1, #0x2b
bl ItemIsActive__022FF898
cmp r0, #0
movne r4, r4, lsl #1
mov r0, r4
ldmia sp!, {r3, r4, r5, pc}
arm_func_end GetMovePower

27
asm/overlay_29_0230231C.s Normal file
View File

@ -0,0 +1,27 @@
.include "asm/macros.inc"
.include "overlay_29_0230231C.inc"
.text
arm_func_start GetMovePower
GetMovePower: ; 0x0230231C
stmdb sp!, {r3, r4, r5, lr}
ldrh r2, [r1, #4]
mov r5, r0
ldrb r4, [r1, #7]
cmp r2, #0x144
ldreq r0, [r5, #0xb4]
ldreqsh r0, [r0, #0x44]
addeq r0, r4, r0
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r1
bl GetMoveBasePower
add r4, r4, r0
mov r0, r5
mov r1, #0x2b
bl ItemIsActive__022FF898
cmp r0, #0
movne r4, r4, lsl #1
mov r0, r4
ldmia sp!, {r3, r4, r5, pc}
arm_func_end GetMovePower

View File

@ -0,0 +1,9 @@
#ifndef PMDSKY_DUNGEON_LOGIC_5_H
#define PMDSKY_DUNGEON_LOGIC_5_H
#include "dungeon_mode.h"
// Check the type of a move when used by a certain monster. Accounts for special cases such as Hidden Power, Weather Ball, the regular attack...
enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move);
#endif //PMDSKY_DUNGEON_LOGIC_5_H

View File

@ -262,7 +262,7 @@ struct monster {
s32 exp; // 0x20: Total Exp. Points
struct monster_stat_modifiers stat_modifiers; // 0x24
s16 hidden_power_base_power; // 0x44
enum type_id hidden_power_type : 8; // 0x46
enum type_id hidden_power_type; // 0x46
u8 field_0x47;
enum dungeon_id joined_at : 8; // 0x48: Also used as a unique identifier for special monsters
u8 joined_at_floor; // 0x49: Floor number of recruitment. 0 for special recruits

View File

@ -2,6 +2,7 @@
#define PMDSKY_MOVE_H
#include "enums.h"
#include "item.h"
enum move_flag
{
@ -58,4 +59,13 @@ struct move {
u8 ginseng; // 0x7: Ginseng boost
};
struct natural_gift_item_info
{
enum item_id item_id;
enum type_id type_id;
// This value is the boost that's added to Natural Gift's default base power of 1
// during damage calculation
s16 base_power_boost;
};
#endif // PMDSKY_MOVE_H

View File

@ -435,6 +435,8 @@ Overlay OVY_29
Object asm/overlay_29_02301E88.o
Object src/dungeon_pokemon_attributes_1.o
Object asm/overlay_29_02301FBC.o
Object src/dungeon_logic_5.o
Object asm/overlay_29_0230231C.o
Object src/dungeon_logic_2.o
Object asm/overlay_29_02302388.o
Object src/overlay_29_023026CC.o

View File

@ -6,6 +6,7 @@
#include "dungeon_capabilities_4.h"
#include "dungeon_logic.h"
#include "dungeon_logic_4.h"
#include "dungeon_logic_5.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_statuses.h"
@ -26,7 +27,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 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);
void ResetAiCanAttackInDirection()

View File

@ -8,6 +8,7 @@
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities_3.h"
#include "dungeon_capabilities_4.h"
#include "dungeon_logic_5.h"
#include "dungeon_misc.h"
#include "dungeon_mode.h"
#include "dungeon_move.h"
@ -25,7 +26,6 @@ extern bool8 TargetRegularAttack(struct entity *pokemon, u32 *target_dir, bool8
extern void SetActionRegularAttack(struct action_data *monster_action, u8 direction);
extern void SetActionStruggle(struct action_data *monster_action, u8 direction);
extern bool8 CanAiUseMove(struct entity *monster, u32 move_index, bool8 extra_checks);
extern enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move);
extern u8 GetMoveAiWeight(struct move *move);
#ifdef SDK_ARM9

30
src/dungeon_logic_5.c Normal file
View File

@ -0,0 +1,30 @@
#include "dungeon_logic_5.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util_static.h"
#include "overlay_29_023000E4.h"
extern bool8 IsRegularAttackOrProjectile(enum move_id move_id);
extern struct natural_gift_item_info* GetEntityNaturalGiftInfo(struct entity* entity);
extern enum type_id GetEntityWeatherBallType(struct entity* entity);
extern enum type_id GetMoveType(struct move* move);
enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move)
{
if (!IsRegularAttackOrProjectile(move->id) && EntityIsValid__023000E4(entity) && AbilityIsActive(entity, ABILITY_NORMALIZE))
return TYPE_NORMAL;
if (move->id == MOVE_HIDDEN_POWER)
return GetEntInfo(entity)->hidden_power_type;
if (move->id == MOVE_NATURAL_GIFT)
{
struct natural_gift_item_info *natural_gift_info = GetEntityNaturalGiftInfo(entity);
if (natural_gift_info != NULL)
return natural_gift_info->type_id;
}
if (move->id == MOVE_WEATHER_BALL)
return GetEntityWeatherBallType(entity);
return GetMoveType(move);
}