From 33d2d6175067e75cd222b8f05234221ec2d2b82b Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 21 Feb 2022 15:40:12 -0500 Subject: Decomped CanLayTrap() --- src/status_checker.c | 3 +-- src/trap.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/trap.c (limited to 'src') 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; +} -- cgit v1.2.3