Skip to content

Commit

Permalink
Removed ALWAYS_CRIT, renamed critBoost (#3779)
Browse files Browse the repository at this point in the history
Replaced ALWAYS_CRIT with an alwaysCriticalHit flag to account for the fact that in earlier generations, there is no crit stage at which crits are guaranteed. Renamed critBoost to criticalHitStage (at Edu's prompting). Reorder .criticalHitStage defines in battle_moves.h to be aligned with struct order.
  • Loading branch information
cfmnephrite authored Dec 20, 2023
1 parent 6137db1 commit 1708c80
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 49 deletions.
3 changes: 0 additions & 3 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,15 +1902,15 @@ 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;
}
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)
Expand Down
Loading

0 comments on commit 1708c80

Please sign in to comment.