From a3b4767dd25b3de64df0ee60418765cd8720f5c3 Mon Sep 17 00:00:00 2001 From: Papa Cancer Date: Fri, 15 Mar 2019 12:54:11 +0000 Subject: [PATCH] Spiky Shield Created generic string "Atk was hurt by Def's BUFF" for use for both Spiky Shield and Rough Skin - can also be used for Aftermath and Rocky Helmet, when programmed --- data/battle_scripts_1.s | 9 +++++++++ include/battle_scripts.h | 1 + src/battle_message.c | 2 +- src/battle_script_commands.c | 18 ++++++++++++++++++ src/battle_util.c | 1 + 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index de90b63b2..fb300e3af 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6366,6 +6366,15 @@ BattleScript_RoughSkinActivates:: tryfaintmon BS_ATTACKER, FALSE, NULL return +BattleScript_SpikyShieldEffect:: + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + printstring STRINGID_PKMNHURTSWITH + waitmessage 0x40 + tryfaintmon BS_ATTACKER, FALSE, NULL + return + BattleScript_CuteCharmActivates:: call BattleScript_AbilityPopUp status2animation BS_ATTACKER, STATUS2_INFATUATION diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1c68b909b..5e49ac615 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -300,5 +300,6 @@ extern const u8 BattleScript_DefiantActivates[]; extern const u8 BattleScript_PowderMoveNoEffect[]; extern const u8 BattleScript_GrassyTerrainLoop[]; extern const u8 BattleScript_VCreateStatLoss[]; +extern const u8 BattleScript_SpikyShieldEffect[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_message.c b/src/battle_message.c index a2d475876..c83553cac 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -276,7 +276,7 @@ static const u8 sText_PkmnRaisedFirePowerWith[] = _("{B_DEF_NAME_WITH_PREFIX}'s static const u8 sText_PkmnAnchorsItselfWith[] = _("{B_DEF_NAME_WITH_PREFIX} anchors\nitself with {B_DEF_ABILITY}!"); static const u8 sText_PkmnCutsAttackWith[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\ncuts {B_DEF_NAME_WITH_PREFIX}'s ATTACK!"); static const u8 sText_PkmnPreventsStatLossWith[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nprevents stat loss!"); -static const u8 sText_PkmnHurtsWith[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_DEF_ABILITY}\nhurt {B_ATK_NAME_WITH_PREFIX}!"); +static const u8 sText_PkmnHurtsWith[] = _("{B_ATK_NAME_WITH_PREFIX} was hurt by\n{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1}!"); static const u8 sText_PkmnTraced[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} TRACED\n{B_BUFF1}'s {B_BUFF2}!"); static const u8 sText_PkmnsXPreventsBurns[] = _("{B_EFF_NAME_WITH_PREFIX}'s {B_EFF_ABILITY}\nprevents burns!"); static const u8 sText_PkmnsXBlocksY[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_DEF_ABILITY}\nblocks {B_CURRENT_MOVE}!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5ed4dec6d..6bca5dcfc 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4151,6 +4151,7 @@ static void atk48_playstatchangeanimation(void) enum { + ATK49_SPIKY_SHIELD, ATK49_RAGE, ATK49_DEFROST, ATK49_SYNCHRONIZE_TARGET, @@ -4202,6 +4203,23 @@ static void atk49_moveend(void) { switch (gBattleScripting.atk49_state) { + case ATK49_SPIKY_SHIELD: + if (gProtectStructs[gBattlerTarget].spikyShielded && gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT) + { + if (!(GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD)) + { + gMoveResultFlags &= ~(MOVE_RESULT_NO_EFFECT); + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_SPIKY_SHIELD); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SpikyShieldEffect; + effect = 1; + } + } + gBattleScripting.atk49_state++; + break; case ATK49_RAGE: // rage check if (gBattleMons[gBattlerTarget].status2 & STATUS2_RAGE && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget diff --git a/src/battle_util.c b/src/battle_util.c index 58826276c..3101027c8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3248,6 +3248,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_RoughSkinActivates; effect++;