diff options
author | Seth Barberee <seth.barberee@gmail.com> | 2022-02-27 08:43:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-27 08:43:59 -0800 |
commit | ea1aa9c0c5c3a4167912d1078fffdd5e69cbbe98 (patch) | |
tree | 1d3f29615f1683fae77ade7d8713e7bfe5a11c26 /src/dungeon_ai_targeting.c | |
parent | 0dd38993f6a4383d6d5743fd0ae0abc01210ae25 (diff) | |
parent | a5296a2f994a0f8e4421c4afd6bac1cedcfb72be (diff) |
Merge pull request #97 from AnonymousRandomPerson/master
More attack AI decomp
Diffstat (limited to 'src/dungeon_ai_targeting.c')
-rw-r--r-- | src/dungeon_ai_targeting.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/dungeon_ai_targeting.c b/src/dungeon_ai_targeting.c new file mode 100644 index 0000000..ec5abd9 --- /dev/null +++ b/src/dungeon_ai_targeting.c @@ -0,0 +1,62 @@ +#include "global.h" +#include "dungeon_ai_targeting.h" + +#include "constants/iq_skill.h" +#include "constants/item.h" +#include "constants/status.h" +#include "dungeon_engine.h" +#include "dungeon_items.h" +#include "dungeon_map_access.h" +#include "dungeon_movement.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_util.h" +#include "map.h" + +const u8 gDirectionBitMasks_2[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80}; + +bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction) +{ + u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID); + struct MapTile *tile; + if (crossableTerrain < CROSSABLE_TERRAIN_CREVICE) + { + crossableTerrain = CROSSABLE_TERRAIN_CREVICE; + } + tile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[direction].x, + pokemon->posWorld.y + gAdjacentTileOffsets[direction].y); + if (!(tile->tileType & TILE_TYPE_MAP_EDGE) && + (tile->pokemon == NULL || GetEntityType(tile->pokemon) == ENTITY_POKEMON)) + { + if (!IsFixedDungeon()) + { + if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE || + HasItem(pokemon, ITEM_ID_MOBILE_SCARF)) + { + crossableTerrain = CROSSABLE_TERRAIN_WALL; + } + else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER)) + { + // BUG: If the Pokémon is a Ghost type that can normally attack through walls, + // All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls. + crossableTerrain = CROSSABLE_TERRAIN_CREVICE; + } + else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE)) + { + if ((direction & 1) != 0) + { + crossableTerrain = CROSSABLE_TERRAIN_CREVICE; + } + else + { + crossableTerrain = CROSSABLE_TERRAIN_WALL; + } + } + } + tile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y); + if (tile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks_2[direction & DIRECTION_MASK]) + { + return TRUE; + } + } + return FALSE; +} |