summaryrefslogtreecommitdiff
path: root/src/dungeon_ai_attack_2.c
diff options
context:
space:
mode:
authorSeth Barberee <seth.barberee@gmail.com>2022-03-11 10:10:49 -0800
committerGitHub <noreply@github.com>2022-03-11 10:10:49 -0800
commit30fea2d6f303e0e57b62032f56da86c8223ef1f7 (patch)
tree9636ef46bb5f555874dc8ba16c82dc79bc563a12 /src/dungeon_ai_attack_2.c
parentea1aa9c0c5c3a4167912d1078fffdd5e69cbbe98 (diff)
parentcf492fd141b33c21f369dfa7aabebf3c52cb8ec1 (diff)
Merge pull request #98 from AnonymousRandomPerson/master
Finished attack AI decomp
Diffstat (limited to 'src/dungeon_ai_attack_2.c')
-rw-r--r--src/dungeon_ai_attack_2.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/dungeon_ai_attack_2.c b/src/dungeon_ai_attack_2.c
deleted file mode 100644
index 41e924a..0000000
--- a/src/dungeon_ai_attack_2.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "global.h"
-#include "dungeon_ai_attack_2.h"
-
-#include "constants/iq_skill.h"
-#include "dungeon_global_data.h"
-#include "dungeon_map_access.h"
-#include "dungeon_pokemon_attributes.h"
-#include "dungeon_util.h"
-
-bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)
-{
- s32 posDiffX = pokemon->posWorld.x - targetPokemon->posWorld.x;
- s32 effectiveMaxRange;
- if (posDiffX < 0)
- {
- posDiffX = -posDiffX;
- }
- effectiveMaxRange = pokemon->posWorld.y - targetPokemon->posWorld.y;
- if (effectiveMaxRange < 0)
- {
- effectiveMaxRange = -effectiveMaxRange;
- }
- if (effectiveMaxRange < posDiffX)
- {
- effectiveMaxRange = posDiffX;
- }
- if (effectiveMaxRange > maxRange)
- {
- effectiveMaxRange = maxRange;
- }
- if (!HasIQSkill(pokemon, IQ_SKILL_COURSE_CHECKER))
- {
- // BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE.
- // The AI also has range checks elsewhere, so this doesn't become an issue in most cases.
- // If the AI has the Long Toss or Pierce statuses and Course Checker is disabled,
- // this incorrect check causes the AI to throw items at targets further than 10 tiles away.
- if (effectiveMaxRange <= maxRange)
- {
- return TRUE;
- }
- }
- else
- {
- s32 currentPosX = pokemon->posWorld.x;
- s32 currentPosY = pokemon->posWorld.y;
- s32 adjacentTileOffsetX = gAdjacentTileOffsets[facingDir].x;
- s32 adjacentTileOffsetY = gAdjacentTileOffsets[facingDir].y;
- s32 i;
- for (i = 0; i <= effectiveMaxRange; i++)
- {
- struct MapTile *mapTile;
- currentPosX += adjacentTileOffsetX;
- currentPosY += adjacentTileOffsetY;
- if (currentPosX <= 0 || currentPosY <= 0 ||
- currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1)
- {
- break;
- }
- while (0); // Extra label needed to swap branch locations in ASM.
- mapTile = GetMapTile_1(currentPosX, currentPosY);
- if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
- {
- break;
- }
- if (mapTile->pokemon == targetPokemon)
- {
- return TRUE;
- }
- if (mapTile->pokemon != NULL)
- {
- break;
- }
- }
- }
- return FALSE;
-}