diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-03-09 21:50:15 -0500 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-03-10 22:33:13 -0500 |
commit | 951b01114ab85800db8ed7f4a1034e2bd303e712 (patch) | |
tree | 6c0d8f50f2aca798c32fd3c344a7ea70183c30a9 /src/move_util.c | |
parent | 26a7012be18beee7bea538c48452efac595eac15 (diff) |
Decomped IsMoveIndexUsable
Diffstat (limited to 'src/move_util.c')
-rw-r--r-- | src/move_util.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/move_util.c b/src/move_util.c new file mode 100644 index 0000000..c5c87ad --- /dev/null +++ b/src/move_util.c @@ -0,0 +1,47 @@ +#include "global.h" +#include "move_util.h" + +extern bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker); + +bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasPPChecker) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + struct PokemonMove *move = &pokemonData->moves[moveIndex]; + s32 i; + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) + { + return FALSE; + } + if (move->moveFlags & MOVE_FLAG_LINKED) + { + return FALSE; + } + if (move->moveFlags & MOVE_FLAG_DISABLED || + move->moveFlags2 & MOVE_FLAG_SEALED) + { + return FALSE; + } + goto initMoveIndex; + returnTrue: + return TRUE; + initMoveIndex: + i = 0; + goto checkMoveUsable; + incMoveIndex: + i++; + checkMoveUsable: + if (i >= MAX_MON_MOVES) + { + return FALSE; + } + if (IsMoveUsable(pokemon, move, hasPPChecker)) + { + goto returnTrue; + } + move++; + if ((u32) move >= (u32) &pokemonData->struggleMoveFlags || !(move->moveFlags & MOVE_FLAG_LINKED)) + { + return FALSE; + } + goto incMoveIndex; +} |