From 98fa84407bff31ded3cf8e74e10154ca7ac30352 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:09:00 +0100 Subject: [PATCH] Fixes Magic Coat message (#5645) --- asm/macros/battle_script.inc | 8 +++--- data/battle_scripts_1.s | 23 +++++++++++------ include/battle_scripts.h | 5 ++-- src/battle_message.c | 49 ++++++++++++++++-------------------- src/battle_script_commands.c | 37 ++++++++++++++------------- 5 files changed, 64 insertions(+), 58 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index b70a3d452f44..d816a2bcb80b 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1700,15 +1700,15 @@ .4byte \failInstr .endm + .macro setmagiccoattarget + callnative BS_SetMagicCoatTarget + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES .endm - .macro setmagiccoattarget battler:req - various \battler, VARIOUS_SET_MAGIC_COAT_TARGET - .endm - .macro getifcantrunfrombattle battler:req various \battler, VARIOUS_IS_RUNNING_IMPOSSIBLE .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4099af2d7895..adae0359e8fb 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6881,25 +6881,34 @@ BattleScript_GrudgeTakesPp:: waitmessage B_WAIT_TIME_LONG return -BattleScript_MagicCoatBounce:: +BattleScript_MagicBounce:: attackstring ppreduce pause B_WAIT_TIME_SHORT - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0, BattleScript_MagicCoatBounce_Print call BattleScript_AbilityPopUp -BattleScript_MagicCoatBounce_Print: - printfromtable gMagicCoatBounceStringIds + printstring STRINGID_PKMNMOVEBOUNCEDABILITY waitmessage B_WAIT_TIME_LONG + setmagiccoattarget orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_ALLOW_NO_PP bicword gHitMarker, HITMARKER_NO_ATTACKSTRING - setmagiccoattarget BS_ATTACKER return -BattleScript_MagicCoatBouncePrankster:: +BattleScript_MagicCoat:: attackstring ppreduce pause B_WAIT_TIME_SHORT - printfromtable gMagicCoatBounceStringIds + setmagiccoattarget + printstring STRINGID_PKMNMOVEBOUNCED + waitmessage B_WAIT_TIME_LONG + orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_ALLOW_NO_PP + bicword gHitMarker, HITMARKER_NO_ATTACKSTRING + return + +BattleScript_MagicCoatPrankster:: + attackstring + ppreduce + pause B_WAIT_TIME_SHORT + printstring STRINGID_PKMNMOVEBOUNCED waitmessage B_WAIT_TIME_LONG printstring STRINGID_ITDOESNTAFFECT waitmessage B_WAIT_TIME_LONG diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 8ef451734e07..3678b4a289a4 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -111,8 +111,9 @@ extern const u8 BattleScript_MoveUsedIsImprisoned[]; extern const u8 BattleScript_SelectingImprisonedMove[]; extern const u8 BattleScript_SelectingImprisonedMoveInPalace[]; extern const u8 BattleScript_GrudgeTakesPp[]; -extern const u8 BattleScript_MagicCoatBounce[]; -extern const u8 BattleScript_MagicCoatBouncePrankster[]; +extern const u8 BattleScript_MagicBounce[]; +extern const u8 BattleScript_MagicCoat[]; +extern const u8 BattleScript_MagicCoatPrankster[]; extern const u8 BattleScript_SnatchedMove[]; extern const u8 BattleScript_EnduredMsg[]; extern const u8 BattleScript_OneHitKOMsg[]; diff --git a/src/battle_message.c b/src/battle_message.c index 999eaa9921a2..465918ee69f3 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -246,28 +246,28 @@ static const u8 sText_PkmnCopiedFoe[] = _("{B_ATK_NAME_WITH_PREFIX} copied\n{B_D static const u8 sText_PkmnMadeWish[] = _("{B_ATK_NAME_WITH_PREFIX} made a WISH!"); static const u8 sText_PkmnWishCameTrue[] = _("{B_BUFF1}'s WISH\ncame true!"); static const u8 sText_PkmnPlantedRoots[] = _("{B_ATK_NAME_WITH_PREFIX} planted its roots!"); -static const u8 sText_PkmnAbsorbedNutrients[] = _("{B_ATK_NAME_WITH_PREFIX} absorbed nutrients with its roots!"); -static const u8 sText_PkmnAnchoredItself[] = _("{B_DEF_NAME_WITH_PREFIX} anchored itself with its roots!"); -static const u8 sText_PkmnWasMadeDrowsy[] = _("{B_DEF_NAME_WITH_PREFIX} grew drowsy!"); -static const u8 sText_PkmnKnockedOff[] = _("{B_ATK_NAME_WITH_PREFIX} knocked off {B_DEF_NAME_WITH_PREFIX}'s {B_LAST_ITEM}!"); -static const u8 sText_PkmnSwappedAbilities[] = _("{B_ATK_NAME_WITH_PREFIX} swapped Abilities with its target!"); -static const u8 sText_PkmnSealedOpponentMove[] = _("{B_ATK_NAME_WITH_PREFIX} sealed any moves its target shares with it!"); -static const u8 sText_PkmnWantsGrudge[] = _("{B_ATK_NAME_WITH_PREFIX} wants its target to bear a grudge!"); -static const u8 sText_PkmnLostPPGrudge[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_BUFF1} lost all its PP due to the grudge!"); -static const u8 sText_PkmnShroudedItself[] = _("{B_ATK_NAME_WITH_PREFIX} shrouded itself with Magic Coat!"); -static const u8 sText_PkmnMoveBounced[] = _("{B_EFF_NAME_WITH_PREFIX} bounced the {B_CURRENT_MOVE} back!"); -static const u8 sText_PkmnWaitsForTarget[] = _("{B_ATK_NAME_WITH_PREFIX} waits for a target to make a move!"); -static const u8 sText_PkmnSnatchedMove[] = _("{B_DEF_NAME_WITH_PREFIX} snatched {B_SCR_ACTIVE_NAME_WITH_PREFIX}'s move!"); -static const u8 sText_ElectricityWeakened[] = _("Electricity's power was weakened!"); -static const u8 sText_FireWeakened[] = _("Fire's power was weakened!"); -static const u8 sText_XFoundOneY[] = _("{B_ATK_NAME_WITH_PREFIX} found one {B_LAST_ITEM}!"); -static const u8 sText_SoothingAroma[] = _("A soothing aroma wafted through the area!"); -static const u8 sText_ItemsCantBeUsedNow[] = _("Items can't be used now.{PAUSE 64}"); //not in gen 5+, i think -static const u8 sText_ForXCommaYZ[] = _("For {B_SCR_ACTIVE_NAME_WITH_PREFIX}, {B_LAST_ITEM} {B_BUFF1}"); //not in gen 5+, expansion doesn't use anymore -static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} used the {B_LAST_ITEM} to get pumped!"); -static const u8 sText_PkmnLostFocus[] = _("{B_ATK_NAME_WITH_PREFIX} lost its focus and couldn't move!"); -static const u8 sText_PkmnWasDraggedOut[] = _("{B_DEF_NAME_WITH_PREFIX} was dragged out!\p"); -static const u8 sText_TheWallShattered[] = _("The wall shattered!"); //not in gen5+, uses "your teams light screen wore off!" etc instead +static const u8 sText_PkmnAbsorbedNutrients[] = _("{B_ATK_NAME_WITH_PREFIX} absorbed\nnutrients with its roots!"); +static const u8 sText_PkmnAnchoredItself[] = _("{B_DEF_NAME_WITH_PREFIX} anchored\nitself with its roots!"); +static const u8 sText_PkmnWasMadeDrowsy[] = _("{B_ATK_NAME_WITH_PREFIX} made\n{B_DEF_NAME_WITH_PREFIX} drowsy!"); +static const u8 sText_PkmnKnockedOff[] = _("{B_ATK_NAME_WITH_PREFIX} knocked off\n{B_DEF_NAME_WITH_PREFIX}'s {B_LAST_ITEM}!"); +static const u8 sText_PkmnSwappedAbilities[] = _("{B_ATK_NAME_WITH_PREFIX} swapped abilities\nwith its opponent!"); +static const u8 sText_PkmnSealedOpponentMove[] = _("{B_ATK_NAME_WITH_PREFIX} sealed the\nopponent's move(s)!"); +static const u8 sText_PkmnWantsGrudge[] = _("{B_ATK_NAME_WITH_PREFIX} wants the\nopponent to bear a GRUDGE!"); +static const u8 sText_PkmnLostPPGrudge[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_BUFF1} lost\nall its PP due to the GRUDGE!"); +static const u8 sText_PkmnShroudedItself[] = _("{B_ATK_NAME_WITH_PREFIX} shrouded\nitself in {B_CURRENT_MOVE}!"); +static const u8 sText_PkmnMoveBounced[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_CURRENT_MOVE}\nwas bounced back by MAGIC COAT!"); +static const u8 sText_PkmnWaitsForTarget[] = _("{B_ATK_NAME_WITH_PREFIX} waits for a target\nto make a move!"); +static const u8 sText_PkmnSnatchedMove[] = _("{B_DEF_NAME_WITH_PREFIX} SNATCHED\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s move!"); +static const u8 sText_ElectricityWeakened[] = _("Electricity's power was\nweakened!"); +static const u8 sText_FireWeakened[] = _("Fire's power was\nweakened!"); +static const u8 sText_XFoundOneY[] = _("{B_ATK_NAME_WITH_PREFIX} found\none {B_LAST_ITEM}!"); +static const u8 sText_SoothingAroma[] = _("A soothing aroma wafted\nthrough the area!"); +static const u8 sText_ItemsCantBeUsedNow[] = _("Items can't be used now.{PAUSE 64}"); +static const u8 sText_ForXCommaYZ[] = _("For {B_SCR_ACTIVE_NAME_WITH_PREFIX},\n{B_LAST_ITEM} {B_BUFF1}"); +static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} used\n{B_LAST_ITEM} to get pumped!"); +static const u8 sText_PkmnLostFocus[] = _("{B_ATK_NAME_WITH_PREFIX} lost its\nfocus and couldn't move!"); +static const u8 sText_PkmnWasDraggedOut[] = _("{B_DEF_NAME_WITH_PREFIX} was\ndragged out!\p"); +static const u8 sText_TheWallShattered[] = _("The wall shattered!"); static const u8 sText_ButNoEffect[] = _("But it had no effect!"); static const u8 sText_PkmnHasNoMovesLeft[] = _("{B_ATK_NAME_WITH_PREFIX} has no\nmoves left!\p"); static const u8 sText_PkmnMoveIsDisabled[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_CURRENT_MOVE}\nis disabled!\p"); @@ -1607,11 +1607,6 @@ const u16 gTerrainPreventsStringIds[] = [B_MSG_TERRAINPREVENTS_PSYCHIC] = STRINGID_PSYCHICTERRAINPREVENTS }; -const u16 gMagicCoatBounceStringIds[] = -{ - STRINGID_PKMNMOVEBOUNCED, STRINGID_PKMNMOVEBOUNCEDABILITY -}; - const u16 gHealingWishStringIds[] = { STRINGID_HEALINGWISHCAMETRUE, STRINGID_LUNARDANCECAMETRUE diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 25cbcba576ef..94410f9822de 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1356,19 +1356,18 @@ static void Cmd_attackcanceler(void) && !gBattleStruct->bouncedMoveIsUsed) { gBattleStruct->bouncedMoveIsUsed = TRUE; - gBattleCommunication[MULTISTRING_CHOOSER] = 0; // Edge case for bouncing a powder move against a grass type pokemon. SetAtkCancellerForCalledMove(); if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE)) { // Opponent used a prankster'd magic coat -> reflected status move should fail against a dark-type attacker gBattlerTarget = gBattlerAttacker; - gBattlescriptCurrInstr = BattleScript_MagicCoatBouncePrankster; + gBattlescriptCurrInstr = BattleScript_MagicCoatPrankster; } else { BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; + gBattlescriptCurrInstr = BattleScript_MagicCoat; } return; } @@ -1391,11 +1390,10 @@ static void Cmd_attackcanceler(void) if (gBattleStruct->bouncedMoveIsUsed) { - gBattleCommunication[MULTISTRING_CHOOSER] = 1; // Edge case for bouncing a powder move against a grass type pokemon. SetAtkCancellerForCalledMove(); BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; + gBattlescriptCurrInstr = BattleScript_MagicBounce; gBattlerAbility = battler; return; } @@ -8627,7 +8625,7 @@ static void Cmd_various(void) struct Pokemon *mon; s32 i; u8 data[10]; - u32 side, battler, bits; + u32 battler, bits; if (gBattleControllerExecFlags) return; @@ -8933,18 +8931,6 @@ static void Cmd_various(void) } break; } - case VARIOUS_SET_MAGIC_COAT_TARGET: - { - VARIOUS_ARGS(); - gBattleStruct->attackerBeforeBounce = battler; - gBattlerAttacker = gBattlerTarget; - side = BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker)); - if (IsAffectedByFollowMe(gBattlerAttacker, side, gCurrentMove)) - gBattlerTarget = gSideTimers[side].followmeTarget; - else - gBattlerTarget = battler; - break; - } case VARIOUS_IS_RUNNING_IMPOSSIBLE: { VARIOUS_ARGS(); @@ -16455,3 +16441,18 @@ void BS_HitSwitchTargetFailed(void) gBattleStruct->hitSwitchTargetFailed = TRUE; gBattlescriptCurrInstr = cmd->nextInstr; } + +void BS_SetMagicCoatTarget(void) +{ + NATIVE_ARGS(); + u32 side; + gBattleStruct->attackerBeforeBounce = gBattleScripting.battler = gBattlerAttacker; + gBattlerAttacker = gBattlerTarget; + side = BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker)); + if (IsAffectedByFollowMe(gBattlerAttacker, side, gCurrentMove)) + gBattlerTarget = gSideTimers[side].followmeTarget; + else + gBattlerTarget = gBattleStruct->attackerBeforeBounce; + + gBattlescriptCurrInstr = cmd->nextInstr; +}