Merge pull request #93 from AnonymousRandomPerson/master

More AI decomp
This commit is contained in:
Seth Barberee
2022-01-20 15:26:19 -08:00
committed by GitHub
29 changed files with 4036 additions and 4183 deletions

View File

@@ -1,34 +1,10 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start SetWalkAction
SetWalkAction:
push {r4,lr}
adds r4, r0, 0
lsls r0, r1, 16
asrs r0, 16
bl GetIsMoving
lsls r0, 24
cmp r0, 0
beq _08044CB6
movs r0, 0x2
b _08044CB8
_08044CB6:
movs r0, 0x1
_08044CB8:
strh r0, [r4]
movs r0, 0
strb r0, [r4, 0x4]
strb r0, [r4, 0xC]
pop {r4}
pop {r0}
bx r0
thumb_func_end SetWalkAction
.syntax unified
.text
thumb_func_start sub_8044CC8
sub_8044CC8:
push {lr}

View File

@@ -12949,7 +12949,7 @@ _0805E0C2:
mov r0, r10
adds r1, r5, 0
str r3, [sp, 0x20]
bl CannotMoveForward
bl CanMoveForward2
lsls r0, 24
ldr r3, [sp, 0x20]
cmp r0, 0
@@ -14878,7 +14878,7 @@ _0805EFF6:
bne _0805F008
mov r0, r8
adds r1, r4, 0
bl CannotMoveForward
bl CanMoveForward2
lsls r0, 24
cmp r0, 0
beq _0805F014

View File

