forked from DizzyEggg/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[battle, damage] refactor damage formula to match gen5+
- Loading branch information
sbird
committed
Aug 4, 2023
1 parent
f94efa9
commit 384ce49
Showing
9 changed files
with
652 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "global.h" | ||
#include "test_battle.h" | ||
|
||
ASSUMPTIONS | ||
{ | ||
ASSUME(gBattleMoves[MOVE_TACKLE].makesContact); | ||
ASSUME(gBattleMoves[MOVE_EMBER].type == TYPE_FIRE); | ||
ASSUME(gBattleMoves[MOVE_TACKLE].makesContact); | ||
ASSUME(gBattleMoves[MOVE_FIRE_PUNCH].makesContact); | ||
ASSUME(gBattleMoves[MOVE_FIRE_PUNCH].type == TYPE_FIRE); | ||
ASSUME(P_GEN_7_POKEMON == TRUE); | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Fluffy halves damage taken from moves that make direct contact", s16 damage) | ||
{ | ||
u32 ability; | ||
PARAMETRIZE { ability = ABILITY_KLUTZ; } | ||
PARAMETRIZE { ability = ABILITY_FLUFFY; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET); | ||
OPPONENT(SPECIES_STUFFUL) { Ability(ability); } | ||
} WHEN { | ||
TURN { MOVE(player, MOVE_TACKLE); } | ||
} SCENE { | ||
MESSAGE("Wobbuffet used Tackle!"); | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(0.5), results[1].damage); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Fluffy doubles damage taken from fire type moves", s16 damage) | ||
{ | ||
u32 ability; | ||
PARAMETRIZE { ability = ABILITY_KLUTZ; } | ||
PARAMETRIZE { ability = ABILITY_FLUFFY; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET); | ||
OPPONENT(SPECIES_STUFFUL) { Ability(ability); } | ||
} WHEN { | ||
TURN { MOVE(player, MOVE_EMBER); } | ||
} SCENE { | ||
MESSAGE("Wobbuffet used Ember!"); | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[1].damage); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Fluffy does not alter damage of fire-type moves that make direct contact", s16 damage) | ||
{ | ||
u32 ability; | ||
PARAMETRIZE { ability = ABILITY_KLUTZ; } | ||
PARAMETRIZE { ability = ABILITY_FLUFFY; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET); | ||
OPPONENT(SPECIES_STUFFUL) { Ability(ability); } | ||
} WHEN { | ||
TURN { MOVE(player, MOVE_FIRE_PUNCH); } | ||
} SCENE { | ||
MESSAGE("Wobbuffet used Fire Punch!"); | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_EQ(results[0].damage, results[1].damage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "global.h" | ||
#include "test_battle.h" | ||
|
||
// From https://bulbapedia.bulbagarden.net/wiki/Damage#Example | ||
|
||
SINGLE_BATTLE_TEST("Damage calculation matches Gen5+") | ||
{ | ||
s16 dmg; | ||
s16 expectedDamage; | ||
PARAMETRIZE { expectedDamage = 196; } | ||
PARAMETRIZE { expectedDamage = 192; } | ||
PARAMETRIZE { expectedDamage = 192; } | ||
PARAMETRIZE { expectedDamage = 192; } | ||
PARAMETRIZE { expectedDamage = 184; } | ||
PARAMETRIZE { expectedDamage = 184; } | ||
PARAMETRIZE { expectedDamage = 184; } | ||
PARAMETRIZE { expectedDamage = 180; } | ||
PARAMETRIZE { expectedDamage = 180; } | ||
PARAMETRIZE { expectedDamage = 180; } | ||
PARAMETRIZE { expectedDamage = 172; } | ||
PARAMETRIZE { expectedDamage = 172; } | ||
PARAMETRIZE { expectedDamage = 172; } | ||
PARAMETRIZE { expectedDamage = 168; } | ||
PARAMETRIZE { expectedDamage = 168; } | ||
PARAMETRIZE { expectedDamage = 168; } | ||
GIVEN { | ||
PLAYER(SPECIES_GLACEON) { Level(75); Attack(123); } | ||
OPPONENT(SPECIES_GARCHOMP) { Defense(163); } | ||
} WHEN { | ||
TURN { | ||
MOVE(player, MOVE_ICE_FANG, WITH_RNG(RNG_DAMAGE_MODIFIER, i)); | ||
} | ||
} | ||
SCENE{ | ||
MESSAGE("Glaceon used Ice Fang!"); | ||
HP_BAR(opponent, captureDamage: &dmg); | ||
} | ||
THEN{ | ||
EXPECT_EQ(expectedDamage, dmg); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Damage calculation matches Gen5+ (Muscle Band, crit)") | ||
{ | ||
s16 dmg; | ||
s16 expectedDamage; | ||
PARAMETRIZE { expectedDamage = 324; } | ||
PARAMETRIZE { expectedDamage = 316; } | ||
PARAMETRIZE { expectedDamage = 312; } | ||
PARAMETRIZE { expectedDamage = 312; } | ||
PARAMETRIZE { expectedDamage = 304; } | ||
PARAMETRIZE { expectedDamage = 304; } | ||
PARAMETRIZE { expectedDamage = 300; } | ||
PARAMETRIZE { expectedDamage = 300; } | ||
PARAMETRIZE { expectedDamage = 292; } | ||
PARAMETRIZE { expectedDamage = 292; } | ||
PARAMETRIZE { expectedDamage = 288; } | ||
PARAMETRIZE { expectedDamage = 288; } | ||
PARAMETRIZE { expectedDamage = 280; } | ||
PARAMETRIZE { expectedDamage = 276; } | ||
PARAMETRIZE { expectedDamage = 276; } | ||
PARAMETRIZE { expectedDamage = 268; } | ||
GIVEN { | ||
PLAYER(SPECIES_GLACEON) { Level(75); Attack(123); Item(ITEM_MUSCLE_BAND); } | ||
OPPONENT(SPECIES_GARCHOMP) { Defense(163); } | ||
} WHEN { | ||
TURN { | ||
MOVE(player, MOVE_ICE_FANG, WITH_RNG(RNG_DAMAGE_MODIFIER, i), criticalHit: TRUE); | ||
} | ||
} | ||
SCENE{ | ||
MESSAGE("Glaceon used Ice Fang!"); | ||
HP_BAR(opponent, captureDamage: &dmg); | ||
} | ||
THEN{ | ||
EXPECT_EQ(expectedDamage, dmg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "global.h" | ||
#include "test_battle.h" | ||
|
||
ASSUMPTIONS { | ||
ASSUME(gBattleMoves[MOVE_MINIMIZE].effect == EFFECT_MINIMIZE); | ||
ASSUME(gBattleMoves[MOVE_STEAMROLLER].minimizeDoubleDamage); | ||
ASSUME(gBattleMoves[MOVE_EARTHQUAKE].damagesUnderground); | ||
ASSUME(gBattleMoves[MOVE_SURF].damagesUnderwater); | ||
ASSUME(gBattleMoves[MOVE_TWISTER].damagesAirborneDoubleDamage); | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Minimize causes the target to take double damage from certain moves", s16 damage) | ||
{ | ||
bool32 useMinimize; | ||
PARAMETRIZE { useMinimize = FALSE; } | ||
PARAMETRIZE { useMinimize = TRUE; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); } | ||
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); } | ||
} WHEN { | ||
if (useMinimize) | ||
TURN { MOVE(opponent, MOVE_MINIMIZE); MOVE(player, MOVE_STEAMROLLER); } | ||
else | ||
TURN { MOVE(player, MOVE_STEAMROLLER); } | ||
} SCENE { | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[1].damage); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Being underground causes the target to take double damage from certain moves", s16 damage) | ||
{ | ||
bool32 useDig; | ||
PARAMETRIZE { useDig = FALSE; } | ||
PARAMETRIZE { useDig = TRUE; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); } | ||
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); } | ||
} WHEN { | ||
if (useDig) | ||
TURN { MOVE(opponent, MOVE_DIG); MOVE(player, MOVE_EARTHQUAKE); } | ||
else | ||
TURN { MOVE(player, MOVE_EARTHQUAKE); } | ||
} SCENE { | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[1].damage); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Being underwater causes the target to take double damage from certain moves", s16 damage) | ||
{ | ||
bool32 useDive; | ||
PARAMETRIZE { useDive = FALSE; } | ||
PARAMETRIZE { useDive = TRUE; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); } | ||
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); } | ||
} WHEN { | ||
if (useDive) | ||
TURN { MOVE(opponent, MOVE_DIVE); MOVE(player, MOVE_SURF); } | ||
else | ||
TURN { MOVE(player, MOVE_SURF); } | ||
} SCENE { | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[1].damage); | ||
} | ||
} | ||
|
||
SINGLE_BATTLE_TEST("Being airborne causes the target to take double damage from certain moves", s16 damage) | ||
{ | ||
bool32 useDive; | ||
PARAMETRIZE { useDive = FALSE; } | ||
PARAMETRIZE { useDive = TRUE; } | ||
GIVEN { | ||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); } | ||
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); } | ||
} WHEN { | ||
if (useDive) | ||
TURN { MOVE(opponent, MOVE_FLY); MOVE(player, MOVE_TWISTER); } | ||
else | ||
TURN { MOVE(player, MOVE_TWISTER); } | ||
} SCENE { | ||
HP_BAR(opponent, captureDamage: &results[i].damage); | ||
} FINALLY { | ||
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[1].damage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters