Fixes spread damage in double battles (#5064)
* Fixes spread move damage in doubles * add DoubleBattle check * add additional check to test * restore trainer party
This commit is contained in:
parent
a89fc9de69
commit
e6175b5b84
2 changed files with 40 additions and 6 deletions
|
@ -8532,12 +8532,12 @@ u32 GetMoveTargetCount(u32 move, u32 battlerAtk, u32 battlerDef)
|
|||
switch (GetBattlerMoveTargetType(gBattlerAttacker, move))
|
||||
{
|
||||
case MOVE_TARGET_BOTH:
|
||||
return IsBattlerAlive(battlerDef)
|
||||
+ IsBattlerAlive(BATTLE_PARTNER(battlerDef));
|
||||
return !(gAbsentBattlerFlags & gBitTable[battlerDef])
|
||||
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerDef)]);
|
||||
case MOVE_TARGET_FOES_AND_ALLY:
|
||||
return IsBattlerAlive(battlerDef)
|
||||
+ IsBattlerAlive(BATTLE_PARTNER(battlerDef))
|
||||
+ IsBattlerAlive(BATTLE_PARTNER(battlerAtk));
|
||||
return !(gAbsentBattlerFlags & gBitTable[battlerDef])
|
||||
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerDef)])
|
||||
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerAtk)]);
|
||||
case MOVE_TARGET_OPPONENTS_FIELD:
|
||||
return 1;
|
||||
case MOVE_TARGET_DEPENDS:
|
||||
|
@ -9654,7 +9654,7 @@ static inline s32 CalculateBaseDamage(u32 power, u32 userFinalAttack, u32 level,
|
|||
|
||||
static inline uq4_12_t GetTargetDamageModifier(u32 move, u32 battlerAtk, u32 battlerDef)
|
||||
{
|
||||
if (GetMoveTargetCount(move, battlerAtk, battlerDef) >= 2)
|
||||
if (IsDoubleBattle() && GetMoveTargetCount(move, battlerAtk, battlerDef) >= 2)
|
||||
return B_MULTIPLE_TARGETS_DMG >= GEN_4 ? UQ_4_12(0.75) : UQ_4_12(0.5);
|
||||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
|
|
@ -116,3 +116,37 @@ SINGLE_BATTLE_TEST("Damage calculation matches Gen5+ (Marshadow vs Mawile)")
|
|||
EXPECT_EQ(expectedDamage, dmg);
|
||||
}
|
||||
}
|
||||
|
||||
DOUBLE_BATTLE_TEST("A spread move will do correct damage to the second mon if the first target faints from first hit of the spread move")
|
||||
{
|
||||
s16 damage[6];
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_REGIROCK);
|
||||
PLAYER(SPECIES_REGIROCK);
|
||||
OPPONENT(SPECIES_WOBBUFFET) { HP(200); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(playerLeft, MOVE_ROCK_SLIDE); }
|
||||
TURN { MOVE(playerLeft, MOVE_ROCK_SLIDE); MOVE(playerRight, MOVE_ROCK_SLIDE); }
|
||||
TURN { MOVE(playerLeft, MOVE_ROCK_SLIDE); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, playerLeft);
|
||||
HP_BAR(opponentLeft, captureDamage: &damage[0]);
|
||||
HP_BAR(opponentRight, captureDamage: &damage[1]);
|
||||
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, playerLeft);
|
||||
HP_BAR(opponentLeft, captureDamage: &damage[2]);
|
||||
HP_BAR(opponentRight, captureDamage: &damage[3]);
|
||||
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, playerRight);
|
||||
HP_BAR(opponentRight, captureDamage: &damage[4]);
|
||||
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, playerLeft);
|
||||
HP_BAR(opponentRight, captureDamage: &damage[5]);
|
||||
} THEN {
|
||||
EXPECT_EQ(damage[0], damage[1]);
|
||||
EXPECT_EQ(damage[1], damage[3]);
|
||||
EXPECT_MUL_EQ(damage[5], UQ_4_12(0.75), damage[3]);
|
||||
EXPECT_EQ(damage[4], damage[5]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue