diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/move_util.c | 43 | ||||
-rw-r--r-- | src/moves.c | 6 |
2 files changed, 45 insertions, 4 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; +} diff --git a/src/moves.c b/src/moves.c index 8a2606f..bd5ccfa 100644 --- a/src/moves.c +++ b/src/moves.c @@ -297,17 +297,17 @@ u8 *GetMoveUseText(u16 moveID) return gMovesData[moveID].useText; } -u8 GetMoveAffectedByMagicCoat(u16 moveID) +bool8 GetMoveAffectedByMagicCoat(u16 moveID) { return gMovesData[moveID].affectedByMagicCoat; } -u8 GetMoveTargetsUser(u16 moveID) +bool8 GetMoveTargetsUser(u16 moveID) { return gMovesData[moveID].targetsUser; } -u8 GetMoveAffectedByMuzzled(u16 moveID) +bool8 GetMoveAffectedByMuzzled(u16 moveID) { return gMovesData[moveID].affectedByMuzzled; } |