Fixes heal blocked leeach seed in tests (#5700)

This commit is contained in:
Alex 2024-11-21 18:18:44 +01:00 committed by GitHub
parent 3cc048cc01
commit 612c8d3ff6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 28 deletions

View file

@ -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

View file

@ -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[];

View file

@ -5722,9 +5722,7 @@ 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 = max(1, (gHpDealt * gMovesInfo[gCurrentMove].argument / 100));
gBattleMoveDamage = GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage);
gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE;
effect = TRUE;

View file

@ -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++;

View file

@ -20,8 +20,64 @@ 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);
HP_BAR(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");