summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/code_80521D0_1.c2
-rw-r--r--src/dungeon_ai_items.c2
-rw-r--r--src/dungeon_movement.c2
-rw-r--r--src/dungeon_visibility.c35
4 files changed, 38 insertions, 3 deletions
diff --git a/src/code_80521D0_1.c b/src/code_80521D0_1.c
index ab497b8..b859485 100644
--- a/src/code_80521D0_1.c
+++ b/src/code_80521D0_1.c
@@ -4,6 +4,7 @@
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "dungeon_random.h"
+#include "dungeon_util.h"
#include "friend_area.h"
#include "map.h"
#include "pokemon.h"
@@ -95,7 +96,6 @@ extern void sub_8042B0C(struct DungeonEntity *);
extern void SetFacingDirection(struct DungeonEntity *, u32);
extern void DisplayDungeonDialogue(u32 *);
extern void sub_803E708(u32, u32);
-extern u8 EntityExists(struct DungeonEntity *);
extern u8 HasRecruitedMon(u32);
extern u8 sub_806FD18(struct DungeonEntity *);
extern u8 sub_8083E74(u32);
diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c
index 94afb70..18bcf42 100644
--- a/src/dungeon_ai_items.c
+++ b/src/dungeon_ai_items.c
@@ -15,6 +15,7 @@
#include "dungeon_random.h"
#include "dungeon_random_1.h"
#include "dungeon_util.h"
+#include "dungeon_visibility.h"
#include "item.h"
#include "team_inventory.h"
@@ -33,7 +34,6 @@ extern struct MapTile* GetMapTileAtPosition(s16, s16);
extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u8);
extern bool8 ToolboxEnabled(struct DungeonEntityData*);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
-extern bool8 CanSee(struct DungeonEntity*, struct DungeonEntity*);
extern void TargetThrownItem(struct DungeonEntity*, struct DungeonEntity*, struct ItemSlot*, u8, bool8);
extern s32 gNumPotentialTargets;
diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c
index 80bf2e5..86a2b01 100644
--- a/src/dungeon_movement.c
+++ b/src/dungeon_movement.c
@@ -13,6 +13,7 @@
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_util_1.h"
+#include "dungeon_visibility.h"
#include "map.h"
#include "pokemon.h"
@@ -25,7 +26,6 @@ extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void SendMessage(struct DungeonEntity*, char*);
extern bool8 HasStatusAffectingActions(struct DungeonEntity*);
-extern bool8 CanSee(struct DungeonEntity*, struct DungeonEntity*);
extern void ResetAction(u16*);
extern void SetWalkAction(u16*, s16);
extern void DecideAttack(struct DungeonEntity*);
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);
+}