From cbf41c6bf31e16fa0ec0b60fc067429e387b5943 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Fri, 7 Jan 2022 23:32:32 -0600 Subject: Decomped HasNegativeStatus() --- src/status_checks.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/status_checks.c (limited to 'src/status_checks.c') diff --git a/src/status_checks.c b/src/status_checks.c new file mode 100644 index 0000000..346afb5 --- /dev/null +++ b/src/status_checks.c @@ -0,0 +1,44 @@ +#include "global.h" +#include "status_checks.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; +} -- cgit v1.2.3 From 453618864e685eacae640dc2b317a645422264e2 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 13 Jan 2022 22:56:30 -0500 Subject: Decomped HasStatusAffectingActions() --- src/status_checks.c | 109 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 25 deletions(-) (limited to 'src/status_checks.c') 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; } -- cgit v1.2.3 From afbc7deaea1d66d39331bc078d3f2e22cbdec0a3 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 13 Jan 2022 23:18:59 -0500 Subject: Decomped SetWalkAction() --- src/status_checks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/status_checks.c') diff --git a/src/status_checks.c b/src/status_checks.c index 5abb0fe..ed39e99 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -14,10 +14,9 @@ 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*); -- cgit v1.2.3