From 6cffd5b045667ed7cd8578376a348b35e901c5fc Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 21 Jul 2018 13:24:20 +0200 Subject: [PATCH] Add new field end turn effects --- data/battle_scripts_1.s | 45 +++++++++++++ include/battle_scripts.h | 9 +++ include/constants/battle_string_ids.h | 6 +- src/battle_message.c | 9 +++ src/battle_util.c | 93 ++++++++++++++++++++++++++- 5 files changed, 160 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5c0092ac1..f47bbbf90 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3237,6 +3237,51 @@ BattleScript_TailwindEnds:: printstring STRINGID_TAILWINDENDS waitmessage 0x40 end2 + +BattleScript_TrickRoomEnds:: + printstring STRINGID_TRICKROOMENDS + waitmessage 0x40 + end2 + +BattleScript_WonderRoomEnds:: + printstring STRINGID_WONDERROOMENDS + waitmessage 0x40 + end2 + +BattleScript_MagicRoomEnds:: + printstring STRINGID_MAGICROOMENDS + waitmessage 0x40 + end2 + +BattleScript_ElectricTerrainEnds:: + printstring STRINGID_ELECTRICTERRAINENDS + waitmessage 0x40 + end2 + +BattleScript_MistyTerrainEnds:: + printstring STRINGID_MISTYTERRAINENDS + waitmessage 0x40 + end2 + +BattleScript_GrassyTerrainEnds:: + printstring STRINGID_GRASSYTERRAINENDS + waitmessage 0x40 + end2 + +BattleScript_PsychicTerrainEnds:: + printstring STRINGID_PSYCHICTERRAINENDS + waitmessage 0x40 + end2 + +BattleScript_MudSportEnds:: + printstring STRINGID_MUDSPORTENDS + waitmessage 0x40 + end2 + +BattleScript_WaterSportEnds:: + printstring STRINGID_WATERSPORTENDS + waitmessage 0x40 + end2 BattleScript_SafeguardProtected:: pause 0x20 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 0fdee16fe..6286af678 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -294,5 +294,14 @@ extern const u8 BattleScript_AquaRingHeal[]; extern const u8 BattleScript_AuroraVeilEnds[]; extern const u8 BattleScript_LuckyChantEnds[]; extern const u8 BattleScript_TailwindEnds[]; +extern const u8 BattleScript_TrickRoomEnds[]; +extern const u8 BattleScript_WonderRoomEnds[]; +extern const u8 BattleScript_MagicRoomEnds[]; +extern const u8 BattleScript_ElectricTerrainEnds[]; +extern const u8 BattleScript_MistyTerrainEnds[]; +extern const u8 BattleScript_GrassyTerrainEnds[]; +extern const u8 BattleScript_PsychicTerrainEnds[]; +extern const u8 BattleScript_MudSportEnds[]; +extern const u8 BattleScript_WaterSportEnds[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index e14e18dae..98e8940f2 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -446,7 +446,11 @@ #define STRINGID_GRAVITYENDS 443 #define STRINGID_AQUARINGHEAL 444 #define STRINGID_AURORAVEILENDS 445 +#define STRINGID_ELECTRICTERRAINENDS 446 +#define STRINGID_MISTYTERRAINENDS 447 +#define STRINGID_PSYCHICTERRAINENDS 448 +#define STRINGID_GRASSYTERRAINENDS 449 -#define BATTLESTRINGS_COUNT 434 +#define BATTLESTRINGS_COUNT 438 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_message.c b/src/battle_message.c index 1b04d361e..d5e78aff1 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -589,6 +589,10 @@ static const u8 sText_AquaRingHeal[] = _("Aqua Ring restored\n{B_ATK_NAME_WITH_P // These strings are currently placeholders, to be fixed. static const u8 sText_AuroraVeilEnds[] = _(""); +static const u8 sText_ElectricTerrainEnds[] = _(""); +static const u8 sText_MistyTerrainEnds[] = _(""); +static const u8 sText_PsychicTerrainEnds[] = _(""); +static const u8 sText_GrassyTerrainEnds[] = _(""); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1026,6 +1030,11 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = sText_WaterSportEnds, // 442 sText_GravityEnds, // 443 sText_AquaRingHeal, // 444 + sText_AuroraVeilEnds, // 445 + sText_ElectricTerrainEnds, // 446 + sText_MistyTerrainEnds, // 447 + sText_PsychicTerrainEnds, // 448 + sText_GrassyTerrainEnds, // 449 }; const u16 gMissStringIds[] = diff --git a/src/battle_util.c b/src/battle_util.c index fc426d94e..995ccf5b1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -758,13 +758,21 @@ enum ENDTURN_SANDSTORM, ENDTURN_SUN, ENDTURN_HAIL, + ENDTURN_WATER_SPORT, + ENDTURN_MUD_SPORT, + ENDTURN_TRICK_ROOM, + ENDTURN_WONDER_ROOM, + ENDTURN_MAGIC_ROOM, + ENDTURN_ELECTRIC_TERRAIN, + ENDTURN_MISTY_TERRAIN, + ENDTURN_GRASSY_TERRAIN, + ENDTURN_PSYCHIC_TERRAIN, ENDTURN_FIELD_COUNT, }; u8 DoFieldEndTurnEffects(void) { u8 effect = 0; - s32 i; for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerAttacker]; gBattlerAttacker++) { @@ -775,6 +783,7 @@ u8 DoFieldEndTurnEffects(void) do { + s32 i; u8 side; switch (gBattleStruct->turnCountersTracker) @@ -1077,11 +1086,93 @@ u8 DoFieldEndTurnEffects(void) } gBattleStruct->turnCountersTracker++; break; + case ENDTURN_TRICK_ROOM: + if (gFieldStatuses & STATUS_FIELD_TRICK_ROOM && --gFieldTimers.trickRoomTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_TRICK_ROOM); + BattleScriptExecute(BattleScript_TrickRoomEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_WONDER_ROOM: + if (gFieldStatuses & STATUS_FIELD_WONDER_ROOM && --gFieldTimers.wonderRoomTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_WONDER_ROOM); + BattleScriptExecute(BattleScript_WonderRoomEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_MAGIC_ROOM: + if (gFieldStatuses & STATUS_FIELD_MAGIC_ROOM && --gFieldTimers.magicRoomTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_MAGIC_ROOM); + BattleScriptExecute(BattleScript_MagicRoomEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_ELECTRIC_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && --gFieldTimers.electricTerrainTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN); + BattleScriptExecute(BattleScript_ElectricTerrainEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_MISTY_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && --gFieldTimers.mistyTerrainTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN); + BattleScriptExecute(BattleScript_MistyTerrainEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_GRASSY_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && --gFieldTimers.grassyTerrainTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN); + BattleScriptExecute(BattleScript_GrassyTerrainEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_PSYCHIC_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && --gFieldTimers.psychicTerrainTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN); + BattleScriptExecute(BattleScript_PsychicTerrainEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_WATER_SPORT: + if (gFieldStatuses & STATUS_FIELD_WATERSPORT && --gFieldTimers.waterSportTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_WATERSPORT); + BattleScriptExecute(BattleScript_WaterSportEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; + case ENDTURN_MUD_SPORT: + if (gFieldStatuses & STATUS_FIELD_MUDSPORT && --gFieldTimers.mudSportTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_MUDSPORT); + BattleScriptExecute(BattleScript_MudSportEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; case ENDTURN_FIELD_COUNT: effect++; break; } } while (effect == 0); + return (gBattleMainFunc != BattleTurnPassed); }