Removes duplicate Booster Energy code (#5656)

This commit is contained in:
Alex 2024-11-11 17:48:23 +01:00 committed by GitHub
parent f770cb1ea3
commit afc7795afc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7069,6 +7069,24 @@ static u8 TryConsumeMirrorHerb(u32 battler, bool32 execute)
return effect;
}
static inline u32 TryBoosterEnergy(u32 battler)
{
if (gBattleStruct->boosterEnergyActivates & gBitTable[battler] || gBattleMons[battler].status2 & STATUS2_TRANSFORMED)
return ITEM_NO_EFFECT;
if (((GetBattlerAbility(battler) == ABILITY_PROTOSYNTHESIS) && !((gBattleWeather & B_WEATHER_SUN) && WEATHER_HAS_EFFECT))
|| ((GetBattlerAbility(battler) == ABILITY_QUARK_DRIVE) && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)))
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler));
gBattlerAbility = gBattleScripting.battler = battler;
gBattleStruct->boosterEnergyActivates |= gBitTable[battler];
BattleScriptExecute(BattleScript_BoosterEnergyEnd2);
return ITEM_EFFECT_OTHER;
}
return ITEM_NO_EFFECT;
}
static u32 RestoreWhiteHerbStats(u32 battler)
{
u32 i, effect = 0;
@ -7585,17 +7603,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
effect = TryConsumeMirrorHerb(battler, TRUE);
break;
case HOLD_EFFECT_BOOSTER_ENERGY:
if (!(gBattleStruct->boosterEnergyActivates & gBitTable[battler])
&& !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED)
&& (((GetBattlerAbility(battler) == ABILITY_PROTOSYNTHESIS) && !((gBattleWeather & B_WEATHER_SUN) && WEATHER_HAS_EFFECT))
|| ((GetBattlerAbility(battler) == ABILITY_QUARK_DRIVE) && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN))))
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler));
gBattleScripting.battler = battler;
gBattleStruct->boosterEnergyActivates |= gBitTable[battler];
BattleScriptExecute(BattleScript_BoosterEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
effect = TryBoosterEnergy(battler);
break;
}
if (effect != 0)
@ -7853,17 +7861,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
effect = TryConsumeMirrorHerb(battler, TRUE);
break;
case HOLD_EFFECT_BOOSTER_ENERGY:
if (!(gBattleStruct->boosterEnergyActivates & gBitTable[battler])
&& !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED)
&& (((GetBattlerAbility(battler) == ABILITY_PROTOSYNTHESIS) && !((gBattleWeather & B_WEATHER_SUN) && WEATHER_HAS_EFFECT))
|| ((GetBattlerAbility(battler) == ABILITY_QUARK_DRIVE) && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN))))
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler));
gBattlerAbility = gBattleScripting.battler = battler;
gBattleStruct->boosterEnergyActivates |= gBitTable[battler];
BattleScriptExecute(BattleScript_BoosterEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
effect = TryBoosterEnergy(battler);
break;
}