summaryrefslogtreecommitdiff
path: root/src/dungeon_visibility.c
diff options
context:
space:
mode:
authorAnonymousRandomPerson <chenghanngan.us@gmail.com>2021-12-14 23:26:56 -0500
committerAnonymousRandomPerson <chenghanngan.us@gmail.com>2021-12-14 23:26:56 -0500
commitda8fcb2ac85554bb099dff69f1d0ec1226156afd (patch)
treec508aa56c680a67d88fe0458f14c66ddec372be3 /src/dungeon_visibility.c
parentb458476078a75905b2cd081455ce18b51d571c79 (diff)
Decomped CanSee()
Diffstat (limited to 'src/dungeon_visibility.c')
-rw-r--r--src/dungeon_visibility.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dungeon_visibility.c b/src/dungeon_visibility.c
new file mode 100644
index 0000000..d258c99
--- /dev/null
+++ b/src/dungeon_visibility.c
@@ -0,0 +1,35 @@
+#include "global.h"
+#include "dungeon_visibility.h"
+
+#include "constants/status.h"
+#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
+
+extern bool8 InSameRoom_2(struct Position*, struct Position*);
+
+bool8 CanSee(struct DungeonEntity *entity, struct DungeonEntity *targetEntity)
+{
+ if (!EntityExists(entity) || !EntityExists(targetEntity) || !targetEntity->visible)
+ {
+ return FALSE;
+ }
+ if (targetEntity->entityType == ENTITY_POKEMON)
+ {
+ if (entity->entityType == ENTITY_POKEMON)
+ {
+ if (!CanSeeInvisible(entity) && targetEntity->entityData->transformStatus == TRANSFORM_STATUS_INVISIBLE)
+ {
+ return FALSE;
+ }
+ if (entity->entityData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
+ {
+ return FALSE;
+ }
+ }
+ else if (targetEntity->entityData->transformStatus == TRANSFORM_STATUS_INVISIBLE)
+ {
+ return FALSE;
+ }
+ }
+ return InSameRoom_2(&entity->posWorld, &targetEntity->posWorld);
+}