From 96372eb336d21e5da66246983e0522212f370bdf Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 12:51:18 -0500 Subject: Decomped CanUseOnSelfWithStatusChecker() --- include/constants/weather.h | 2 +- include/dungeon_entity.h | 3 +++ include/status_checker.h | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 include/status_checker.h (limited to 'include') diff --git a/include/constants/weather.h b/include/constants/weather.h index e7225b9..2a8cf42 100644 --- a/include/constants/weather.h +++ b/include/constants/weather.h @@ -4,7 +4,7 @@ #define WEATHER_CLEAR 0 #define WEATHER_SUNNY 1 #define WEATHER_SANDSTORM 2 -#define WEATHER_CLOUDY` 3 +#define WEATHER_CLOUDY 3 #define WEATHER_RAIN 4 #define WEATHER_HAIL 5 #define WEATHER_FOG 6 diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index 9e9f1f7..2567f79 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -6,6 +6,9 @@ #include "item.h" #include "position.h" +#define MAX_STAT_STAGE 20 +#define MAX_MOVEMENT_SPEED 4 +#define MAX_STOCKPILE_COUNT 3 #define NUM_SPEED_TURN_COUNTERS 5 struct DungeonActionContainer diff --git a/include/status_checker.h b/include/status_checker.h new file mode 100644 index 0000000..1b65030 --- /dev/null +++ b/include/status_checker.h @@ -0,0 +1,10 @@ +#ifndef GUARD_STATUS_CHECKER_H +#define GUARD_STATUS_CHECKER_H + +#include "constants/move.h" +#include "dungeon_entity.h" + +// 0x5C498 +bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move); + +#endif -- cgit v1.2.3 From 60a19d681cda14c4ebeab5d18a98e3b07a5e93a3 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 21:59:07 -0500 Subject: Decomped GetMapTile_2 --- include/dungeon_global_data.h | 2 +- include/dungeon_map_access.h | 9 ++++++++- include/dungeon_util.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dungeon_global_data.h b/include/dungeon_global_data.h index 948603e..74e052e 100644 --- a/include/dungeon_global_data.h +++ b/include/dungeon_global_data.h @@ -71,7 +71,7 @@ struct DungeonGlobalData /* 0xE277 */ u8 mudSportTurnsLeft; /* 0xE278 */ u8 waterSportTurnsLeft; u8 fillE279[0xE8C0 - 0xE279]; - /* 0xE8C0 */ struct MapTile* mapEntityPointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; + /* 0xE8C0 */ struct MapTile* mapTilePointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; u8 fill104C0[0x104C4 - 0x104C0]; /* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT]; u8 fill10764[0x10844 - 0x10764]; diff --git a/include/dungeon_map_access.h b/include/dungeon_map_access.h index 5e4e3da..c715483 100644 --- a/include/dungeon_map_access.h +++ b/include/dungeon_map_access.h @@ -3,7 +3,14 @@ #include "map.h" +struct unkStruct_202F190 +{ + struct MapTile* unk0[6]; +}; + // 0x4954C -struct MapTile* GetMapTileAtPosition(s32 x, s32 y); +struct MapTile* GetMapTile_1(s32 x, s32 y); +// 0x49590 +struct MapTile* GetMapTile_2(s32 x, s32 y); #endif diff --git a/include/dungeon_util.h b/include/dungeon_util.h index 4d91b29..b32b85d 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -15,6 +15,6 @@ u32 GetEntityType(struct DungeonEntity *entity); struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity); // 0x45108 struct ItemSlot *GetItemData(struct DungeonEntity *entity); -struct MapTile *GetMapEntityForDungeonEntity(struct DungeonEntity *entity); +struct MapTile *GetMapTileForDungeonEntity_2(struct DungeonEntity *entity); #endif -- cgit v1.2.3 From e54b3427db443f40cc07da650f64c1573ae0d4a0 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 22:12:40 -0500 Subject: Decomped IsBossBattle() --- include/dungeon_engine.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/dungeon_engine.h b/include/dungeon_engine.h index f987b11..d2be40b 100644 --- a/include/dungeon_engine.h +++ b/include/dungeon_engine.h @@ -1,6 +1,8 @@ #ifndef GUARD_DUNGEON_ENGINE_H #define GUARD_DUNGEON_ENGINE_H +// 0x441BC +bool8 IsBossBattle(); // 0x441E8 bool8 IsFixedDungeon(); -- cgit v1.2.3 From 7c714bd14e68ee9528512108e8b2cbd7f9da46c7 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 22:30:05 -0500 Subject: Decomped GetWeather() --- include/weather.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 include/weather.h (limited to 'include') diff --git a/include/weather.h b/include/weather.h new file mode 100644 index 0000000..b7fa725 --- /dev/null +++ b/include/weather.h @@ -0,0 +1,9 @@ +#ifndef GUARD_WEATHER_H +#define GUARD_WEATHER_H + +#include "dungeon_entity.h" + +// 0x7E580 +u8 GetWeather(struct DungeonEntity* pokemon); + +#endif -- cgit v1.2.3 From ec6abc684ebc571fc186ca61f1410770ea17fa14 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 22:51:36 -0500 Subject: Decomped HasQuarterHPOrLess --- include/status_checks_1.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/status_checks_1.h b/include/status_checks_1.h index 486adb2..a90bdb0 100644 --- a/include/status_checks_1.h +++ b/include/status_checks_1.h @@ -7,5 +7,7 @@ bool8 HasNegativeStatus(struct DungeonEntity *pokemon); // 0x70B28 bool8 IsSleeping(struct DungeonEntity *pokemon); +// 0x70B48 +bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon); #endif -- cgit v1.2.3 From 4aafa434a61c07b70e6bc2364ab6f63c7e2c4169 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 23:43:06 -0500 Subject: Decomped IsTileGround() --- include/tile_types.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 include/tile_types.h (limited to 'include') diff --git a/include/tile_types.h b/include/tile_types.h new file mode 100644 index 0000000..2096201 --- /dev/null +++ b/include/tile_types.h @@ -0,0 +1,13 @@ +#ifndef GUARD_TILE_TYPES_H +#define GUARD_TILE_TYPES_H + +#include "map.h" + +#define DUNGEON_WATER_TYPE_NONE 0 +#define DUNGEON_WATER_TYPE_LAVA 1 +#define DUNGEON_WATER_TYPE_WATER 2 + +// 0x4AF20 +bool8 IsTileGround(struct MapTile* tile); + +#endif -- cgit v1.2.3 From 07795b6ff619c30426ad279ef840842ef3dea2ac Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 20 Feb 2022 23:59:57 -0500 Subject: Decomped IsWaterTileset() --- include/tile_types.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/tile_types.h b/include/tile_types.h index 2096201..f1bc412 100644 --- a/include/tile_types.h +++ b/include/tile_types.h @@ -9,5 +9,7 @@ // 0x4AF20 bool8 IsTileGround(struct MapTile* tile); +// 0x4AF74 +bool8 IsWaterTileset(); #endif -- cgit v1.2.3 From 33d2d6175067e75cd222b8f05234221ec2d2b82b Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 21 Feb 2022 15:40:12 -0500 Subject: Decomped CanLayTrap() --- include/trap.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 include/trap.h (limited to 'include') diff --git a/include/trap.h b/include/trap.h new file mode 100644 index 0000000..49a5216 --- /dev/null +++ b/include/trap.h @@ -0,0 +1,9 @@ +#ifndef GUARD_TRAP_H +#define GUARD_TRAP_H + +#include "position.h" + +// 0x4AF74 +bool8 CanLayTrap(struct Position *pos); + +#endif -- cgit v1.2.3 From 598a588589cb581b269f2e46373c657ec897a3a3 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 21 Feb 2022 15:59:34 -0500 Subject: Decomped CanAttackInFront() --- include/dungeon_ai.h | 11 ----------- include/dungeon_ai_1.h | 9 --------- include/dungeon_ai_targeting.h | 9 +++++++++ include/dungeon_ai_targeting_1.h | 11 +++++++++++ include/dungeon_ai_targeting_2.h | 9 +++++++++ 5 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 include/dungeon_ai.h delete mode 100644 include/dungeon_ai_1.h create mode 100644 include/dungeon_ai_targeting.h create mode 100644 include/dungeon_ai_targeting_1.h create mode 100644 include/dungeon_ai_targeting_2.h (limited to 'include') diff --git a/include/dungeon_ai.h b/include/dungeon_ai.h deleted file mode 100644 index e3f7a37..0000000 --- a/include/dungeon_ai.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GUARD_DUNGEON_AI_H -#define GUARD_DUNGEON_AI_H - -#include "dungeon_entity.h" - -// 0x71494 -bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon); -// 0x71518 -bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect); - -#endif diff --git a/include/dungeon_ai_1.h b/include/dungeon_ai_1.h deleted file mode 100644 index dace65a..0000000 --- a/include/dungeon_ai_1.h +++ /dev/null @@ -1,9 +0,0 @@ -#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_ai_targeting.h b/include/dungeon_ai_targeting.h new file mode 100644 index 0000000..945c490 --- /dev/null +++ b/include/dungeon_ai_targeting.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_AI_TARGETING_H +#define GUARD_DUNGEON_AI_TARGETING_H + +#include "dungeon_entity.h" + +// 0x71138 +bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction); + +#endif diff --git a/include/dungeon_ai_targeting_1.h b/include/dungeon_ai_targeting_1.h new file mode 100644 index 0000000..49b700f --- /dev/null +++ b/include/dungeon_ai_targeting_1.h @@ -0,0 +1,11 @@ +#ifndef GUARD_DUNGEON_AI_TARGETING_1_H +#define GUARD_DUNGEON_AI_TARGETING_1_H + +#include "dungeon_entity.h" + +// 0x71494 +bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon); +// 0x71518 +bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect); + +#endif diff --git a/include/dungeon_ai_targeting_2.h b/include/dungeon_ai_targeting_2.h new file mode 100644 index 0000000..c314646 --- /dev/null +++ b/include/dungeon_ai_targeting_2.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_AI_TARGETING_2_H +#define GUARD_DUNGEON_AI_TARGETING_2_H + +#include "dungeon_entity.h" + +// 0x71598 +u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified); + +#endif -- cgit v1.2.3 From 40a34fafd685b7df6d1777ec335374ea081adad0 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Tue, 22 Feb 2022 22:38:57 -0500 Subject: Decomped WeightMoveIfUsable() --- include/dungeon_ai_attack_1.h | 4 ++-- include/dungeon_ai_attack_2.h | 9 +++++++++ include/moves.h | 2 +- include/targeting_flags.h | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 include/dungeon_ai_attack_2.h (limited to 'include') diff --git a/include/dungeon_ai_attack_1.h b/include/dungeon_ai_attack_1.h index 89a1f0d..19969f2 100644 --- a/include/dungeon_ai_attack_1.h +++ b/include/dungeon_ai_attack_1.h @@ -3,7 +3,7 @@ #include "dungeon_entity.h" -// 0x7C9F8 -bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange); +// 0x7C580 +s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, u32 hasStatusChecker); #endif diff --git a/include/dungeon_ai_attack_2.h b/include/dungeon_ai_attack_2.h new file mode 100644 index 0000000..00711b6 --- /dev/null +++ b/include/dungeon_ai_attack_2.h @@ -0,0 +1,9 @@ +#ifndef GUARD_DUNGEON_AI_ATTACK_2_H +#define GUARD_DUNGEON_AI_ATTACK_2_H + +#include "dungeon_entity.h" + +// 0x7C9F8 +bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange); + +#endif diff --git a/include/moves.h b/include/moves.h index 22f7ba6..ad68320 100644 --- a/include/moves.h +++ b/include/moves.h @@ -6,7 +6,7 @@ // 0x92A88 void InitPokemonMove(struct PokemonMove *move, u16 moveID); // 0x92AE0 -s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 isAI); +s16 GetMoveTargetingFlags(struct PokemonMove *move, bool32 isAI); u8 GetMoveType(struct PokemonMove *move); // 0x92B90 u8 GetMoveWeight(struct PokemonMove *move); diff --git a/include/targeting_flags.h b/include/targeting_flags.h index 54e7063..d7d4737 100644 --- a/include/targeting_flags.h +++ b/include/targeting_flags.h @@ -5,6 +5,6 @@ #include "dungeon_entity.h" // 0x7CD64 -s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, u32 isAI); +s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, bool32 isAI); #endif -- cgit v1.2.3 From 6e56b9f0341be0a6c960ea9e8db0939e4fa3cdac Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 24 Feb 2022 23:38:21 -0500 Subject: Decomped CanUseStatusMove() --- include/constants/move.h | 18 ++++++++++++++---- include/dungeon_ai_attack_1.h | 2 ++ include/moves.h | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/constants/move.h b/include/constants/move.h index 15ae1b9..0601969 100644 --- a/include/constants/move.h +++ b/include/constants/move.h @@ -11,6 +11,18 @@ enum MoveFlags MOVE_FLAG_DISABLED = 1 << 5 // Disabled by an effect like Taunt. }; +enum AccuracyType +{ + // Accuracy used for all moves. + ACCURACY_TYPE_GLOBAL, + // Multiplied with the global accuracy for offensive moves (i.e., not status moves). + ACCURACY_TYPE_OFFENSIVE, + // Used by the AI to determine how often to use Spikes. + // Values exist for all other moves, though they seem to be unused. + ACCURACY_TYPE_USE_CHANCE, + NUM_ACCURACY_TYPES +}; + struct MoveData { u8 *namePointer; @@ -22,10 +34,8 @@ struct MoveData // The AI consider certain moves to have different range than they actually do. /* 0xC */ u8 maxPP; /* 0xD */ u8 weight; - /* 0xE */ u8 accuracy[2]; - // Used by the AI to determine how often to use Spikes. - // Values exist for all other moves, though they seem to be unused. - /* 0x10 */ u8 useChance; + // There are multiple accuracy values. These are define with the AccuracyType enum. + /* 0xE */ u8 accuracy[NUM_ACCURACY_TYPES]; /* 0x11 */ u8 hitCount; // Maximum number of times the move will hit. Used for multi-hit moves like Fury Attack. u8 unk12; /* 0x13 */ u8 criticalHitChance; diff --git a/include/dungeon_ai_attack_1.h b/include/dungeon_ai_attack_1.h index 19969f2..7272256 100644 --- a/include/dungeon_ai_attack_1.h +++ b/include/dungeon_ai_attack_1.h @@ -5,5 +5,7 @@ // 0x7C580 s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, u32 hasStatusChecker); +// 0x7C648 +bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker); #endif diff --git a/include/moves.h b/include/moves.h index ad68320..3bf4344 100644 --- a/include/moves.h +++ b/include/moves.h @@ -11,6 +11,8 @@ u8 GetMoveType(struct PokemonMove *move); // 0x92B90 u8 GetMoveWeight(struct PokemonMove *move); s32 GetMovePower(struct PokemonMove *move); +// 0x92BD8 +s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType); // 0x92BF4 u32 GetMoveMaxPP(struct PokemonMove *move); // 0x92C54 -- cgit v1.2.3