summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-02-05 20:23:01 -0500
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-02-05 20:23:01 -0500
commita9b5977d4ca6c0aeedea966a0165b625a4c2dbab (patch)
treebd0ceaf643aafb41fc5bb4e87936dc7b638ddd31 /src
parentf728e7e90ebd50521dbc32f7f2b2be5858d91477 (diff)
Decomped MoveMatchesChargingStatus
Diffstat (limited to 'src')
-rw-r--r--src/charge_move.c48
-rw-r--r--src/dungeon_ai_attack.c4
2 files changed, 49 insertions, 3 deletions
diff --git a/src/charge_move.c b/src/charge_move.c
index 7fe358c..c0d09fc 100644
--- a/src/charge_move.c
+++ b/src/charge_move.c
@@ -1,9 +1,29 @@
#include "global.h"
#include "charge_move.h"
+#include "constants/move_id.h"
#include "constants/status.h"
#include "dungeon_util.h"
+struct MultiTurnChargeMove
+{
+ u16 moveID;
+ u8 chargingStatus;
+};
+
+const struct MultiTurnChargeMove gMultiTurnChargeMoves[10] = {
+ {MOVE_SOLARBEAM, CHARGING_STATUS_SOLARBEAM},
+ {MOVE_SKY_ATTACK, CHARGING_STATUS_SKY_ATTACK},
+ {MOVE_RAZOR_WIND, CHARGING_STATUS_RAZOR_WIND},
+ {MOVE_FOCUS_PUNCH, CHARGING_STATUS_FOCUS_PUNCH},
+ {MOVE_SKULL_BASH, CHARGING_STATUS_SKULL_BASH},
+ {MOVE_FLY, CHARGING_STATUS_FLY},
+ {MOVE_BOUNCE, CHARGING_STATUS_BOUNCE},
+ {MOVE_DIVE, CHARGING_STATUS_DIVE},
+ {MOVE_DIG, CHARGING_STATUS_DIG},
+ {MOVE_NONE, CHARGING_STATUS_NONE}
+};
+
const u32 gMultiTurnChargingStatuses[10] = {
CHARGING_STATUS_SOLARBEAM,
CHARGING_STATUS_SKY_ATTACK,
@@ -19,6 +39,32 @@ const u32 gMultiTurnChargingStatuses[10] = {
ALIGNED(4) const char chargingStatusFill[] = "pksdir0";
+bool8 MoveMatchesChargingStatus(struct DungeonEntity *pokemon, struct PokemonMove *move)
+{
+ if (!EntityExists(pokemon))
+ {
+ return FALSE;
+ }
+ else
+ {
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ s32 i;
+ for (i = 0; i < 100; i++)
+ {
+ if (gMultiTurnChargeMoves[i].moveID == MOVE_NONE)
+ {
+ return FALSE;
+ }
+ if (move->moveID == gMultiTurnChargeMoves[i].moveID &&
+ pokemonData->chargingStatus == gMultiTurnChargeMoves[i].chargingStatus)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+}
+
bool8 IsCharging(struct DungeonEntity *pokemon, bool8 checkCharge)
{
if (!EntityExists(pokemon))
@@ -53,4 +99,4 @@ bool8 IsCharging(struct DungeonEntity *pokemon, bool8 checkCharge)
}
return FALSE;
}
-}
+} \ No newline at end of file
diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c
index e695422..0c48f24 100644
--- a/src/dungeon_ai_attack.c
+++ b/src/dungeon_ai_attack.c
@@ -8,6 +8,7 @@
#include "constants/status.h"
#include "constants/tactic.h"
#include "constants/type.h"
+#include "charge_move.h"
#include "dungeon_action.h"
#include "dungeon_ai.h"
#include "dungeon_capabilities_1.h"
@@ -29,7 +30,6 @@ struct MoveTargetResults
s32 moveWeight;
};
-extern bool8 IsChargeMove(struct DungeonEntity*, struct PokemonMove*);
extern void TargetTileInFront(struct DungeonEntity*);
extern s32 FindMoveTarget(struct MoveTargetResults*, struct DungeonEntity*, struct PokemonMove*);
extern bool8 IsMoveUsable(struct DungeonEntity*, s32, bool8);
@@ -63,7 +63,7 @@ void DecideAttack(struct DungeonEntity *pokemon)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (pokemonData->moves[i].moveFlags & MOVE_FLAG_EXISTS &&
- IsChargeMove(pokemon, &pokemonData->moves[i]) &&
+ MoveMatchesChargingStatus(pokemon, &pokemonData->moves[i]) &&
pokemonData->chargingStatusMoveIndex == i)
{
s32 chosenMoveIndex;