@@ -1,210 +1,9 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
#include "asm/macros.inc"
.syntax unified
.syntax unified
.text
thumb_func_start HasStatusAffectingActions
HasStatusAffectingActions:
push {r4-r6,lr}
adds r5, r0, 0
ldr r4, [r5, 0x70]
ldr r0, _08070050
adds r1, r5, 0
movs r2, 0
bl SetMessageArgument
adds r0, r4, 0
adds r0, 0x44
movs r1, 0x1
bl SetAction
adds r0, r4, 0
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x3
bne _08070042
b _0807019C
_08070042:
cmp r0, 0x3
bgt _08070054
cmp r0, 0x1
bne _0807004C
b _0807019C
_0807004C:
b _0807005A
.align 2, 0
_08070050: .4byte gAvailablePokemonNames
_08070054:
cmp r0, 0x5
bne _0807005A
b _0807019C
_0807005A:
adds r0, r4, 0
adds r0, 0xB0
ldrb r0, [r0]
cmp r0, 0x3
beq _0807008C
cmp r0, 0x3
bgt _0807006E
cmp r0, 0x1
beq _0807007A
b _080700AC
_0807006E:
cmp r0, 0x4
beq _0807009C
cmp r0, 0x6
bne _08070078
b _0807019C
_08070078:
b _080700AC
_0807007A:
ldr r0, _08070088
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_08070088: .4byte gFrozenMessage
_0807008C:
ldr r0, _08070098
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_08070098: .4byte gWrappedAroundMessage
_0807009C:
ldr r0, _080700A8
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_080700A8: .4byte gWrappedByMessage
_080700AC:
adds r0, r4, 0
adds r0, 0xBC
ldrb r0, [r0]
cmp r0, 0x3
beq _080700D4
cmp r0, 0x7
beq _080700E4
adds r0, r4, 0
adds r0, 0xC0
ldrb r0, [r0]
cmp r0, 0x1
bne _080700F4
ldr r0, _080700D0
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_080700D0: .4byte gBideMessage
_080700D4:
ldr r0, _080700E0
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_080700E0: .4byte gPausedMessage
_080700E4:
ldr r0, _080700F0
ldr r1, [r0]
adds r0, r5, 0
bl SendMessage
b _0807019C
.align 2, 0
_080700F0: .4byte gInfatuatedMessage
_080700F4:
adds r0, r4, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _0807012E
adds r0, r4, 0
adds r0, 0x44
movs r2, 0x2
ldrsh r1, [r4, r2]
bl SetWalkAction
movs r0, 0x8
bl DungeonRandomCapped
adds r1, r4, 0
adds r1, 0x46
strb r0, [r1]
ldrh r1, [r5, 0x4]
movs r2, 0xB6
lsls r2, 1
adds r0, r4, r2
strh r1, [r0]
ldrh r0, [r5, 0x6]
subs r0, 0x1
movs r1, 0xB7
lsls r1, 1
adds r2, r4, r1
strh r0, [r2]
b _0807019C
_0807012E:
ldrb r0, [r4, 0x8]
cmp r0, 0x1
beq _0807019C
adds r0, r4, 0
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x1
bne _0807017C
adds r6, r4, 0
adds r6, 0x46
ldrb r1, [r6]
adds r0, r5, 0
bl CannotMoveForward
lsls r0, 24
cmp r0, 0
bne _08070166
movs r0, 0x2
bl DungeonRandomCapped
cmp r0, 0
beq _08070174
movs r0, 0x8
bl DungeonRandomCapped
movs r1, 0x7
ands r1, r0
strb r1, [r6]
_08070166:
adds r0, r4, 0
adds r0, 0x44
movs r2, 0x2
ldrsh r1, [r4, r2]
bl SetWalkAction
b _0807019C
_08070174:
adds r0, r5, 0
bl DecideAttack
b _0807019C
_0807017C:
cmp r0, 0x2
beq _08070184
movs r0, 0
b _0807019E
_08070184:
adds r0, r4, 0
adds r0, 0x44
movs r2, 0x2
ldrsh r1, [r4, r2]
bl SetWalkAction
movs r0, 0x8
bl DungeonRandomCapped
adds r1, r4, 0
adds r1, 0x46
strb r0, [r1]
_0807019C:
movs r0, 0x1
_0807019E:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end HasStatusAffectingActions
.text
thumb_func_start sub_80701A4
sub_80701A4:
@@ -261,17 +60,17 @@ _08070202:
ldr r0, _08070208
b _08070278
.align 2, 0
_08070208: .4byte gFrozenMessage
_08070208: .4byte gPtrFrozenMessage
_0807020C:
ldr r0, _08070210
b _08070278
.align 2, 0
_08070210: .4byte gWrappedAroundMessage
_08070210: .4byte gPtrWrappedAroundMessage
_08070214:
ldr r0, _08070218
b _08070278
.align 2, 0
_08070218: .4byte gWrappedByMessage
_08070218: .4byte gPtrWrappedByMessage
_0807021C:
adds r0, r6, 0
adds r0, 0xBC
@@ -303,12 +102,12 @@ _0807025C:
ldr r0, _08070260
b _08070278
.align 2, 0
_08070260: .4byte gPausedMessage
_08070260: .4byte gPtrPausedMessage
_08070264:
ldr r0, _08070268
b _08070278
.align 2, 0
_08070268: .4byte gInfatuatedMessage
_08070268: .4byte gPtrInfatuatedMessage
_0807026C:
adds r0, r6, 0
adds r0, 0xC0
@@ -324,7 +123,7 @@ _08070280:
movs r0, 0x1
b _08070322
.align 2, 0
_08070284: .4byte gBideMessage
_08070284: .4byte gPtrBideMessage
_08070288:
cmp r0, 0
beq _08070320
@@ -1397,165 +1196,4 @@ _08070A50: .4byte gRecruitedPokemonRef
_08070A54: .4byte 0x00008df8
thumb_func_end sub_80709C8
thumb_func_start HasNegativeStatus
HasNegativeStatus:
push {r4,lr}
ldr r0, [r0, 0x70]
mov r12, r0
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x1
beq _08070ADE
cmp r0, 0x3
beq _08070ADE
cmp r0, 0x4
beq _08070ADE
mov r0, r12
adds r0, 0xAC
ldrb r0, [r0]
cmp r0, 0
bne _08070ADE
mov r0, r12
adds r0, 0xB0
ldrb r0, [r0]
cmp r0, 0x5
beq _08070A86
cmp r0, 0
bne _08070ADE
_08070A86:
mov r0, r12
adds r0, 0xBC
ldrb r0, [r0]
cmp r0, 0
bne _08070ADE
mov r0, r12
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x1
beq _08070ADE
cmp r0, 0x2
beq _08070ADE
mov r0, r12
adds r0, 0xD0
ldrb r0, [r0]
cmp r0, 0x1
beq _08070ADE
mov r0, r12
adds r0, 0xDC
ldrb r0, [r0]
cmp r0, 0x2
beq _08070ADE
mov r0, r12
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x1
beq _08070ADE
cmp r0, 0x2
beq _08070ADE
mov r0, r12
adds r0, 0xEC
ldrb r0, [r0]
cmp r0, 0x1
beq _08070ADE
mov r0, r12
adds r0, 0xF5
ldrb r0, [r0]
cmp r0, 0
bne _08070ADE
mov r0, r12
adds r0, 0xFD
ldrb r0, [r0]
cmp r0, 0
beq _08070AE2
_08070ADE:
movs r0, 0x1
b _08070B1E
_08070AE2:
movs r3, 0
movs r4, 0x1
movs r2, 0x8C
lsls r2, 1
add r2, r12
_08070AEC:
ldrb r1, [r2]
adds r0, r4, 0
ands r0, r1
cmp r0, 0
beq _08070B00
ldrb r1, [r2, 0x1]
adds r0, r4, 0
ands r0, r1
cmp r0, 0
bne _08070ADE
_08070B00:
adds r2, 0x8
adds r3, 0x1
cmp r3, 0x3
ble _08070AEC
movs r3, 0
ldr r1, _08070B24
add r1, r12
_08070B0E:
adds r0, r1, r3
ldrb r0, [r0]
cmp r0, 0
bne _08070ADE
adds r3, 0x1
cmp r3, 0x4
ble _08070B0E
movs r0, 0
_08070B1E:
pop {r4}
pop {r1}
bx r1
.align 2, 0
_08070B24: .4byte 0x0000010d
thumb_func_end HasNegativeStatus
thumb_func_start IsSleeping
IsSleeping:
push {lr}
ldr r0, [r0, 0x70]
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x1
beq _08070B40
cmp r0, 0x5
beq _08070B40
cmp r0, 0x3
beq _08070B40
movs r0, 0
b _08070B42
_08070B40:
movs r0, 0x1
_08070B42:
pop {r1}
bx r1
thumb_func_end IsSleeping
thumb_func_start HasQuarterHPOrLess
HasQuarterHPOrLess:
push {lr}
ldr r0, [r0, 0x70]
adds r1, r0, 0
movs r2, 0x10
ldrsh r0, [r1, r2]
cmp r0, 0
bge _08070B58
adds r0, 0x3
_08070B58:
movs r2, 0xE
ldrsh r1, [r1, r2]
asrs r0, 2
cmp r1, r0
ble _08070B66
movs r0, 0
b _08070B68
_08070B66:
movs r0, 0x1
_08070B68:
pop {r1}
bx r1
thumb_func_end HasQuarterHPOrLess
.align 2, 0
.align 2, 0

