Skip to content

Commit

Permalink
Fixes Grassy Terrain heal turn duration (#4903)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Jul 3, 2024
1 parent 594633a commit dd7b735
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
10 changes: 9 additions & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
5 changes: 4 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/battle/terrain/grassy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

0 comments on commit dd7b735

Please sign in to comment.