summaryrefslogtreecommitdiff
path: root/src/dungeon_ai_item_weight.c
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-01-07 01:45:35 -0600
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2022-01-07 01:45:35 -0600
commit42bcb068b61656f083009816b927207393a35b10 (patch)
tree2d5924a28e208e14d302c24f9ea5f0a17a8e81a2 /src/dungeon_ai_item_weight.c
parent05768ae71decc1539bd7f6e2c6d371b8c619cb24 (diff)
Decomped CanTargetAdjacentPokemon()
Diffstat (limited to 'src/dungeon_ai_item_weight.c')
-rw-r--r--src/dungeon_ai_item_weight.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c
index 175b0c2..2f497cc 100644
--- a/src/dungeon_ai_item_weight.c
+++ b/src/dungeon_ai_item_weight.c
@@ -2,11 +2,14 @@
#include "dungeon_ai_item_weight.h"
#include "constants/status.h"
+#include "constants/targeting.h"
+#include "dungeon_ai_1.h"
+#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
#include "moves.h"
#include "number_util.h"
-extern bool8 CanTargetAdjacentPokemon(struct DungeonEntity*);
extern bool8 HasNegativeStatus(struct DungeonEntity*);
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags)
@@ -440,3 +443,19 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32
}
return itemWeight;
}
+
+bool8 CanTargetAdjacentPokemon(struct DungeonEntity *pokemon)
+{
+ s32 facingDir;
+ for (facingDir = 0; facingDir < NUM_DIRECTIONS; facingDir++)
+ {
+ struct MapTile *mapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x, pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
+ struct DungeonEntity *adjacentPokemon = mapTile->pokemon;
+ if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) != ENTITY_NONE &&
+ CanTarget(pokemon, adjacentPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}