From c8abf00cac0a56cf722355f2751ed7fbe2957386 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 20 Dec 2022 05:21:16 -0300 Subject: [PATCH] Applied corrections Anger Shell: -Made it print a string from the gStatDownStringIds table while lowering Def and Sp. Def -Made it use the shiny new modifybattlerstatstage macro. -Made it activate multiple times per battle, as it should. Well-Baked Body: -Turned it into an absorbing ability. Wind Rider: -Turned it into an absorbing ability. -For its Tailwind interaction, I made it activate only when Tailwind kicks in successfully, instead of whenever it's active at the end of a turn. Guard Dog: -Updated its check inside BattleScript_EffectHitEscape. -Moved it from Cmd_forcerandomswitch to BattleScript_EffectRoar. Wind Power: -Split off its move end effect from Electromorphosis'. Electromorphosis: -Split off its move end effect from Wind Power's. Hadron Engine: -Merged its Switch In effect with Electric Surge's. Protosynthesis: -Fixed its stat boost. Quark Drive: -Fixed its stat boost. Cud Chew: -Updated its ENDTURN effect's berry check. Supreme Overlord: -Tweaked the looping i variable's data type, the order of the variables and the checks inside ApplySupremeOverlordModifier. Earth Eater: -Turned it into an absorbing ability. Misc changes: -Added a variable to set the amount of stat stages raised inside AbilityMoveEffects' case ABILITYEFFECT_ABSORBING. -Added a preproc config to update the text string that they print. -Limited the scope of atkHighestStat and defHighestStat in CalcMoveBasePowerAfterModifiers to Protosynthesis's and Quark Drive's effects. --- data/battle_scripts_1.s | 62 ++++++++++---------- include/battle.h | 1 - include/config/battle.h | 3 +- src/battle_script_commands.c | 4 +- src/battle_util.c | 107 ++++++++++++++++++----------------- 5 files changed, 92 insertions(+), 85 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 61392433d..af0352e68 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2876,8 +2876,25 @@ BattleScript_EffectTailwind: waitanimation printstring STRINGID_TAILWINDBLEW waitmessage B_WAIT_TIME_LONG + call TryActivateWindRiderLoop goto BattleScript_MoveEnd +TryActivateWindRiderLoop: + savetarget + setbyte gBattlerTarget, 0 +BattleScript_WindRiderLoop_Iter: + jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_WindRiderLoop_Activate + goto BattleScript_WindRiderLoop_Increment +BattleScript_WindRiderLoop_Activate: + call BattleScript_AbilityPopUp + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderLoop_Increment, ANIM_ON +BattleScript_WindRiderLoop_Increment: + addbyte gBattlerTarget, 0x1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_WindRiderLoop_Iter +BattleScript_WindRiderLoop_Ret: + restoretarget + return + BattleScript_EffectMircleEye: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE @@ -2965,9 +2982,9 @@ BattleScript_EffectHitEscape: resultmessage waitmessage B_WAIT_TIME_LONG jumpifmovehadnoeffect BattleScript_MoveEnd + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd seteffectwithchance tryfaintmon BS_TARGET - jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd moveendto MOVEEND_ATTACKER_VISIBLE moveendfrom MOVEEND_TARGET_VISIBLE jumpifbattleend BattleScript_HitEscapeEnd @@ -3557,6 +3574,7 @@ BattleScript_EffectRoar:: attackstring ppreduce jumpifroarfails BattleScript_ButItFailed + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_ButItFailed jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON @@ -7151,38 +7169,16 @@ BattleScript_AngerShellActivates:: jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPDEF, MIN_STAT_STAGE, BattleScript_ButItFailed BattleScript_AngerShellTryDef:: setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_TARGET, BIT_DEF | BIT_SPDEF, STAT_CHANGE_NEGATIVE | STAT_CHANGE_CANT_PREVENT - setstatchanger STAT_DEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTrySpDef - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpDef - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_DEF, DECREASE, 1, BattleScript_AngerShellTrySpDef, ANIM_ON BattleScript_AngerShellTrySpDef: - setstatchanger STAT_SPDEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTryAttack - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTryAttack - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPDEF, DECREASE, 1, BattleScript_AngerShellTryAttack, ANIM_ON BattleScript_AngerShellTryAttack: setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_TARGET, BIT_SPATK | BIT_ATK | BIT_SPEED, STAT_CHANGE_BY_TWO - setstatchanger STAT_ATK, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpAtk - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpAtk - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_ATK, INCREASE, 1, BattleScript_AngerShellTrySpAtk, ANIM_ON BattleScript_AngerShellTrySpAtk: - setstatchanger STAT_SPATK, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpeed - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpeed - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPATK, INCREASE, 1, BattleScript_AngerShellTrySpeed, ANIM_ON BattleScript_AngerShellTrySpeed: - setstatchanger STAT_SPEED, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellRet - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellRet - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPEED, INCREASE, 1, BattleScript_AngerShellRet, ANIM_ON BattleScript_AngerShellRet: return @@ -7210,7 +7206,7 @@ BattleScript_EarthEaterActivates:: call BattleScript_AbilityPopUp pause B_WAIT_TIME_LONG tryhealquarterhealth BS_TARGET, BattleScript_EarthEaterRet - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + orword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_TARGET datahpupdate BS_TARGET printstring STRINGID_PKMNREGAINEDHEALTH @@ -8451,6 +8447,7 @@ BattleScript_IntimidatePrevented: BattleScript_IntimidateInReverse: copybyte sBATTLER, gBattlerTarget + copybyte gBattlerAbility, gBattlerTarget call BattleScript_AbilityPopUp pause B_WAIT_TIME_SHORT modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_IntimidateLoopIncrement, ANIM_ON @@ -8703,8 +8700,15 @@ BattleScript_MoveStatDrain:: setgraphicalstatchangevalues playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 waitanimation +.if B_ABSORBING_ABILITY_STRING >= GEN_5 + statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MoveStatDrain_Cont + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +.else printstring STRINGID_TARGETABILITYSTATRAISE waitmessage B_WAIT_TIME_LONG +.endif +BattleScript_MoveStatDrain_Cont: clearsemiinvulnerablebit tryfaintmon BS_ATTACKER goto BattleScript_MoveEnd diff --git a/include/battle.h b/include/battle.h index 317995333..883b70d26 100644 --- a/include/battle.h +++ b/include/battle.h @@ -653,7 +653,6 @@ struct BattleStruct u8 attackerBeforeBounce:2; u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit. u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) - bool8 endturnAbilityDone[PARTY_SIZE][2]; // For some reason, adding a switchInAbilityDone equivalent in SpecialStatus didn't work. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/config/battle.h b/include/config/battle.h index 3f359a6f2..3f06f54da 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -110,6 +110,7 @@ #define B_WEATHER_FORMS GEN_LATEST // In Gen5+, Castform and Cherrim revert to their base form upon losing their respective ability. Cherrim needs Flower Gift to swap forms. #define B_SYMBIOSIS_GEMS GEN_LATEST // In Gen7+, Symbiosis passes an item after a gem-boosted attack. Previously, items are passed before the gem-boosted attack hits, making the item effect apply. #define B_CHECK_IF_CHARGED_UP TRUE // If set to TRUE, certain abilities such as Electromorphosis WILL check if the STATUS3_CHARGED_UP status flag is applied. +#define B_ABSORBING_ABILITY_STRING GEN_LATEST // In Gen5+, the abilities that absorb moves of a certain type use a generic string for stat increases and decreases. // Item settings #define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. @@ -174,7 +175,7 @@ #define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. // Other settings -#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_DOUBLE_WILD_CHANCE 100 // % chance of encountering two Pokémon in a Wild Encounter. #define B_MULTI_BATTLE_WHITEOUT GEN_LATEST // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. #define B_EVOLUTION_AFTER_WHITEOUT GEN_LATEST // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 98cee311b..ab7e144f7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11238,8 +11238,8 @@ static void Cmd_forcerandomswitch(void) } else { - // In normal wild doubles, Roar will always fail if the user's level is less than the target's or if the target's ability is Guard Dog. - if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) + // In normal wild doubles, Roar will always fail if the user's level is less than the target's. + if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) gBattlescriptCurrInstr = BattleScript_RoarSuccessEndBattle; else gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); diff --git a/src/battle_util.c b/src/battle_util.c index df16999eb..9556c8fc3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2378,11 +2378,6 @@ u8 DoFieldEndTurnEffects(void) BattleScriptExecute(BattleScript_TailwindEnds); effect++; } - if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_RIDER)) - { - BattleScriptExecute(BattleScript_WindRiderActivatesEnd2); - effect++; - } if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_POWER)) { gCurrentMove = MOVE_TAILWIND; @@ -3245,7 +3240,7 @@ u8 DoBattlerEndTurnEffects(void) gBattleStruct->turnEffectsTracker++; break; case ENDTURN_CUD_CHEW: - if (GetBattlerAbility(gActiveBattler) == ABILITY_CUD_CHEW && !gDisableStructs[gActiveBattler].cudChew && GetUsedHeldItem(gActiveBattler) != ITEM_NONE) + if (GetBattlerAbility(gActiveBattler) == ABILITY_CUD_CHEW && !gDisableStructs[gActiveBattler].cudChew && ItemId_GetPocket(GetUsedHeldItem(gActiveBattler)) == POCKET_BERRIES) gDisableStructs[gActiveBattler].cudChew = TRUE; gBattleStruct->turnEffectsTracker++; break; @@ -4773,6 +4768,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_ELECTRIC_SURGE: + case ABILITY_HADRON_ENGINE: if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer)) { BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates); @@ -4957,13 +4953,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_HADRON_ENGINE: - if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer)) - { - BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates); - effect++; - } - break; case ABILITY_SUPREME_OVERLORD: if (!gSpecialStatuses[battler].switchInAbilityDone && CountUsablePartyMons(battler) < PARTY_SIZE) { @@ -5233,16 +5222,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; effect = 1; } - else if (targetAbility == ABILITY_WELL_BAKED_BODY && gBattleMoves[gCurrentMove].type == TYPE_FIRE) - { - gBattlescriptCurrInstr = BattleScript_WellBakedBodyActivates; - effect = 1; - } - else if (targetAbility == ABILITY_WIND_RIDER && gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE && !(moveTarget & MOVE_TARGET_USER)) - { - gBattlescriptCurrInstr = BattleScript_WindRiderActivatesMoveEnd; - effect = 1; - } else if (GetBattlerAbility(gBattlerTarget) == ABILITY_GOOD_AS_GOLD && IS_MOVE_STATUS(gCurrentMove) && !(moveTarget & MOVE_TARGET_USER) @@ -5258,6 +5237,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (move != MOVE_NONE) { u8 statId; + u8 statAmount = 1; switch (gLastUsedAbility) { case ABILITY_VOLT_ABSORB: @@ -5315,6 +5295,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } } break; + case ABILITY_WELL_BAKED_BODY: + if (moveType == TYPE_FIRE) + effect = 2, statId = STAT_DEF, statAmount = 2; + break; + case ABILITY_WIND_RIDER: + if (gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE && !(GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove) & MOVE_TARGET_USER)) + effect = 2, statId = STAT_ATK; + break; + case ABILITY_EARTH_EATER: + if (moveType == TYPE_GROUND) + effect = 1; + break; } if (effect == 1) // Drain Hp ability. @@ -5359,9 +5351,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move else gBattlescriptCurrInstr = BattleScript_MoveStatDrain_PPLoss; - SET_STATCHANGER(statId, 1, FALSE); + SET_STATCHANGER(statId, statAmount, FALSE); + #if B_ABSORBING_ABILITY_STRING < GEN_5 gBattleMons[battler].statStages[statId]++; PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + #endif } } } @@ -5894,10 +5888,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2) - && !gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)]) + && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2)) { - gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)] = TRUE; gBattlerAttacker = gBattlerTarget; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AngerShellActivates; @@ -5905,7 +5897,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_WIND_POWER: - case ABILITY_ELECTROMORPHOSIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED @@ -5918,6 +5909,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ELECTROMORPHOSIS: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerTarget)) + { + gBattlerAttacker = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WindPowerActivates; + effect++; + } + break; case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg @@ -5932,18 +5935,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_EARTH_EATER: - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && gBattleMoves[gCurrentMove].type == TYPE_GROUND - && TARGET_TURN_DAMAGED - && IsBattlerAlive(gBattlerTarget)) - { - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_EarthEaterActivates; - effect++; - } - break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker @@ -8773,15 +8764,17 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) // The first ally adds a x1.2 boost, and subsequent allies add an extra x0.1 boost each. static u16 ApplySupremeOverlordModifier(u8 battlerId) { + u32 i; u8 side = GetBattlerSide(battlerId); struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - u8 i; u16 modifier = UQ_4_12(1.0); bool8 appliedFirstBoost = FALSE; for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&party[i], MON_DATA_HP) == 0) + if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetMonData(&party[i], MON_DATA_IS_EGG) + && GetMonData(&party[i], MON_DATA_HP) == 0) modifier += (!appliedFirstBoost) ? UQ_4_12(0.2) : UQ_4_12(0.1); appliedFirstBoost = TRUE; } @@ -8799,8 +8792,6 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe u32 atkSide = GET_BATTLER_SIDE(battlerAtk); u16 atkAbility = GetBattlerAbility(battlerAtk); u16 defAbility = GetBattlerAbility(battlerDef); - u8 atkHighestStat = GetHighestStatId(battlerAtk); - u8 defHighestStat = GetHighestStatId(battlerDef); // attacker's abilities switch (atkAbility) @@ -8914,12 +8905,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(1.5)); break; case ABILITY_PROTOSYNTHESIS: - if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) - MulModifier(&modifier, UQ_4_12(1.3)); + { + u8 atkHighestStat = GetHighestStatId(battlerAtk); + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + } break; case ABILITY_QUARK_DRIVE: - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) - MulModifier(&modifier, UQ_4_12(1.3)); + { + u8 atkHighestStat = GetHighestStatId(battlerAtk); + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + } break; case ABILITY_ORICHALCUM_PULSE: if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT) @@ -9006,12 +9003,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case ABILITY_PROTOSYNTHESIS: - if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) - MulModifier(&modifier, UQ_4_12(0.3)); + { + u8 defHighestStat = GetHighestStatId(battlerDef); + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.7)); + } break; case ABILITY_QUARK_DRIVE: - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) - MulModifier(&modifier, UQ_4_12(0.3)); + { + u8 defHighestStat = GetHighestStatId(battlerDef); + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.7)); + } break; }