From ed9e860400e839c824d724c7937809d360126eae Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Mar 2023 20:09:21 -0300 Subject: [PATCH] Post cherrypick corrections and improvements -Made BattleScript_EffectTakeHeart use modifybattlerstatstage -Optimized usage of BattleScript_EffectInfernalParade -Tweaked the way in which Triple Arrows' increased crit. hit chance is handled -Optimized syntax for case MOVE_EFFECT_TRIPLE_ARROWS in SetMoveEffect -Optimized case EFFECT_INFERNAL_PARADE in CalcMoveBasePower -Infernal Parade is not known to interact with Comatose, so Eduardo and I will extrapolate that here -Added AI conditionals for some of the effects -Made Triage notice Jungle Healing and moves that use its effect --- data/battle_scripts_1.s | 18 +++--------------- include/battle_scripts.h | 2 +- src/battle_ai_main.c | 13 ++++++++++++- src/battle_main.c | 1 + src/battle_script_commands.c | 18 +++++++----------- src/battle_util.c | 5 +---- src/data/battle_moves.h | 2 +- 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 52a32f3ff..21d952674 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -479,27 +479,14 @@ BattleScript_AxeKickHitFromAtkString: end BattleScript_EffectTakeHeart:: -@ TO DO: Use modifybattlerstatstage here once PR #2470 is merged. printstring STRINGID_EMPTYSTRING3 - playstatchangeanimation BS_ATTACKER, BIT_SPATK, 0 - setstatchanger STAT_SPATK, 1, FALSE - statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TakeHeartTrySpDef - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPATK, INCREASE, 1, BattleScript_TakeHeartTrySpDef, ANIM_ON BattleScript_TakeHeartTrySpDef: printstring STRINGID_EMPTYSTRING3 - playstatchangeanimation BS_ATTACKER, BIT_SPDEF, 0 - setstatchanger STAT_SPDEF, 1, FALSE - statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TakeHeart_MoveEnd - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPDEF, INCREASE, 1, BattleScript_TakeHeart_MoveEnd, ANIM_ON BattleScript_TakeHeart_MoveEnd: goto BattleScript_MoveEnd -BattleScript_EffectInfernalParade:: - setmoveeffect MOVE_EFFECT_BURN - goto BattleScript_EffectHit - BattleScript_EffectTripleArrows:: setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS goto BattleScript_EffectHit @@ -3527,6 +3514,7 @@ BattleScript_AbsorbHealBlock:: tryfaintmon BS_TARGET goto BattleScript_MoveEnd +BattleScript_EffectInfernalParade:: BattleScript_EffectBurnHit:: setmoveeffect MOVE_EFFECT_BURN goto BattleScript_EffectHit diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 590a9232c..aac118d03 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -457,11 +457,11 @@ extern const u8 BattleScript_DampPreventsAftermath[]; extern const u8 BattleScript_HealingWishActivates[]; extern const u8 BattleScript_LunarDanceActivates[]; extern const u8 BattleScript_ShellTrapSetUp[]; -extern const u8 BattleScript_DefDown[]; extern const u8 BattleScript_CouldntFullyProtect[]; extern const u8 BattleScript_MoveEffectStockpileWoreOff[]; extern const u8 BattleScript_StealthRockActivates[]; extern const u8 BattleScript_SpikesActivates[]; +extern const u8 BattleScript_DefDown[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 19eedb41c..a17f621b0 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1788,6 +1788,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_RESTORE_HP: case EFFECT_SOFTBOILED: case EFFECT_ROOST: + case EFFECT_JUNGLE_HEALING: if (AtMaxHp(battlerAtk)) score -= 10; else if (AI_DATA->hpPercents[battlerAtk] >= 90) @@ -2610,6 +2611,10 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) if (gBattleMons[battlerAtk].hp <= gBattleMons[battlerAtk].maxHP / 3) score -= 10; break;*/ + case EFFECT_TAKE_HEART: + if (!AnyPartyMemberStatused(battlerAtk, FALSE) || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, AI_DATA->partnerMove)) + score -= 10; + break; case EFFECT_PLACEHOLDER: return 0; // cannot even select } // move effect checks @@ -3475,6 +3480,11 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) if (AI_DATA->holdEffects[battlerAtk] == HOLD_EFFECT_BIG_ROOT) score++; break; + case EFFECT_JUNGLE_HEALING: + if (ShouldRecover(battlerAtk, battlerDef, move, 25) + || (ShouldRecover(BATTLE_PARTNER(battlerAtk), battlerDef, move, 25) && ShouldRecover(BATTLE_PARTNER(battlerAtk), BATTLE_PARTNER(battlerDef), move, 25))) + score += 3; + break; case EFFECT_TOXIC: case EFFECT_POISON: case EFFECT_BARB_BARRAGE: @@ -3721,8 +3731,9 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) break; case EFFECT_WISH: case EFFECT_HEAL_BELL: + case EFFECT_TAKE_HEART: if (ShouldUseWishAromatherapy(battlerAtk, battlerDef, move)) - score += 7; + score += 3; break; case EFFECT_THIEF: { diff --git a/src/battle_main.c b/src/battle_main.c index efbf1b819..ff3233f2e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4726,6 +4726,7 @@ s8 GetMovePriority(u32 battlerId, u16 move) case EFFECT_SOFTBOILED: case EFFECT_ABSORB: case EFFECT_ROOST: + case EFFECT_JUNGLE_HEALING: priority += 3; break; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 424ba7dd3..078986777 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2082,8 +2082,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi #if B_AFFECTION_MECHANICS == TRUE + 2 * (GetBattlerFriendshipScore(gBattlerAttacker) >= FRIENDSHIP_200_TO_254) #endif - + (abilityAtk == ABILITY_SUPER_LUCK) - + (gBattleMoves[move].effect == EFFECT_TRIPLE_ARROWS); + + (abilityAtk == ABILITY_SUPER_LUCK); if (critChance >= ARRAY_COUNT(sCriticalHitChance)) critChance = ARRAY_COUNT(sCriticalHitChance) - 1; @@ -3802,7 +3801,7 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u32 randomChance = Random() % 100; + u8 randomChance = Random() % 100; if (randomChance < 50) // Chance to reduce a foe's Defense by 1 stat stage. { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -3810,15 +3809,12 @@ void SetMoveEffect(bool32 primary, u32 certain) } if (randomChance >= 50 && randomChance <= 80) // Chance to cause a foe to flinch. { - if (battlerAbility == ABILITY_INNER_FOCUS) + if (battlerAbility == ABILITY_INNER_FOCUS && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { - if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) - { - gLastUsedAbility = ABILITY_INNER_FOCUS; - gBattlerAbility = gEffectBattler; - RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); - gBattlescriptCurrInstr = BattleScript_FlinchPrevention; - } + gLastUsedAbility = ABILITY_INNER_FOCUS; + gBattlerAbility = gEffectBattler; + RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); + gBattlescriptCurrInstr = BattleScript_FlinchPrevention; } else { diff --git a/src/battle_util.c b/src/battle_util.c index 84ce98a22..e1f0a5ec9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8627,6 +8627,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) basePower = 120 * gBattleMons[battlerDef].hp / gBattleMons[battlerDef].maxHP; break; case EFFECT_HEX: + case EFFECT_INFERNAL_PARADE: if (gBattleMons[battlerDef].status1 & STATUS1_ANY || GetBattlerAbility(battlerDef) == ABILITY_COMATOSE) basePower *= 2; break; @@ -8780,10 +8781,6 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) if (IsBattlerTerrainAffected(gBattlerAttacker, STATUS_FIELD_ELECTRIC_TERRAIN)) MulModifier(&basePower, UQ_4_12(1.5)); break; - case EFFECT_INFERNAL_PARADE: - if (gBattleMons[battlerDef].status1 & STATUS1_ANY) - basePower *= 2; - break; } // Move-specific base power changes diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 9eeacac4b..89a72e0af 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12737,7 +12737,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIGH_CRIT, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, },