33
asm/code_8070B48.s Normal file
View File

@@ -0,0 +1,33 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start HasQuarterHPOrLess
HasQuarterHPOrLess:
push {lr}
ldr r0, [r0, 0x70]
adds r1, r0, 0
movs r2, 0x10
ldrsh r0, [r1, r2]
cmp r0, 0
bge _08070B58
adds r0, 0x3
_08070B58:
movs r2, 0xE
ldrsh r1, [r1, r2]
asrs r0, 2
cmp r1, r0
ble _08070B66
movs r0, 0
b _08070B68
_08070B66:
movs r0, 0x1
_08070B68:
pop {r1}
bx r1
thumb_func_end HasQuarterHPOrLess
.align 2, 0

View File

@@ -5,8 +5,8 @@
.text
thumb_func_start CannotMoveForward
CannotMoveForward:
thumb_func_start CanMoveForward2
CanMoveForward2:
push {r4-r6,lr}
adds r4, r0, 0
adds r6, r1, 0
@@ -108,7 +108,7 @@ _08070E36:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CannotMoveForward
thumb_func_end CanMoveForward2
thumb_func_start sub_8070E3C
sub_8070E3C:

View File

@@ -2652,7 +2652,7 @@ _08072F84:
bne _08072FCC
adds r0, r4, 0
adds r1, r3, 0
bl CannotMoveForward
bl CanMoveForward2
lsls r0, 24
cmp r0, 0
bne _08072FCC

View File

@@ -1,63 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start CalculateFacingDir
CalculateFacingDir:
push {r4,lr}
movs r2, 0
ldrsh r3, [r1, r2]
movs r4, 0
ldrsh r2, [r0, r4]
subs r2, r3, r2
movs r3, 0x2
ldrsh r1, [r1, r3]
movs r4, 0x2
ldrsh r0, [r0, r4]
subs r1, r0
cmp r2, 0
bne _080983FA
cmp r1, 0
bne _080983FA
movs r0, 0
b _08098428
_080983FA:
cmp r2, 0
ble _08098400
movs r2, 0x1
_08098400:
cmp r1, 0
ble _08098406
movs r1, 0x1
_08098406:
movs r0, 0x1
negs r0, r0
cmp r2, r0
bgt _08098410
adds r2, r0, 0
_08098410:
cmp r1, r0
bgt _08098416
adds r1, r0, 0
_08098416:
ldr r3, _08098430
adds r2, 0x1
adds r1, 0x1
lsls r0, r1, 1
adds r0, r1
adds r0, r2
lsls r0, 2
adds r0, r3
ldr r0, [r0]
_08098428:
pop {r4}
pop {r1}
bx r1
.align 2, 0
_08098430: .4byte gUnknown_8115E94
thumb_func_end CalculateFacingDir
.align 2,0

