mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-20 15:55:05 -05:00
Decomped WeightMove()
This commit is contained in:
@@ -5,94 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start WeightMove
|
||||
WeightMove:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
adds r5, r0, 0
|
||||
mov r8, r2
|
||||
lsls r1, 16
|
||||
asrs r1, 16
|
||||
lsls r3, 24
|
||||
lsrs r3, 24
|
||||
mov r9, r3
|
||||
movs r6, 0x1
|
||||
ldr r4, [r2, 0x70]
|
||||
adds r7, r4, 0
|
||||
ldrb r0, [r4, 0x6]
|
||||
cmp r0, 0
|
||||
beq _0807C7D6
|
||||
movs r0, 0xF
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _0807C7DA
|
||||
_0807C7D6:
|
||||
movs r0, 0x1
|
||||
b _0807C848
|
||||
_0807C7DA:
|
||||
adds r0, r5, 0
|
||||
movs r1, 0x9
|
||||
bl HasIQSkill
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _0807C804
|
||||
ldr r0, _0807C7FC
|
||||
ldr r0, [r0]
|
||||
movs r2, 0x2
|
||||
ldrsh r1, [r4, r2]
|
||||
ldr r2, _0807C800
|
||||
adds r0, r2
|
||||
adds r0, r1
|
||||
ldrb r6, [r0]
|
||||
b _0807C846
|
||||
.align 2, 0
|
||||
_0807C7FC: .4byte gDungeonGlobalData
|
||||
_0807C800: .4byte 0x0000363c
|
||||
_0807C804:
|
||||
adds r0, r5, 0
|
||||
movs r1, 0xA
|
||||
bl HasIQSkill
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _0807C828
|
||||
ldrb r1, [r7, 0xE]
|
||||
movs r2, 0xC
|
||||
negs r2, r2
|
||||
adds r0, r2, 0
|
||||
subs r0, r1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
cmp r6, 0
|
||||
bne _0807C846
|
||||
movs r6, 0x1
|
||||
b _0807C846
|
||||
_0807C828:
|
||||
adds r0, r5, 0
|
||||
movs r1, 0xB
|
||||
bl HasIQSkill
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _0807C846
|
||||
adds r0, r5, 0
|
||||
mov r1, r8
|
||||
mov r2, r9
|
||||
bl WeightWeakTypePicker
|
||||
adds r0, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_0807C846:
|
||||
adds r0, r6, 0
|
||||
_0807C848:
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end WeightMove
|
||||
|
||||
thumb_func_start TargetRegularAttack
|
||||
TargetRegularAttack:
|
||||
push {r4-r7,lr}
|
||||
@@ -7,5 +7,7 @@
|
||||
s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, u32 hasStatusChecker);
|
||||
// 0x7C648
|
||||
bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker);
|
||||
// 0x7C7AC
|
||||
s32 WeightMove(struct DungeonEntity *user, s32 targetingFlags, struct DungeonEntity *target, u32 moveType);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -241,7 +241,7 @@ SECTIONS {
|
||||
src/dungeon_ai_attack.o(.text);
|
||||
asm/code_807C4A0.o(.text);
|
||||
src/dungeon_ai_attack_1.o(.text);
|
||||
asm/code_807C7AC.o(.text);
|
||||
asm/code_807C854.o(.text);
|
||||
src/dungeon_ai_attack_2.o(.text);
|
||||
asm/code_807CABC.o(.text);
|
||||
src/targeting_flags.o(.text);
|
||||
|
||||
@@ -42,7 +42,6 @@ extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS];
|
||||
extern bool8 IsMoveUsable_1(struct DungeonEntity*, s32, bool8);
|
||||
extern bool8 TargetRegularAttack(struct DungeonEntity*, u32*, bool8);
|
||||
extern bool8 IsTargetInLineRange(struct DungeonEntity*, struct DungeonEntity*, s32);
|
||||
extern s32 WeightMove(struct DungeonEntity*, s32, struct DungeonEntity*, u8);
|
||||
|
||||
void DecideAttack(struct DungeonEntity *pokemon)
|
||||
{
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#include "dungeon_ai_attack_1.h"
|
||||
|
||||
#include "constants/direction.h"
|
||||
#include "constants/iq_skill.h"
|
||||
#include "constants/targeting.h"
|
||||
#include "constants/type.h"
|
||||
#include "dungeon_ai_targeting_2.h"
|
||||
#include "dungeon_global_data.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "moves.h"
|
||||
@@ -17,7 +19,7 @@ extern s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS];
|
||||
extern u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS];
|
||||
extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS];
|
||||
|
||||
extern s32 WeightMove(struct DungeonEntity*, s32, struct DungeonEntity*, u8);
|
||||
extern s32 WeightWeakTypePicker(struct DungeonEntity *user, struct DungeonEntity *target, u8 moveType);
|
||||
|
||||
s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker)
|
||||
{
|
||||
@@ -173,3 +175,41 @@ bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct Du
|
||||
}
|
||||
return hasTarget;
|
||||
}
|
||||
|
||||
s32 WeightMove(struct DungeonEntity *user, s32 targetingFlags, struct DungeonEntity *target, u32 moveType)
|
||||
{
|
||||
#ifndef NONMATCHING
|
||||
register struct DungeonEntityData *targetData asm("r4");
|
||||
#else
|
||||
struct DungeonEntityData *targetData;
|
||||
#endif
|
||||
s32 targetingFlags2 = (s16) targetingFlags;
|
||||
u8 moveType2 = moveType;
|
||||
u8 weight = 1;
|
||||
struct DungeonEntityData *targetData2;
|
||||
targetData2 = targetData = target->entityData;
|
||||
if (!targetData->isEnemy || (targetingFlags2 & 0xF) != TARGETING_FLAG_TARGET_OTHER)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (HasIQSkill(user, IQ_SKILL_EXP_GO_GETTER))
|
||||
{
|
||||
// BUG: expYieldRankings has lower values as the Pokémon's experience yield increases.
|
||||
// This causes Exp. Go-Getter to prioritizes Pokémon worth less experience
|
||||
// instead of Pokémon worth more experience.
|
||||
weight = gDungeonGlobalData->expYieldRankings[targetData->entityID];
|
||||
}
|
||||
else if (HasIQSkill(user, IQ_SKILL_EFFICIENCY_EXPERT))
|
||||
{
|
||||
weight = -12 - targetData2->HP;
|
||||
if (weight == 0)
|
||||
{
|
||||
weight = 1;
|
||||
}
|
||||
}
|
||||
else if (HasIQSkill(user, IQ_SKILL_WEAK_TYPE_PICKER))
|
||||
{
|
||||
weight = WeightWeakTypePicker(user, target, moveType2) + 1;
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user