Updated Supreme Overlord's effect's code (#2809)

This commit is contained in:
Martin Griffin 2023-03-07 22:30:25 +00:00 committed by GitHub
commit cf432b088b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 23 deletions

View File

@ -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)

View File

@ -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;
}