Skip to content

Commit

Permalink
Fixes Magic Coat message (rh-hideout#5645)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored and ivaantxo committed Nov 12, 2024
1 parent ce69942 commit 98fa844
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 58 deletions.
8 changes: 4 additions & 4 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
49 changes: 22 additions & 27 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
37 changes: 19 additions & 18 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

0 comments on commit 98fa844

Please sign in to comment.