From 2b0702ec04a5c0e3b3a036ef7ee587b36c1763d3 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 11 Dec 2020 19:00:30 -0300 Subject: [PATCH] Implemented Perish Body Inspired by Raguzero's implementation. --- data/battle_scripts_1.s | 7 +++++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 2 ++ src/battle_util.c | 22 ++++++++++++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c03384cfbd..5701d223e2 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5733,6 +5733,13 @@ BattleScript_PerishSongTakesLife:: tryfaintmon BS_ATTACKER, FALSE, NULL end2 +BattleScript_PerishBodyActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNSWILLPERISHIN3TURNS + waitmessage 0x40 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage 0x40 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index f97c992c98..2d4fb2ed28 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -354,5 +354,6 @@ extern const u8 BattleScript_BattlerAbilityStatRaiseOnSwitchIn[]; extern const u8 BattleScript_CottonDownActivates[]; extern const u8 BattleScript_BallFetch[]; extern const u8 BattleScript_SandSpitActivates[]; +extern const u8 BattleScript_PerishBodyActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 7f1737ac1c..297233eb07 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -561,8 +561,9 @@ #define STRINGID_FETCHEDPOKEBALL 557 #define STRINGID_BATTLERABILITYRAISEDSTAT 558 #define STRINGID_ASANDSTORMKICKEDUP 559 +#define STRINGID_PKMNSWILLPERISHIN3TURNS 560 -#define BATTLESTRINGS_COUNT 560 +#define BATTLESTRINGS_COUNT 561 //// multichoice message IDs // switch in ability message diff --git a/src/battle_message.c b/src/battle_message.c index 2fec453b0d..ea574f0e99 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -688,9 +688,11 @@ static const u8 sText_ScreenCleanerActivates[] = _("All screens on the field wer static const u8 sText_FetchedPokeBall[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} found\na {B_LAST_ITEM}!"); static const u8 sText_BattlerAbilityRaisedStat[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nraised its {B_BUFF1}!"); static const u8 sText_ASandstormKickedUp[] = _("A sandstorm kicked up!"); +static const u8 sText_PkmnsWillPerishIn3Turns[] = _("Both Pokémon will perish\nin three turns!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_PKMNSWILLPERISHIN3TURNS - 12] = sText_PkmnsWillPerishIn3Turns, [STRINGID_ASANDSTORMKICKEDUP - 12] = sText_ASandstormKickedUp, [STRINGID_BATTLERABILITYRAISEDSTAT - 12] = sText_BattlerAbilityRaisedStat, [STRINGID_FETCHEDPOKEBALL - 12] = sText_FetchedPokeBall, diff --git a/src/battle_util.c b/src/battle_util.c index 73304c8fe3..65f55001b9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4663,6 +4663,28 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_PERISH_BODY: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && !(gStatuses3[gBattlerAttacker] & STATUS3_PERISH_SONG)) + { + if (!(gStatuses3[battler] & STATUS3_PERISH_SONG)) + { + gStatuses3[battler] |= STATUS3_PERISH_SONG; + gDisableStructs[battler].perishSongTimer = 3; + gDisableStructs[battler].perishSongTimerStartValue = 3; + } + gStatuses3[gBattlerAttacker] |= STATUS3_PERISH_SONG; + gDisableStructs[gBattlerAttacker].perishSongTimer = 3; + gDisableStructs[gBattlerAttacker].perishSongTimerStartValue = 3; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_PerishBodyActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker