summaryrefslogtreecommitdiff
path: root/src/dungeon_capabilities_1.c
diff options
context:
space:
mode:
authorCheng Hann Gan <chenghanngan.us@gmail.com>2021-10-28 12:01:07 -0400
committerGitHub <noreply@github.com>2021-10-28 09:01:07 -0700
commitdd128d78c6da20395edcbe8dab8a224aa6679146 (patch)
treedeec8715283a26754ec64e7dabdeca25faf7e361 /src/dungeon_capabilities_1.c
parentc98fb2c11272680a20b9cfb9efe2ce482d3779dd (diff)
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()
Diffstat (limited to 'src/dungeon_capabilities_1.c')
-rw-r--r--src/dungeon_capabilities_1.c56
1 files changed, 56 insertions, 0 deletions
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;
+}