diff options
author | Cheng Hann Gan <chenghanngan.us@gmail.com> | 2021-12-09 13:56:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 10:56:12 -0800 |
commit | a34c9ab91b553fcb1f72b94eb912b94bea58885b (patch) | |
tree | a31d0805938a56d1552f952db6ec6ab2defdebe5 /include | |
parent | 4fc272fea6bc7332fae031ebeb12362cff1c35de (diff) |
AI decomp + type cleanup (#82)
* Decomped SetAction()
* Changed MapTile.tileType to u16 bit field
* Decomped FindStraightThrowableTargets()
* Cleaned up CannotAttack()
* Cleaned up some externs
* Converted dungeon action to substruct
Diffstat (limited to 'include')
-rw-r--r-- | include/dungeon_action.h | 9 | ||||
-rw-r--r-- | include/dungeon_ai_items.h | 2 | ||||
-rw-r--r-- | include/dungeon_entity.h | 26 | ||||
-rw-r--r-- | include/dungeon_pokemon_attributes_1.h | 2 | ||||
-rw-r--r-- | include/dungeon_util.h | 7 | ||||
-rw-r--r-- | include/map.h | 19 |
6 files changed, 41 insertions, 24 deletions
diff --git a/include/dungeon_action.h b/include/dungeon_action.h new file mode 100644 index 0000000..c3631f7 --- /dev/null +++ b/include/dungeon_action.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_ACTION_H +#define GUARD_DUNGEON_ACTION_H + +#include "dungeon_entity.h" + +// 0x44C94 +void SetAction(struct DungeonActionContainer *actionPointer, u16 action); + +#endif diff --git a/include/dungeon_ai_items.h b/include/dungeon_ai_items.h index e7d9f4f..b9e7625 100644 --- a/include/dungeon_ai_items.h +++ b/include/dungeon_ai_items.h @@ -5,5 +5,7 @@ // 0x73658 void DecideUseItem(struct DungeonEntity *pokemon); +// 0x739DC +void FindStraightThrowableTargets(struct DungeonEntity* pokemon, s32 thrownAIFlag, struct ItemSlot* item, bool8 ignoreRollChance); #endif diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index 63c85d6..ef18c67 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -4,6 +4,20 @@ #include "item.h" #include "constants/move.h" +struct DungeonActionContainer +{ + /* 0x0 */ u16 action; + /* 0x2 */ s8 facingDir; + u8 fill3; + // Additional parameter alongside actionIndex. Used for things like indicating which move a Pokémon should use from its moveset. + /* 0x4 */ u8 actionUseIndex; + u8 fill5[0x8 - 0x5]; + // Position of the Pokémon the last time it threw an item. + /* 0x8 */ s16 lastItemThrowPositionX; + /* 0xA */ s16 lastItemThrowPositionY; + u8 unkC; +}; + struct DungeonEntityData { // This has different purposes for Pokémon, items, and traps. @@ -51,16 +65,8 @@ struct DungeonEntityData u8 fill3F; /* 0x40 */ u8 joinLocation; // Uses the dungeon index in dungeon.h. u8 fill41[0x44 - 0x41]; - /* 0x44 */ u16 action; - /* 0x46 */ s8 facingDir; - u8 fill47; - // Additional parameter alongside actionIndex. Used for things like indiciating which move a Pokémon should use from its moveset. - /* 0x48 */ u8 actionUseIndex; - u8 fill49[0x4C - 0x49]; - // Position of the Pokémon the last time it threw an item. - /* 0x4C */ s16 lastItemThrowPositionX; - /* 0x4E */ s16 lastItemThrowPositionY; - u8 fill50[0x58 - 0x50]; + /* 0x44 */ struct DungeonActionContainer action; + u8 fill55[0x58 - 0x55]; // Position of the target that the Pokémon wants throw an item at. /* 0x58 */ s16 *itemTargetPosition; /* 0x5C */ u8 type1; diff --git a/include/dungeon_pokemon_attributes_1.h b/include/dungeon_pokemon_attributes_1.h index 51788d2..0c8037b 100644 --- a/include/dungeon_pokemon_attributes_1.h +++ b/include/dungeon_pokemon_attributes_1.h @@ -5,5 +5,7 @@ // 0x718AC bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic); +// 0x718D8 +bool8 HasIQSkill(struct DungeonEntity* pokemon, u8 IQSkill); #endif diff --git a/include/dungeon_util.h b/include/dungeon_util.h index f3059b0..ca62184 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -5,5 +5,12 @@ // 0x450E0 bool8 EntityExists(struct DungeonEntity *pokemon); +// 0x450F8 +u32 GetEntityType(struct DungeonEntity *entity); +// 0x45104 +struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity); +// 0x45108 +struct ItemSlot *GetItemData(struct DungeonEntity *entity); +struct MapTile *sub_8045128(struct DungeonEntity *entity); #endif diff --git a/include/map.h b/include/map.h index a0a5660..38fe68a 100644 --- a/include/map.h +++ b/include/map.h @@ -5,21 +5,11 @@ #define MAX_ROOM_COUNT 24 // Empirical max, not sure if the code supports any more. - -struct MapTileBitFlagStair -{ - /* 0x0 */ u8 tileFlags; - /* 0x1 */ bool8 stairs; -}; - struct MapTile { - // TODO: can we get rid of the union... is tileFlags a u16 only? - union MapTileUnion - { - struct MapTileBitFlagStair unk0; - u16 tileFlags_u16; - } MapTileUnion; + // Uses the TileType bit flags. + /* 0x0 */ u16 tileType; + u8 fill2[0x4 - 0x2]; u16 unk4; u16 unk6; u8 unk8; @@ -52,9 +42,10 @@ struct RoomExit s16 y; }; -enum TileFlag +enum TileType { TILE_TYPE_FLOOR = 1 << 0, + TILE_TYPE_UNK_1 = 1 << 1, TILE_TYPE_LIQUID = 1 << 2, // Water or lava depending on the dungeon. TILE_TYPE_ROOM_EXIT = 1 << 3, TILE_TYPE_MAP_EDGE = 1 << 4, |