pmd-red/src/dungeon_visibility.c
2023-01-16 00:07:59 -05:00

82 lines
2.2 KiB
C

#include "global.h"
#include "dungeon_visibility.h"
#include "constants/status.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_range.h"
#include "dungeon_util.h"
bool8 CanSeeTarget(struct Entity *entity, struct Entity *targetEntity)
{
if (!EntityExists(entity) || !EntityExists(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && targetEntity->info->transformStatus == STATUS_INVISIBLE)
{
return FALSE;
}
if (entity->info->eyesightStatus == STATUS_BLINKER)
{
return FALSE;
}
}
else if (targetEntity->info->transformStatus == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
bool8 CanTargetEntity(struct Entity *entity, struct Entity *targetEntity)
{
if (!EntityExists(entity) || !EntityExists(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && targetEntity->info->transformStatus == STATUS_INVISIBLE)
{
return FALSE;
}
if (entity->info->eyesightStatus == STATUS_BLINKER)
{
return FALSE;
}
}
else if (targetEntity->info->transformStatus == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionInSight(&entity->pos, &targetEntity->pos);
}
bool8 sub_8045A70(struct Entity *entity, struct Entity *targetEntity)
{
if (EntityExists(entity) && EntityExists(targetEntity) && targetEntity->isVisible)
{
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
return FALSE;
}
bool8 sub_8045AAC(struct Entity *entity, struct Position *pos)
{
return IsPositionActuallyInSight(&entity->pos, pos);
}
bool8 CanTargetPosition(struct Entity *entity, struct Position *pos)
{
return IsPositionInSight(&entity->pos, pos);
}