View File

@@ -1423,31 +1423,65 @@ gUnknown_80F9510: @ 80F9510
.global gUnknown_80F9530
gUnknown_80F9530: @ 80F9530
.incbin "baserom.gba", 0xF9530, 0x1C
.incbin "baserom.gba", 0xF9530, 0x4
.global gFrozenMessage
gFrozenMessage: @ 80F954C
.incbin "baserom.gba", 0xF954C, 0x20
gFrozenMessage: @ 80F9534
.string "{ARG_POKEMON_0} is frozen solid!\0"
.align 2, 0
.global gPtrFrozenMessage
gPtrFrozenMessage: @ 80F954C
.4byte gFrozenMessage
.global gWrappedAroundMessage
gWrappedAroundMessage: @ 80F956C
.incbin "baserom.gba", 0xF956C, 0x20
gWrappedAroundMessage: @ 80F9550
.string "{ARG_POKEMON_0} has its foe wrapped!\0"
.align 2, 0
.global gPtrWrappedAroundMessage
gPtrWrappedAroundMessage: @ 80F956C
.4byte gWrappedAroundMessage
.global gWrappedByMessage
gWrappedByMessage: @ 80F958C
.incbin "baserom.gba", 0xF958C, 0x18
gWrappedByMessage: @ 80F9570
.string "{ARG_POKEMON_0} is wrapped by its foe!\0"
.align 2, 0
.global gPtrWrappedByMessage
gPtrWrappedByMessage: @ 80F958C
.4byte gWrappedByMessage
.global gPausedMessage
gPausedMessage: @ 80F95A4
.incbin "baserom.gba", 0xF95A4, 0x18
gPausedMessage: @ 80F9590
.string "{ARG_POKEMON_0} can{APOSTROPHE}t move!\0"
.align 2, 0
.global gPtrPausedMessage
gPtrPausedMessage: @ 80F95A4
.4byte gPausedMessage
.global gInfatuatedMessage
gInfatuatedMessage: @ 80F95BC
.incbin "baserom.gba", 0xF95BC, 0x1C
gInfatuatedMessage: @ 80F95A8
.string "{ARG_POKEMON_0} is infatuated!\0"
.align 2, 0
.global gPtrInfatuatedMessage
gPtrInfatuatedMessage: @ 80F95BC
.4byte gInfatuatedMessage
.global gBideMessage
gBideMessage: @ 80F95D8
.incbin "baserom.gba", 0xF95D8, 0x14
gBideMessage: @ 80F95C0
.string "{ARG_POKEMON_0} is storing energy!\0"
.align 2, 0
.global gPtrBideMessage
gPtrBideMessage: @ 80F95D8
.4byte gBideMessage
.global gUnknown_80F95DC
gUnknown_80F95DC: @ 80F95DC
.incbin "baserom.gba", 0xF95DC, 0x10
.global gUnknown_80F95EC
gUnknown_80F95EC: @ 80F95EC

File diff suppressed because it is too large Load Diff

3425
data/data_8115EB8.s Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

8
include/code_80521D0.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef GUARD_CODE_80521D0_H
#define GUARD_CODE_80521D0_H
#include "dungeon_entity.h"
void SendMessage(struct DungeonEntity *pokemon, const char message[]);
#endif

View File

@@ -5,5 +5,7 @@
// 0x44C94
void SetAction(struct DungeonActionContainer *actionPointer, u16 action);
// 0x44CA0
void SetWalkAction(struct DungeonActionContainer *actionPointer, s16 species);
#endif

View File

