diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-01-07 01:45:35 -0600 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-01-07 01:45:35 -0600 |
commit | 42bcb068b61656f083009816b927207393a35b10 (patch) | |
tree | 2d5924a28e208e14d302c24f9ea5f0a17a8e81a2 /src | |
parent | 05768ae71decc1539bd7f6e2c6d371b8c619cb24 (diff) |
Decomped CanTargetAdjacentPokemon()
Diffstat (limited to 'src')
-rw-r--r-- | src/data/adjacent_tile_offsets.h | 17 | ||||
-rw-r--r-- | src/dungeon_ai_attack.c | 2 | ||||
-rw-r--r-- | src/dungeon_ai_item_weight.c | 21 | ||||
-rw-r--r-- | src/dungeon_util.c | 11 |
4 files changed, 32 insertions, 19 deletions
diff --git a/src/data/adjacent_tile_offsets.h b/src/data/adjacent_tile_offsets.h deleted file mode 100644 index e96b771..0000000 --- a/src/data/adjacent_tile_offsets.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GUARD_CONSTANTS_ADJACENT_TILE_OFFSETS_H -#define GUARD_CONSTANTS_ADJACENT_TILE_OFFSETS_H - -#include "position.h" - -const struct Position gAdjacentTileOffsets[8] = { - {0, 1}, - {1, 1}, - {1, 0}, - {1, -1}, - {0, -1}, - {-1, -1}, - {-1, 0}, - {-1, 1} -}; - -#endif
\ No newline at end of file diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index eaefbd9..5794038 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -2,10 +2,10 @@ #include "dungeon_ai_attack.h" #include "constants/iq_skill.h" -#include "data/adjacent_tile_offsets.h" #include "dungeon_global_data.h" #include "dungeon_map_access.h" #include "dungeon_pokemon_attributes_1.h" +#include "dungeon_util.h" bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange) { 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; +} diff --git a/src/dungeon_util.c b/src/dungeon_util.c index 3594274..5b6bd5a 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -3,6 +3,17 @@ #include "dungeon_map_access.h" +const struct Position gAdjacentTileOffsets[NUM_DIRECTIONS] = { + {0, 1}, + {1, 1}, + {1, 0}, + {1, -1}, + {0, -1}, + {-1, -1}, + {-1, 0}, + {-1, 1} +}; + extern struct MapTile* GetMapEntity(s16, s16); bool8 EntityExists(struct DungeonEntity *entity) |