diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8bceedfa47..028c85b05c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5931,6 +5931,10 @@ BattleScript_MagicRoomEnds:: waitmessage B_WAIT_TIME_LONG end2 +BattleScript_GrassyTerrainEnds:: + call BattleScript_GrassyTerrainHeals_Ret + goto BattleScript_TerrainEnds + BattleScript_TerrainEnds_Ret:: printfromtable gTerrainStringIds waitmessage B_WAIT_TIME_LONG @@ -8225,6 +8229,10 @@ BattleScript_MoveUsedPsychicTerrainPrevents:: goto BattleScript_MoveEnd BattleScript_GrassyTerrainHeals:: + call BattleScript_GrassyTerrainHeals_Ret + end2 + +BattleScript_GrassyTerrainHeals_Ret:: setbyte gBattleCommunication, 0 BattleScript_GrassyTerrainLoop: copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 1 @@ -8242,7 +8250,7 @@ BattleScript_GrassyTerrainLoopEnd:: bicword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd BattleScript_GrassyTerrainHealEnd: - end2 + return BattleScript_AbilityNoSpecificStatLoss:: pause B_WAIT_TIME_SHORT diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1fd77449f6..148a91783b 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -265,6 +265,7 @@ extern const u8 BattleScript_WonderRoomEnds[]; extern const u8 BattleScript_MagicRoomEnds[]; extern const u8 BattleScript_TerrainEnds[]; extern const u8 BattleScript_TerrainEnds_Ret[]; +extern const u8 BattleScript_GrassyTerrainEnds[]; extern const u8 BattleScript_MudSportEnds[]; extern const u8 BattleScript_WaterSportEnds[]; extern const u8 BattleScript_SturdiedMsg[]; diff --git a/src/battle_util.c b/src/battle_util.c index debcd6b6d2..e785679de2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1716,7 +1716,10 @@ static bool32 EndTurnTerrain(u32 terrainFlag, u32 stringTableId) gFieldStatuses &= ~terrainFlag; TryToRevertMimicryAndFlags(); gBattleCommunication[MULTISTRING_CHOOSER] = stringTableId; - BattleScriptExecute(BattleScript_TerrainEnds); + if (terrainFlag & STATUS_FIELD_GRASSY_TERRAIN) + BattleScriptExecute(BattleScript_GrassyTerrainEnds); + else + BattleScriptExecute(BattleScript_TerrainEnds); return TRUE; } } diff --git a/test/battle/terrain/grassy.c b/test/battle/terrain/grassy.c index 678352dc5e..862c9052fd 100644 --- a/test/battle/terrain/grassy.c +++ b/test/battle/terrain/grassy.c @@ -85,3 +85,27 @@ SINGLE_BATTLE_TEST("Grassy Terrain lasts for 5 turns") MESSAGE("The grass disappeared from the battlefield."); } } + +SINGLE_BATTLE_TEST("Grassy Terrain heals the pokemon on the field for the duration of the terrain, including last turn") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { HP(1); }; + } WHEN { + TURN { MOVE(opponent, MOVE_CELEBRATE); MOVE(player, MOVE_GRASSY_TERRAIN); } + TURN {} + TURN {} + TURN {} + TURN {} + } SCENE { + MESSAGE("Foe Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_GRASSY_TERRAIN, player); + MESSAGE("Grass grew to cover the battlefield!"); + MESSAGE("Foe Wobbuffet is healed by the grassy terrain!"); + MESSAGE("Foe Wobbuffet is healed by the grassy terrain!"); + MESSAGE("Foe Wobbuffet is healed by the grassy terrain!"); + MESSAGE("Foe Wobbuffet is healed by the grassy terrain!"); + MESSAGE("Foe Wobbuffet is healed by the grassy terrain!"); + MESSAGE("The grass disappeared from the battlefield."); + } +}