Fix Download raising the wrong stat

This commit is contained in:
DizzyEggg 2019-02-09 13:30:45 +01:00
parent 691544fa0b
commit 872389b15c

View File

@ -2714,30 +2714,27 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITY_DOWNLOAD: case ABILITY_DOWNLOAD:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
u8 statId; u32 statId, opposingBattler;
u32 opposingBattler = BATTLE_OPPOSITE(battler); u32 opposingDef = 0, opposingSpDef = 0;
u32 opposingDef = gBattleMons[opposingBattler].defense
* gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][0]
/ gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][1];
u32 opposingSpDef = gBattleMons[opposingBattler].spDefense
* gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][0]
/ gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][1];
opposingBattler = BATTLE_PARTNER(opposingBattler); opposingBattler = BATTLE_OPPOSITE(battler);
if (IsBattlerAlive(opposingBattler)) for (i = 0; i < 2; opposingBattler ^= BIT_SIDE, i++)
{ {
opposingDef += gBattleMons[opposingBattler].defense if (IsBattlerAlive(opposingBattler))
* gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][0] {
/ gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][1]; opposingDef += gBattleMons[opposingBattler].defense
opposingSpDef += gBattleMons[opposingBattler].spDefense * gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][0]
* gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][0] / gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_DEF]][1];
/ gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][1]; opposingSpDef += gBattleMons[opposingBattler].spDefense
* gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][0]
/ gStatStageRatios[gBattleMons[opposingBattler].statStages[STAT_SPDEF]][1];
}
} }
if (opposingSpDef > opposingDef) if (opposingDef < opposingSpDef)
statId = STAT_SPATK;
else
statId = STAT_ATK; statId = STAT_ATK;
else
statId = STAT_SPATK;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = 1;