From dd128d78c6da20395edcbe8dab8a224aa6679146 Mon Sep 17 00:00:00 2001 From: Cheng Hann Gan Date: Thu, 28 Oct 2021 12:01:07 -0400 Subject: Decomped more dungeon AI (#67) * Decomped IsMovingClient() * Fixed typos in boss dialogue * Fixed spelling of Pelipper * Decomped CannotUseItems * Decomped ShouldAvoidEnemies() * Decomped HasAbility() * Decomped HasTactic() * Decomped CannotMove * Decomped CannotAct() and IsCharging() --- src/dungeon_capabilities_1.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/dungeon_capabilities_1.c (limited to 'src/dungeon_capabilities_1.c') diff --git a/src/dungeon_capabilities_1.c b/src/dungeon_capabilities_1.c new file mode 100644 index 0000000..956c6e1 --- /dev/null +++ b/src/dungeon_capabilities_1.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "dungeon_capabilities_1.h" + +#include "constants/dungeon.h" +#include "constants/status.h" +#include "charge_move.h" +#include "dungeon_ai.h" +#include "dungeon_capabilities.h" + +static inline bool8 JoinLocationCannotUseItems(struct DungeonEntityData *pokemonData) +{ + if (pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + { + return TRUE; + } + if (pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE) + { + return TRUE; + } + return FALSE; +} + +bool8 CannotUseItems(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + if (pokemonData->clientType == CLIENT_TYPE_CLIENT + || JoinLocationCannotUseItems(pokemonData) + || (!pokemonData->isLeader && ShouldAvoidEnemies(pokemon)) + || CannotMove(pokemon, FALSE) + || CannotAct(pokemon)) + { + return TRUE; + } + if (IsCharging(pokemon, FALSE)) + { + return TRUE; + } + return FALSE; +} + +bool8 CannotAct(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + if ((pokemonData->sleepStatus != SLEEP_STATUS_SLEEPLESS + && pokemonData->sleepStatus != SLEEP_STATUS_NONE) + || pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_FROZEN + || pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED) + { + return TRUE; + } + if (pokemonData->chargingStatus == CHARGING_STATUS_BIDE) + { + return TRUE; + } + return FALSE; +} -- cgit v1.2.3