summaryrefslogtreecommitdiff
path: root/src/status_checks.c
diff options
context:
space:
mode:
authorSeth Barberee <seth.barberee@gmail.com>2022-01-20 15:26:19 -0800
committerGitHub <noreply@github.com>2022-01-20 15:26:19 -0800
commit408fe77d7b9440d7eb5d46eda5f920572d516d67 (patch)
tree38953616b74da130bd832635bed1c605d4b0e322 /src/status_checks.c
parent3cdde2a92a187d437dc7d24273177b59ab5b9511 (diff)
parentc5cd6e137fbad180a21ec24a50fde76633db0c20 (diff)
Merge pull request #93 from AnonymousRandomPerson/master
More AI decomp
Diffstat (limited to 'src/status_checks.c')
-rw-r--r--src/status_checks.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/status_checks.c b/src/status_checks.c
new file mode 100644
index 0000000..ed39e99
--- /dev/null
+++ b/src/status_checks.c
@@ -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;
+}