summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-02-13 22:30:25 -0500
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-02-13 22:30:25 -0500
commit3bbb6035e746cdb83b128b1d6153436756cb3be0 (patch)
treed92d7d818749543e4d7012411198c6dac9750468 /src
parenta02346be01efa13b6d969a89be642e3450f7ca35 (diff)
Decomped GetMoveTargetingFlagsForPokemon()
Diffstat (limited to 'src')
-rw-r--r--src/dungeon_ai_attack.c6
-rw-r--r--src/moves.c4
-rw-r--r--src/targeting_flags.c17
3 files changed, 22 insertions, 5 deletions
diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c
index 5667d75..f0362ed 100644
--- a/src/dungeon_ai_attack.c
+++ b/src/dungeon_ai_attack.c
@@ -25,6 +25,7 @@
#include "position_util.h"
#include "status_checks.h"
#include "targeting.h"
+#include "targeting_flags.h"
#define REGULAR_ATTACK_INDEX 4
@@ -38,7 +39,6 @@ extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS];
extern bool8 IsMoveUsable(struct DungeonEntity*, s32, bool8);
extern bool8 TargetRegularAttack(struct DungeonEntity*, u32*, bool8);
-extern s16 GetTargetingFlags(struct DungeonEntity*, struct PokemonMove*, bool8);
extern bool8 CanUseWithStatusChecker(struct DungeonEntity*, struct PokemonMove*);
extern bool8 CanAttackInFront(struct DungeonEntity*, s32);
extern s32 WeightMoveIfUsable(s32, s32, struct DungeonEntity*, struct DungeonEntity*, struct PokemonMove*, bool8);
@@ -346,7 +346,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
gCanAttackInDirection[i] = FALSE;
}
- targetingFlags = GetTargetingFlags(pokemon, move, TRUE);
+ targetingFlags = GetMoveTargetingFlagsForPokemon(pokemon, move, TRUE);
hasStatusChecker = HasIQSkill(pokemon, IQ_SKILL_STATUS_CHECKER);
moveTargetResults->moveUsable = FALSE;
if ((pokemonData->volatileStatus == VOLATILE_STATUS_TAUNTED && !GetMoveDealsDirectDamage(move)) ||
@@ -477,7 +477,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
}
}
}
- else if (rangeTargetingFlags == TARGETING_FLAG_SELF_HEAL)
+ else if (rangeTargetingFlags == TARGETING_FLAG_TARGET_SELF)
{
numPotentialTargets = WeightMoveIfUsable(numPotentialTargets, targetingFlags, pokemon, pokemon, move, hasStatusChecker);
}
diff --git a/src/moves.c b/src/moves.c
index 2a0703b..b7c8ad8 100644
--- a/src/moves.c
+++ b/src/moves.c
@@ -158,9 +158,9 @@ void InitZeroedPPPokemonMove(struct PokemonMove *move, u16 moveID)
move->PP = 0;
}
-s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 r1)
+s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 isAI)
{
- return gMovesData[move->moveID].targetingFlags[r1];
+ return gMovesData[move->moveID].targetingFlags[isAI];
}
u8 GetMoveType(struct PokemonMove *move)
diff --git a/src/targeting_flags.c b/src/targeting_flags.c
new file mode 100644
index 0000000..d342d51
--- /dev/null
+++ b/src/targeting_flags.c
@@ -0,0 +1,17 @@
+#include "global.h"
+#include "targeting_flags.h"
+
+#include "constants/move_id.h"
+#include "constants/type.h"
+#include "moves.h"
+
+extern bool8 HasType(struct DungeonEntity *pokemon, u8 type);
+
+s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, u32 isAI)
+{
+ if (move->moveID == MOVE_CURSE && !isAI && !HasType(pokemon, TYPE_GHOST))
+ {
+ return TARGETING_FLAG_BOOST_SELF | TARGETING_FLAG_TARGET_SELF;
+ }
+ return GetMoveTargetingFlags(move, isAI);
+}