summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/code_805744C.s (renamed from asm/code_80573CC.s)73
-rw-r--r--include/move_util.h1
-rw-r--r--include/moves.h10
-rwxr-xr-xld_script.txt2
-rw-r--r--src/move_util.c43
-rw-r--r--src/moves.c6
6 files changed, 53 insertions, 82 deletions
diff --git a/asm/code_80573CC.s b/asm/code_805744C.s
index 688181b..4272c44 100644
--- a/asm/code_80573CC.s
+++ b/asm/code_805744C.s
@@ -4,78 +4,7 @@
.syntax unified
.text
-
- thumb_func_start IsMoveUsable
-IsMoveUsable:
- push {r4-r6,lr}
- adds r4, r1, 0
- lsls r2, 24
- lsrs r2, 24
- ldr r6, [r0, 0x70]
- ldrh r1, [r4, 0x2]
- ldr r0, _08057430
- cmp r1, r0
- beq _08057442
- ldrb r1, [r4]
- movs r0, 0x20
- ands r0, r1
- cmp r0, 0
- bne _0805743E
- ldrb r1, [r4, 0x1]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- bne _0805743E
- cmp r2, 0
- beq _08057442
- ldrb r0, [r4, 0x4]
- cmp r0, 0
- beq _0805743E
- adds r0, r6, 0
- adds r0, 0xBC
- ldrb r1, [r0]
- adds r5, r0, 0
- cmp r1, 0x5
- bne _08057414
- adds r0, r4, 0
- bl MoveDealsDirectDamage
- lsls r0, 24
- cmp r0, 0
- beq _0805743E
-_08057414:
- ldrb r0, [r5]
- cmp r0, 0x6
- bne _08057442
- ldrh r1, [r4, 0x2]
- movs r0, 0xB0
- lsls r0, 1
- cmp r1, r0
- bne _08057434
- movs r1, 0x9C
- lsls r1, 1
- adds r0, r6, r1
- ldrb r1, [r0]
- b _08057436
- .align 2, 0
-_08057430: .4byte 0x00000163
-_08057434:
- ldrb r1, [r4]
-_08057436:
- movs r0, 0x10
- ands r0, r1
- cmp r0, 0
- bne _08057442
-_0805743E:
- movs r0, 0
- b _08057444
-_08057442:
- movs r0, 0x1
-_08057444:
- pop {r4-r6}
- pop {r1}
- bx r1
- thumb_func_end IsMoveUsable
-
+
thumb_func_start sub_805744C
sub_805744C:
push {r4-r6,lr}
diff --git a/include/move_util.h b/include/move_util.h
index d4deda3..2bfc1c6 100644
--- a/include/move_util.h
+++ b/include/move_util.h
@@ -4,5 +4,6 @@
#include "dungeon_entity.h"
bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasPPChecker);
+bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker);
#endif
diff --git a/include/moves.h b/include/moves.h
index b612e69..a811f0b 100644
--- a/include/moves.h
+++ b/include/moves.h
@@ -18,14 +18,14 @@ s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType);
u32 GetMoveMaxPP(struct PokemonMove *move);
u8 GetMoveUnk12(struct PokemonMove *move);
u8 GetMoveCriticalHitChance(struct PokemonMove *move);
-u8 MoveCannotHitFrozen(struct PokemonMove *move);
-u8 MoveDealsDirectDamage(struct PokemonMove *move);
+bool8 MoveCannotHitFrozen(struct PokemonMove *move);
+bool8 MoveDealsDirectDamage(struct PokemonMove *move);
u32 GetMoveRangeType(struct PokemonMove *move);
void sub_8092C84(u8 *buffer, u16 moveID);
u8 *GetMoveUseText(u16 moveID);
-u8 GetMoveAffectedByMagicCoat(u16 moveID);
-u8 GetMoveTargetsUser(u16 moveID);
-u8 GetMoveAffectedByMuzzled(u16 moveID);
+bool8 GetMoveAffectedByMagicCoat(u16 moveID);
+bool8 GetMoveTargetsUser(u16 moveID);
+bool8 GetMoveAffectedByMuzzled(u16 moveID);
bool8 IsBlockedBySoundproof(struct PokemonMove *move);
bool8 DoesMoveCharge(u16 move);
diff --git a/ld_script.txt b/ld_script.txt
index 0457f43..e2cbe38 100755
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -209,7 +209,7 @@ SECTIONS {
src/charge_move.o(.text);
asm/code_8057144.o(.text);
src/move_util.o(.text);
- asm/code_80573CC.o(.text);
+ asm/code_805744C.o(.text);
src/code_8057824.o(.text);
asm/code_8057824.o(.text);
src/status_checker.o(.text);
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;
}