@@ -6,10 +6,12 @@
#include "item.h"
#include "position.h"
#define NUM_SPEED_TURN_COUNTERS 5
struct DungeonActionContainer
{
/* 0x0 */ u16 action;
/* 0x2 */ s8 facingDir;
/* 0x2 */ u8 facingDir;
u8 fill3;
// Additional parameter alongside actionIndex. Used for things like indicating which move a Pokémon should use from its moveset.
/* 0x4 */ u8 actionUseIndex;
@@ -167,8 +169,8 @@ struct DungeonEntityData
/* 0x104 */ s32 movementSpeed;
// The turn counter for movement speed up/down is split into five timers each. Multiple timers are used if the Pokémon is affected by multiple
// speed-up/slow effects at once, like using Agility twice.
/* 0x108 */ u8 speedUpTurnsLeft[5];
/* 0x10D */ u8 slowTurnsLeft[5];
/* 0x108 */ u8 speedUpTurnsLeft[NUM_SPEED_TURN_COUNTERS];
/* 0x10D */ u8 slowTurnsLeft[NUM_SPEED_TURN_COUNTERS];
/* 0x112 */ u8 stockpileCount;
u8 fill113;
// When true, an AI Pokémon will move in a random direction every turn.

9
include/position_util.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GUARD_POSITION_UTIL_H
#define GUARD_POSITION_UTIL_H
#include "position.h"
// 0x983D8
s32 CalculateFacingDir(struct Position *originPos, struct Position *targetPos);
#endif

9
include/status_checks.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GUARD_STATUS_CHECKS_H
#define GUARD_STATUS_CHECKS_H
#include "dungeon_entity.h"
// 0x7001C
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon);
#endif

11
include/status_checks_1.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef GUARD_STATUS_CHECKS_1_H
#define GUARD_STATUS_CHECKS_1_H
#include "dungeon_entity.h"
// 0x70A58
bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
// 0x70B28
bool8 IsSleeping(struct DungeonEntity *pokemon);
#endif

View File

@@ -187,7 +187,7 @@ SECTIONS {
src/code_80428A0.o(.text);
asm/code_80428A0.o(.text);
src/dungeon_action.o(.text);
asm/code_804ACA0.o(.text);
asm/code_8044CC8.o(.text);
src/dungeon_util.o(.text);
asm/code_80450F8.o(.text);
src/dungeon_visibility.o(.text);
@@ -207,7 +207,10 @@ SECTIONS {
asm/code_8057824.o(.text);
src/code_806CD90.o(.text);
asm/code_806CD90.o(.text);
asm/code_807001C.o(.text);
src/status_checks.o(.text);
asm/code_80701A4.o(.text);
src/status_checks_1.o(.text);
asm/code_8070B48.o(.text);
src/dungeon_capabilities.o(.text);
asm/code_8070BC0.o(.text);
src/dungeon_capabilities_1.o(.text);
@@ -282,7 +285,7 @@ SECTIONS {
src/exclusive_pokemon.o(.text);
asm/exclusive_pokemon.o(.text);
src/exclusive_pokemon_1.o(.text);
src/code_80983D8.o(.text);
src/position_util.o(.text);
asm/code_8098468.o(.text);
src/code_8098BDC.o(.text);
asm/code_8098BDC.o(.text);
@@ -405,6 +408,8 @@ SECTIONS {
src/rescue_team_info.o(.rodata);
src/text_util.o(.rodata);
data/data_810AE24.o(.rodata);
src/position_util.o(.rodata);
data/data_8115EB8.o(.rodata);
data/friend_area_dialogue.o(.rodata);
data/cutscenes.o(.rodata);
data/cutscenes_1.o(.rodata);

View File

@@ -1,7 +1,10 @@
#include "global.h"
#include "play_time.h"
#include "file_system.h"
#include "code_80521D0.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "file_system.h"
#include "play_time.h"
extern s32 gUnknown_80F6568[];
extern u8 gUnknown_202EE01;
@@ -20,14 +23,13 @@ extern void sub_8011860(void);
extern void sub_803F580(u32);
extern void sub_8049ED4();
extern void sub_8040A84();
extern void SendMessage(u32, const char *);
extern const char *gUnknown_80FD040; // It became brighter on the floor
extern struct MapTile *GetMapEntity(u32, u32);
// Luminous Orb???
void HandleLuminousOrbAction(u32 param_1)
void HandleLuminousOrbAction(struct DungeonEntity *param_1)
{
struct MapTile *mapTile;
int XCoord;

View File

@@ -1,9 +1,9 @@
#include "global.h"
#include "dungeon_entity.h"
#include "code_80521D0.h"
extern void sub_80526D0(u8 r0);
extern u8 sub_8045888(struct DungeonEntity *r0);
extern void sub_80523A8(struct DungeonEntity *r0, u32 r1, u8 r2);
extern void sub_80523A8(struct DungeonEntity *r0, const char r1[], u8 r2);
extern u8 sub_8052DC0(struct DungeonEntity *);
extern u8 sub_803F428(u32);
@@ -12,26 +12,26 @@ void sub_805229C(void)
return sub_80526D0(0x50);
}
void SendMessage(struct DungeonEntity *r0, u32 r1)
void SendMessage(struct DungeonEntity *pokemon, const char message[])
{
if (sub_8045888(r0) != 0){
sub_80523A8(r0, r1, 1);
if (sub_8045888(pokemon) != 0){
sub_80523A8(pokemon, message, 1);
}
}
void sub_80522C8(struct DungeonEntity *r0, u32 r1)
void sub_80522C8(struct DungeonEntity *r0, const char r1[])
{
if (sub_8045888(r0) != 0){
sub_80523A8(r0, r1, 0);
}
}
void sub_80522E8(struct DungeonEntity *r0, u32 r1)
void sub_80522E8(struct DungeonEntity *r0, const char r1[])
{
sub_80523A8(r0, r1, 0);
}
void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2)
void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, const char r2[])
{
u8 temp;
u32 temp_reg;
@@ -49,7 +49,7 @@ void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2)
}
}
void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2)
void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, const char r2[])
{
u8 temp;
u32 temp_reg;
@@ -67,7 +67,7 @@ void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2)
}
}
void sub_8052364(struct DungeonEntity *r0, u32 r1, u32 r2)
void sub_8052364(struct DungeonEntity *r0, u32 r1, const char r2[])
{
u8 temp;
u32 temp_reg;
@@ -85,7 +85,7 @@ void sub_8052364(struct DungeonEntity *r0, u32 r1, u32 r2)
}
}
void sub_805239C(struct DungeonEntity *r0, u32 r1)
void sub_805239C(struct DungeonEntity *r0, const char r1[])
{
sub_80523A8(r0, r1, 1);
}

