From 40ed4086e7f94bb8ccb70b2d62b29a3e103d34ba Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 31 Oct 2025 10:53:14 +0100 Subject: [PATCH] Start Blue/Sky based clean-up --- include/dungeon_8041AD0.h | 19 +++-- include/move_orb_actions_1.h | 7 +- include/move_orb_actions_2.h | 5 +- include/move_orb_actions_3.h | 3 +- include/move_orb_actions_4.h | 3 +- include/move_orb_effects_1.h | 17 ++-- include/structs/dungeon_entity.h | 10 --- include/structs/str_dungeon.h | 2 - include/structs/str_stat_index.h | 15 ++++ src/dungeon_8041AD0.c | 36 ++++---- src/dungeon_move.c | 23 +++--- src/move_checks.c | 65 +++++++-------- src/move_orb_actions_1.c | 46 ++++------- src/move_orb_actions_2.c | 14 ++-- src/move_orb_actions_3.c | 13 ++- src/move_orb_actions_4.c | 9 +- src/move_orb_effects_1.c | 137 ++++++++++++++++--------------- 17 files changed, 204 insertions(+), 220 deletions(-) create mode 100644 include/structs/str_stat_index.h diff --git a/include/dungeon_8041AD0.h b/include/dungeon_8041AD0.h index 7a7bf5455..5cf66999f 100644 --- a/include/dungeon_8041AD0.h +++ b/include/dungeon_8041AD0.h @@ -3,6 +3,7 @@ #include "structs/dungeon_entity.h" #include "structs/str_damage.h" +#include "structs/str_stat_index.h" s32 sub_80416E0(PixelPos *pos, u32 param_2, bool8 param_3); void sub_804178C(u8 param_1); @@ -93,15 +94,15 @@ void sub_8041EE8(Entity *pokemon); void sub_8041EF8(Entity *pokemon); void sub_8041F08(Entity *pokemon); void nullsub_90(Entity *pokemon); -void sub_8041F28(Entity *pokemon, u32 r1); -void sub_8041F4C(Entity *pokemon, u32 r1); -void sub_8041F70(Entity *pokemon, u32 r1); -void sub_8041F94(Entity *pokemon, u32 r1); -void sub_8041FB4(Entity *pokemon, u32 r1); -void sub_8041FD8(Entity *pokemon, u32 r1); -void sub_8041FFC(Entity *pokemon, u32 r1); -void sub_804201C(Entity *pokemon, u32 r1); -void sub_8042040(Entity *pokemon, u32 r1); +void sub_8041F28(Entity *pokemon, struct StatIndex stat); +void sub_8041F4C(Entity *pokemon, struct StatIndex stat); +void sub_8041F70(Entity *pokemon, struct StatIndex stat); +void sub_8041F94(Entity *pokemon, struct StatIndex stat); +void sub_8041FB4(Entity *pokemon, struct StatIndex stat); +void sub_8041FD8(Entity *pokemon, struct StatIndex stat); +void sub_8041FFC(Entity *pokemon, struct StatIndex stat); +void sub_804201C(Entity *pokemon, struct StatIndex stat); +void sub_8042040(Entity *pokemon, struct StatIndex stat); void sub_8042060(Entity *pokemon, u32 r1); void sub_8042080(Entity *pokemon, u32 r1); void sub_80420A0(Entity *pokemon); diff --git a/include/move_orb_actions_1.h b/include/move_orb_actions_1.h index 0dae4dc0c..1eedd7d1e 100644 --- a/include/move_orb_actions_1.h +++ b/include/move_orb_actions_1.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_1_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 sub_805768C(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -27,7 +28,7 @@ bool8 SwaggerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 SnoreMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId); bool8 ScreechMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 RockSlideMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId); -bool32 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); +bool8 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); bool8 FakeTearsMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId); bool8 SpiteMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId); @@ -79,7 +80,7 @@ bool8 RapidSpinMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 SureShotMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 CosmicPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -extern const s32 gStatIndexAtkDef; -extern const s32 gStatIndexSpecial; +extern const struct StatIndex gStatIndexAtkDef; +extern const struct StatIndex gStatIndexSpecial; #endif /* ifndef GUARD_MOVE_ORB_ACTIONS_1_H */ diff --git a/include/move_orb_actions_2.h b/include/move_orb_actions_2.h index 46fa2a15a..393bd92f5 100644 --- a/include/move_orb_actions_2.h +++ b/include/move_orb_actions_2.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_2_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 SkyAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 BasicIceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -32,7 +33,7 @@ bool8 BlockMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 PoisonGasMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 ToxicMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 PoisonFangMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); +bool8 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 UproarMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 SandstormMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 Conversion2MoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -42,7 +43,7 @@ bool8 SketchMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 NaturePowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HelpingHandMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 EndureMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5); +bool8 DamageLowerDefMoveAction(Entity *pokemon, Entity *target, Move *move, struct StatIndex stat, u32 param_5); bool8 SonicboomMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 SelfDestructMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 ExplosionMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_actions_3.h b/include/move_orb_actions_3.h index 29a67736f..d64b2c6b4 100644 --- a/include/move_orb_actions_3.h +++ b/include/move_orb_actions_3.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_3_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 PoisonStingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 TriAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -41,7 +42,7 @@ bool8 SunnyDayMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 BellyDrumMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HiJumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId,u8 param_5); bool8 JumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId,u8 param_5); -bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5); +bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, struct StatIndex stat, u32 param_5); bool8 BulkUpMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 AmnesiaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HandleColorChange(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_actions_4.h b/include/move_orb_actions_4.h index 0ee9f29c5..3dd74248e 100644 --- a/include/move_orb_actions_4.h +++ b/include/move_orb_actions_4.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_4_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 DreamEaterMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 sub_805B734(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -50,7 +51,7 @@ bool8 AttractMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 MimicMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 FrustrationMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 LeechSeedMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool8 MetalClawMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId, s32 param_5); +bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, struct StatIndex stat, s32 param_5); bool8 InvisifyOrbAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 CalmMindMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 DefenseCurlMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_effects_1.h b/include/move_orb_effects_1.h index a2b6d9387..08d5fe3fe 100644 --- a/include/move_orb_effects_1.h +++ b/include/move_orb_effects_1.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_EFFECTS_1_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" #include "number_util.h" #define FLASH_FIRE_STATUS_NONE 0 @@ -27,16 +28,16 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target); void WrapTarget(Entity * pokemon, Entity * target); void sub_8076CB4(s32 param_1); void PetrifiedStatusTarget(Entity * pokemon, Entity * target); -void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage); -void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage); -void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment); -void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment); +void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 decrement, u8 param_5, bool8 displayMessage); +void LowerDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected); +void RaiseAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment); +void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment); u8 GetFlashFireStatus(Entity *pokemon); void UpdateFlashFireBoost(Entity * pokemon, Entity *target); -void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage); -void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage); -void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage); -void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, bool8 displayMessage); +void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, struct StatIndex stat, s24_8 param_4, bool8 displayMessage); +void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, struct StatIndex stat, s24_8 param_4, bool8 displayMessage); +void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat); +void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, bool8 displayMessage); void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage); void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage); void RaiseMovementSpeedTarget(Entity * pokemon, Entity * target, s32 turns, bool8 diplayMessage); diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 5d73c3715..6231b5bc9 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -21,13 +21,6 @@ #define NUM_SPEED_COUNTERS 5 #define NUM_PREV_POS 4 -#define STAT_STAGE_ATK 0 -#define STAT_STAGE_SP_ATK 1 -#define STAT_STAGE_DEF 0 -#define STAT_STAGE_SP_DEF 1 -#define STAT_STAGE_ACCURACY 0 -#define STAT_STAGE_EVASION 1 - // size: 0x8 typedef struct ActionParameter { @@ -237,12 +230,10 @@ typedef struct EntityInfo /* 0x8C */ IqSkillFlags IQSkillMenuFlags; // IQ skills selected in the IQ skills menu. /* 0x90 */ IqSkillFlags IQSkillFlags; /* 0x94 */ u8 tactic; - u8 fill95[0x98 - 0x95]; /* 0x98 */ u32 dungeonSpriteId; /* 0x9C */ u32 unk9C; /* 0xA0 */ s32 unkA0; /* 0xA4 */ u8 monsterBehavior; - u8 fillA5[0xA8 - 0xA5]; // Statuses are split into groups based on which ones can't overlap. // See status.h for which statuses are in each group. /* 0xA8 */ SleepClassStatus sleepClassStatus; @@ -299,7 +290,6 @@ typedef struct EntityInfo /* 0x14A */ u8 unk14A; /* 0x14B */ u8 unk14B; /* 0x14C */ u8 unk14C; - /* 0x14D */ u8 unk14D; /* 0x14E */ u16 visualFlags; /* 0x150 */ u16 previousVisualFlags; /* 0x152 */ u8 unk152; diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 62ae80c98..d81270463 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -452,11 +452,9 @@ typedef struct Dungeon u8 unk1356C; u8 fill1356D[0x13570 - 0x1356D]; /* 0x13570 */ u8 unk13570; - u8 fill13571[0x13574 - 0x13571]; /* 0x13574 */ DungeonPos trapPos; /* 0x13578 */ u8 trapID; /* 0x13579 */ u8 unk13579; - u8 fill1357A[0x1357C - 0x1357A]; /* 0x1357C */ Entity *teamPokemon[MAX_TEAM_MEMBERS]; /* 0x1358C */ Entity *wildPokemon[DUNGEON_MAX_WILD_POKEMON]; /* 0x135CC */ Entity *activePokemon[DUNGEON_MAX_POKEMON]; // Contains both team and wild Pokémon diff --git a/include/structs/str_stat_index.h b/include/structs/str_stat_index.h new file mode 100644 index 000000000..3e8d5bcc2 --- /dev/null +++ b/include/structs/str_stat_index.h @@ -0,0 +1,15 @@ +#ifndef GUARD_STR_STAT_INDEX_X +#define GUARD_STR_STAT_INDEX_X + +#define STAT_INDEX_PHYSICAL 0 // Atk, Def +#define STAT_INDEX_SPECIAL 1 // Sp Atk, Sp Def +#define STAT_INDEX_ACCURACY STAT_INDEX_PHYSICAL +#define STAT_INDEX_EVASION STAT_INDEX_SPECIAL + +// Needed to match in Blue/Sky. I wonder what was the reason for making it a struct as opposed to a simple int... +struct StatIndex +{ + int id; +}; + +#endif // GUARD_STR_STAT_INDEX_X diff --git a/src/dungeon_8041AD0.c b/src/dungeon_8041AD0.c index fa893285d..9c595490c 100644 --- a/src/dungeon_8041AD0.c +++ b/src/dungeon_8041AD0.c @@ -840,9 +840,9 @@ void nullsub_90(Entity *pokemon) { } -void sub_8041F28(Entity *pokemon, u32 r1) +void sub_8041F28(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xCA << 1, 1); } @@ -852,9 +852,9 @@ void sub_8041F28(Entity *pokemon, u32 r1) } } -void sub_8041F4C(Entity *pokemon, u32 r1) +void sub_8041F4C(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x18f, 1); } @@ -864,9 +864,9 @@ void sub_8041F4C(Entity *pokemon, u32 r1) } } -void sub_8041F70(Entity *pokemon, u32 r1) +void sub_8041F70(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x1a9, 1); } @@ -876,9 +876,9 @@ void sub_8041F70(Entity *pokemon, u32 r1) } } -void sub_8041F94(Entity *pokemon, u32 r1) +void sub_8041F94(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xC7 << 1, 1); } @@ -888,9 +888,9 @@ void sub_8041F94(Entity *pokemon, u32 r1) } } -void sub_8041FB4(Entity *pokemon, u32 r1) +void sub_8041FB4(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x1a9, 1); } @@ -900,9 +900,9 @@ void sub_8041FB4(Entity *pokemon, u32 r1) } } -void sub_8041FD8(Entity *pokemon, u32 r1) +void sub_8041FD8(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xCA << 1, 1); } @@ -912,9 +912,9 @@ void sub_8041FD8(Entity *pokemon, u32 r1) } } -void sub_8041FFC(Entity *pokemon, u32 r1) +void sub_8041FFC(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xC7 << 1, 1); } @@ -924,9 +924,9 @@ void sub_8041FFC(Entity *pokemon, u32 r1) } } -void sub_804201C(Entity *pokemon, u32 r1) +void sub_804201C(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x18f, 1); } @@ -936,9 +936,9 @@ void sub_804201C(Entity *pokemon, u32 r1) } } -void sub_8042040(Entity *pokemon, u32 r1) +void sub_8042040(Entity *pokemon, struct StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_ACCURACY) { sub_804151C(pokemon, 0xC6 << 1, 1); } diff --git a/src/dungeon_move.c b/src/dungeon_move.c index decdf3a18..d28282c2d 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -70,9 +70,9 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, Entity *currTargetSaved; Entity *currTarget; EntityInfo *targetInfo; - bool32 moveHits; - bool32 lightRodRedirect; - bool32 moveRedirected; + bool8 moveHits; + bool8 lightRodRedirect; + bool8 moveRedirected; moveId = move->id; for (i = 0; i < MAX_MOVE_TARGETS; i++) { @@ -86,7 +86,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, if (!EntityIsValid(attacker)) break; if (EntityIsValid(currTarget)) { - bool32 r4; + bool8 r4; bool8 moveHadEffect; originalAttacker = attacker; @@ -188,10 +188,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, } sub_806A1E8(currTarget); TrySendImmobilizeSleepEndMsg(attacker, currTarget); - r4 = FALSE; - if (!MoveMatchesBideClassStatus(attacker, move)) { - r4 = (MoveRequiresCharging(attacker, move->id) != 0); - } + r4 = (!MoveMatchesBideClassStatus(attacker, move) && MoveRequiresCharging(attacker, move->id)); if (!lightRodRedirect) { if (targetInfo->reflectClassStatus.status == STATUS_MAGIC_COAT) { @@ -275,7 +272,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, SetMessageArgument_2(gFormatBuffer_Monsters[1], GetEntInfo(currTarget), 0); // Interesting that these 3 strings are the same. Curious if that's the case in Blue/Europe versions. if (attacker == currTarget) { - TryDisplayDungeonLoggableMessage3(attacker, attacker, gUnknown_80F9380); // The move missed + TryDisplayDungeonLoggableMessage3(attacker, currTarget, gUnknown_80F9380); // The move missed } else if (GetTreatmentBetweenMonsters(attacker, currTarget, TRUE, FALSE) == 0) { TryDisplayDungeonLoggableMessage3(attacker, currTarget, gUnknown_80F9384); // The move missed @@ -304,9 +301,9 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, break; // breaks out of the loop } else { - s32 expMultiplierBeforeMove = targetInfo->expMultiplier; + u32 expMultiplierBeforeMove = targetInfo->expMultiplier; if (targetInfo->isNotTeamMember) { - if (move->id != MOVE_REGULAR_ATTACK && itemId == 0 && expMultiplierBeforeMove == EXP_HALVED) { + if (move->id != MOVE_REGULAR_ATTACK && itemId == 0 && expMultiplierBeforeMove < EXP_REGULAR) { targetInfo->expMultiplier = EXP_REGULAR; } if (isLinkedMove == TRUE) { @@ -474,10 +471,10 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, moveHadEffect = PoisonStingMoveAction(attacker, currTarget, move, itemId); break; case MOVE_PSYCHIC: - moveHadEffect = sub_8058C98(attacker, currTarget, move, gStatIndexSpecial, itemId); + moveHadEffect = DamageLowerDefMoveAction(attacker, currTarget, move, gStatIndexSpecial, itemId); break; case MOVE_ACID: - moveHadEffect = sub_8058C98(attacker, currTarget, move, gStatIndexAtkDef, itemId); + moveHadEffect = DamageLowerDefMoveAction(attacker, currTarget, move, gStatIndexAtkDef, itemId); break; case MOVE_METAL_CLAW: moveHadEffect = MetalClawMoveAction(attacker, currTarget, move, gStatIndexAtkDef, itemId); diff --git a/src/move_checks.c b/src/move_checks.c index 71fce7cfc..ec9d1659c 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -17,6 +17,7 @@ #include "trap.h" #include "weather.h" #include "dungeon_config.h" +#include "structs/str_stat_index.h" bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) { @@ -51,13 +52,13 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) case MOVE_HOWL: case MOVE_MEDITATE: case MOVE_SHARPEN: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_BELLY_DRUM: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE || FixedPointToInt(pokemonInfo->belly) <= 0) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE || FixedPointToInt(pokemonInfo->belly) <= 0) { return FALSE; } @@ -68,13 +69,13 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) case MOVE_HARDEN: case MOVE_IRON_DEFENSE: case MOVE_WITHDRAW: - if (pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_AMNESIA: - if (pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -100,7 +101,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_COSMIC_POWER: - if (pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -130,7 +131,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_MINIMIZE: - if (pokemonInfo->hitChanceStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) + if (pokemonInfo->hitChanceStages[STAT_INDEX_EVASION] >= MAX_STAT_STAGE) { return FALSE; } @@ -161,7 +162,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_BULK_UP: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -173,7 +174,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_TAIL_GLOW: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -197,7 +198,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_DRAGON_DANCE: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && GetEntInfo(pokemon)->speedStage >= MAX_SPEED_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && GetEntInfo(pokemon)->speedStage >= MAX_SPEED_STAGE) { return FALSE; } @@ -327,19 +328,19 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_DOUBLE_TEAM: - if (pokemonInfo->hitChanceStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) + if (pokemonInfo->hitChanceStages[STAT_INDEX_EVASION] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_GROWTH: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_SWORDS_DANCE: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -363,7 +364,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_CALM_MIND: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -405,11 +406,11 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) Entity *target = gDungeon->wildPokemon[i]; if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { continue; } - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_SP_ATK] < MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_SPECIAL] < MAX_STAT_STAGE) { break; } @@ -429,11 +430,11 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) Entity *target = gDungeon->teamPokemon[i]; if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { continue; } - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_SP_ATK] < MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_SPECIAL] < MAX_STAT_STAGE) { break; } @@ -488,13 +489,13 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_SWEET_SCENT: - if (targetData->hitChanceStages[STAT_STAGE_EVASION] <= 0) + if (targetData->hitChanceStages[STAT_INDEX_EVASION] <= 0) { return FALSE; } break; case MOVE_CHARM: - if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } @@ -536,13 +537,13 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_SCREECH: - if (F248LessThanFloat(targetData->defensiveMultipliers[STAT_STAGE_DEF], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->defensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } break; case MOVE_FAKE_TEARS: - if (targetData->defensiveStages[STAT_STAGE_SP_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_SPECIAL] <= 0) { return FALSE; } @@ -560,8 +561,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_MEMENTO: - if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD) && - F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_SP_ATK], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD) && + F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_SPECIAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } @@ -581,7 +582,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; } } - if (targetData->hitChanceStages[STAT_STAGE_EVASION] <= DEFAULT_STAT_STAGE) + if (targetData->hitChanceStages[STAT_INDEX_EVASION] <= DEFAULT_STAT_STAGE) { return FALSE; } @@ -603,20 +604,20 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; case MOVE_LEER: case MOVE_TAIL_WHIP: - if (targetData->defensiveStages[STAT_STAGE_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } break; case MOVE_METAL_SOUND: - if (targetData->defensiveStages[STAT_STAGE_SP_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_SPECIAL] <= 0) { return FALSE; } break; case MOVE_TICKLE: - if (targetData->offensiveStages[STAT_STAGE_ATK] <= 0 && - targetData->defensiveStages[STAT_STAGE_DEF] <= 0) + if (targetData->offensiveStages[STAT_INDEX_PHYSICAL] <= 0 && + targetData->defensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } @@ -676,7 +677,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) case MOVE_FLASH: case MOVE_KINESIS: case MOVE_SAND_ATTACK: - if (targetData->hitChanceStages[STAT_STAGE_ACCURACY] <= 0) + if (targetData->hitChanceStages[STAT_INDEX_ACCURACY] <= 0) { return FALSE; } @@ -702,7 +703,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; case MOVE_FEATHERDANCE: case MOVE_GROWL: - if (targetData->offensiveStages[STAT_STAGE_ATK] <= 0) + if (targetData->offensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } @@ -724,8 +725,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } else { - if (userData->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && - userData->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (userData->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && + userData->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } diff --git a/src/move_orb_actions_1.c b/src/move_orb_actions_1.c index 872e358f0..d6332b355 100644 --- a/src/move_orb_actions_1.c +++ b/src/move_orb_actions_1.c @@ -38,6 +38,9 @@ #include "move_orb_effects_4.h" #include "move_orb_effects_5.h" +const struct StatIndex gStatIndexAtkDef = {.id = STAT_INDEX_PHYSICAL}; +const struct StatIndex gStatIndexSpecial = {.id = STAT_INDEX_SPECIAL}; + bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { bool8 flag; @@ -52,7 +55,9 @@ bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId return flag; } -static const s24_8 sRolloutModifiers[]; +static const s24_8 sRolloutModifiers[] = { + IntToF248_2(1.0), IntToF248_2(1.0), IntToF248_2(1.5), IntToF248_2(2.0), IntToF248_2(2.5), IntToF248_2(3.0), IntToF248_2(3.5), IntToF248_2(4.0), IntToF248_2(4.5), IntToF248_2(5.0) +}; bool8 sub_805768C(Entity *pokemon, Entity *target, Move *move, s32 itemId) { @@ -338,18 +343,10 @@ bool8 RockSlideMoveAction(Entity *pokemon, Entity *target, Move * move, s32 item return flag; } -bool32 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) +bool8 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) { - u32 weather; - s32 flag; - - weather = GetApparentWeather(pokemon); - flag = sub_80556BC(pokemon,target,gWeatherBallTypes[weather],move, - gWeatherBallModifiers[weather],itemId); - if (flag) { - flag = TRUE; - } - return flag; + u32 weather = GetApparentWeather(pokemon); + return (sub_80556BC(pokemon,target,gWeatherBallTypes[weather],move,gWeatherBallModifiers[weather],itemId) != 0); } bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) @@ -886,9 +883,8 @@ bool8 MetalSoundMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 TickleMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - s32 index = gStatIndexAtkDef; - LowerAttackStageTarget(pokemon, target, index, 1, 1, TRUE); - LowerDefenseStageTarget(pokemon, target, index, 1, 1, TRUE); + LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); + LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); return TRUE; } @@ -933,8 +929,6 @@ bool8 AncientPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it { bool8 flag = FALSE; EntityInfo *entityInfo; - s32 index1; - s32 index2; if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { flag = TRUE; @@ -942,12 +936,10 @@ bool8 AncientPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it { entityInfo = GetEntInfo(pokemon); RaiseMovementSpeedTarget(pokemon, pokemon, 0, TRUE); - index1 = gStatIndexAtkDef; - RaiseAttackStageTarget(pokemon, pokemon, index1, 1); - index2 = gStatIndexSpecial; - RaiseAttackStageTarget(pokemon, pokemon, index2, 1); - RaiseDefenseStageTarget(pokemon, pokemon, index1, 1); - RaiseDefenseStageTarget(pokemon, pokemon, index2, 1); + RaiseAttackStageTarget(pokemon, pokemon, gStatIndexAtkDef, 1); + RaiseAttackStageTarget(pokemon, pokemon, gStatIndexSpecial, 1); + RaiseDefenseStageTarget(pokemon, pokemon, gStatIndexAtkDef, 1); + RaiseDefenseStageTarget(pokemon, pokemon, gStatIndexSpecial, 1); SetExpMultplier(entityInfo); } } @@ -992,11 +984,3 @@ bool8 CosmicPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite RaiseDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1); return TRUE; } - -// Put all the way below for matching. -const s32 gStatIndexAtkDef = 0; -const s32 gStatIndexSpecial = 1; - -static const s24_8 sRolloutModifiers[] = { - IntToF248_2(1.0), IntToF248_2(1.0), IntToF248_2(1.5), IntToF248_2(2.0), IntToF248_2(2.5), IntToF248_2(3.0), IntToF248_2(3.5), IntToF248_2(4.0), IntToF248_2(4.5), IntToF248_2(5.0) -}; diff --git a/src/move_orb_actions_2.c b/src/move_orb_actions_2.c index 3e16b214d..6fe0201fe 100644 --- a/src/move_orb_actions_2.c +++ b/src/move_orb_actions_2.c @@ -140,7 +140,7 @@ bool8 PsywaveMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) return flag; } -bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5) +bool8 DamageLowerDefMoveAction(Entity *pokemon, Entity *target, Move *move, struct StatIndex stat, u32 param_5) { bool8 flag; @@ -149,7 +149,7 @@ bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 p flag = TRUE; if(sub_805727C(pokemon, target, gPsychicSecondaryChance)) { - LowerDefenseStageTarget(pokemon, target, itemId, 1, 1, FALSE); + LowerDefenseStageTarget(pokemon, target, stat, 1, 1, FALSE); } } return flag; @@ -252,9 +252,8 @@ bool8 sub_8058EE0(Entity *pokemon, Entity *target, Move *move, s32 itemId) return TRUE; } -bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) +bool8 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - bool32 flag; EntityInfo *entityInfo; s32 modifierInt; @@ -265,11 +264,8 @@ bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite if (entityInfo->bideClassStatus.status == STATUS_DIGGING) { modifierInt = 2; } - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(modifierInt),itemId); - if (flag != 0) { - flag = TRUE; - } - return flag; + + return (HandleDamagingMove(pokemon,target,move,IntToF248_2(modifierInt),itemId) != 0); } bool8 NaturePowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) diff --git a/src/move_orb_actions_3.c b/src/move_orb_actions_3.c index fb430e705..6f7a08fd0 100644 --- a/src/move_orb_actions_3.c +++ b/src/move_orb_actions_3.c @@ -437,22 +437,20 @@ bool8 sub_805A568(Entity * pokemon, Entity * target, Move *move, s32 itemId) bool8 SuperpowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - u32 stat; bool8 flag; flag = FALSE; if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,pokemon,0) != 0) { - stat = gStatIndexAtkDef; - LowerAttackStageTarget(pokemon,pokemon,stat,1,0,FALSE); - LowerDefenseStageTarget(pokemon,pokemon,stat,1,0,FALSE); + LowerAttackStageTarget(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE); + LowerDefenseStageTarget(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE); } } return flag; } -bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 stat, u32 param_5) +bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, struct StatIndex stat, u32 param_5) { EntityInfo *entityInfo; bool8 flag; @@ -751,9 +749,8 @@ bool8 sub_805AC90(Entity * pokemon, Entity * target, Move *move, s32 itemId) bool8 BulkUpMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - s32 stat = gStatIndexAtkDef; - RaiseAttackStageTarget(pokemon, target, stat, 1); - RaiseDefenseStageTarget(pokemon, target, stat, 1); + RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1); + RaiseDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1); return TRUE; } diff --git a/src/move_orb_actions_4.c b/src/move_orb_actions_4.c index 472750e64..3241c6bae 100644 --- a/src/move_orb_actions_4.c +++ b/src/move_orb_actions_4.c @@ -102,9 +102,8 @@ bool8 MirrorCoatMoveAction(Entity * pokemon,Entity * target,Move *move, s32 item bool8 CalmMindMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) { - u32 stat = gStatIndexSpecial; - RaiseAttackStageTarget(pokemon,target,stat,1); - RaiseDefenseStageTarget(pokemon,target,stat,1); + RaiseAttackStageTarget(pokemon,target,gStatIndexSpecial,1); + RaiseDefenseStageTarget(pokemon,target,gStatIndexSpecial,1); return TRUE; } @@ -114,7 +113,7 @@ bool8 HiddenPowerMoveAction(Entity * pokemon,Entity * target,Move *move, s32 ite return TRUE; } -bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId, s32 param_5) +bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, struct StatIndex stat, s32 param_5) { EntityInfo *entityInfo; bool8 flag; @@ -124,7 +123,7 @@ bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemI flag = TRUE; if (sub_805727C(pokemon,pokemon,gMetalClawSecondaryChance) != 0) { entityInfo = GetEntInfo(pokemon); - RaiseAttackStageTarget(pokemon,pokemon,itemId,1); + RaiseAttackStageTarget(pokemon,pokemon,stat,1); SetExpMultplier(entityInfo); } } diff --git a/src/move_orb_effects_1.c b/src/move_orb_effects_1.c index 7d43c7bec..e6f898b03 100644 --- a/src/move_orb_effects_1.c +++ b/src/move_orb_effects_1.c @@ -851,7 +851,7 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) } } -void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) +void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 decrement, u8 param_5, bool8 displayMessage) { EntityInfo *entityInfo; s32 attackStage = decrement; @@ -859,7 +859,7 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 de if (!EntityIsValid(target)) return; - if (index != STAT_STAGE_ATK) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0], gUnknown_80FC0C8); } else { @@ -876,7 +876,7 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 de return; } - if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && index == STAT_STAGE_ATK) { + if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && stat.id == STAT_INDEX_PHYSICAL) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); return; @@ -885,21 +885,21 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 de entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F28(target,index); + sub_8041F28(target,stat); if (decrement == 1) { strcpy(gFormatBuffer_Items[1], gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1], gUnknown_80FC0D4); } - attackStage = entityInfo->offensiveStages[index]; + attackStage = entityInfo->offensiveStages[stat.id]; attackStage -= decrement; if (attackStage < 0) { attackStage = 0; } - if (entityInfo->offensiveStages[index] != attackStage) { - entityInfo->offensiveStages[index] = attackStage; + if (entityInfo->offensiveStages[stat.id] != attackStage) { + entityInfo->offensiveStages[stat.id] = attackStage; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC15C); } else { @@ -909,43 +909,44 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 de EntityUpdateStatusSprites(target); } -void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) +void LowerDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected) { EntityInfo *entityInfo; - s32 defenseStage = decrement; + s32 newStage; if (!EntityIsValid(target)) return; - if (index != STAT_STAGE_DEF) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); } - if (param_5) { - if (sub_8071728(pokemon,target,displayMessage)) + if (checkProtected) { + if (sub_8071728(pokemon,target,logMsgProtected)) return; } entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F4C(target,index); - if (decrement == 1) { + sub_8041F4C(target,stat); + if (nStages == 1) { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - defenseStage = entityInfo->defensiveStages[index]; - defenseStage = defenseStage - decrement; - if (defenseStage < 0) { - defenseStage = 0; + + newStage = entityInfo->defensiveStages[stat.id]; + newStage -= nStages; + if (newStage < 0) { + newStage = 0; } - if (entityInfo->defensiveStages[index] != defenseStage) { - entityInfo->defensiveStages[index] = defenseStage; + if (entityInfo->defensiveStages[stat.id] != newStage) { + entityInfo->defensiveStages[stat.id] = newStage; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC158); } else { @@ -955,7 +956,7 @@ void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 d EntityUpdateStatusSprites(target); } -void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment) +void RaiseAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment) { EntityInfo *entityInfo; s32 attackStage = increment; @@ -965,8 +966,8 @@ void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 in } entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F70(target,index); - if (index != STAT_STAGE_ATK) { + sub_8041F70(target,stat); + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); } else { @@ -980,13 +981,13 @@ void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 in strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - attackStage = entityInfo->offensiveStages[index]; + attackStage = entityInfo->offensiveStages[stat.id]; attackStage = attackStage + increment; if (attackStage >= MAX_STAT_STAGE) { attackStage = MAX_STAT_STAGE; } - if (entityInfo->offensiveStages[index] != attackStage) { - entityInfo->offensiveStages[index] = attackStage; + if (entityInfo->offensiveStages[stat.id] != attackStage) { + entityInfo->offensiveStages[stat.id] = attackStage; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC13C); } else { @@ -995,7 +996,7 @@ void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 in EntityUpdateStatusSprites(target); } -void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment) +void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment) { EntityInfo *entityInfo; s32 defenseStage = increment; @@ -1005,8 +1006,8 @@ void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 i } entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F94(target,index); - if (index != STAT_STAGE_DEF) { + sub_8041F94(target,stat); + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { @@ -1020,13 +1021,13 @@ void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 i strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - defenseStage = entityInfo->defensiveStages[index]; + defenseStage = entityInfo->defensiveStages[stat.id]; defenseStage = defenseStage + increment; if (defenseStage >= MAX_STAT_STAGE) { defenseStage = MAX_STAT_STAGE; } - if (entityInfo->defensiveStages[index] != defenseStage) { - entityInfo->defensiveStages[index] = defenseStage; + if (entityInfo->defensiveStages[stat.id] != defenseStage) { + entityInfo->defensiveStages[stat.id] = defenseStage; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC138); } else { @@ -1067,7 +1068,7 @@ void UpdateFlashFireBoost(Entity * pokemon, Entity *target) } } -void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage) +void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, struct StatIndex stat, s24_8 param_4, bool8 displayMessage) { EntityInfo *entityInfo; s24_8 oldMulti; @@ -1076,7 +1077,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage return; } - if (statStage != STAT_STAGE_ATK) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); } else { @@ -1092,7 +1093,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage return; } - if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && (statStage == STAT_STAGE_ATK) && F248LessThanInt(param_4, 1)) { + if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && (stat.id == STAT_INDEX_PHYSICAL) && F248LessThanInt(param_4, 1)) { if (displayMessage) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); @@ -1102,27 +1103,27 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - oldMulti = entityInfo->offensiveMultipliers[statStage]; + oldMulti = entityInfo->offensiveMultipliers[stat.id]; if (F248LessThanInt(param_4, 1)) { - sub_8041FD8(target,statStage); + sub_8041FD8(target,stat); } else { - sub_8041FB4(target,statStage); + sub_8041FB4(target,stat); } - entityInfo->offensiveMultipliers[statStage] = s24_8_mul(entityInfo->offensiveMultipliers[statStage],param_4); + entityInfo->offensiveMultipliers[stat.id] = s24_8_mul(entityInfo->offensiveMultipliers[stat.id],param_4); - if (F248LessThanFloat(entityInfo->offensiveMultipliers[statStage], 0.01)) { - entityInfo->offensiveMultipliers[statStage] = FloatToF248(0.01); + if (F248LessThanFloat(entityInfo->offensiveMultipliers[stat.id], 0.01)) { + entityInfo->offensiveMultipliers[stat.id] = FloatToF248(0.01); } - if (FloatLessThanF248(99.99, entityInfo->offensiveMultipliers[statStage])) { - entityInfo->offensiveMultipliers[statStage] = FloatToF248(99.99); + if (FloatLessThanF248(99.99, entityInfo->offensiveMultipliers[stat.id])) { + entityInfo->offensiveMultipliers[stat.id] = FloatToF248(99.99); } - if (F248GreaterThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) { + if (F248GreaterThan(oldMulti, entityInfo->offensiveMultipliers[stat.id])) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC11C); } - else if (F248LessThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) { + else if (F248LessThan(oldMulti, entityInfo->offensiveMultipliers[stat.id])) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC118); } else @@ -1132,7 +1133,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage EntityUpdateStatusSprites(target); } -void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage) +void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, struct StatIndex stat, s24_8 param_4, bool8 displayMessage) { EntityInfo *entityInfo; s24_8 oldMulti; @@ -1141,7 +1142,7 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag return; } - if (statStage != STAT_STAGE_DEF) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { @@ -1153,27 +1154,27 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - oldMulti = entityInfo->defensiveMultipliers[statStage]; + oldMulti = entityInfo->defensiveMultipliers[stat.id]; if (F248LessThanInt(param_4, 1)) { - sub_804201C(target,statStage); + sub_804201C(target,stat); } else { - sub_8041FFC(target,statStage); + sub_8041FFC(target,stat); } - entityInfo->defensiveMultipliers[statStage] = s24_8_mul(entityInfo->defensiveMultipliers[statStage],param_4); + entityInfo->defensiveMultipliers[stat.id] = s24_8_mul(entityInfo->defensiveMultipliers[stat.id],param_4); - if (F248LessThanFloat(entityInfo->defensiveMultipliers[statStage], 0.01)) { - entityInfo->defensiveMultipliers[statStage] = FloatToF248(0.01); + if (F248LessThanFloat(entityInfo->defensiveMultipliers[stat.id], 0.01)) { + entityInfo->defensiveMultipliers[stat.id] = FloatToF248(0.01); } - if (FloatLessThanF248(99.99, entityInfo->defensiveMultipliers[statStage])) { - entityInfo->defensiveMultipliers[statStage] = FloatToF248(99.99); + if (FloatLessThanF248(99.99, entityInfo->defensiveMultipliers[stat.id])) { + entityInfo->defensiveMultipliers[stat.id] = FloatToF248(99.99); } - if (F248GreaterThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) { + if (F248GreaterThan(oldMulti, entityInfo->defensiveMultipliers[stat.id])) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC114); } - else if (F248LessThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) { + else if (F248LessThan(oldMulti, entityInfo->defensiveMultipliers[stat.id])) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC0FC); } else @@ -1183,22 +1184,22 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag EntityUpdateStatusSprites(target); } -void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage) +void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat) { EntityInfo *entityInfo; if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8042040(target,statStage); - if (statStage != STAT_STAGE_ACCURACY) { + sub_8042040(target,stat); + if (stat.id != STAT_INDEX_ACCURACY) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC090); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC084); } - if (entityInfo->hitChanceStages[statStage] < MAX_STAT_STAGE) { - entityInfo->hitChanceStages[statStage]++; + if (entityInfo->hitChanceStages[stat.id] < MAX_STAT_STAGE) { + entityInfo->hitChanceStages[stat.id]++; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC1C4); } else { @@ -1208,19 +1209,19 @@ void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage) } } -void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, bool8 displayMessage) +void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, bool8 displayMessage) { EntityInfo *entityInfo; if (EntityIsValid(target)) { - if (statStage != STAT_STAGE_ACCURACY) { + if (stat.id != STAT_INDEX_ACCURACY) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC090); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC084); } if (!sub_8071728(pokemon,target,displayMessage)) { - if (AbilityIsActive(target, ABILITY_KEEN_EYE) && (statStage == STAT_STAGE_ACCURACY)){ + if (AbilityIsActive(target, ABILITY_KEEN_EYE) && (stat.id == STAT_INDEX_ACCURACY)){ if(displayMessage) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -1230,9 +1231,9 @@ void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, else { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8042060(target,statStage); - if (entityInfo->hitChanceStages[statStage] != 0) { - entityInfo->hitChanceStages[statStage]--; + sub_8042060(target,stat.id); + if (entityInfo->hitChanceStages[stat.id] != 0) { + entityInfo->hitChanceStages[stat.id]--; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC1A4); } else {