From 13062b5a8fad46ec1d4e9ecfcdee08b15f334023 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 22 Sep 2021 09:43:40 -0400 Subject: [PATCH] fix lash out, obstruct, and decorate --- asm/macros/battle_script.inc | 5 --- data/battle_scripts_1.s | 39 +++++++++------------- include/battle.h | 1 - include/constants/battle_script_commands.h | 1 - src/battle_main.c | 1 - src/battle_script_commands.c | 27 ++++++--------- src/battle_util.c | 2 +- 7 files changed, 26 insertions(+), 50 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 70ddbdf58..02c2a91d1 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1816,11 +1816,6 @@ various BS_ATTACKER, VARIOUS_REMOVE_TERRAIN .endm - .macro jumpifobstruct ptr:req - various BS_ATTACKER, VARIOUS_JUMP_IF_OBSTRUCT - .4byte \ptr - .endm - @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 261145048..755b2c382 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -382,6 +382,7 @@ gBattleScriptsForMoveEffects:: BattleScript_EffectDecorate: attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, 12, BattleScript_DecorateBoost @@ -396,13 +397,13 @@ BattleScript_DecorateBoost: statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_DecorateBoostSpAtk jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DecorateBoostSpAtk printfromtable gStatUpStringIds - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG BattleScript_DecorateBoostSpAtk: setstatchanger STAT_SPATK, 2, FALSE statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MoveEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_MoveEnd printfromtable gStatUpStringIds - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd BattleScript_EffectRemoveTerrain: @@ -421,13 +422,13 @@ BattleScript_EffectRemoveTerrain: healthbarupdate BS_TARGET datahpupdate BS_TARGET critmessage - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG resultmessage - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG removeterrain jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 4, BattleScript_MoveEnd printfromtable gTerrainEndingStringIds - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL tryfaintmon BS_TARGET, FALSE, NULL goto BattleScript_MoveEnd @@ -441,8 +442,8 @@ BattleScript_EffectCoaching: setallytonexttarget EffectCoaching_CheckAllyStats goto BattleScript_ButItFailed EffectCoaching_CheckAllyStats: - jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, 12, BattleScript_CoachingWorks - jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_DEF, 12, BattleScript_CoachingWorks + jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, MAX_STAT_STAGE, BattleScript_CoachingWorks + jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_DEF, MAX_STAT_STAGE, BattleScript_CoachingWorks goto BattleScript_ButItFailed @ ally at max atk, def BattleScript_CoachingWorks: attackanimation @@ -453,13 +454,13 @@ BattleScript_CoachingWorks: statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_CoachingBoostDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_CoachingBoostDef printfromtable gStatUpStringIds - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG BattleScript_CoachingBoostDef: setstatchanger STAT_DEF, 1, FALSE statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MoveEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_MoveEnd printfromtable gStatUpStringIds - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd BattleScript_EffectJungleHealing: @@ -478,7 +479,7 @@ JungleHealing_RestoreTargetHealth: healthbarupdate BS_TARGET datahpupdate BS_TARGET printstring STRINGID_PKMNREGAINEDHEALTH - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG BattleScript_JungleHealing_TryCureStatus: jumpifmove MOVE_LIFE_DEW, BattleScript_JungleHealingTryRestoreAlly @ life dew only heals jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_JungleHealingCureStatus @@ -487,7 +488,7 @@ BattleScript_JungleHealingCureStatus: curestatus BS_TARGET updatestatusicon BS_TARGET printstring STRINGID_PKMNSTATUSNORMAL - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG BattleScript_JungleHealingTryRestoreAlly: jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_MoveEnd addbyte gBattleCommunication, 1 @@ -2233,17 +2234,6 @@ BattleScript_MoveMissed:: effectivenesssound resultmessage waitmessage B_WAIT_TIME_LONG - jumpifobstruct BattleScript_ObstructActivates - goto BattleScript_MoveEnd - -BattleScript_ObstructActivates: - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, MIN_STAT_STAGE, BattleScript_ObstructActivationEnd - setgraphicalstatchangevalues - playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 - statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_ObstructActivationEnd - printfromtable gStatDownStringIds - waitmessage B_WAIT_TIME_LONG -BattleScript_ObstructActivationEnd: goto BattleScript_MoveEnd BattleScript_EffectSleep:: @@ -3624,12 +3614,13 @@ BattleScript_EffectEerieSpell:: healthbarupdate BS_TARGET datahpupdate BS_TARGET critmessage - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG resultmessage - waitmessage 0x40 + waitmessage B_WAIT_TIME_LONG tryfaintmon BS_TARGET, FALSE, NULL eeriespellppreduce BattleScript_MoveEnd printstring STRINGID_PKMNREDUCEDPP + waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd BattleScript_EffectSpite:: diff --git a/include/battle.h b/include/battle.h index 491e67acf..cf231f5ae 100644 --- a/include/battle.h +++ b/include/battle.h @@ -143,7 +143,6 @@ struct ProtectStruct u32 usedGravityPreventedMove:1; u32 powderSelfDmg:1; u32 usedThroatChopPreventedMove:1; - u32 statFell:1; u32 statRaised:1; u32 micle:1; u32 custap:1; // also quick claw diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 1f3a72a67..12a789c8b 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -183,7 +183,6 @@ #define VARIOUS_JUMP_IF_TEAM_HEALTHY 111 #define VARIOUS_TRY_HEAL_QUARTER_HP 112 #define VARIOUS_REMOVE_TERRAIN 113 -#define VARIOUS_JUMP_IF_OBSTRUCT 114 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index ebdd54e41..0780c8802 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3093,7 +3093,6 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].usesBouncedMove = 0; gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0; gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; - gProtectStructs[gActiveBattler].statFell = 0; gProtectStructs[gActiveBattler].statRaised = 0; gDisableStructs[gActiveBattler].isFirstTurn = 2; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e58e34725..313d3ea46 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1237,16 +1237,21 @@ static const u8 sBattlePalaceNatureToFlavorTextId[NUM_NATURES] = bool32 IsBattlerProtected(u8 battlerId, u16 move) { + // Decorate bypasses protect and detect, but not crafty shield + if (move == MOVE_DECORATE) + { + if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD) + return TRUE; + else if (gProtectStructs[battlerId].protected) + return FALSE; + } + if (!(gBattleMoves[move].flags & FLAG_PROTECT_AFFECTED)) return FALSE; else if (gBattleMoves[move].effect == MOVE_EFFECT_FEINT) return FALSE; else if (gProtectStructs[battlerId].protected) - { - if (move == MOVE_DECORATE && !(gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD)) - return FALSE; // decorate bypasses protect and detect, but not crafty shield return TRUE; - } else if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_WIDE_GUARD && gBattleMoves[move].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY)) return TRUE; @@ -4778,6 +4783,7 @@ static void Cmd_moveend(void) } else if (gProtectStructs[gBattlerTarget].obstructed && gCurrentMove != MOVE_SUCKER_PUNCH) { + gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; i = gBattlerAttacker; gBattlerAttacker = gBattlerTarget; gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable @@ -8697,19 +8703,6 @@ static void Cmd_various(void) } gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY; // remove the terrain break; - case VARIOUS_JUMP_IF_OBSTRUCT: - // if obstruct blocked a contact move, sharply lower defense - if (IsMoveMakingContact(gCurrentMove, gBattlerAttacker) && gProtectStructs[gBattlerTarget].obstructed && !IS_MOVE_STATUS(gCurrentMove)) - { - SET_STATCHANGER(STAT_DEF, 2, TRUE); - gBattleScripting.battler = gBattlerAttacker; - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - } - else - { - gBattlescriptCurrInstr += 7; - } - return; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 0473fa054..16adcda75 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7468,7 +7468,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) basePower *= 2; break; case EFFECT_LASH_OUT: - if (gProtectStructs[battlerAtk].statFell == 1) + if (gSpecialStatuses[battlerAtk].statFell == 1) basePower *= 2; break; case EFFECT_EXPLOSION: