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_ai.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/dungeon_ai.c (limited to 'src/dungeon_ai.c') diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c new file mode 100644 index 0000000..6253a64 --- /dev/null +++ b/src/dungeon_ai.c @@ -0,0 +1,42 @@ +#include "global.h" +#include "dungeon_ai.h" + +#include "constants/ability.h" +#include "constants/tactic.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_pokemon_attributes_1.h" +#include "dungeon_util.h" + +bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon) +{ + if (!EntityExists(pokemon)) + { + return FALSE; + } + else + { + struct DungeonEntityData *pokemonData = pokemon->entityData; + if (pokemonData->terrifiedTurnsLeft != 0) + { + return TRUE; + } + if (pokemonData->isLeader) + { + return FALSE; + } + if (HasAbility(pokemon, ABILITY_RUN_AWAY)) + { + bool8 runAwayActive = pokemonData->HP < pokemonData->maxHP / 2; + if (runAwayActive) + { + return TRUE; + } + } + if (HasTactic(pokemon, TACTIC_GET_AWAY) + || (HasTactic(pokemon, TACTIC_AVOID_TROUBLE) && pokemonData->HP <= pokemonData->maxHP / 2)) + { + return TRUE; + } + return FALSE; + } +} -- cgit v1.2.3