From cd9a8c5a384124999e15626d9623b48f2687deba Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 13 Dec 2021 23:22:03 -0500 Subject: Decomped CanTarget() --- include/constants/status.h | 4 ---- include/constants/targeting.h | 12 ++++++++++++ include/dungeon_ai_1.h | 9 +++++++++ include/dungeon_entity.h | 9 +++++---- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 include/constants/targeting.h create mode 100644 include/dungeon_ai_1.h (limited to 'include') diff --git a/include/constants/status.h b/include/constants/status.h index 19b860b..cf911c0 100644 --- a/include/constants/status.h +++ b/include/constants/status.h @@ -94,10 +94,6 @@ #define MUZZLED_STATUS_NONE 0 #define MUZZLED_STATUS_MUZZLED 1 -#define TARGETING_DECOY_NONE 0 -#define TARGETING_DECOY_TEAM 1 -#define TARGETING_DECOY_WILD 2 - #define STATUS_SPRITE_SLEEPLESS (1 << 0) #define STATUS_SPRITE_BURNED (1 << 1) #define STATUS_SPRITE_POISONED (1 << 2) diff --git a/include/constants/targeting.h b/include/constants/targeting.h new file mode 100644 index 0000000..6140716 --- /dev/null +++ b/include/constants/targeting.h @@ -0,0 +1,12 @@ +#ifndef GUARD_CONSTANTS_TARGETING_H +#define GUARD_CONSTANTS_TARGETING_H + +#define TARGETING_DECOY_NONE 0 +#define TARGETING_DECOY_TEAM 1 +#define TARGETING_DECOY_WILD 2 + +#define TARGET_CAPABILITY_CANNOT_ATTACK 0 +#define TARGET_CAPABILITY_CAN_TARGET 1 +#define TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET 2 + +#endif diff --git a/include/dungeon_ai_1.h b/include/dungeon_ai_1.h new file mode 100644 index 0000000..dace65a --- /dev/null +++ b/include/dungeon_ai_1.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_AI_1_H +#define GUARD_DUNGEON_AI_1_H + +#include "dungeon_entity.h" + +// 0x71598 +u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified); + +#endif diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index b894a2f..29e3112 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -287,10 +287,11 @@ enum MovementFlag enum ShopkeeperMode { - SHOPKEEPER_FRIENDLY = 1, + SHOPKEEPER_NONE, + SHOPKEEPER_FRIENDLY, // These two modes trigger if an explosion damages the shopkeeper. The shopkeeper attacks the side that damaged it. - SHOPKEEPER_AGGRESSIVE_TO_WILD = 2, - SHOPKEEPER_AGGRESSIVE_TO_PLAYER = 3 + SHOPKEEPER_AGGRESSIVE_TO_WILD, + SHOPKEEPER_AGGRESSIVE_TO_PLAYER }; enum MovementAction @@ -308,7 +309,7 @@ enum ClientType { CLIENT_TYPE_NONE = 0, CLIENT_TYPE_CLIENT = 1, // Used for mission clients that need rescuing. - CLIENT_TYPE_DONT_MOVE = 3 // Used for Diglett in the Skarmory boss fight. + CLIENT_TYPE_DONT_MOVE = 4 // Used for Diglett in the Skarmory boss fight. }; enum VisualFlag -- cgit v1.2.3 From da8fcb2ac85554bb099dff69f1d0ec1226156afd Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Tue, 14 Dec 2021 23:26:56 -0500 Subject: Decomped CanSee() --- include/dungeon_entity.h | 8 ++++---- include/dungeon_pokemon_attributes_1.h | 2 ++ include/dungeon_visibility.h | 9 +++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 include/dungeon_visibility.h (limited to 'include') diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index 29e3112..bf263ae 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -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 diff --git a/include/dungeon_pokemon_attributes_1.h b/include/dungeon_pokemon_attributes_1.h index 0c8037b..ccf68e5 100644 --- a/include/dungeon_pokemon_attributes_1.h +++ b/include/dungeon_pokemon_attributes_1.h @@ -3,6 +3,8 @@ #include "dungeon_entity.h" +// 0x71884 +bool8 CanSeeInvisible(struct DungeonEntity *pokemon); // 0x718AC bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic); // 0x718D8 diff --git a/include/dungeon_visibility.h b/include/dungeon_visibility.h new file mode 100644 index 0000000..f94926e --- /dev/null +++ b/include/dungeon_visibility.h @@ -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 -- cgit v1.2.3 From b1fc911965c584f5af6522849162527f41461b7c Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Tue, 14 Dec 2021 23:36:22 -0500 Subject: Decomped InSameRoom_2() --- include/dungeon_ai_items.h | 2 +- include/dungeon_entity.h | 2 +- include/dungeon_global_data.h | 5 ++++- include/dungeon_pokemon_sprites.h | 2 +- include/dungeon_range.h | 9 +++++++++ include/map.h | 23 ++++++++--------------- include/position.h | 16 ++++++++++++++++ 7 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 include/dungeon_range.h create mode 100644 include/position.h (limited to 'include') diff --git a/include/dungeon_ai_items.h b/include/dungeon_ai_items.h index f4effd2..676200a 100644 --- a/include/dungeon_ai_items.h +++ b/include/dungeon_ai_items.h @@ -2,7 +2,7 @@ #define GUARD_DUNGEON_AI_ITEMS_H #include "dungeon_entity.h" -#include "map.h" +#include "position.h" // 0x73658 void DecideUseItem(struct DungeonEntity *pokemon); diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index bf263ae..f4e836c 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -3,7 +3,7 @@ #include "constants/move.h" #include "item.h" -#include "map.h" +#include "position.h" struct DungeonActionContainer { diff --git a/include/dungeon_global_data.h b/include/dungeon_global_data.h index 1d0a971..2e46ef0 100644 --- a/include/dungeon_global_data.h +++ b/include/dungeon_global_data.h @@ -5,6 +5,7 @@ #include "dungeon_entity.h" #include "global.h" #include "map.h" +#include "position.h" #define DUNGEON_MAX_SIZE_X 55 #define DUNGEON_MAX_SIZE_Y 31 @@ -69,7 +70,9 @@ struct DungeonGlobalData /* 0xE278 */ u8 waterSportTurnsLeft; u8 fillE279[0xE8C0 - 0xE279]; /* 0xE8C0 */ u32 mapEntityPointers[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y]; - u8 fill10364[0x10844 - 0x10364]; + u8 fill10364[0x104C4 - 0x10364]; + /* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT]; + u8 fill10604[0x10844 - 0x10764]; /* 0x10844 */ u16 numRoomExits[MAX_ROOM_COUNT]; u8 fill10874[0x10884 - 0x10874]; /* 0x10884 */ struct Position roomExits[MAX_ROOM_COUNT][32]; // Arrays of room exits for each room. diff --git a/include/dungeon_pokemon_sprites.h b/include/dungeon_pokemon_sprites.h index 50595ea..fe934e2 100644 --- a/include/dungeon_pokemon_sprites.h +++ b/include/dungeon_pokemon_sprites.h @@ -1,7 +1,7 @@ #ifndef GUARD_DUNGEON_POKEMON_SPRITES_H #define GUARD_DUNGEON_POKEMON_SPRITES_H -#include "map.h" +#include "position.h" struct DungeonPokemonStatusSprite { diff --git a/include/dungeon_range.h b/include/dungeon_range.h new file mode 100644 index 0000000..3d76011 --- /dev/null +++ b/include/dungeon_range.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_RANGE_H +#define GUARD_DUNGEON_RANGE_H + +#include "position.h" + +// 0x83294 +bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2); + +#endif diff --git a/include/map.h b/include/map.h index 7863b46..2989c6c 100644 --- a/include/map.h +++ b/include/map.h @@ -2,8 +2,10 @@ #define GUARD_MAP_H #include "dungeon_entity.h" +#include "position.h" #define MAX_ROOM_COUNT 24 // Empirical max, not sure if the code supports any more. +#define CORRIDOR_ROOM_INDEX 0xFF struct MapTile { @@ -25,25 +27,16 @@ struct MapTile /* 0x14 */ struct DungeonEntity *mapObject; // Item or trap on the tile. }; -struct Position -{ - s16 x; - s16 y; -}; - -struct Position32 -{ - s32 x; - s32 y; -}; - struct MapRoom { u8 fill0[0x2 - 0x0]; // All coordinates are inclusive. - /* 0x2 */ struct Position start; - /* 0x6 */ struct Position end; - u8 fillA[0x1C - 0xA]; + // These are not aligned properly to use the Position struct. + /* 0x2 */ s16 startX; + /* 0x4 */ s16 startY; + /* 0x6 */ s16 endX; + /* 0x8 */ s16 endY; + u8 fillA[0x1A - 0xA]; }; enum TileType diff --git a/include/position.h b/include/position.h new file mode 100644 index 0000000..3a24df4 --- /dev/null +++ b/include/position.h @@ -0,0 +1,16 @@ +#ifndef GUARD_POSITION_H +#define GUARD_POSITION_H + +struct Position +{ + s16 x; + s16 y; +}; + +struct Position32 +{ + s32 x; + s32 y; +}; + +#endif -- cgit v1.2.3 From c033aea36e73365c28da1de93af29ec11b3945b2 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Fri, 17 Dec 2021 23:39:50 -0500 Subject: Moved gDungeonGlobalData definition to dungeon_global_data.h --- include/dungeon_global_data.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/dungeon_global_data.h b/include/dungeon_global_data.h index 2e46ef0..d1d57ae 100644 --- a/include/dungeon_global_data.h +++ b/include/dungeon_global_data.h @@ -12,6 +12,8 @@ #define DUNGEON_MAX_WILD_POKEMON 16 #define DUNGEON_MAX_POKEMON MAX_TEAM_MEMBERS + DUNGEON_MAX_WILD_POKEMON +extern struct DungeonGlobalData *gDungeonGlobalData; + struct DungeonGlobalData { u8 unk0; -- cgit v1.2.3 From 0369264407563b64d60c885f8bf79322b6f663c8 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sat, 18 Dec 2021 00:22:03 -0500 Subject: Decomped GetMapTileAtPosition() --- include/dungeon_global_data.h | 14 +++++++------- include/dungeon_map_access.h | 9 +++++++++ include/dungeon_util.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 include/dungeon_map_access.h (limited to 'include') diff --git a/include/dungeon_global_data.h b/include/dungeon_global_data.h index d1d57ae..948603e 100644 --- a/include/dungeon_global_data.h +++ b/include/dungeon_global_data.h @@ -7,8 +7,8 @@ #include "map.h" #include "position.h" -#define DUNGEON_MAX_SIZE_X 55 -#define DUNGEON_MAX_SIZE_Y 31 +#define DUNGEON_MAX_SIZE_X 56 +#define DUNGEON_MAX_SIZE_Y 32 #define DUNGEON_MAX_WILD_POKEMON 16 #define DUNGEON_MAX_POKEMON MAX_TEAM_MEMBERS + DUNGEON_MAX_WILD_POKEMON @@ -54,8 +54,8 @@ struct DungeonGlobalData u8 fill3A10[0x3A14 - 0x3A10]; /* 0x3A14 */ s16 bossBattleIndex; u8 fill3A16[0x3A18 - 0x3A16]; - /* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y]; - u8 fill54BC[0xE23C - 0xD9F0]; + /* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; + u8 fillE218[0xE23C - 0xE218]; s16 unkE23C; s16 unkE23E; u8 fillE240[0xE264 - 0xE240]; @@ -71,10 +71,10 @@ struct DungeonGlobalData /* 0xE277 */ u8 mudSportTurnsLeft; /* 0xE278 */ u8 waterSportTurnsLeft; u8 fillE279[0xE8C0 - 0xE279]; - /* 0xE8C0 */ u32 mapEntityPointers[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y]; - u8 fill10364[0x104C4 - 0x10364]; + /* 0xE8C0 */ struct MapTile* mapEntityPointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; + u8 fill104C0[0x104C4 - 0x104C0]; /* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT]; - u8 fill10604[0x10844 - 0x10764]; + u8 fill10764[0x10844 - 0x10764]; /* 0x10844 */ u16 numRoomExits[MAX_ROOM_COUNT]; u8 fill10874[0x10884 - 0x10874]; /* 0x10884 */ struct Position roomExits[MAX_ROOM_COUNT][32]; // Arrays of room exits for each room. diff --git a/include/dungeon_map_access.h b/include/dungeon_map_access.h new file mode 100644 index 0000000..5e4e3da --- /dev/null +++ b/include/dungeon_map_access.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_MAP_ACCESS_H +#define GUARD_DUNGEON_MAP_ACCESS_H + +#include "map.h" + +// 0x4954C +struct MapTile* GetMapTileAtPosition(s32 x, s32 y); + +#endif diff --git a/include/dungeon_util.h b/include/dungeon_util.h index ca62184..82d44ba 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -11,6 +11,6 @@ u32 GetEntityType(struct DungeonEntity *entity); struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity); // 0x45108 struct ItemSlot *GetItemData(struct DungeonEntity *entity); -struct MapTile *sub_8045128(struct DungeonEntity *entity); +struct MapTile *GetMapEntityForDungeonEntity(struct DungeonEntity *entity); #endif -- cgit v1.2.3