From c914ed8572c800d9239642ee2f92cc6124d1dbda Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 25 Jul 2021 09:38:54 -0600 Subject: [PATCH] fix sucker punch, surging strikes, obstruct, and snipe shot --- asm/macros/battle_script.inc | 5 +++ data/battle_scripts_1.s | 39 +++++++++++++++++---- include/battle.h | 2 +- include/constants/battle_move_effects.h | 5 +-- include/constants/battle_script_commands.h | 1 + src/battle_main.c | 2 +- src/battle_script_commands.c | 40 ++++++++++++++++------ src/battle_util.c | 6 ++-- src/data/battle_moves.h | 8 ++--- 9 files changed, 80 insertions(+), 28 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9d2c58b56..6aacc37de 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1787,6 +1787,11 @@ .macro removeterrain 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 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a376ae4ef..8ff056d76 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -374,8 +374,10 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectLashOut .4byte BattleScript_EffectGrassyGlide .4byte BattleScript_EffectRemoveTerrain - .4byte BattleScript_EffectBehemoth + .4byte BattleScript_EffectDynamaxDoubleDmg .4byte BattleScript_EffectDecorate + .4byte BattleScript_EffectSnipeShot + .4byte BattleScript_EffectTripleHit BattleScript_EffectDecorate: attackcanceler @@ -470,22 +472,22 @@ BattleScript_EffectJungleHealing: setbyte gBattleCommunication, 0 JungleHealing_RestoreTargetHealth: copybyte gBattlerAttacker, gBattlerTarget - tryhealquarterhealth BS_TARGET, JungleHealing_TryCureStatus + tryhealquarterhealth BS_TARGET, BattleScript_JungleHealing_TryCureStatus orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_TARGET datahpupdate BS_TARGET printstring STRINGID_PKMNREGAINEDHEALTH waitmessage 0x40 -JungleHealing_TryCureStatus: - jumpifmove MOVE_LIFE_DEW, JungleHealingTryRestoreAlly @ life dew only heals +BattleScript_JungleHealing_TryCureStatus: + jumpifmove MOVE_LIFE_DEW, BattleScript_JungleHealingTryRestoreAlly @ life dew only heals jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_JungleHealingCureStatus - goto JungleHealingTryRestoreAlly + goto BattleScript_JungleHealingTryRestoreAlly BattleScript_JungleHealingCureStatus: curestatus BS_TARGET updatestatusicon BS_TARGET printstring STRINGID_PKMNSTATUSNORMAL waitmessage 0x40 -JungleHealingTryRestoreAlly: +BattleScript_JungleHealingTryRestoreAlly: jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_MoveEnd addbyte gBattleCommunication, 1 jumpifnoally BS_TARGET, BattleScript_MoveEnd @@ -2183,7 +2185,8 @@ BattleScript_EffectBelch: BattleScript_EffectBodyPress: BattleScript_EffectLashOut: BattleScript_EffectGrassyGlide: -BattleScript_EffectBehemoth: +BattleScript_EffectDynamaxDoubleDmg: +BattleScript_EffectSnipeShot: BattleScript_HitFromAtkCanceler:: attackcanceler @@ -2255,6 +2258,17 @@ 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:: @@ -2932,6 +2946,16 @@ BattleScript_EffectTrap:: setmoveeffect MOVE_EFFECT_WRAP goto BattleScript_EffectHit +BattleScript_EffectTripleHit:: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + setmultihitcounter 3 + initmultihitstring + sethword sMULTIHIT_EFFECT, 0 + goto BattleScript_MultiHitLoop + BattleScript_EffectDoubleHit:: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE @@ -8130,3 +8154,4 @@ BattleScript_JabocaRowapBerryActivate_Dmg: call BattleScript_HurtAttacker removeitem BS_TARGET return + diff --git a/include/battle.h b/include/battle.h index 3dfe8f42a..73de6fadf 100644 --- a/include/battle.h +++ b/include/battle.h @@ -119,7 +119,7 @@ struct ProtectStruct u32 spikyShielded:1; u32 kingsShielded:1; u32 banefulBunkered:1; - u32 obstruct:1; + u32 obstructed:1; u32 endured:1; u32 noValidMoves:1; u32 helpingHand:1; diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 7690c974f..43b5615a5 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -358,10 +358,11 @@ #define EFFECT_LASH_OUT 352 #define EFFECT_GRASSY_GLIDE 353 #define EFFECT_REMOVE_TERRAIN 354 -#define EFFECT_BEHEMOTH 355 +#define EFFECT_DYNAMAX_DOUBLE_DMG 355 #define EFFECT_DECORATE 356 #define EFFECT_SNIPE_SHOT 357 +#define EFFECT_TRIPLE_HIT 358 -#define NUM_BATTLE_MOVE_EFFECTS 358 +#define NUM_BATTLE_MOVE_EFFECTS 359 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d0d5a7899..c23ec6c63 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -177,6 +177,7 @@ #define VARIOUS_JUMP_IF_TEAM_HEALTHY 106 #define VARIOUS_TRY_HEAL_QUARTER_HP 107 #define VARIOUS_REMOVE_TERRAIN 108 +#define VARIOUS_JUMP_IF_OBSTRUCT 109 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index 844d0e20e..1dada5a2e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3064,7 +3064,7 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].banefulBunkered = 0; - gProtectStructs[gActiveBattler].obstruct = 0; + gProtectStructs[gActiveBattler].obstructed = 0; gProtectStructs[gActiveBattler].endured = 0; gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].helpingHand = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f4a1c879f..5b2c9e4a4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1241,14 +1241,18 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) return FALSE; else if (gBattleMoves[move].effect == MOVE_EFFECT_FEINT) return FALSE; - else if (gProtectStructs[battlerId].protected && move != MOVE_DECORATE) + 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; else if (gProtectStructs[battlerId].banefulBunkered) return TRUE; - else if (gProtectStructs[battlerId].obstruct && !IS_MOVE_STATUS(move)) + else if (gProtectStructs[battlerId].obstructed && !IS_MOVE_STATUS(move)) return TRUE; else if (gProtectStructs[battlerId].spikyShielded) return TRUE; @@ -1258,10 +1262,10 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) && GetChosenMovePriority(gBattlerAttacker) > 0) return TRUE; else if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD - && gBattleMoves[move].power == 0) + && IS_MOVE_STATUS(move)) return TRUE; else if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_MAT_BLOCK - && gBattleMoves[move].power != 0) + && !IS_MOVE_STATUS(move)) return TRUE; else return FALSE; @@ -1324,7 +1328,7 @@ static bool32 TryAegiFormChange(void) static void Cmd_attackcanceler(void) { s32 i, moveType; - + if (gBattleOutcome != 0) { gCurrentActionFuncId = B_ACTION_FINISHED; @@ -3203,7 +3207,7 @@ void SetMoveEffect(bool32 primary, u32 certain) || gProtectStructs[gBattlerTarget].spikyShielded || gProtectStructs[gBattlerTarget].kingsShielded || gProtectStructs[gBattlerTarget].banefulBunkered - || gProtectStructs[gBattlerTarget].obstruct) + || gProtectStructs[gBattlerTarget].obstructed) { gProtectStructs[gBattlerTarget].protected = 0; gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); @@ -3213,7 +3217,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gProtectStructs[gBattlerTarget].spikyShielded = 0; gProtectStructs[gBattlerTarget].kingsShielded = 0; gProtectStructs[gBattlerTarget].banefulBunkered = 0; - gProtectStructs[gBattlerTarget].obstruct = 0; + gProtectStructs[gBattlerTarget].obstructed = 0; if (gCurrentMove == MOVE_FEINT) { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -4814,7 +4818,7 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_BanefulBunkerEffect; effect = 1; } - else if (gProtectStructs[gBattlerTarget].obstruct && gCurrentMove != MOVE_SUCKER_PUNCH) + else if (gProtectStructs[gBattlerTarget].obstructed && gCurrentMove != MOVE_SUCKER_PUNCH) { i = gBattlerAttacker; gBattlerAttacker = gBattlerTarget; @@ -7766,7 +7770,9 @@ static void Cmd_various(void) } return; case VARIOUS_SUCKER_PUNCH_CHECK: - if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)) + if (gProtectStructs[gBattlerTarget].obstructed) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else if (gBattleMoves[gBattleMons[gBattlerTarget].moves[gBattleStruct->chosenMovePositions[gBattlerTarget]]].power == 0) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); @@ -8538,6 +8544,20 @@ 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; @@ -8585,7 +8605,7 @@ static void Cmd_setprotectlike(void) } else if (gCurrentMove == MOVE_OBSTRUCT) { - gProtectStructs[gBattlerAttacker].obstruct = 1; + gProtectStructs[gBattlerAttacker].obstructed = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } diff --git a/src/battle_util.c b/src/battle_util.c index babd0b5d4..5a415ce66 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7199,11 +7199,11 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) break; case EFFECT_EXPLOSION: if (move == MOVE_MISTY_EXPLOSION && gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && IsBattlerGrounded(battlerAtk)) - basePower = 150; + MulModifier(&basePower, UQ_4_12(1.5)); break; - case EFFECT_BEHEMOTH: + case EFFECT_DYNAMAX_DOUBLE_DMG: #ifdef B_DYNAMAX - if (IsDynamaxed(battlerDef))/ + if (IsDynamaxed(battlerDef)) basePower *= 2; #endif break; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 5c4a035a5..be4240a21 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10996,7 +10996,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_BEHEMOTH_BLADE] = { - .effect = EFFECT_BEHEMOTH, + .effect = EFFECT_DYNAMAX_DOUBLE_DMG, .power = 100, .type = TYPE_STEEL, .accuracy = 100, @@ -11010,7 +11010,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_BEHEMOTH_BASH] = { - .effect = EFFECT_BEHEMOTH, + .effect = EFFECT_DYNAMAX_DOUBLE_DMG, .power = 100, .type = TYPE_STEEL, .accuracy = 100, @@ -11158,7 +11158,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 4, - .flags = 0, + .flags = FLAG_PROTECTION_MOVE, .split = SPLIT_STATUS, }, @@ -11513,7 +11513,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_SURGING_STRIKES] = { - .effect = EFFECT_TRIPLE_KICK, + .effect = EFFECT_TRIPLE_HIT, .power = 25, .type = TYPE_WATER, .accuracy = 100,