summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-01-13 22:56:30 -0500
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-01-13 22:56:30 -0500
commit453618864e685eacae640dc2b317a645422264e2 (patch)
tree3391b31f2c6a9a5985931ffc44328f573a3279b0
parent52e7368f30bb1a80a470bb1492b816dd6c8e97f7 (diff)
Decomped HasStatusAffectingActions()
-rw-r--r--asm/code_8057824.s4
-rw-r--r--asm/code_80701A4.s (renamed from asm/code_807001C.s)219
-rw-r--r--asm/code_8070D04.s6
-rw-r--r--asm/code_80718D8.s2
-rw-r--r--data/data_80F59C8.s60
-rw-r--r--include/code_80521D0.h8
-rw-r--r--include/dungeon_entity.h2
-rw-r--r--include/status_checks.h4
-rw-r--r--include/status_checks_1.h9
-rwxr-xr-xld_script.txt3
-rw-r--r--src/code_8040094.c10
-rw-r--r--src/code_80521D0.c22
-rw-r--r--src/dungeon_ai_item_weight.c2
-rw-r--r--src/dungeon_movement.c8
-rw-r--r--src/friend_list_menu.c2
-rw-r--r--src/status_checks.c109
-rw-r--r--src/status_checks_1.c44
17 files changed, 235 insertions, 279 deletions
diff --git a/asm/code_8057824.s b/asm/code_8057824.s
index a456d99..84d3407 100644
--- a/asm/code_8057824.s
+++ b/asm/code_8057824.s
@@ -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
diff --git a/asm/code_807001C.s b/asm/code_80701A4.s
index a9c4a93..d8549f9 100644
--- a/asm/code_807001C.s
+++ b/asm/code_80701A4.s
@@ -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
diff --git a/asm/code_8070D04.s b/asm/code_8070D04.s
index 7a511ab..ce9f343 100644
--- a/asm/code_8070D04.s
+++ b/asm/code_8070D04.s
@@ -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:
diff --git a/asm/code_80718D8.s b/asm/code_80718D8.s
index caa62de..4ee7f09 100644
--- a/asm/code_80718D8.s
+++ b/asm/code_80718D8.s
@@ -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
diff --git a/data/data_80F59C8.s b/data/data_80F59C8.s
index ce1abc5..7440857 100644
--- a/data/data_80F59C8.s
+++ b/data/data_80F59C8.s
@@ -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
diff --git a/include/code_80521D0.h b/include/code_80521D0.h
new file mode 100644
index 0000000..588ad9b
--- /dev/null
+++ b/include/code_80521D0.h
@@ -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
diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h
index 7e562fc..9e9f1f7 100644
--- a/include/dungeon_entity.h
+++ b/include/dungeon_entity.h
@@ -11,7 +11,7 @@
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;
diff --git a/include/status_checks.h b/include/status_checks.h
index e899f74..086711d 100644
--- a/include/status_checks.h
+++ b/include/status_checks.h
@@ -3,7 +3,7 @@
#include "dungeon_entity.h"
-// 0x70A58
-bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
+// 0x7001C
+bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon);
#endif
diff --git a/include/status_checks_1.h b/include/status_checks_1.h
new file mode 100644
index 0000000..770767a
--- /dev/null
+++ b/include/status_checks_1.h
@@ -0,0 +1,9 @@
+#ifndef GUARD_STATUS_CHECKS_1_H
+#define GUARD_STATUS_CHECKS_1_H
+
+#include "dungeon_entity.h"
+
+// 0x70A58
+bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
+
+#endif
diff --git a/ld_script.txt b/ld_script.txt
index 2208bd0..80f8a64 100755
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -207,8 +207,9 @@ 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_8070B28.o(.text);
src/dungeon_capabilities.o(.text);
asm/code_8070BC0.o(.text);
diff --git a/src/code_8040094.c b/src/code_8040094.c
index c834602..c0e7eac 100644
--- a/src/code_8040094.c
+++ b/src/code_8040094.c
@@ -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;
diff --git a/src/code_80521D0.c b/src/code_80521D0.c
index 272991d..4867acf 100644
--- a/src/code_80521D0.c
+++ b/src/code_80521D0.c
@@ -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);
}
diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c
index 34e3440..6c9669b 100644
--- a/src/dungeon_ai_item_weight.c
+++ b/src/dungeon_ai_item_weight.c
@@ -9,7 +9,7 @@
#include "dungeon_util.h"
#include "moves.h"
#include "number_util.h"
-#include "status_checks.h"
+#include "status_checks_1.h"
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags)
{
diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c
index bcf6163..3df74ee 100644
--- a/src/dungeon_movement.c
+++ b/src/dungeon_movement.c
@@ -6,6 +6,7 @@
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "constants/targeting.h"
+#include "code_80521D0.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
@@ -16,6 +17,7 @@
#include "dungeon_visibility.h"
#include "map.h"
#include "pokemon.h"
+#include "status_checks.h"
extern char gAvailablePokemonNames[];
extern char *gPtrCouldntBeUsedMessage;
@@ -23,8 +25,6 @@ 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*);
@@ -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)
{
@@ -210,7 +210,7 @@ void DecideAction(struct DungeonEntity *pokemon)
if (pokemonData->clientType == CLIENT_TYPE_CLIENT)
{
SetWalkAction(&pokemonData->action.action, pokemonData->entityID);
- pokemonData->action.facingDir = DungeonRandomCapped(8);
+ pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->targetPosition.x = pokemon->posWorld.x;
pokemonData->targetPosition.y = pokemon->posWorld.y - 1;
}
diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c
index 7dbc441..50b8c02 100644
--- a/src/friend_list_menu.c
+++ b/src/friend_list_menu.c
@@ -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)) {
diff --git a/src/status_checks.c b/src/status_checks.c
index 346afb5..5abb0fe 100644
--- a/src/status_checks.c
+++ b/src/status_checks.c
@@ -1,44 +1,103 @@
#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"
-bool8 HasNegativeStatus(struct DungeonEntity *pokemon)
+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 void SetWalkAction(struct DungeonActionContainer*, s16);
+extern bool8 CanMoveForward2(struct DungeonEntity*, u8);
+extern void DecideAttack(struct DungeonEntity*);
+
+bool8 HasStatusAffectingActions(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)
+ SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
+ SetAction(&pokemonData->action, DUNGEON_ACTION_WAIT);
+ switch (pokemonData->sleepStatus)
{
- return TRUE;
+ case SLEEP_STATUS_NIGHTMARE:
+ case SLEEP_STATUS_SLEEP:
+ case SLEEP_STATUS_NAPPING:
+ return TRUE;
}
- for (i = 0; i < MAX_MON_MOVES; i++)
+ switch (pokemonData->immobilizeStatus)
{
- struct PokemonMove *moves = pokemonData->moves;
- if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE)
- {
+ 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;
}
- for (i = 0; i < NUM_SPEED_TURN_COUNTERS; i++)
+ if (pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
{
- if (pokemonData->slowTurnsLeft[i] != 0)
+ 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;
}
diff --git a/src/status_checks_1.c b/src/status_checks_1.c
new file mode 100644
index 0000000..32ed6bf
--- /dev/null
+++ b/src/status_checks_1.c
@@ -0,0 +1,44 @@
+#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;
+}