Decomped CanSee()

This commit is contained in:
AnonymousRandomPerson 2021-12-14 23:26:56 -05:00
parent b458476078
commit da8fcb2ac8
10 changed files with 5134 additions and 5139 deletions

File diff suppressed because it is too large Load Diff

5078
asm/code_8045A00.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -272,10 +272,10 @@ struct DungeonEntity
enum EntityType
{
ENTITY_NONE = 0,
ENTITY_POKEMON = 1,
ENTITY_TRAP = 2,
ENTITY_ITEM = 3
ENTITY_NONE,
ENTITY_POKEMON,
ENTITY_TRAP,
ENTITY_ITEM
};
enum MovementFlag

View File

@ -3,6 +3,8 @@
#include "dungeon_entity.h"
// 0x71884
bool8 CanSeeInvisible(struct DungeonEntity *pokemon);
// 0x718AC
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic);
// 0x718D8

View File

@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_VISIBILITY_H
#define GUARD_DUNGEON_VISIBILITY_H
#include "dungeon_entity.h"
// 0x45990
bool8 CanSee(struct DungeonEntity *entity, struct DungeonEntity *targetEntity);
#endif

View File

@ -190,6 +190,8 @@ SECTIONS {
asm/code_804ACA0.o(.text);
src/dungeon_util.o(.text);
asm/code_80450F8.o(.text);
src/dungeon_visibility.o(.text);
asm/code_8045A00.o(.text);
src/code_8048480.o(.text);
asm/code_8048480.o(.text);
src/code_80521D0.o(.text);

View File

@ -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);

View File

@ -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;

View File

@ -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*);

35
src/dungeon_visibility.c Normal file
View File

@ -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);
}