From 0a1d8bf75428515bee97f5a27c62e682a5b36822 Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Sat, 27 Dec 2025 09:54:09 +0100 Subject: [PATCH] Fix stat access for stats other than Attack in BS_GetStatValue (#8684) --- src/battle_script_commands.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 411421a29a..eaf4f7147b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16609,7 +16609,27 @@ void BS_GetStatValue(void) { NATIVE_ARGS(u8 stat); u32 stat = cmd->stat; - gBattleStruct->passiveHpUpdate[gBattlerAttacker] = *(u16 *)(&gBattleMons[gBattlerTarget].attack) + (stat - 1); + switch (stat) + { + case STAT_ATK: + gBattleStruct->passiveHpUpdate[gBattlerAttacker] = gBattleMons[gBattlerTarget].attack; + break; + case STAT_DEF: + gBattleStruct->passiveHpUpdate[gBattlerAttacker] = gBattleMons[gBattlerTarget].defense; + break; + case STAT_SPATK: + gBattleStruct->passiveHpUpdate[gBattlerAttacker] = gBattleMons[gBattlerTarget].spAttack; + break; + case STAT_SPDEF: + gBattleStruct->passiveHpUpdate[gBattlerAttacker] = gBattleMons[gBattlerTarget].spDefense; + break; + case STAT_SPEED: + gBattleStruct->passiveHpUpdate[gBattlerAttacker] = gBattleMons[gBattlerTarget].speed; + break; + default: + // Add errorf here on upcoming + return; + } gBattleStruct->passiveHpUpdate[gBattlerAttacker] *= gStatStageRatios[gBattleMons[gBattlerTarget].statStages[stat]][0]; gBattleStruct->passiveHpUpdate[gBattlerAttacker] /= gStatStageRatios[gBattleMons[gBattlerTarget].statStages[stat]][1]; gBattlescriptCurrInstr = cmd->nextInstr;