diff options
Diffstat (limited to 'src/move_util.c')
-rw-r--r-- | src/move_util.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/move_util.c b/src/move_util.c index c5c87ad..4487862 100644 --- a/src/move_util.c +++ b/src/move_util.c @@ -1,7 +1,9 @@ #include "global.h" #include "move_util.h" -extern bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker); +#include "constants/move_id.h" +#include "constants/status.h" +#include "moves.h" bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasPPChecker) { @@ -45,3 +47,42 @@ bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasP } goto incMoveIndex; } + +bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + if (move->moveID == MOVE_REGULAR_ATTACK) + { + return TRUE; + } + if (move->moveFlags & MOVE_FLAG_DISABLED || move->moveFlags2 & MOVE_FLAG_SEALED) + { + return FALSE; + } + if (hasPPChecker) + { + if (move->PP == 0) + { + return FALSE; + } + if (pokemonData->volatileStatus == VOLATILE_STATUS_TAUNTED && !MoveDealsDirectDamage(move)) + { + return FALSE; + } + if (pokemonData->volatileStatus == VOLATILE_STATUS_ENCORE) + { + if (move->moveID == MOVE_STRUGGLE) + { + if (!(pokemonData->struggleMoveFlags & MOVE_FLAG_LAST_USED)) + { + return FALSE; + } + } + else if (!(move->moveFlags & MOVE_FLAG_LAST_USED)) + { + return FALSE; + } + } + } + return TRUE; +} |