summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dungeon_capabilities_1.c51
-rw-r--r--src/dungeon_util.c2
-rw-r--r--src/status_checks.c4
3 files changed, 54 insertions, 3 deletions
diff --git a/src/dungeon_capabilities_1.c b/src/dungeon_capabilities_1.c
index 721bdcb..7ad12d8 100644
--- a/src/dungeon_capabilities_1.c
+++ b/src/dungeon_capabilities_1.c
@@ -2,10 +2,21 @@
#include "dungeon_capabilities_1.h"
#include "constants/dungeon.h"
+#include "constants/iq_skill.h"
#include "constants/status.h"
#include "charge_move.h"
#include "dungeon_ai.h"
#include "dungeon_capabilities.h"
+#include "dungeon_items.h"
+#include "dungeon_map_access.h"
+#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
+#include "map.h"
+
+const u8 gDirectionBitMasks[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
+
+extern u8 GetCrossableTerrain(s16);
+extern bool8 IsFixedDungeon();
static inline bool8 JoinLocationCannotUseItems(struct DungeonEntityData *pokemonData)
{
@@ -75,3 +86,43 @@ bool8 CannotAttack(struct DungeonEntity *pokemon, bool8 skipSleep)
}
return TRUE;
}
+
+bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
+{
+ u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
+ struct MapTile *currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
+ pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
+ if (currentMapTile->tileType & TILE_TYPE_MAP_EDGE || currentMapTile->pokemon != NULL)
+ {
+ return FALSE;
+ }
+ 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))
+ {
+ crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
+ }
+ else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
+ {
+ if (facingDir & 1)
+ {
+ // Super Mobile can't break walls diagonally.
+ crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
+ }
+ else
+ {
+ crossableTerrain = CROSSABLE_TERRAIN_WALL;
+ }
+ }
+ }
+ currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
+ if (!(currentMapTile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks[facingDir & DIRECTION_MASK]))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/src/dungeon_util.c b/src/dungeon_util.c
index 5b6bd5a..c5b5695 100644
--- a/src/dungeon_util.c
+++ b/src/dungeon_util.c
@@ -3,7 +3,7 @@
#include "dungeon_map_access.h"
-const struct Position gAdjacentTileOffsets[NUM_DIRECTIONS] = {
+const struct Position gAdjacentTileOffsets[] = {
{0, 1},
{1, 1},
{1, 0},
diff --git a/src/status_checks.c b/src/status_checks.c
index ed39e99..b371934 100644
--- a/src/status_checks.c
+++ b/src/status_checks.c
@@ -6,6 +6,7 @@
#include "constants/status.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
+#include "dungeon_capabilities_1.h"
#include "dungeon_random.h"
extern char *gPtrFrozenMessage;
@@ -17,7 +18,6 @@ extern char *gPtrInfatuatedMessage;
extern char gAvailablePokemonNames[];
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
-extern bool8 CanMoveForward2(struct DungeonEntity*, u8);
extern void DecideAttack(struct DungeonEntity*);
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
@@ -74,7 +74,7 @@ bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
}
if (pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
{
- if (!CanMoveForward2(pokemon, pokemonData->action.facingDir))
+ if (!CanMoveInDirection(pokemon, pokemonData->action.facingDir))
{
if (DungeonRandomCapped(2) != 0)
{