summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-03-09 22:19:20 -0500
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-03-10 22:33:13 -0500
commit458001dbbdb9c11a129cfe4286b536cfefc349f0 (patch)
tree4a071af20f73201e9f3e25afc8713c10dc9b8e6e /src
parent951b01114ab85800db8ed7f4a1034e2bd303e712 (diff)
Decomped IsMoveUsable()
Diffstat (limited to 'src')
-rw-r--r--src/move_util.c43
-rw-r--r--src/moves.c6
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;
}