summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/status_checker.c3
-rw-r--r--src/trap.c27
2 files changed, 28 insertions, 2 deletions
diff --git a/src/status_checker.c b/src/status_checker.c
index 667f0cb..07d6c7f 100644
--- a/src/status_checker.c
+++ b/src/status_checker.c
@@ -14,6 +14,7 @@
#include "number_util.h"
#include "status_checks_1.h"
#include "tile_types.h"
+#include "trap.h"
#include "weather.h"
// Array indices correspond to the current dungeon tileset.
@@ -96,8 +97,6 @@ const u8 gDungeonCamouflageTypes[76] = {
TYPE_ROCK
};
-extern bool8 CanLayTrap(struct Position*);
-
bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
diff --git a/src/trap.c b/src/trap.c
new file mode 100644
index 0000000..e054706
--- /dev/null
+++ b/src/trap.c
@@ -0,0 +1,27 @@
+#include "global.h"
+#include "trap.h"
+
+#include "dungeon_map_access.h"
+#include "dungeon_util.h"
+#include "map.h"
+
+bool8 CanLayTrap(struct Position *pos)
+{
+ struct MapTile *tile = GetMapTile_2(pos->x, pos->y);
+ if (tile->tileType & TILE_TYPE_STAIRS ||
+ tile->roomIndex == CORRIDOR_ROOM_INDEX ||
+ tile->tileType & TILE_TYPE_ROOM_EXIT)
+ {
+ return FALSE;
+ }
+ if (tile->tileType & TILE_TYPE_SHOP)
+ {
+ return FALSE;
+ }
+ if ((tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_FLOOR ||
+ (tile->mapObject != NULL && GetEntityType(tile->mapObject) != ENTITY_TRAP))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}