Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes heal blocked leeach seed in tests #5700

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
4 changes: 1 addition & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 17 additions & 4 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
58 changes: 57 additions & 1 deletion test/battle/move_effect/leech_seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this second turn?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really but I followed the name of the test that was already present as a todo and thought I'll add it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge it as-is, but I thiiink unless I'm misreading the test that it would pass with just the first TURN :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, right. will adjust

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed I think. I compare the drained damage only once though. The other is just a normal hp check. I think this should be enough

} 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");
Loading