View File

@@ -1,52 +0,0 @@
#include "global.h"
extern u32 gUnknown_8115E94[5][3]; // NOTE: Factor of two difference in array sizes
s32 CalculateFacingDir(short *param_1,short *param_2)
{
s32 uVar1;
s32 uVar2;
s32 uVar3;
uVar3 = param_2[0] - param_1[0];
uVar2 = param_2[1] - param_1[1];
if ((uVar3 == 0) && (uVar2 == 0)) {
uVar1 = 0;
}
else {
if (0 < uVar3) {
uVar3 = 1;
}
if (0 < uVar2) {
uVar2 = 1;
}
if (-1 >= uVar3) {
uVar3 = -1;
}
if (-1 >= uVar2) {
uVar2 = -1;
}
uVar1 = gUnknown_8115E94[(uVar2 + 1)][(uVar3 + 1)];
}
return uVar1;
}
s32 GetMaxPositionDifference(short param_1[],short param_2[])
{
s32 diff_index1;
s32 diff_index0;
diff_index0 = param_1[0] - param_2[0];
if (diff_index0 < 0) {
diff_index0 = -diff_index0;
}
diff_index1 = param_1[1] - param_2[1];
if (diff_index1 < 0) {
diff_index1 = -diff_index1;
}
if (diff_index1 < diff_index0) {
diff_index1 = diff_index0;
}
return diff_index1;
}

View File

@@ -1,6 +1,9 @@
#include "global.h"
#include "dungeon_action.h"
#include "constants/dungeon_action.h"
#include "dungeon_entity.h"
#include "pokemon.h"
void SetAction(struct DungeonActionContainer *actionPointer, u16 action)
{
@@ -8,3 +11,17 @@ void SetAction(struct DungeonActionContainer *actionPointer, u16 action)
actionPointer->actionUseIndex = 0;
actionPointer->unkC = 0;
}
void SetWalkAction(struct DungeonActionContainer *actionPointer, s16 species)
{
if (GetIsMoving(species))
{
actionPointer->action = DUNGEON_ACTION_WALK;
}
else
{
actionPointer->action = DUNGEON_ACTION_WAIT;
}
actionPointer->actionUseIndex = 0;
actionPointer->unkC = 0;
}

View File

@@ -9,8 +9,7 @@
#include "dungeon_util.h"
#include "moves.h"
#include "number_util.h"
extern bool8 HasNegativeStatus(struct DungeonEntity*);
#include "status_checks_1.h"
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags)
{
@@ -96,7 +95,7 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32
}
}
}
if (itemWeight > 98)
if (itemWeight >= 99)
{
itemWeight = 99;
}

View File

@@ -22,6 +22,7 @@
#include "dungeon_visibility.h"
#include "item.h"
#include "position.h"
#include "position_util.h"
#include "team_inventory.h"
#define NUM_POTENTIAL_ROCK_TARGETS 20
@@ -35,7 +36,6 @@ enum ItemTargetFlag
ITEM_TARGET_ALLY = 1 << 1
};
extern s32 CalculateFacingDir(struct Position*, struct Position*);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
extern s32 gNumPotentialTargets;

