merge dungeon util and dungeon visibility

This commit is contained in:
DizzyEggg
2025-03-30 10:34:30 +02:00
parent ca64d58479
commit 1af147eb11
34 changed files with 86 additions and 134 deletions

View File

@@ -9,6 +9,11 @@
extern const DungeonPos gAdjacentTileOffsets[NUM_DIRECTIONS];
static inline EntityInfo *GetEntInfo(Entity *entity)
{
return entity->axObj.info.monster;
}
bool8 EntityIsValid(Entity *pokemon);
u32 GetEntityType(Entity *entity);
u8 GetEntityRoom(Entity *entity);
@@ -16,18 +21,17 @@ Tile *GetTileAtEntitySafe(Entity *entity);
void sub_804535C(Entity *entity, PixelPos *pos);
void SetEntityPixelPos(Entity *entity, s32 x, s32 y);
void IncreaseEntityPixelPos(Entity *entity, s32 x, s32 y);
static inline EntityInfo *GetEntInfo(Entity *entity)
{
return entity->axObj.info.monster;
}
Item *GetItemData(Entity *entity);
Item *GetItemData_1(Entity *entity);
Trap *GetTrapData(Entity *entity);
Trap* GetTrapData_1(Entity *entity);
Entity *SpawnTrap(u8 trapID, DungeonPos *pos, u8 c);
Entity *sub_8045708(DungeonPos *pos);
void sub_80457DC(Entity* ent);
bool8 CanSeeTarget(Entity *entity, Entity *targetEntity);
bool8 CanTargetEntity(Entity *entity, Entity *targetEntity);
bool8 sub_8045A70(Entity *entity, Entity *targetEntity);
bool8 sub_8045AAC(Entity *entity, DungeonPos *pos);
bool8 CanTargetPosition(Entity *entity, DungeonPos *pos);
#endif // GUARD_DUNGEON_UTIL_H

View File

@@ -1,12 +0,0 @@
#ifndef GUARD_DUNGEON_VISIBILITY_H
#define GUARD_DUNGEON_VISIBILITY_H
#include "structs/dungeon_entity.h"
bool8 CanSeeTarget(Entity *entity, Entity *targetEntity);
bool8 CanTargetEntity(Entity *entity, Entity *targetEntity);
bool8 sub_8045A70(Entity *entity, Entity *targetEntity);
bool8 sub_8045AAC(Entity *entity, DungeonPos *pos);
bool8 CanTargetPosition(Entity *entity, DungeonPos *pos);
#endif

View File

