From 09cbcfaefd300b9cd526bb7710abcd58341f9b7c Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Thu, 21 Nov 2024 15:54:18 +0100 Subject: [PATCH 1/3] Fixes heal blocked leeach seed in tests --- data/battle_scripts_1.s | 39 +++++++++---------- include/battle_scripts.h | 4 +- src/battle_script_commands.c | 6 +-- src/battle_util.c | 21 +++++++++-- test/battle/move_effect/leech_seed.c | 56 +++++++++++++++++++++++++++- 5 files changed, 97 insertions(+), 29 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8d24dc472d58..76b75075ad15 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6032,33 +6032,34 @@ BattleScript_SafeguardEnds:: waitmessage B_WAIT_TIME_LONG end2 -BattleScript_LeechSeedTurnDrain:: - playanimation BS_ATTACKER, B_ANIM_LEECH_SEED_DRAIN, sB_ANIM_ARG1 - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE - healthbarupdate BS_ATTACKER - datahpupdate BS_ATTACKER - copyword gBattleMoveDamage, gHpDealt - jumpifability BS_ATTACKER, ABILITY_LIQUID_OOZE, BattleScript_LeechSeedTurnPrintLiquidOoze - setbyte cMULTISTRING_CHOOSER, B_MSG_LEECH_SEED_DRAIN - jumpifstatus3 BS_TARGET, STATUS3_HEAL_BLOCK, BattleScript_LeechSeedHealBlock - manipulatedamage DMG_BIG_ROOT - goto BattleScript_LeechSeedTurnPrintAndUpdateHp -BattleScript_LeechSeedTurnPrintLiquidOoze:: +BattleScript_LeechSeedTurnDrainLiquidOoze:: + call BattleScript_LeechSeedTurnDrain + manipulatedamage DMG_CHANGE_SIGN copybyte gBattlerAbility, gBattlerAttacker call BattleScript_AbilityPopUp - setbyte cMULTISTRING_CHOOSER, B_MSG_LEECH_SEED_OOZE -BattleScript_LeechSeedTurnPrintAndUpdateHp:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE + goto BattleScript_LeechSeedTurnDrainGainHp + +BattleScript_LeechSeedTurnDrainHealBlock:: + call BattleScript_LeechSeedTurnDrain + end2 + +BattleScript_LeechSeedTurnDrainRecovery:: + call BattleScript_LeechSeedTurnDrain +BattleScript_LeechSeedTurnDrainGainHp: + manipulatedamage DMG_BIG_ROOT healthbarupdate BS_TARGET datahpupdate BS_TARGET printfromtable gLeechSeedStringIds waitmessage B_WAIT_TIME_LONG - tryfaintmon BS_ATTACKER tryfaintmon BS_TARGET end2 -BattleScript_LeechSeedHealBlock: - setword gBattleMoveDamage, 0 - goto BattleScript_LeechSeedTurnPrintAndUpdateHp + +BattleScript_LeechSeedTurnDrain: + playanimation BS_ATTACKER, B_ANIM_LEECH_SEED_DRAIN, sB_ANIM_ARG1 + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + tryfaintmon BS_ATTACKER + return BattleScript_BideStoringEnergy:: printstring STRINGID_PKMNSTORINGENERGY diff --git a/include/battle_scripts.h b/include/battle_scripts.h index a1722a511def..1148c955e5f6 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -65,7 +65,9 @@ extern const u8 BattleScript_OverworldTerrain[]; extern const u8 BattleScript_SideStatusWoreOff[]; extern const u8 BattleScript_SafeguardProtected[]; extern const u8 BattleScript_SafeguardEnds[]; -extern const u8 BattleScript_LeechSeedTurnDrain[]; +extern const u8 BattleScript_LeechSeedTurnDrainLiquidOoze[]; +extern const u8 BattleScript_LeechSeedTurnDrainHealBlock[]; +extern const u8 BattleScript_LeechSeedTurnDrainRecovery[]; extern const u8 BattleScript_BideStoringEnergy[]; extern const u8 BattleScript_BideAttack[]; extern const u8 BattleScript_BideNoEnergyToAttack[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2958d200abe5..9564ed7e466b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5723,10 +5723,8 @@ static void Cmd_moveend(void) else if (IsBattlerAlive(gBattlerAttacker) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gBattleMoveDamage = (gHpDealt * gMovesInfo[gCurrentMove].argument / 100); - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - gBattleMoveDamage = GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage); - gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE; + gBattleMoveDamage = max(1, GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage)); + gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE; effect = TRUE; if (GetBattlerAbility(gBattlerTarget) == ABILITY_LIQUID_OOZE) { diff --git a/src/battle_util.c b/src/battle_util.c index e4c78132ede9..336297932388 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2436,12 +2436,25 @@ u8 DoBattlerEndTurnEffects(void) && !IsBattlerProtectedByMagicGuard(battler, ability)) { gBattlerTarget = gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER; // Notice gBattlerTarget is actually the HP receiver. - gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 8; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + gBattlerAttacker = battler; gBattleScripting.animArg1 = gBattlerTarget; gBattleScripting.animArg2 = gBattlerAttacker; - BattleScriptExecute(BattleScript_LeechSeedTurnDrain); + gBattleMoveDamage = max(1, GetNonDynamaxMaxHP(battler) / 8); + gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE; + if (GetBattlerAbility(battler) == ABILITY_LIQUID_OOZE) + { + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_LEECH_SEED_OOZE; + BattleScriptExecute(BattleScript_LeechSeedTurnDrainLiquidOoze); + } + else if (gStatuses3[gBattlerTarget] & STATUS3_HEAL_BLOCK) + { + BattleScriptExecute(BattleScript_LeechSeedTurnDrainHealBlock); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_LEECH_SEED_DRAIN; + BattleScriptExecute(BattleScript_LeechSeedTurnDrainRecovery); + } effect++; } gBattleStruct->turnEffectsTracker++; diff --git a/test/battle/move_effect/leech_seed.c b/test/battle/move_effect/leech_seed.c index fce80c661c57..bae80c049136 100644 --- a/test/battle/move_effect/leech_seed.c +++ b/test/battle/move_effect/leech_seed.c @@ -20,8 +20,62 @@ SINGLE_BATTLE_TEST("Leech Seed doesn't affect Grass-type Pokémon") MESSAGE("It doesn't affect the opposing Oddish…"); } } + +SINGLE_BATTLE_TEST("Leech Seeded targets lose 1/8 of its max HP every turn and give it to the user") +{ + s16 damage; + s16 healed; + + GIVEN { + PLAYER(SPECIES_WYNAUT) { HP(1); } + OPPONENT(SPECIES_SHELLDER); + } WHEN { + TURN { MOVE(player, MOVE_LEECH_SEED); } + TURN {} + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_LEECH_SEED, player); + HP_BAR(opponent, captureDamage: &damage); + HP_BAR(player, captureDamage: &healed); + } THEN { + EXPECT_MUL_EQ(damage, Q_4_12(-1), healed); + } +} + +SINGLE_BATTLE_TEST("Leech Seed recovery is prevented by Heal Block") +{ + GIVEN { + PLAYER(SPECIES_WYNAUT) { HP(1); } + OPPONENT(SPECIES_SHELLDER); + } WHEN { + TURN { MOVE(opponent, MOVE_HEAL_BLOCK); MOVE(player, MOVE_LEECH_SEED); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_HEAL_BLOCK, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_LEECH_SEED, player); + HP_BAR(opponent); + NOT HP_BAR(player); + } +} + +SINGLE_BATTLE_TEST("Leech Seed recovery will drain the hp of user if leech seeded mon has Liquid Ooze") +{ + s16 damage; + s16 healed; + + GIVEN { + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_TENTACOOL) { Ability(ABILITY_LIQUID_OOZE); } + } WHEN { + TURN { MOVE(player, MOVE_LEECH_SEED); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_LEECH_SEED, player); + HP_BAR(opponent, captureDamage: &damage); + HP_BAR(player, captureDamage: &healed); + } THEN { + EXPECT_EQ(damage, healed); + } +} + TO_DO_BATTLE_TEST("Leech Seed doesn't affect already seeded targets") -TO_DO_BATTLE_TEST("Leech Seeded targets lose 1/8 of its max HP every turn and give it to the user") TO_DO_BATTLE_TEST("Leech Seed's effect is paused until a new battler replaces the original user's position") // Faint, can't be replaced, then revived. TO_DO_BATTLE_TEST("Leech Seed's effect pause still prevents it from being seeded again") TO_DO_BATTLE_TEST("Baton Pass passes Leech Seed's effect"); From f313c552d1ed67ce96e60df76c7abd5a76923947 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Thu, 21 Nov 2024 16:15:20 +0100 Subject: [PATCH 2/3] fix test --- test/battle/move_effect/leech_seed.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/battle/move_effect/leech_seed.c b/test/battle/move_effect/leech_seed.c index bae80c049136..67e829cf8ad4 100644 --- a/test/battle/move_effect/leech_seed.c +++ b/test/battle/move_effect/leech_seed.c @@ -34,6 +34,8 @@ SINGLE_BATTLE_TEST("Leech Seeded targets lose 1/8 of its max HP every turn and g TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_LEECH_SEED, player); + HP_BAR(opponent); + HP_BAR(player); HP_BAR(opponent, captureDamage: &damage); HP_BAR(player, captureDamage: &healed); } THEN { From 550c33f582fa38675e1fe256bdcfd4d7b14a6ea4 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Thu, 21 Nov 2024 17:21:15 +0100 Subject: [PATCH 3/3] fix absorb tests --- src/battle_script_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9564ed7e466b..46d050330709 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5722,9 +5722,9 @@ static void Cmd_moveend(void) } else if (IsBattlerAlive(gBattlerAttacker) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - gBattleMoveDamage = (gHpDealt * gMovesInfo[gCurrentMove].argument / 100); - gBattleMoveDamage = max(1, GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage)); - gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE; + gBattleMoveDamage = max(1, (gHpDealt * gMovesInfo[gCurrentMove].argument / 100)); + gBattleMoveDamage = GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage); + gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE; effect = TRUE; if (GetBattlerAbility(gBattlerTarget) == ABILITY_LIQUID_OOZE) {