From ca656b63b935e17de1b14f8b6de3952df6ae74c3 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 02:04:33 -0300 Subject: [PATCH] Added Well Baked Body's effect and misc. changes -Added a modifybattlerstatstage macro to handle stat stages in battle. -Rewrote the checks inside the case ABILITYEFFECT_MOVES_BLOCK of AbilityBattleEffects. --- asm/macros/battle_script.inc | 31 ++++++++++++++++ data/battle_scripts_1.s | 12 +++++++ include/battle_scripts.h | 1 + src/battle_util.c | 68 +++++++++++++++++++----------------- 4 files changed, 80 insertions(+), 32 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 27c5a86c41..72ca567dcf 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2157,3 +2157,34 @@ .macro trysymbiosis various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS .endm + + @ Tries to increase or decrease a battler's stat's stat stage by a specified amount. If impossible, jumps to \script. + .macro modifybattlerstatstage battler:req, stat:req, mode:req, amount:req, script:req, animation:req, customString + + @ \mode parameters + INCREASE = FALSE + DECREASE = TRUE + + @ \animation parameters + ANIM_OFF = FALSE + ANIM_ON = TRUE + + setstatchanger \stat, \amount, \mode + statbuffchange STAT_CHANGE_ALLOW_PTR, \script + setgraphicalstatchangevalues + .if \animation == TRUE + playanimation \battler, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + .endif + .ifnb \customString + printstring \customString + .else + .if \mode == DECREASE + printfromtable gStatDownStringIds + .else + .if \mode == INCREASE + printfromtable gStatUpStringIds + .endif + .endif + .endif + waitmessage B_WAIT_TIME_LONG + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index cf686fec9a..d7aa7f53f2 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9800,6 +9800,18 @@ BattleScript_DarkTypePreventsPrankster:: orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT goto BattleScript_MoveEnd +BattleScript_WellBakedBodyActivates:: + attackstring + ppreduce + showabilitypopup BS_TARGET + pause B_WAIT_TIME_MED + printstring STRINGID_ITDOESNTAFFECT + waitmessage B_WAIT_TIME_MED + orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT + modifybattlerstatstage BS_TARGET, STAT_DEF, INCREASE, 1, BattleScript_WellBakedBodyEnd, ANIM_ON +BattleScript_WellBakedBodyEnd: + goto BattleScript_MoveEnd + BattleScript_PastelVeilActivates:: setbyte gBattleCommunication, 0 setbyte gBattleCommunication + 1, 0 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 462da38dbd..b909b9711d 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -435,6 +435,7 @@ extern const u8 BattleScript_BurnUpRemoveType[]; extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; extern const u8 BattleScript_SeedSowerActivates[]; extern const u8 BattleScript_AngerShellActivates[]; +extern const u8 BattleScript_WellBakedBodyActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index fd6374e74c..8746dbbf05 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5079,40 +5079,44 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITYEFFECT_MOVES_BLOCK: // 2 - { - u16 moveTarget = GetBattlerMoveTargetType(battler, move); + { + u16 moveTarget = GetBattlerMoveTargetType(battler, move); + u16 battlerAbility = GetBattlerAbility(battler); + u16 targetAbility = GetBattlerAbility(gBattlerTarget); - if ((gLastUsedAbility == ABILITY_SOUNDPROOF && gBattleMoves[move].flags & FLAG_SOUND && !(moveTarget & MOVE_TARGET_USER)) - || (gLastUsedAbility == ABILITY_BULLETPROOF && gBattleMoves[move].flags & FLAG_BALLISTIC)) - { - if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) - gHitMarker |= HITMARKER_NO_PPDEDUCT; - gBattlescriptCurrInstr = BattleScript_SoundproofProtected; - effect = 1; + if ((gLastUsedAbility == ABILITY_SOUNDPROOF && gBattleMoves[move].flags & FLAG_SOUND && !(moveTarget & MOVE_TARGET_USER)) + || (gLastUsedAbility == ABILITY_BULLETPROOF && gBattleMoves[move].flags & FLAG_BALLISTIC)) + { + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = BattleScript_SoundproofProtected; + effect = 1; + } + else if ((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY || IsBattlerAlive(battler ^= BIT_FLANK)) + && (battlerAbility == ABILITY_DAZZLING || battlerAbility == ABILITY_QUEENLY_MAJESTY) + && GetChosenMovePriority(gBattlerAttacker) > 0 + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) + { + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = BattleScript_DazzlingProtected; + effect = 1; + } + else if (BlocksPrankster(move, gBattlerAttacker, gBattlerTarget, TRUE) && !(IS_MOVE_STATUS(move) && targetAbility == ABILITY_MAGIC_BOUNCE)) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(moveTarget & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) + CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected + gBattleScripting.battler = gBattlerAbility = gBattlerTarget; + gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; + effect = 1; + } + else if (targetAbility == ABILITY_WELL_BAKED_BODY && gBattleMoves[gCurrentMove].type == TYPE_FIRE) + { + gBattlescriptCurrInstr = BattleScript_WellBakedBodyActivates; + effect = 1; + } + break; } - else if ((((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY - || (IsBattlerAlive(battler ^= BIT_FLANK) - && ((GetBattlerAbility(battler) == ABILITY_DAZZLING) || GetBattlerAbility(battler) == ABILITY_QUEENLY_MAJESTY))) - )) - && GetChosenMovePriority(gBattlerAttacker) > 0 - && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) - { - if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) - gHitMarker |= HITMARKER_NO_PPDEDUCT; - gBattlescriptCurrInstr = BattleScript_DazzlingProtected; - effect = 1; - } - else if (BlocksPrankster(move, gBattlerAttacker, gBattlerTarget, TRUE) - && !(IS_MOVE_STATUS(move) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) - { - if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(moveTarget & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) - CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected - gBattleScripting.battler = gBattlerAbility = gBattlerTarget; - gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; - effect = 1; - } - break; - } case ABILITYEFFECT_ABSORBING: // 3 if (move != MOVE_NONE) {