@@ -210,8 +210,6 @@ SECTIONS {
src/dungeon_action.o(.text);
src/code_8044CC8.o(.text);
src/dungeon_util.o(.text);
src/code_80450F8.o(.text);
src/dungeon_visibility.o(.text);
src/code_8045A00.o(.text);
src/dungeon_items.o(.text);
asm/code_8046CE4.o(.text);

View File

@@ -23,7 +23,6 @@
#include "dungeon_random.h"
#include "dungeon_misc.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "exclusive_pokemon.h"
#include "game_options.h"
#include "move_effects_target.h"

View File

@@ -16,7 +16,6 @@
#include "number_util.h"
#include "status.h"
#include "dungeon_random.h"
#include "code_80450F8.h"
#include "code_8045A00.h"
#include "dungeon_items.h"
#include "structs/str_damage.h"

View File

@@ -15,7 +15,6 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "friend_area.h"
#include "pokemon.h"
#include "pokemon_3.h"

View File

@@ -6,7 +6,6 @@
#include "dungeon_leader.h"
#include "dungeon_message.h"
#include "code_8041AD0.h"
#include "code_80450F8.h"
#include "code_8045A00.h"
#include "code_8077274_1.h"
#include "constants/dungeon.h"

View File

@@ -1,6 +1,5 @@
#include "global.h"
#include "dungeon_ai.h"
#include "constants/iq_skill.h"
#include "constants/item.h"
#include "constants/status.h"
@@ -11,7 +10,6 @@
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "structs/str_dungeon.h"
#include "position_util.h"
#include "trap.h"

View File

@@ -14,7 +14,6 @@
#include "string_format.h"
#include "dungeon_movement.h"
#include "dungeon_capabilities.h"
#include "dungeon_visibility.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_ai_targeting.h"
@@ -29,7 +28,6 @@
#include "dungeon_items.h"
#include "move_util.h"
#include "moves.h"
#include "code_80450F8.h"
#include "math.h"
#include "constants/ability.h"
#include "constants/monster.h"

View File

@@ -1,6 +1,5 @@
#include "global.h"
#include "dungeon_ai.h"
#include "code_803E668.h"
#include "code_803E724.h"
#include "code_8045A00.h"
@@ -28,7 +27,6 @@
#include "dungeon_random.h"
#include "dungeon_util_1.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "pokemon.h"
#include "status_checks.h"
#include "structs/map.h"

View File

@@ -22,7 +22,6 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "items.h"
#include "move_checks.h"
#include "move_util.h"

View File

@@ -17,7 +17,6 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "items.h"
#include "structs/str_position.h"
#include "position_util.h"

View File

@@ -24,7 +24,6 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "move_util.h"
#include "moves.h"
#include "pokemon_3.h"

View File

@@ -17,7 +17,6 @@
#include "dungeon_random.h"
#include "dungeon_range.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "structs/map.h"
#include "number_util.h"
#include "position_util.h"

View File

@@ -9,7 +9,6 @@
#include "dungeon_util.h"
#include "items.h"
#include "pokemon.h"
#include "code_80450F8.h"
#include "code_803E668.h"
#include "constants/direction.h"
#include "constants/item.h"

View File

@@ -5,7 +5,6 @@
#include "dungeon_map_access.h"
#include "items.h"
#include "pokemon.h"
#include "code_80450F8.h"
#include "dungeon_util.h"
#include "dungeon_items.h"
#include "dungeon_message.h"

View File

@@ -25,7 +25,6 @@
#include "structs/map.h"
#include "trap.h"
#include "math.h"
#include "code_80450F8.h"
#include "structs/str_item_text.h"
#include "code_803E46C.h"
#include "sprite.h"

View File

@@ -43,7 +43,6 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "game_options.h"
#include "input.h"
#include "items.h"

View File

@@ -13,7 +13,6 @@
#include "dungeon_map.h"
#include "dungeon_movement.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "game_options.h"
#include "random.h"
#include "text_1.h"

View File

@@ -18,7 +18,6 @@
#include "dungeon_submenu.h"
#include "dungeon_strings.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "input.h"
#include "moves.h"
#include "menu_input.h"

View File

@@ -31,7 +31,6 @@
#include "dungeon_random.h"
#include "dungeon_submenu.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "input.h"
#include "items.h"
#include "menu_input.h"

View File

@@ -11,7 +11,6 @@
#include "moves.h"
#include "string_format.h"
#include "friend_area.h"
#include "code_80450F8.h"
#include "code_8045A00.h"
#include "code_803E668.h"
#include "dungeon_engine.h"

View File

@@ -32,7 +32,6 @@
#include "dungeon_random.h"
#include "dungeon_strings.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "math.h"
#include "move_effects_target.h"
#include "move_util.h"

View File

@@ -32,7 +32,6 @@
#include "dungeon_random.h"
#include "dungeon_strings.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "math.h"
#include "move_effects_target.h"
#include "move_util.h"

View File

@@ -11,7 +11,6 @@
#include "constants/type.h"
#include "dungeon_items.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "moves.h"
#include "pokemon_3.h"
#include "pokemon.h"

View File

@@ -2,7 +2,6 @@
#include "globaldata.h"
#include "structs/str_dungeon.h"
#include "code_800F958.h"
#include "code_80450F8.h"
#include "code_8045A00.h"
#include "code_805D8C8.h"
#include "code_806CD90.h"

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "dungeon_util.h"
#include "structs/str_dungeon.h"
#include "structs/str_traps.h"
#include "code_800F958.h"
@@ -9,10 +10,11 @@
#include "dungeon_map_access.h"
#include "dungeon_util.h"
#include "code_803E724.h"
#include "code_80450F8.h"
#include "dungeon_range.h"
#include "pokemon.h"
#include "code_805D8C8.h"
#include "constants/status.h"
#include "dungeon_pokemon_attributes.h"
extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE];
extern u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE];
@@ -482,3 +484,76 @@ bool8 sub_8045888(Entity *ent)
return FALSE;
}
bool8 CanSeeTarget(Entity *entity, Entity *targetEntity)
{
if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
if (GetEntInfo(entity)->blinkerClassStatus.status == STATUS_BLINKER)
{
return FALSE;
}
}
else if (GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
bool8 CanTargetEntity(Entity *entity, Entity *targetEntity)
{
if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
if (GetEntInfo(entity)->blinkerClassStatus.status == STATUS_BLINKER)
{
return FALSE;
}
}
else if (GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionInSight(&entity->pos, &targetEntity->pos);
}
bool8 sub_8045A70(Entity *entity, Entity *targetEntity)
{
if (EntityIsValid(entity) && EntityIsValid(targetEntity) && targetEntity->isVisible)
{
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
return FALSE;
}
bool8 sub_8045AAC(Entity *entity, DungeonPos *pos)
{
return IsPositionActuallyInSight(&entity->pos, pos);
}
bool8 CanTargetPosition(Entity *entity, DungeonPos *pos)
{
return IsPositionInSight(&entity->pos, pos);
}

View File

@@ -3,7 +3,6 @@
#include "dungeon_misc.h"
#include "code_803E46C.h"
#include "code_803E668.h"
#include "code_80450F8.h"
#include "code_806CD90.h"
#include "constants/direction.h"
#include "constants/dungeon.h"

View File

@@ -1,81 +0,0 @@
#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(Entity *entity, Entity *targetEntity)
{
if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
if (GetEntInfo(entity)->blinkerClassStatus.status == STATUS_BLINKER)
{
return FALSE;
}
}
else if (GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
bool8 CanTargetEntity(Entity *entity, Entity *targetEntity)
{
if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible)
{
return FALSE;
}
if (targetEntity->type == ENTITY_MONSTER)
{
if (entity->type == ENTITY_MONSTER)
{
if (!CanSeeInvisibleMonsters(entity) && GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
if (GetEntInfo(entity)->blinkerClassStatus.status == STATUS_BLINKER)
{
return FALSE;
}
}
else if (GetEntInfo(targetEntity)->invisibleClassStatus.status == STATUS_INVISIBLE)
{
return FALSE;
}
}
return IsPositionInSight(&entity->pos, &targetEntity->pos);
}
bool8 sub_8045A70(Entity *entity, Entity *targetEntity)
{
if (EntityIsValid(entity) && EntityIsValid(targetEntity) && targetEntity->isVisible)
{
return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos);
}
return FALSE;
}
bool8 sub_8045AAC(Entity *entity, DungeonPos *pos)
{
return IsPositionActuallyInSight(&entity->pos, pos);
}
bool8 CanTargetPosition(Entity *entity, DungeonPos *pos)
{
return IsPositionInSight(&entity->pos, pos);
}

View File

@@ -10,7 +10,6 @@
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "move_checks.h"
#include "moves.h"
#include "number_util.h"

View File

@@ -26,7 +26,6 @@
#include "dungeon_random.h"
#include "dungeon_util_1.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "pokemon.h"
#include "status_checks.h"
#include "status_checks_1.h"

View File

@@ -27,7 +27,6 @@
#include "dungeon_random.h"
#include "dungeon_strings.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "moves.h"
#include "move_effects_target.h"
#include "move_util.h"

View File

@@ -22,7 +22,6 @@
#include "dungeon_misc.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "move_util.h"
#include "moves.h"
#include "number_util.h"

View File

@@ -2,7 +2,6 @@
#include "trap.h"
#include "code_803E668.h"
#include "code_803E724.h"
#include "code_80450F8.h"
#include "code_8041AD0.h"
#include "code_8045A00.h"
#include "dungeon_message.h"