View File

@@ -6,6 +6,8 @@
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "constants/targeting.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
@@ -16,6 +18,7 @@
#include "dungeon_visibility.h"
#include "map.h"
#include "pokemon.h"
#include "status_checks.h"
extern char gAvailablePokemonNames[];
extern char *gPtrCouldntBeUsedMessage;
@@ -23,10 +26,7 @@ extern char *gPtrItsaMonsterHouseMessage;
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void SendMessage(struct DungeonEntity*, char*);
extern bool8 HasStatusAffectingActions(struct DungeonEntity*);
extern void ResetAction(u16*);
extern void SetWalkAction(u16*, s16);
extern void DecideAttack(struct DungeonEntity*);
extern void MoveIfPossible(struct DungeonEntity*, bool8);
extern u8 sub_8044B28(void);
@@ -155,7 +155,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
void DecideAction(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if ((pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED) != 0)
if (pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)
{
if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
{
@@ -209,8 +209,8 @@ void DecideAction(struct DungeonEntity *pokemon)
ResetAction(&pokemonData->action.action);
if (pokemonData->clientType == CLIENT_TYPE_CLIENT)
{
SetWalkAction(&pokemonData->action.action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(8);
SetWalkAction(&pokemonData->action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->targetPosition.x = pokemon->posWorld.x;
pokemonData->targetPosition.y = pokemon->posWorld.y - 1;
}
@@ -228,7 +228,7 @@ void DecideAction(struct DungeonEntity *pokemon)
}
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action.action, pokemonData->entityID);
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{
@@ -243,7 +243,7 @@ void DecideAction(struct DungeonEntity *pokemon)
{
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action.action, pokemonData->entityID);
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{

View File

@@ -208,7 +208,7 @@ void sub_8026C14(void)
struct unkStruct_8090F58 temp;
int menuAction;
struct ItemSlot slot;
menuAction = 0;
sub_801A6E8(0);
if ((sub_8012FD8(&gUnknown_203B2B8->unkCC) == '\0') && (sub_8013114(&gUnknown_203B2B8->unkCC,&menuAction), menuAction != 1)) {

65
src/position_util.c Normal file
View File

@@ -0,0 +1,65 @@
#include "global.h"
#include "position_util.h"
#include "constants/direction.h"
const s32 gFacingDirMapping[3][3] = {
{DIRECTION_NORTHWEST, DIRECTION_NORTH, DIRECTION_NORTHEAST},
{DIRECTION_WEST, DIRECTION_SOUTH, DIRECTION_EAST},
{DIRECTION_SOUTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST}
};
s32 CalculateFacingDir(struct Position *originPos, struct Position *targetPos)
{
s32 facingDir;
s32 yDiff;
s32 xDiff;
xDiff = targetPos->x - originPos->x;
yDiff = targetPos->y - originPos->y;
if (xDiff == 0 && yDiff == 0)
{
facingDir = DIRECTION_SOUTH;
}
else
{
if (xDiff > 0)
{
xDiff = 1;
}
if (yDiff > 0)
{
yDiff = 1;
}
if (xDiff <= -1)
{
xDiff = -1;
}
if (yDiff <= -1)
{
yDiff = -1;
}
facingDir = gFacingDirMapping[yDiff + 1][xDiff + 1];
}
return facingDir;
}
s32 GetMaxPositionDifference(short param_1[],short param_2[])
{
s32 diff_index1;
s32 diff_index0;
diff_index0 = param_1[0] - param_2[0];
if (diff_index0 < 0) {
diff_index0 = -diff_index0;
}
diff_index1 = param_1[1] - param_2[1];
if (diff_index1 < 0) {
diff_index1 = -diff_index1;
}
if (diff_index1 < diff_index0) {
diff_index1 = diff_index0;
}
return diff_index1;
}

102
src/status_checks.c Normal file
View File

@@ -0,0 +1,102 @@
#include "global.h"
#include "status_checks.h"
#include "constants/direction.h"
#include "constants/dungeon_action.h"
#include "constants/status.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
#include "dungeon_random.h"
extern char *gPtrFrozenMessage;
extern char *gPtrWrappedAroundMessage;
extern char *gPtrWrappedByMessage;
extern char *gPtrBideMessage;
extern char *gPtrPausedMessage;
extern char *gPtrInfatuatedMessage;
extern char gAvailablePokemonNames[];
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern bool8 CanMoveForward2(struct DungeonEntity*, u8);
extern void DecideAttack(struct DungeonEntity*);
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
SetAction(&pokemonData->action, DUNGEON_ACTION_WAIT);
switch (pokemonData->sleepStatus)
{
case SLEEP_STATUS_NIGHTMARE:
case SLEEP_STATUS_SLEEP:
case SLEEP_STATUS_NAPPING:
return TRUE;
}
switch (pokemonData->immobilizeStatus)
{
case IMMOBILIZE_STATUS_FROZEN:
SendMessage(pokemon, gPtrFrozenMessage);
return TRUE;
case IMMOBILIZE_STATUS_WRAPPED_AROUND_FOE:
SendMessage(pokemon, gPtrWrappedAroundMessage);
return TRUE;
case IMMOBILIZE_STATUS_WRAPPED_BY_FOE:
SendMessage(pokemon, gPtrWrappedByMessage);
return TRUE;
case IMMOBILIZE_STATUS_PETRIFIED:
return TRUE;
}
switch (pokemonData->volatileStatus)
{
case VOLATILE_STATUS_PAUSED:
SendMessage(pokemon, gPtrPausedMessage);
return TRUE;
case VOLATILE_STATUS_INFATUATED:
SendMessage(pokemon, gPtrInfatuatedMessage);
return TRUE;
}
if (pokemonData->chargingStatus == CHARGING_STATUS_BIDE)
{
SendMessage(pokemon, gPtrBideMessage);
return TRUE;
}
if (pokemonData->waitingStatus == WAITING_STATUS_DECOY)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->targetPosition.x = pokemon->posWorld.x;
pokemonData->targetPosition.y = pokemon->posWorld.y - 1;
return TRUE;
}
if (pokemonData->shopkeeperMode == SHOPKEEPER_FRIENDLY)
{
return TRUE;
}
if (pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
{
if (!CanMoveForward2(pokemon, pokemonData->action.facingDir))
{
if (DungeonRandomCapped(2) != 0)
{
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->action.facingDir = pokemonData->action.facingDir & DIRECTION_MASK;
goto walk;
}
}
else
{
walk:
SetWalkAction(&pokemonData->action, pokemonData->entityID);
return TRUE;
}
DecideAttack(pokemon);
return TRUE;
}
if (pokemonData->eyesightStatus == EYESIGHT_STATUS_CROSS_EYED)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
return TRUE;
}
return FALSE;
}

55
src/status_checks_1.c Normal file
View File

@@ -0,0 +1,55 @@
#include "global.h"
#include "status_checks_1.h"
#include "constants/status.h"
bool8 HasNegativeStatus(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
s32 i;
if (pokemonData->sleepStatus == SLEEP_STATUS_SLEEP ||
pokemonData->sleepStatus == SLEEP_STATUS_NIGHTMARE ||
pokemonData->sleepStatus == SLEEP_STATUS_YAWNING ||
pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_NONE ||
(pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_INGRAIN && pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_NONE) ||
pokemonData->volatileStatus != VOLATILE_STATUS_NONE ||
pokemonData->waitingStatus == WAITING_STATUS_CURSED ||
pokemonData->waitingStatus == WAITING_STATUS_DECOY ||
pokemonData->linkedStatus == LINKED_STATUS_LEECH_SEED ||
pokemonData->moveStatus == MOVE_STATUS_WHIFFER ||
pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER ||
pokemonData->eyesightStatus == EYESIGHT_STATUS_CROSS_EYED ||
pokemonData->muzzledStatus == MUZZLED_STATUS_MUZZLED ||
pokemonData->exposedStatus ||
pokemonData->perishSongTimer != 0)
{
return TRUE;
}
for (i = 0; i < MAX_MON_MOVES; i++)
{
struct PokemonMove *moves = pokemonData->moves;
if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE)
{
return TRUE;
}
}
for (i = 0; i < NUM_SPEED_TURN_COUNTERS; i++)
{
if (pokemonData->slowTurnsLeft[i] != 0)
{
return TRUE;
}
}
return FALSE;
}
bool8 IsSleeping(struct DungeonEntity *pokemon)
{
if (pokemon->entityData->sleepStatus != SLEEP_STATUS_SLEEP &&
pokemon->entityData->sleepStatus != SLEEP_STATUS_NAPPING &&
pokemon->entityData->sleepStatus != SLEEP_STATUS_NIGHTMARE)
{
return FALSE;
}
return TRUE;
}