From fdebc994d23be0dedfa64f54fe2bf01c46e0acbe Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 7 Mar 2023 19:14:38 -0300 Subject: [PATCH] Updated Supreme Overlord's effect's code --- include/battle.h | 1 + src/battle_util.c | 48 ++++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/battle.h b/include/battle.h index 83b552e7e1..a43fc65cdf 100644 --- a/include/battle.h +++ b/include/battle.h @@ -662,6 +662,7 @@ struct BattleStruct u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party. u8 storedHealingWish:4; // Each battler as a bit. u8 storedLunarDance:4; // Each battler as a bit. + u16 supremeOverlordModifier[MAX_BATTLERS_COUNT]; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/src/battle_util.c b/src/battle_util.c index 9520e761f7..4b50bc7045 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -62,6 +62,7 @@ static u8 GetFlingPowerFromItemId(u16 itemId); static void SetRandomMultiHitCounter(); static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item); static u16 GetInverseTypeMultiplier(u16 multiplier); +static u16 GetSupremeOverlordModifier(u8 battlerId); extern const u8 *const gBattleScriptsForMoveEffects[]; extern const u8 *const gBattlescriptsForRunningByItem[]; @@ -4319,6 +4320,28 @@ bool8 ChangeTypeBasedOnTerrain(u8 battlerId) return TRUE; } +// Supreme Overlord adds a damage boost for each fainted ally. +// The first ally adds a x1.2 boost, and subsequent allies add an extra x0.1 boost each. +static u16 GetSupremeOverlordModifier(u8 battlerId) +{ + u32 i; + u8 side = GetBattlerSide(battlerId); + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + u16 modifier = UQ_4_12(1.0); + bool8 appliedFirstBoost = FALSE; + + for (i = 0; i < PARTY_SIZE; i++) + { + 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; + } + + return modifier; +} + u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 moveArg) { u8 effect = 0; @@ -4867,6 +4890,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone && CountUsablePartyMons(battler) < PARTY_SIZE) { gSpecialStatuses[battler].switchInAbilityDone = TRUE; + gBattleStruct->supremeOverlordModifier[battler] = GetSupremeOverlordModifier(battler); BattleScriptPushCursorAndCallback(BattleScript_SupremeOverlordActivates); effect++; } @@ -8761,28 +8785,6 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) return basePower; } -// Supreme Overlord adds a damage boost for each fainted ally. -// The first ally adds a x1.2 boost, and subsequent allies add an extra x0.1 boost each. -static u16 GetSupremeOverlordModifier(u8 battlerId) -{ - u32 i; - u8 side = GetBattlerSide(battlerId); - struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - u16 modifier = UQ_4_12(1.0); - bool8 appliedFirstBoost = FALSE; - - for (i = 0; i < PARTY_SIZE; i++) - { - 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; - } - - return modifier; -} - static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, bool32 updateFlags) { u32 i; @@ -8932,7 +8934,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(1.5)); break; case ABILITY_SUPREME_OVERLORD: - MulModifier(&modifier, GetSupremeOverlordModifier(battlerAtk)); + MulModifier(&modifier, gBattleStruct->supremeOverlordModifier[battlerAtk]); break; }