diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 5b675ef8352e..67053a281997 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -230,9 +230,6 @@ #define BATTLE_CATEGORY_SPECIAL 1 #define BATTLE_CATEGORY_STATUS 2 -// Just for readability -#define ALWAYS_CRIT 3 - // Growth rates #define GROWTH_MEDIUM_FAST 0 #define GROWTH_ERRATIC 1 diff --git a/include/pokemon.h b/include/pokemon.h index 7426315d8886..b081a86fef72 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -412,12 +412,12 @@ struct BattleMove u16 accuracy:7; u16 recoil:7; - u16 critBoost:2; + u16 criticalHitStage:2; + u8 pp; u8 secondaryEffectChance; - s8 priority; u16 target; - u8 pp; + s8 priority; union { u8 effect; u8 powerOverride; @@ -430,6 +430,7 @@ struct BattleMove u32 snatchAffected:1; u32 mirrorMoveBanned:1; u32 ignoresKingsRock:1; + u32 alwaysCriticalHit:1; u32 twoTurnMove:1; u32 punchingMove:1; u32 sheerForceBoost:1; diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index dbe1e29e3e5b..f9400abe5961 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2721,7 +2721,7 @@ static s32 AI_DoubleBattle(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) } // check partner move effect // Adjust for always crit moves - if (gBattleMoves[aiData->partnerMove].critBoost == ALWAYS_CRIT && aiData->abilities[battlerAtk] == ABILITY_ANGER_POINT) + if (gBattleMoves[aiData->partnerMove].alwaysCriticalHit && aiData->abilities[battlerAtk] == ABILITY_ANGER_POINT) { if (AI_WhoStrikesFirst(battlerAtk, battlerAtkPartner, move) == AI_IS_SLOWER) // Partner moving first { @@ -4976,7 +4976,7 @@ static s32 AI_Risky(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (IS_TARGETING_PARTNER(battlerAtk, battlerDef)) return score; - if (gBattleMoves[move].critBoost > 0) + if (gBattleMoves[move].criticalHitStage > 0) ADJUST_SCORE(2); switch (gBattleMoves[move].effect) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 686a34d30ce7..70ade87c41a1 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -2236,8 +2236,7 @@ bool32 HasHighCritRatioMove(u32 battler) for (i = 0; i < MAX_MON_MOVES; i++) { - if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && gBattleMoves[moves[i]].critBoost > 0 - && gBattleMoves[moves[i]].critBoost < ALWAYS_CRIT) // don't count always crit moves + if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && gBattleMoves[moves[i]].criticalHitStage > 0) return TRUE; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2b46485ebcfd..a14f387b044e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1902,7 +1902,7 @@ s32 CalcCritChanceStageArgs(u32 battlerAtk, u32 battlerDef, u32 move, bool32 rec critChance = -1; } else if (gStatuses3[battlerAtk] & STATUS3_LASER_FOCUS - || gBattleMoves[gCurrentMove].critBoost == ALWAYS_CRIT + || gBattleMoves[gCurrentMove].alwaysCriticalHit || (abilityAtk == ABILITY_MERCILESS && gBattleMons[battlerDef].status1 & STATUS1_PSN_ANY)) { critChance = -2; @@ -1910,7 +1910,7 @@ s32 CalcCritChanceStageArgs(u32 battlerAtk, u32 battlerDef, u32 move, bool32 rec else { critChance = 2 * ((gBattleMons[battlerAtk].status2 & STATUS2_FOCUS_ENERGY) != 0) - + gBattleMoves[gCurrentMove].critBoost + + gBattleMoves[gCurrentMove].criticalHitStage + (holdEffectAtk == HOLD_EFFECT_SCOPE_LENS) + 2 * (holdEffectAtk == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[battlerAtk].species == SPECIES_CHANSEY) + 2 * BENEFITS_FROM_LEEK(battlerAtk, holdEffectAtk) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index b29ce710e34d..2d659c963251 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -36,11 +36,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 50, .type = TYPE_FIGHTING, .accuracy = 100, + .criticalHitStage = 1, .pp = 25, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, }, @@ -202,11 +202,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 80, .type = TYPE_NORMAL, .accuracy = 100, + .criticalHitStage = 1, .pp = 10, .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, .twoTurnMove = TRUE, .sleepTalkBanned = TRUE, @@ -1266,11 +1266,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 55, .type = TYPE_GRASS, .accuracy = 95, + .criticalHitStage = 1, .pp = 25, .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .slicingMove = TRUE, }, @@ -2617,11 +2617,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = #endif .effect = EFFECT_HIT, .type = TYPE_WATER, + .criticalHitStage = 1, .pp = 10, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, }, @@ -2789,11 +2789,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_NORMAL, .accuracy = 100, + .criticalHitStage = 1, .pp = 20, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .slicingMove = TRUE, @@ -3057,11 +3057,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 100, .type = TYPE_FLYING, .accuracy = 95, + .criticalHitStage = 1, .pp = 5, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, }, @@ -4115,11 +4115,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 100, .type = TYPE_FIGHTING, .accuracy = 80, + .criticalHitStage = 1, .pp = 5, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, }, @@ -5181,11 +5181,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 85, .type = TYPE_FIRE, .accuracy = 90, + .criticalHitStage = 1, .pp = 10, .secondaryEffectChance = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .sheerForceBoost = TRUE, @@ -5432,11 +5432,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .effect = EFFECT_HIT, .type = TYPE_FLYING, .accuracy = 95, + .criticalHitStage = 1, .pp = 25, .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, .windMove = TRUE, .slicingMove = TRUE, @@ -5901,11 +5901,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 50, .type = TYPE_POISON, .accuracy = 100, + .criticalHitStage = 1, .pp = 25, .secondaryEffectChance = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .sheerForceBoost = TRUE, @@ -6018,11 +6018,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .effect = EFFECT_HIT, .type = TYPE_GRASS, .accuracy = 100, + .criticalHitStage = 1, .pp = 15, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .slicingMove = TRUE, @@ -6876,11 +6876,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_DARK, .accuracy = 100, + .criticalHitStage = 1, .pp = 15, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .slicingMove = TRUE, @@ -7209,11 +7209,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_GHOST, .accuracy = 100, + .criticalHitStage = 1, .pp = 15, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, }, @@ -7308,11 +7308,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_PSYCHIC, .accuracy = 100, + .criticalHitStage = 1, .pp = 20, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .slicingMove = TRUE, }, @@ -7502,11 +7502,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_POISON, .accuracy = 100, + .criticalHitStage = 1, .pp = 20, .secondaryEffectChance = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .sheerForceBoost = TRUE, @@ -7566,11 +7566,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 100, .type = TYPE_ROCK, .accuracy = 80, + .criticalHitStage = 1, .pp = 5, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, }, @@ -7730,11 +7730,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 90, .type = TYPE_BUG, .accuracy = 100, + .criticalHitStage = 1, .pp = 15, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, }, @@ -7822,11 +7822,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 100, .type = TYPE_DRAGON, .accuracy = 95, + .criticalHitStage = 1, .pp = 5, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, }, @@ -8169,9 +8169,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = ALWAYS_CRIT, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, + .alwaysCriticalHit = TRUE, }, [MOVE_FLAME_BURST] = @@ -8878,8 +8878,8 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = ALWAYS_CRIT, .category = BATTLE_CATEGORY_SPECIAL, + .alwaysCriticalHit = TRUE, }, [MOVE_DRAGON_TAIL] = @@ -8950,11 +8950,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 80, .type = TYPE_GROUND, .accuracy = 95, + .criticalHitStage = 1, .pp = 10, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, }, @@ -11327,10 +11327,10 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 2, - .critBoost = ALWAYS_CRIT, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, .mirrorMoveBanned = B_UPDATED_MOVE_FLAGS < GEN_8, + .alwaysCriticalHit = TRUE, .metronomeBanned = TRUE, }, @@ -11614,11 +11614,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 80, .type = TYPE_WATER, .accuracy = 100, + .criticalHitStage = 1, .pp = 15, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, }, @@ -12447,9 +12447,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = ALWAYS_CRIT, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, + .alwaysCriticalHit = TRUE, .punchingMove = TRUE, .metronomeBanned = TRUE, }, @@ -12461,12 +12461,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .type = TYPE_WATER, .accuracy = 100, .pp = 5, - .critBoost = ALWAYS_CRIT, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, .category = BATTLE_CATEGORY_PHYSICAL, .makesContact = TRUE, + .alwaysCriticalHit = TRUE, .punchingMove = TRUE, .strikeCount = 3, .metronomeBanned = TRUE, @@ -12833,11 +12833,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = #endif .effect = EFFECT_SPEED_UP_HIT, .type = TYPE_PSYCHIC, + .criticalHitStage = 1, .pp = 10, .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_SPECIAL, .sheerForceBoost = TRUE, }, @@ -12888,7 +12888,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .effect = EFFECT_TRIPLE_ARROWS, .type = TYPE_FIGHTING, .accuracy = 100, - .critBoost = 1, + .criticalHitStage = 1, .secondaryEffectChance = 100, // 50% Defense down, 30% Flinch. Can be modified in 'SetMoveEffect' .target = MOVE_TARGET_SELECTED, .priority = 0, @@ -13326,8 +13326,8 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = ALWAYS_CRIT, .category = BATTLE_CATEGORY_PHYSICAL, + .alwaysCriticalHit = TRUE, }, [MOVE_TORCH_SONG] = @@ -13674,11 +13674,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 70, .type = TYPE_WATER, .accuracy = 100, + .criticalHitStage = 1, .pp = 20, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 1, .category = BATTLE_CATEGORY_PHYSICAL, .slicingMove = TRUE, }, @@ -13879,11 +13879,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .type = TYPE_GRASS, .accuracy = 100, .pp = 10, + .criticalHitStage = 1, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, .category = BATTLE_CATEGORY_PHYSICAL, - .critBoost = 1, .argument = HOLD_EFFECT_MASK, .metronomeBanned = TRUE, }, @@ -14124,11 +14124,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .power = 195, .type = TYPE_ELECTRIC, .accuracy = 0, + .criticalHitStage = 2, .pp = 1, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .critBoost = 2, .category = BATTLE_CATEGORY_SPECIAL, }, [MOVE_STOKED_SPARKSURFER] = diff --git a/test/battle/crit_chance.c b/test/battle/crit_chance.c index aa2dd9278c78..7763058e4bdb 100644 --- a/test/battle/crit_chance.c +++ b/test/battle/crit_chance.c @@ -152,7 +152,7 @@ SINGLE_BATTLE_TEST("High crit rate increases the critical hit ratio by one stage { PASSES_RANDOMLY(1, 8, RNG_CRITICAL_HIT); GIVEN { - ASSUME(gBattleMoves[MOVE_SLASH].critBoost == 1); + ASSUME(gBattleMoves[MOVE_SLASH].criticalHitStage == 1); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -195,7 +195,7 @@ SINGLE_BATTLE_TEST("Scope Lens increases the critical hit ratio by one stage") SINGLE_BATTLE_TEST("High crit rate, Super Luck and Scope Lens cause the move to result in a critical hit") { GIVEN { - ASSUME(gBattleMoves[MOVE_SLASH].critBoost == 1); + ASSUME(gBattleMoves[MOVE_SLASH].criticalHitStage == 1); ASSUME(gItems[ITEM_SCOPE_LENS].holdEffect == HOLD_EFFECT_SCOPE_LENS); PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_SUPER_LUCK); Item(ITEM_SCOPE_LENS); }; OPPONENT(SPECIES_WOBBUFFET); diff --git a/test/battle/hold_effect/critical_hit_up.c b/test/battle/hold_effect/critical_hit_up.c index 9435c46457cf..b714bdb30d2e 100644 --- a/test/battle/hold_effect/critical_hit_up.c +++ b/test/battle/hold_effect/critical_hit_up.c @@ -51,7 +51,7 @@ SINGLE_BATTLE_TEST("Lansat Berry raises the holder's critical-hit-ratio by two s { PASSES_RANDOMLY(1, 2, RNG_CRITICAL_HIT); GIVEN { - ASSUME(gBattleMoves[MOVE_TACKLE].critBoost == 0); + ASSUME(gBattleMoves[MOVE_TACKLE].criticalHitStage == 0); ASSUME(B_CRIT_CHANCE >= GEN_6); PLAYER(SPECIES_WOBBUFFET) { MaxHP(160); HP(80); Item(ITEM_LANSAT_BERRY); } OPPONENT(SPECIES_WOBBUFFET); diff --git a/test/battle/move.c b/test/battle/move.c index 1f0d5765d6bd..a444fe2d5dc2 100644 --- a/test/battle/move.c +++ b/test/battle/move.c @@ -99,7 +99,7 @@ SINGLE_BATTLE_TEST("Critical hits occur at a 1/24 rate") SINGLE_BATTLE_TEST("Slash's critical hits occur at a 1/8 rate") { ASSUME(B_CRIT_CHANCE >= GEN_7); - ASSUME(gBattleMoves[MOVE_SLASH].critBoost == 1); + ASSUME(gBattleMoves[MOVE_SLASH].criticalHitStage == 1); PASSES_RANDOMLY(1, 8, RNG_CRITICAL_HIT); GIVEN { PLAYER(SPECIES_WOBBUFFET); diff --git a/test/battle/move_effect/triple_arrows.c b/test/battle/move_effect/triple_arrows.c index 5778b593d402..c82d95bdcdf0 100644 --- a/test/battle/move_effect/triple_arrows.c +++ b/test/battle/move_effect/triple_arrows.c @@ -46,7 +46,7 @@ SINGLE_BATTLE_TEST("Triple Arrows makes the foe flinch 30% of the time") SINGLE_BATTLE_TEST("Triple Arrows lands a critical hit") { ASSUME(B_CRIT_CHANCE >= GEN_7); - ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].critBoost == 1); + ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].criticalHitStage == 1); PASSES_RANDOMLY(1, 8, RNG_CRITICAL_HIT); GIVEN { PLAYER(SPECIES_WOBBUFFET); diff --git a/test/battle/move_flags/strike_count.c b/test/battle/move_flags/strike_count.c index b00864bccacd..d397d805c60c 100644 --- a/test/battle/move_flags/strike_count.c +++ b/test/battle/move_flags/strike_count.c @@ -50,7 +50,7 @@ SINGLE_BATTLE_TEST("Surging Strikes hits 3 times with each hit being a critical GIVEN { ASSUME(gBattleMoves[MOVE_SURGING_STRIKES].strikeCount == 3); - ASSUME(gBattleMoves[MOVE_SURGING_STRIKES].critBoost == ALWAYS_CRIT); + ASSUME(gBattleMoves[MOVE_SURGING_STRIKES].alwaysCriticalHit == TRUE); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN {