Skip to content

Commit

Permalink
Fixes spread move damage in doubles
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Jul 29, 2024
1 parent b54226d commit 21d4952
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8531,12 +8531,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:
Expand Down
30 changes: 30 additions & 0 deletions test/battle/damage_formula.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,33 @@ 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[5];
GIVEN {
PLAYER(SPECIES_REGIROCK);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { HP(200); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(playerLeft, MOVE_ROCK_SLIDE); }
TURN { MOVE(playerLeft, 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, playerLeft);
HP_BAR(opponentRight, captureDamage: &damage[4]);
} THEN {
EXPECT_EQ(damage[0], damage[1]);
EXPECT_EQ(damage[1], damage[3]);
EXPECT_MUL_EQ(damage[4], UQ_4_12(0.75), damage[3]);
}
}

0 comments on commit 21d4952

Please sign in to comment.