From 1595a66559571b365ece5c8f9275a1bf33e3df34 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 10:18:38 -0300 Subject: [PATCH 01/22] Implemented Triple Arrows' effect --- data/battle_scripts_1.s | 10 ++++++++ include/battle_scripts.h | 1 + include/constants/battle.h | 3 ++- include/constants/battle_move_effects.h | 3 ++- src/battle_script_commands.c | 32 ++++++++++++++++++++++++- src/data/battle_moves.h | 5 ++-- 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 200a04461085..5be16a0a16d8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -423,6 +423,11 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHitSetEntryHazard @ EFFECT_HIT_SET_ENTRY_HAZARD .4byte BattleScript_EffectDireClaw @ EFFECT_DIRE_CLAW .4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE + .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS + +BattleScript_EffectTripleArrows:: + setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS + goto BattleScript_EffectHit BattleScript_StealthRockActivates:: setstealthrock BattleScript_MoveEnd @@ -1451,6 +1456,11 @@ BattleScript_DoubleShockRemoveType:: waitmessage B_WAIT_TIME_LONG return +BattleScript_DefDown:: + modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDown_Ret, ANIM_ON +BattleScript_DefDown_Ret: + return + BattleScript_EffectPurify: attackcanceler attackstring diff --git a/include/battle_scripts.h b/include/battle_scripts.h index c78fcafe48c8..590a9232cb55 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -457,6 +457,7 @@ 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[]; diff --git a/include/constants/battle.h b/include/constants/battle.h index 61c3776c6c42..8bde7d2f1cb7 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -376,8 +376,9 @@ #define MOVE_EFFECT_DIRE_CLAW 74 #define MOVE_EFFECT_STEALTH_ROCK 75 #define MOVE_EFFECT_SPIKES 76 +#define MOVE_EFFECT_TRIPLE_ARROWS 77 -#define NUM_MOVE_EFFECTS 77 +#define NUM_MOVE_EFFECTS 78 #define MOVE_EFFECT_AFFECTS_USER 0x4000 #define MOVE_EFFECT_CERTAIN 0x8000 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 27ad6601ffd9..017320eefecf 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -404,7 +404,8 @@ #define EFFECT_HIT_SET_ENTRY_HAZARD 398 #define EFFECT_DIRE_CLAW 399 #define EFFECT_BARB_BARRAGE 400 +#define EFFECT_TRIPLE_ARROWS 401 -#define NUM_BATTLE_MOVE_EFFECTS 401 +#define NUM_BATTLE_MOVE_EFFECTS 402 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 12a2f65e275a..424ba7dd3936 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2082,7 +2082,8 @@ 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); + + (abilityAtk == ABILITY_SUPER_LUCK) + + (gBattleMoves[move].effect == EFFECT_TRIPLE_ARROWS); if (critChance >= ARRAY_COUNT(sCriticalHitChance)) critChance = ARRAY_COUNT(sCriticalHitChance) - 1; @@ -3799,6 +3800,35 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_SpikesActivates; } break; + case MOVE_EFFECT_TRIPLE_ARROWS: + { + u32 randomChance = Random() % 100; + if (randomChance < 50) // Chance to reduce a foe's Defense by 1 stat stage. + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } + if (randomChance >= 50 && randomChance <= 80) // Chance to cause a foe to flinch. + { + if (battlerAbility == ABILITY_INNER_FOCUS) + { + if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) + { + gLastUsedAbility = ABILITY_INNER_FOCUS; + gBattlerAbility = gEffectBattler; + RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); + gBattlescriptCurrInstr = BattleScript_FlinchPrevention; + } + } + else + { + if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; + gBattlescriptCurrInstr++; + } + } + } + break; } } } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 64ce246862b4..32927b82ed66 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12726,13 +12726,14 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = { #if B_UPDATED_MOVE_DATA >= GEN_9 .power = 90, + .pp = 10, #else .power = 50, + .pp = 15, #endif - .effect = EFFECT_PLACEHOLDER, // EFFECT_TRIPLE_ARROWS, + .effect = EFFECT_TRIPLE_ARROWS, .type = TYPE_FIGHTING, .accuracy = 100, - .pp = 15, .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, From 05a34edb7d5c7b33799a82ff6e20cf51e3152935 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 11:03:46 -0300 Subject: [PATCH 02/22] Implemented Infernal Parade's effect --- data/battle_scripts_1.s | 5 +++++ include/constants/battle_move_effects.h | 3 ++- src/battle_util.c | 4 ++++ src/data/battle_moves.h | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5be16a0a16d8..f1f312e6a9b1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -424,6 +424,11 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectDireClaw @ EFFECT_DIRE_CLAW .4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS + .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE + +BattleScript_EffectInfernalParade:: + setmoveeffect MOVE_EFFECT_BURN + goto BattleScript_EffectHit BattleScript_EffectTripleArrows:: setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 017320eefecf..a60d8ee03250 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -405,7 +405,8 @@ #define EFFECT_DIRE_CLAW 399 #define EFFECT_BARB_BARRAGE 400 #define EFFECT_TRIPLE_ARROWS 401 +#define EFFECT_INFERNAL_PARADE 402 -#define NUM_BATTLE_MOVE_EFFECTS 402 +#define NUM_BATTLE_MOVE_EFFECTS 403 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/battle_util.c b/src/battle_util.c index dea28b5d8367..84ce98a22215 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8780,6 +8780,10 @@ 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 32927b82ed66..83cd8d616c7d 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12744,12 +12744,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_INFERNAL_PARADE] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_INFERNAL_PARADE, + .effect = EFFECT_INFERNAL_PARADE, .power = 60, .type = TYPE_GHOST, .accuracy = 100, .pp = 15, - .secondaryEffectChance = 0, + .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, From d2a221eb85779686701c2430bffbd636e0a88050 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 11:08:49 -0300 Subject: [PATCH 03/22] Corrected Lunar Blessing's data --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 83cd8d616c7d..685742e0805f 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12835,7 +12835,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_LUNAR_BLESSING] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_LUNAR_BLESSING, + .effect = EFFECT_JUNGLE_HEALING, .power = 0, .type = TYPE_PSYCHIC, .accuracy = 0, From 8ae57dc912cc96c08a37c630ec5b1283d134f9b7 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 11:13:52 -0300 Subject: [PATCH 04/22] Implemented Take Heart's effect --- data/battle_scripts_1.s | 19 +++++++++++++++++++ include/constants/battle_move_effects.h | 3 ++- src/data/battle_moves.h | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f1f312e6a9b1..9c1cb1587acc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -425,6 +425,25 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE + .4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART + +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 +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 +BattleScript_TakeHeart_MoveEnd: + goto BattleScript_MoveEnd BattleScript_EffectInfernalParade:: setmoveeffect MOVE_EFFECT_BURN diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index a60d8ee03250..4188c341bd39 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -406,7 +406,8 @@ #define EFFECT_BARB_BARRAGE 400 #define EFFECT_TRIPLE_ARROWS 401 #define EFFECT_INFERNAL_PARADE 402 +#define EFFECT_TAKE_HEART 403 -#define NUM_BATTLE_MOVE_EFFECTS 403 +#define NUM_BATTLE_MOVE_EFFECTS 404 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 685742e0805f..66b9c0dc5d42 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12850,7 +12850,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_TAKE_HEART] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_TAKE_HEART, + .effect = EFFECT_TAKE_HEART, .power = 0, .type = TYPE_PSYCHIC, .accuracy = 0, From 000077f6712524d54fbb8c91729feda12797120c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 23:36:29 -0300 Subject: [PATCH 05/22] Implemented Axe Kick's effect --- data/battle_scripts_1.s | 51 +++++++++++++++++++++++++ include/constants/battle_move_effects.h | 3 +- src/data/battle_moves.h | 4 +- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 9c1cb1587acc..52a32f3ffdeb 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -426,6 +426,57 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE .4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART + .4byte BattleScript_EffectAxeKick @ EFFECT_AXE_KICK + +BattleScript_EffectAxeKick:: + attackcanceler + accuracycheck BattleScript_AxeKickMissedDoDamage, ACC_CURR_MOVE + typecalc + jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_AxeKickMissedDoDamage + goto BattleScript_AxeKickHitFromAtkString +BattleScript_AxeKickMissedDoDamage:: + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_PrintMoveMissed + attackstring + ppreduce + pause B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + printstring STRINGID_PKMNCRASHED + waitmessage B_WAIT_TIME_LONG + damagecalc + typecalc + adjustdamage + manipulatedamage DMG_RECOIL_FROM_MISS + bichalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + tryfaintmon BS_ATTACKER + orhalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE + goto BattleScript_MoveEnd + +BattleScript_AxeKickHitFromAtkString: + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + setmoveeffect MOVE_EFFECT_CONFUSION + seteffectwithchance + tryfaintmon BS_TARGET + moveendall + end BattleScript_EffectTakeHeart:: @ TO DO: Use modifybattlerstatstage here once PR #2470 is merged. diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 4188c341bd39..c0aa6c69769d 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -407,7 +407,8 @@ #define EFFECT_TRIPLE_ARROWS 401 #define EFFECT_INFERNAL_PARADE 402 #define EFFECT_TAKE_HEART 403 +#define EFFECT_AXE_KICK 404 -#define NUM_BATTLE_MOVE_EFFECTS 404 +#define NUM_BATTLE_MOVE_EFFECTS 405 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 66b9c0dc5d42..9eeacac4b244 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12895,12 +12895,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_AXE_KICK] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_RECOIL_IF_MISS + 30% chance to confuse + .effect = EFFECT_AXE_KICK, .power = 120, .type = TYPE_FIGHTING, .accuracy = 90, .pp = 10, - .secondaryEffectChance = 0, + .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, From ed9e860400e839c824d724c7937809d360126eae Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Mar 2023 20:09:21 -0300 Subject: [PATCH 06/22] 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 52a32f3ffdeb..21d952674b75 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 590a9232cb55..aac118d0367d 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 19eedb41ccf1..a17f621b0089 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 efbf1b8195c1..ff3233f2ed8f 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 424ba7dd3936..078986777c6a 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 84ce98a22215..e1f0a5ec9120 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 9eeacac4b244..89a72e0af143 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, }, From 5bde98741ae2156d2d2c51ad30c3219d13e0b3d5 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 29 Mar 2023 00:21:09 -0300 Subject: [PATCH 07/22] Completed Take Heart's effect It was missing its "heals any status condition" effect because I'm dumb and I forgot to actually go and do it. --- data/battle_scripts_1.s | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 21d952674b75..c3d0055d8a9e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -479,10 +479,22 @@ BattleScript_AxeKickHitFromAtkString: end BattleScript_EffectTakeHeart:: - printstring STRINGID_EMPTYSTRING3 + attackcanceler + accuracycheck BattleScript_AxeKickMissedDoDamage, ACC_CURR_MOVE + attackstring + ppreduce + attackanimation + waitanimation + jumpifstatus BS_ATTACKER, STATUS1_ANY, BattleScript_TakeHeart_HealStatusConditions + goto BattleScript_TakeHeart_TryToRaiseSpecialStats +BattleScript_TakeHeart_HealStatusConditions: + curestatus BS_ATTACKER + updatestatusicon BS_ATTACKER + printstring STRINGID_PKMNSTATUSNORMAL + waitmessage B_WAIT_TIME_LONG +BattleScript_TakeHeart_TryToRaiseSpecialStats: modifybattlerstatstage BS_ATTACKER, STAT_SPATK, INCREASE, 1, BattleScript_TakeHeartTrySpDef, ANIM_ON BattleScript_TakeHeartTrySpDef: - printstring STRINGID_EMPTYSTRING3 modifybattlerstatstage BS_ATTACKER, STAT_SPDEF, INCREASE, 1, BattleScript_TakeHeart_MoveEnd, ANIM_ON BattleScript_TakeHeart_MoveEnd: goto BattleScript_MoveEnd From 8c4396ddafc329ac37beb6e895e7dc81c28da835 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Mar 2023 13:01:20 +0200 Subject: [PATCH 08/22] Gen9 move tests batch2 --- include/random.h | 1 + src/battle_script_commands.c | 6 ++-- test/move_effect_axe_kick.c | 54 ++++++++++++++++++++++++++++ test/move_effect_infernal_parade.c | 48 +++++++++++++++++++++++++ test/move_effect_take_heart.c | 47 +++++++++++++++++++++++++ test/move_effect_triple_arrows.c | 56 ++++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 test/move_effect_axe_kick.c create mode 100644 test/move_effect_infernal_parade.c create mode 100644 test/move_effect_take_heart.c create mode 100644 test/move_effect_triple_arrows.c diff --git a/include/random.h b/include/random.h index 60c718348c63..14b6a253e3fa 100644 --- a/include/random.h +++ b/include/random.h @@ -60,6 +60,7 @@ enum RandomTag RNG_SPEED_TIE, RNG_STATIC, RNG_STENCH, + RNG_TRIPLE_ARROWS, }; #define RandomWeighted(tag, ...) \ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 38e949131bac..775f8c456a91 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3801,13 +3801,13 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u8 randomChance = Random() % 100; - if (randomChance < 50) // Chance to reduce a foe's Defense by 1 stat stage. + u8 randomChance = RandomUniform(RNG_TRIPLE_ARROWS, 1, 10); + if (randomChance <= 5) // Chance to reduce a foe's Defense by 1 stat stage. { BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_DefDown; } - if (randomChance >= 50 && randomChance <= 80) // Chance to cause a foe to flinch. + if (randomChance > 5 && randomChance <= 8) // Chance to cause a foe to flinch. { if (battlerAbility == ABILITY_INNER_FOCUS && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { diff --git a/test/move_effect_axe_kick.c b/test/move_effect_axe_kick.c new file mode 100644 index 000000000000..cf04e601e2dc --- /dev/null +++ b/test/move_effect_axe_kick.c @@ -0,0 +1,54 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_AXE_KICK].effect == EFFECT_AXE_KICK); +} + +SINGLE_BATTLE_TEST("Axe Kick confuses the target") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_AXE_KICK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_AXE_KICK, player); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_CONFUSION, opponent); + MESSAGE("Foe Wobbuffet became confused!"); + } +} + +SINGLE_BATTLE_TEST("Axe Kick deals damage half the hp to user if def battler protected") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_PROTECT); MOVE(player, MOVE_AXE_KICK); } + } SCENE { + s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP); + ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, opponent); + MESSAGE("Foe Wobbuffet protected itself!"); + MESSAGE("Foe Wobbuffet protected itself!"); + MESSAGE("Wobbuffet kept going and crashed!"); + HP_BAR(player, hp: maxHP / 2); + } +} + +SINGLE_BATTLE_TEST("Axe Kick deals damage half the hp to user if it fails") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_AXE_KICK, hit: FALSE); } + } SCENE { + s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP); + MESSAGE("Wobbuffet used Axe Kick!"); + MESSAGE("Wobbuffet's attack missed!"); + MESSAGE("Wobbuffet kept going and crashed!"); + HP_BAR(player, hp: maxHP / 2); + } +} diff --git a/test/move_effect_infernal_parade.c b/test/move_effect_infernal_parade.c new file mode 100644 index 000000000000..5b951eca1cf9 --- /dev/null +++ b/test/move_effect_infernal_parade.c @@ -0,0 +1,48 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_INFERNAL_PARADE].effect == EFFECT_INFERNAL_PARADE); +} + +SINGLE_BATTLE_TEST("Infernal Parade inflicts poison") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_INFERNAL_PARADE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_INFERNAL_PARADE, player); + HP_BAR(opponent); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponent); + STATUS_ICON(opponent, burn: TRUE); + } +} + +SINGLE_BATTLE_TEST("Infernal Parade's power doubles if the target has a status condition", s16 damage) +{ + u32 status1; + PARAMETRIZE { status1 = STATUS1_NONE; } + PARAMETRIZE { status1 = STATUS1_SLEEP; } + PARAMETRIZE { status1 = STATUS1_POISON; } + PARAMETRIZE { status1 = STATUS1_BURN; } + PARAMETRIZE { status1 = STATUS1_FREEZE; } + PARAMETRIZE { status1 = STATUS1_PARALYSIS; } + PARAMETRIZE { status1 = STATUS1_TOXIC_POISON; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { Status1(status1); }; + } WHEN { + TURN { MOVE(player, MOVE_INFERNAL_PARADE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_INFERNAL_PARADE, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } THEN { + if (i > 0) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[i].damage); + if (i > 1) + EXPECT_EQ(results[i-1].damage, results[i].damage); + } +} diff --git a/test/move_effect_take_heart.c b/test/move_effect_take_heart.c new file mode 100644 index 000000000000..82745957ffe7 --- /dev/null +++ b/test/move_effect_take_heart.c @@ -0,0 +1,47 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_TAKE_HEART].effect == EFFECT_TAKE_HEART); +} + +SINGLE_BATTLE_TEST("Take Heart increases Sp. Atk and Sp. Def by one stage") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TAKE_HEART); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + } +} + +SINGLE_BATTLE_TEST("Take Heart cures the user of all status conditions") +{ + u32 status1; + PARAMETRIZE { status1 = STATUS1_SLEEP; } + PARAMETRIZE { status1 = STATUS1_POISON; } + PARAMETRIZE { status1 = STATUS1_FREEZE; } + PARAMETRIZE { status1 = STATUS1_BURN; } + PARAMETRIZE { status1 = STATUS1_PARALYSIS; } + PARAMETRIZE { status1 = STATUS1_TOXIC_POISON; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Status1(status1); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TAKE_HEART); } + } SCENE { + if (status1 == STATUS1_SLEEP) { + MESSAGE("Wobbuffet is fast asleep."); + } else if (status1 == STATUS1_FREEZE) { + PASSES_RANDOMLY(20, 100, RNG_FROZEN); + STATUS_ICON(player, none: TRUE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + } else { + MESSAGE("Wobbuffet's status returned to normal!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + } + } +} diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c new file mode 100644 index 000000000000..4dd717d80b32 --- /dev/null +++ b/test/move_effect_triple_arrows.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].effect == EFFECT_TRIPLE_ARROWS); +} + +SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") +{ + PASSES_RANDOMLY(50, 100, RNG_TRIPLE_ARROWS); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Foe Wobbuffet's defense fell!"); + } +} + +SINGLE_BATTLE_TEST("Triple Arrows flinch 30% of the time") +{ + PASSES_RANDOMLY(30, 100, RNG_TRIPLE_ARROWS); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Foe Wobbuffet's defense fell!"); + } + MESSAGE("Foe Wobbuffet flinched!"); + } +} + +SINGLE_BATTLE_TEST("Triple Arrows lands a critical hit") +{ + ASSUME(B_CRIT_CHANCE >= GEN_7); + ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].flags & FLAG_HIGH_CRIT); + PASSES_RANDOMLY(1, 8, RNG_CRITICAL_HIT); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); + MESSAGE("A critical hit!"); + } +} \ No newline at end of file From 318b1ce4a217bc3f7981904f65d63f4695b04208 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 2 Apr 2023 05:30:26 -0300 Subject: [PATCH 09/22] Added empty line at the end of test/move_effect_triple_arrows.c Compilers on Unix-based systems hate it when a file doesn't end with an empty line. --- test/move_effect_triple_arrows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index 4dd717d80b32..020e46c6bbde 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -53,4 +53,4 @@ SINGLE_BATTLE_TEST("Triple Arrows lands a critical hit") ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); MESSAGE("A critical hit!"); } -} \ No newline at end of file +} From 7d499548e8451b05a4aa2c62e1b44e8a653e0586 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 15 Apr 2023 10:48:46 -0300 Subject: [PATCH 10/22] Updates -Added EFFECT_JUNGLE_HEALING to IsHealingMoveEffect -Modified the code for EFFECT_TAKE_HEART inside AI_CheckViability and AI_CheckBadMove --- src/battle_ai_main.c | 7 +++++-- src/battle_ai_util.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index a17f621b0089..c52f9bc0327b 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2612,7 +2612,10 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score -= 10; break;*/ case EFFECT_TAKE_HEART: - if (!AnyPartyMemberStatused(battlerAtk, FALSE) || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, AI_DATA->partnerMove)) + if ((!(gBattleMons[battlerAtk].status1 & STATUS1_ANY) + || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, AI_DATA->partnerMove)) + && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) + && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPDEF)) score -= 10; break; case EFFECT_PLACEHOLDER: @@ -3731,7 +3734,6 @@ 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 += 3; break; @@ -4368,6 +4370,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score++; break; case EFFECT_REFRESH: + case EFFECT_TAKE_HEART: if (gBattleMons[battlerAtk].status1 & STATUS1_ANY) score += 2; break; diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index a9e3ed3e0bd0..4c4f132bebab 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -2021,6 +2021,7 @@ bool32 IsHealingMoveEffect(u16 effect) case EFFECT_HEALING_WISH: case EFFECT_HEAL_PULSE: case EFFECT_REST: + case EFFECT_JUNGLE_HEALING: return TRUE; default: return FALSE; From 43a5aa09ef69bceb1cf2554cc8db45958b22b0af Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 16 Apr 2023 15:12:53 -0300 Subject: [PATCH 11/22] Corrections -Optimized BattleScript_EffectTakeHeart -Updated the checks for EFFECT_JUNGLE_HEALING and EFFECT_TAKE_HEART in AI_CheckBadMove -Updated the code for MOVE_EFFECT_TRIPLE_ARROWS inside SetMoveEffect --- data/battle_scripts_1.s | 28 +++++++++++-------- include/battle_scripts.h | 1 + include/random.h | 3 +- src/battle_ai_main.c | 32 ++++++++++++++++------ src/battle_script_commands.c | 47 +++++++++++++++++++++++--------- test/move_effect_triple_arrows.c | 4 +-- 6 files changed, 80 insertions(+), 35 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c3d0055d8a9e..70e56f9f55a7 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -480,24 +480,22 @@ BattleScript_AxeKickHitFromAtkString: BattleScript_EffectTakeHeart:: attackcanceler - accuracycheck BattleScript_AxeKickMissedDoDamage, ACC_CURR_MOVE attackstring ppreduce + cureifburnedparalysedorpoisoned BattleScript_EffectTakeHeart_TryToRaiseStats attackanimation waitanimation - jumpifstatus BS_ATTACKER, STATUS1_ANY, BattleScript_TakeHeart_HealStatusConditions - goto BattleScript_TakeHeart_TryToRaiseSpecialStats -BattleScript_TakeHeart_HealStatusConditions: - curestatus BS_ATTACKER updatestatusicon BS_ATTACKER printstring STRINGID_PKMNSTATUSNORMAL waitmessage B_WAIT_TIME_LONG -BattleScript_TakeHeart_TryToRaiseSpecialStats: - modifybattlerstatstage BS_ATTACKER, STAT_SPATK, INCREASE, 1, BattleScript_TakeHeartTrySpDef, ANIM_ON -BattleScript_TakeHeartTrySpDef: - modifybattlerstatstage BS_ATTACKER, STAT_SPDEF, INCREASE, 1, BattleScript_TakeHeart_MoveEnd, ANIM_ON -BattleScript_TakeHeart_MoveEnd: - goto BattleScript_MoveEnd + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_CalmMindStatRaise + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CalmMindStatRaise + goto BattleScript_CantRaiseMultipleStats + +BattleScript_EffectTakeHeart_TryToRaiseStats: + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim + goto BattleScript_CantRaiseMultipleStats BattleScript_EffectTripleArrows:: setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS @@ -1535,6 +1533,13 @@ BattleScript_DefDown:: BattleScript_DefDown_Ret: return +BattleScript_ReduceDefenseAndFlinch:: + modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDown_Ret, ANIM_ON + jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_FlinchPrevention + setmoveeffect MOVE_EFFECT_FLINCH + seteffectprimary + goto BattleScript_MoveEnd + BattleScript_EffectPurify: attackcanceler attackstring @@ -6387,6 +6392,7 @@ BattleScript_EffectCalmMind:: BattleScript_CalmMindDoMoveAnim:: attackanimation waitanimation +BattleScript_CalmMindStatRaise:: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_SPATK | BIT_SPDEF, 0 setstatchanger STAT_SPATK, 1, FALSE diff --git a/include/battle_scripts.h b/include/battle_scripts.h index aac118d0367d..c58f0afc23cd 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -462,6 +462,7 @@ extern const u8 BattleScript_MoveEffectStockpileWoreOff[]; extern const u8 BattleScript_StealthRockActivates[]; extern const u8 BattleScript_SpikesActivates[]; extern const u8 BattleScript_DefDown[]; +extern const u8 BattleScript_ReduceDefenseAndFlinch[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/random.h b/include/random.h index 14b6a253e3fa..e5f8c05ecea3 100644 --- a/include/random.h +++ b/include/random.h @@ -60,7 +60,8 @@ enum RandomTag RNG_SPEED_TIE, RNG_STATIC, RNG_STENCH, - RNG_TRIPLE_ARROWS, + RNG_TRIPLE_ARROWS_DEFENSE_DOWN, + RNG_TRIPLE_ARROWS_FLINCH, }; #define RandomWeighted(tag, ...) \ diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index c52f9bc0327b..c51517d371d2 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1788,7 +1788,6 @@ 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) @@ -2611,9 +2610,20 @@ 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_JUNGLE_HEALING: + if (AtMaxHp(battlerAtk) + && AtMaxHp(BATTLE_PARTNER(battlerAtk)) + && !(gBattleMons[battlerAtk].status1 & STATUS1_ANY) + && !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY)) + score -= 10; + else if (AI_DATA->hpPercents[battlerAtk] >= 90 || AI_DATA->hpPercents[BATTLE_PARTNER(battlerAtk)] >= 90) + score -= 9; //No point in healing, but should at least do it if nothing better + break; case EFFECT_TAKE_HEART: if ((!(gBattleMons[battlerAtk].status1 & STATUS1_ANY) - || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, AI_DATA->partnerMove)) + || PartnerMoveIs(BATTLE_PARTNER(battlerAtk), AI_DATA->partnerMove, MOVE_JUNGLE_HEALING) + || PartnerMoveIs(BATTLE_PARTNER(battlerAtk), AI_DATA->partnerMove, MOVE_HEAL_BELL) + || PartnerMoveIs(BATTLE_PARTNER(battlerAtk), AI_DATA->partnerMove, MOVE_AROMATHERAPY)) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPDEF)) score -= 10; @@ -3483,11 +3493,6 @@ 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: @@ -4371,7 +4376,9 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) break; case EFFECT_REFRESH: case EFFECT_TAKE_HEART: - if (gBattleMons[battlerAtk].status1 & STATUS1_ANY) + if (gBattleMons[battlerAtk].status1 & STATUS1_ANY + || BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) + || BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPDEF)) score += 2; break; case EFFECT_PSYCHO_SHIFT: @@ -4817,6 +4824,15 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) //break; //case EFFECT_SKY_DROP //break; + case EFFECT_JUNGLE_HEALING: + if (ShouldRecover(battlerAtk, battlerDef, move, 25) + || ShouldRecover(battlerAtk, BATTLE_PARTNER(battlerDef), move, 25) + || ShouldRecover(BATTLE_PARTNER(battlerAtk), battlerDef, move, 25) + || ShouldRecover(BATTLE_PARTNER(battlerAtk), BATTLE_PARTNER(battlerDef), move, 25) + || gBattleMons[battlerAtk].status1 & STATUS1_ANY + || gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY) + score += 3; + break; } // move effect checks return score; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 775f8c456a91..f5f8ccf31a7d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3801,26 +3801,47 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u8 randomChance = RandomUniform(RNG_TRIPLE_ARROWS, 1, 10); - if (randomChance <= 5) // Chance to reduce a foe's Defense by 1 stat stage. + u8 randomLowerDefenseChance; + u8 randomFlinchChance; + + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_SERENE_GRACE) + { + randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 100); + randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 60); + } + else + { + randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 50); + randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 30); + } + + if (randomLowerDefenseChance && randomFlinchChance) { BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; + gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch; } - if (randomChance > 5 && randomChance <= 8) // Chance to cause a foe to flinch. + else { - if (battlerAbility == ABILITY_INNER_FOCUS && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + if (randomLowerDefenseChance) { - gLastUsedAbility = ABILITY_INNER_FOCUS; - gBattlerAbility = gEffectBattler; - RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); - gBattlescriptCurrInstr = BattleScript_FlinchPrevention; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; } - else + else if (randomFlinchChance) { - if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) - gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; - gBattlescriptCurrInstr++; + if (battlerAbility == ABILITY_INNER_FOCUS) + { + gLastUsedAbility = ABILITY_INNER_FOCUS; + gBattlerAbility = gEffectBattler; + RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); + gBattlescriptCurrInstr = BattleScript_FlinchPrevention; + } + else + { + if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; + gBattlescriptCurrInstr++; + } } } } diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index 020e46c6bbde..5fdf30737f8f 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -8,7 +8,7 @@ ASSUMPTIONS SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") { - PASSES_RANDOMLY(50, 100, RNG_TRIPLE_ARROWS); + PASSES_RANDOMLY(50, 100, RNG_TRIPLE_ARROWS_DEFENSE_DOWN); GIVEN { PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); @@ -23,7 +23,7 @@ SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") SINGLE_BATTLE_TEST("Triple Arrows flinch 30% of the time") { - PASSES_RANDOMLY(30, 100, RNG_TRIPLE_ARROWS); + PASSES_RANDOMLY(30, 100, RNG_TRIPLE_ARROWS_FLINCH); GIVEN { PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); From 2043380ee2b852c8840cb340faf78f3b940f668e Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 18 Apr 2023 10:34:39 -0300 Subject: [PATCH 12/22] Oopsie --- include/constants/battle_move_effects.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 9e514702d831..2c874f4f8172 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -411,6 +411,5 @@ #define EFFECT_AXE_KICK 405 #define NUM_BATTLE_MOVE_EFFECTS 406 ->>>>>>> afdfe1503dcb8720cede18b69ed5216e770399e6 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H From 787c0a159a7ee73c28cebc9f029a8d91438fc112 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 18 Apr 2023 11:26:43 -0300 Subject: [PATCH 13/22] Updated Triple Arrows' tests Thanks to MGriffin. --- test/move_effect_triple_arrows.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index 5fdf30737f8f..07a8186037c8 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -8,9 +8,13 @@ ASSUMPTIONS SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") { - PASSES_RANDOMLY(50, 100, RNG_TRIPLE_ARROWS_DEFENSE_DOWN); + u32 ability; + u32 chance; + PARAMETRIZE { ability = ABILITY_HUSTLE; chance = 50; } + PARAMETRIZE { ability = ABILITY_SERENE_GRACE; chance = 100; } + PASSES_RANDOMLY(chance, 100, RNG_TRIPLE_ARROWS_DEFENSE_DOWN); GIVEN { - PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_TOGEPI) { Ability(ability); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } @@ -23,18 +27,18 @@ SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") SINGLE_BATTLE_TEST("Triple Arrows flinch 30% of the time") { - PASSES_RANDOMLY(30, 100, RNG_TRIPLE_ARROWS_FLINCH); + u32 ability; + u32 chance; + PARAMETRIZE { ability = ABILITY_HUSTLE; chance = 30; } + PARAMETRIZE { ability = ABILITY_SERENE_GRACE; chance = 60; } + PASSES_RANDOMLY(chance, 100, RNG_TRIPLE_ARROWS_FLINCH); GIVEN { - PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_TOGEPI) { Ability(ability); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); - NONE_OF { - ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); - MESSAGE("Foe Wobbuffet's defense fell!"); - } MESSAGE("Foe Wobbuffet flinched!"); } } From b09ab5a3ee4ba3ec9b0d925c73fec317f6933ff1 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 19 Apr 2023 01:52:23 -0300 Subject: [PATCH 14/22] Updated Triple Arrows' effect's code and tests yet again Also added a function to get a move's secondaryEffectChance, meant to handle abilities, side statuses and the like that modify it. --- data/battle_scripts_1.s | 7 +++-- include/battle_util.h | 1 + src/battle_script_commands.c | 52 +++++++------------------------- src/battle_util.c | 8 +++++ test/move_effect_triple_arrows.c | 35 +++++++++++++++++++-- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index af141c297576..73dc7e79b8b1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1553,11 +1553,12 @@ BattleScript_DefDown_Ret: return BattleScript_ReduceDefenseAndFlinch:: - modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDown_Ret, ANIM_ON - jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_FlinchPrevention + modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDownAndFlinch_Ret, ANIM_ON + jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_DefDownAndFlinch_Ret setmoveeffect MOVE_EFFECT_FLINCH seteffectprimary - goto BattleScript_MoveEnd +BattleScript_DefDownAndFlinch_Ret: + return BattleScript_EffectPurify: attackcanceler diff --git a/include/battle_util.h b/include/battle_util.h index 0661081e43b8..0b25cabddf1e 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -234,5 +234,6 @@ u32 GetBattlerFriendshipScore(u8 battlerId); u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc); bool32 IsMyceliumMightOnField(void); bool8 ChangeTypeBasedOnTerrain(u8 battlerId); +u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f69ddf395fb5..c79a76d7ac00 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3803,48 +3803,23 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u8 randomLowerDefenseChance; - u8 randomFlinchChance; - - if (GetBattlerAbility(gBattlerAttacker) == ABILITY_SERENE_GRACE) - { - randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 100); - randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 60); - } - else - { - randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 50); - randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 30); - } + u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, GetMoveSecondaryEffectChance(gBattlerAttacker, 50)); + u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, GetMoveSecondaryEffectChance(gBattlerAttacker, 30)); if (randomLowerDefenseChance && randomFlinchChance) { BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch; } - else + else if (randomLowerDefenseChance) { - if (randomLowerDefenseChance) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; - } - else if (randomFlinchChance) - { - if (battlerAbility == ABILITY_INNER_FOCUS) - { - gLastUsedAbility = ABILITY_INNER_FOCUS; - gBattlerAbility = gEffectBattler; - RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); - gBattlescriptCurrInstr = BattleScript_FlinchPrevention; - } - else - { - if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) - gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; - gBattlescriptCurrInstr++; - } - } + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } + else if (randomFlinchChance && battlerAbility != ABILITY_INNER_FOCUS && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + { + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; + gBattlescriptCurrInstr++; } } break; @@ -3859,12 +3834,7 @@ static void Cmd_seteffectwithchance(void) { CMD_ARGS(); - u32 percentChance; - - if (GetBattlerAbility(gBattlerAttacker) == ABILITY_SERENE_GRACE) - percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2; - else - percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance; + u32 percentChance = GetMoveSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance); if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleScripting.moveEffect) diff --git a/src/battle_util.c b/src/battle_util.c index f23272b460f4..a2e1790948a7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10859,3 +10859,11 @@ static void SetRandomMultiHitCounter() gMultiHitCounter = 5 - (Random() & 1); } } + +u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance) +{ + if (GetBattlerAbility(battlerId) == ABILITY_SERENE_GRACE) + return (secondaryEffectChance * 2); + + return secondaryEffectChance; +} diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index 07a8186037c8..e7f48e0d0828 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -6,7 +6,7 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].effect == EFFECT_TRIPLE_ARROWS); } -SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") +SINGLE_BATTLE_TEST("Triple Arrows lowers Defense by one stage") { u32 ability; u32 chance; @@ -25,7 +25,7 @@ SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage") } } -SINGLE_BATTLE_TEST("Triple Arrows flinch 30% of the time") +SINGLE_BATTLE_TEST("Triple Arrows make the foe flinch 30% of the time") { u32 ability; u32 chance; @@ -58,3 +58,34 @@ SINGLE_BATTLE_TEST("Triple Arrows lands a critical hit") MESSAGE("A critical hit!"); } } + +SINGLE_BATTLE_TEST("Triple Arrows can lower Defense and cause flinch at the time") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_ARROWS); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Foe Wobbuffet's defense fell!"); + MESSAGE("Foe Wobbuffet flinched!"); + } +} + +SINGLE_BATTLE_TEST("Triple Arrows's flinching is prevented by Inner Focus") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_RIOLU) { Ability(ABILITY_INNER_FOCUS); } + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_ARROWS); + MOVE(opponent, MOVE_TACKLE); + } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); + NONE_OF { MESSAGE("Foe Wobbuffet flinched!"); } + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + } +} From 5fbfc119da2c9ca5cd21ad16e5da1e047659f9a6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 13 Jun 2023 05:51:32 -0300 Subject: [PATCH 15/22] 'Triple Arrows [the move] makeS the foe'... etc --- test/move_effect_triple_arrows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index e7f48e0d0828..715db298f155 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -25,7 +25,7 @@ SINGLE_BATTLE_TEST("Triple Arrows lowers Defense by one stage") } } -SINGLE_BATTLE_TEST("Triple Arrows make the foe flinch 30% of the time") +SINGLE_BATTLE_TEST("Triple Arrows makes the foe flinch 30% of the time") { u32 ability; u32 chance; From eb26039f33065725554539b6a6b63b8ada98fa3d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 13 Jun 2023 06:03:37 -0300 Subject: [PATCH 16/22] Adjusted Triple Arrows' checks --- src/battle_script_commands.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f48e76488461..79337250fd31 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3872,12 +3872,15 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch; } - else if (randomLowerDefenseChance) + else if (randomLowerDefenseChance && !randomFlinchChance) { BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_DefDown; } - else if (randomFlinchChance && battlerAbility != ABILITY_INNER_FOCUS && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + else if (randomFlinchChance + && !randomLowerDefenseChance + && battlerAbility != ABILITY_INNER_FOCUS + && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) { gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; gBattlescriptCurrInstr++; From 3a23207ef496c3fb3047c3cae2b6b16d0ccb5d3e Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 13 Jun 2023 06:29:39 -0300 Subject: [PATCH 17/22] Applied Alex's corrections to Triple Arrows' tests --- test/move_effect_triple_arrows.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/move_effect_triple_arrows.c b/test/move_effect_triple_arrows.c index 715db298f155..a899ab7a3464 100644 --- a/test/move_effect_triple_arrows.c +++ b/test/move_effect_triple_arrows.c @@ -6,7 +6,7 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].effect == EFFECT_TRIPLE_ARROWS); } -SINGLE_BATTLE_TEST("Triple Arrows lowers Defense by one stage") +SINGLE_BATTLE_TEST("Triple Arrows may lower Defense by one stage") { u32 ability; u32 chance; @@ -21,7 +21,7 @@ SINGLE_BATTLE_TEST("Triple Arrows lowers Defense by one stage") } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); - MESSAGE("Foe Wobbuffet's defense fell!"); + MESSAGE("Foe Wobbuffet's Defense fell!"); } } @@ -69,7 +69,7 @@ SINGLE_BATTLE_TEST("Triple Arrows can lower Defense and cause flinch at the time } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); - MESSAGE("Foe Wobbuffet's defense fell!"); + MESSAGE("Foe Wobbuffet's Defense fell!"); MESSAGE("Foe Wobbuffet flinched!"); } } From 81bb299e7f5952e1a7c596ca9d4643a987d46d9f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 13 Jun 2023 06:50:12 -0300 Subject: [PATCH 18/22] Updated Axe Kick's battle script I have no idea why is this working now when I'm pretty sure it didn't work before, but I consider this a win all the same. --- data/battle_scripts_1.s | 48 +---------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 25b935a0032e..41689d297c5a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -436,54 +436,8 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectAxeKick @ EFFECT_AXE_KICK BattleScript_EffectAxeKick:: - attackcanceler - accuracycheck BattleScript_AxeKickMissedDoDamage, ACC_CURR_MOVE - typecalc - jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_AxeKickMissedDoDamage - goto BattleScript_AxeKickHitFromAtkString -BattleScript_AxeKickMissedDoDamage:: - jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_PrintMoveMissed - attackstring - ppreduce - pause B_WAIT_TIME_LONG - resultmessage - waitmessage B_WAIT_TIME_LONG - printstring STRINGID_PKMNCRASHED - waitmessage B_WAIT_TIME_LONG - damagecalc - typecalc - adjustdamage - manipulatedamage DMG_RECOIL_FROM_MISS - bichalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE - healthbarupdate BS_ATTACKER - datahpupdate BS_ATTACKER - tryfaintmon BS_ATTACKER - orhalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE - goto BattleScript_MoveEnd - -BattleScript_AxeKickHitFromAtkString: - attackstring - ppreduce - critcalc - damagecalc - adjustdamage - attackanimation - waitanimation - effectivenesssound - hitanimation BS_TARGET - waitstate - healthbarupdate BS_TARGET - datahpupdate BS_TARGET - critmessage - waitmessage B_WAIT_TIME_LONG - resultmessage - waitmessage B_WAIT_TIME_LONG setmoveeffect MOVE_EFFECT_CONFUSION - seteffectwithchance - tryfaintmon BS_TARGET - moveendall - end + goto BattleScript_EffectRecoilIfMiss BattleScript_EffectTakeHeart:: attackcanceler From 9896f20eb83b0acc44a5856ff4bdff7080a127a7 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 13 Jun 2023 21:57:01 -0300 Subject: [PATCH 19/22] Applied fixes and corrections (Jun 2023) --- data/battle_scripts_1.s | 9 ++------- include/battle_util.h | 2 +- src/battle_ai_main.c | 10 ++++++---- src/battle_script_commands.c | 22 ++++++++-------------- src/battle_util.c | 4 ++-- src/data/battle_moves.h | 2 +- 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 41689d297c5a..db8e6e221ef4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -443,7 +443,7 @@ BattleScript_EffectTakeHeart:: attackcanceler attackstring ppreduce - cureifburnedparalysedorpoisoned BattleScript_EffectTakeHeart_TryToRaiseStats + cureifburnedparalysedorpoisoned BattleScript_CalmMindTryToRaiseStats attackanimation waitanimation updatestatusicon BS_ATTACKER @@ -453,11 +453,6 @@ BattleScript_EffectTakeHeart:: jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CalmMindStatRaise goto BattleScript_CantRaiseMultipleStats -BattleScript_EffectTakeHeart_TryToRaiseStats: - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim - goto BattleScript_CantRaiseMultipleStats - BattleScript_EffectTripleArrows:: setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS goto BattleScript_EffectHit @@ -1520,7 +1515,6 @@ BattleScript_DefDown_Ret: BattleScript_ReduceDefenseAndFlinch:: modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDownAndFlinch_Ret, ANIM_ON - jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_DefDownAndFlinch_Ret setmoveeffect MOVE_EFFECT_FLINCH seteffectprimary BattleScript_DefDownAndFlinch_Ret: @@ -6389,6 +6383,7 @@ BattleScript_EffectCalmMind:: attackcanceler attackstring ppreduce +BattleScript_CalmMindTryToRaiseStats:: jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats BattleScript_CalmMindDoMoveAnim:: diff --git a/include/battle_util.h b/include/battle_util.h index 43b613e06222..633bdb610363 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -236,6 +236,6 @@ bool8 ChangeTypeBasedOnTerrain(u8 battlerId); void RemoveConfusionStatus(u8 battlerId); u8 GetBattlerGender(u8 battlerId); bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2); -u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); +u32 CalcMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 89f2e75ae6b1..11b0a51e86a4 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2644,8 +2644,11 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) && !(gBattleMons[battlerAtk].status1 & STATUS1_ANY) && !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY)) score -= 10; - else if (AI_DATA->hpPercents[battlerAtk] >= 90 || AI_DATA->hpPercents[BATTLE_PARTNER(battlerAtk)] >= 90) - score -= 9; //No point in healing, but should at least do it if nothing better + else if (gBattleMons[battlerAtk].status1 & STATUS1_ANY + || gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY + || AI_DATA->hpPercents[battlerAtk] >= 90 + || AI_DATA->hpPercents[BATTLE_PARTNER(battlerAtk)] >= 90) + score -= 9; // No point in healing, but should at least do it if there's nothing better or if it's afflicted by a status ailment. break; case EFFECT_TAKE_HEART: if ((!(gBattleMons[battlerAtk].status1 & STATUS1_ANY) @@ -2654,6 +2657,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) || PartnerMoveIs(BATTLE_PARTNER(battlerAtk), AI_DATA->partnerMove, MOVE_AROMATHERAPY)) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPDEF)) + score -= 10; break; case EFFECT_PLACEHOLDER: return 0; // cannot even select @@ -4893,9 +4897,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) //break; case EFFECT_JUNGLE_HEALING: if (ShouldRecover(battlerAtk, battlerDef, move, 25) - || ShouldRecover(battlerAtk, BATTLE_PARTNER(battlerDef), move, 25) || ShouldRecover(BATTLE_PARTNER(battlerAtk), battlerDef, move, 25) - || ShouldRecover(BATTLE_PARTNER(battlerAtk), BATTLE_PARTNER(battlerDef), move, 25) || gBattleMons[battlerAtk].status1 & STATUS1_ANY || gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY) score += 3; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 79337250fd31..86923b86ee5d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3864,25 +3864,19 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, GetMoveSecondaryEffectChance(gBattlerAttacker, 50)); - u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, GetMoveSecondaryEffectChance(gBattlerAttacker, 30)); + u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, CalcMoveSecondaryEffectChance(gBattlerAttacker, 50)); + u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, CalcMoveSecondaryEffectChance(gBattlerAttacker, 30)); - if (randomLowerDefenseChance && randomFlinchChance) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch; - } - else if (randomLowerDefenseChance && !randomFlinchChance) + if (randomFlinchChance && battlerAbility != ABILITY_INNER_FOCUS && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; + + if (randomLowerDefenseChance) { BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_DefDown; } - else if (randomFlinchChance - && !randomLowerDefenseChance - && battlerAbility != ABILITY_INNER_FOCUS - && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + else { - gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; gBattlescriptCurrInstr++; } } @@ -3898,7 +3892,7 @@ static void Cmd_seteffectwithchance(void) { CMD_ARGS(); - u32 percentChance = GetMoveSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance); + u32 percentChance = CalcMoveSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance); if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleScripting.moveEffect) diff --git a/src/battle_util.c b/src/battle_util.c index 6706c6955e2d..a6e123e65e29 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10930,10 +10930,10 @@ bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2) return (gender1 != MON_GENDERLESS && gender2 != MON_GENDERLESS && gender1 != gender2); } -u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance) +u32 CalcMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance) { if (GetBattlerAbility(battlerId) == ABILITY_SERENE_GRACE) - return (secondaryEffectChance * 2); + secondaryEffectChance *= 2; return secondaryEffectChance; } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 8594a72fafcb..c8487f311918 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12764,7 +12764,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 | FLAG_HIGH_CRIT, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIGH_CRIT, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, From 9984a9e0968f8e61416c8df5711e544acdbb65cc Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 15 Jun 2023 09:59:25 -0300 Subject: [PATCH 20/22] Update src/data/battle_moves.h Co-authored-by: Eduardo Quezada D'Ottone --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index c8487f311918..65ace8f3b84c 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12761,7 +12761,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .effect = EFFECT_TRIPLE_ARROWS, .type = TYPE_FIGHTING, .accuracy = 100, - .secondaryEffectChance = 100, + .secondaryEffectChance = 100, // 50% Defense down, 30% Flinch. Can be modified in 'SetMoveEffect' .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIGH_CRIT, From 48c04f936a3eebfcf88b57ae3f41928bc2835244 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 19 Jun 2023 00:07:47 -0300 Subject: [PATCH 21/22] Split Refresh's and Take Heart's effects in AI_CheckViability --- src/battle_ai_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 11b0a51e86a4..b8ab23027406 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -4442,6 +4442,9 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score++; break; case EFFECT_REFRESH: + if (gBattleMons[battlerAtk].status1 & STATUS1_ANY) + score += 2; + break; case EFFECT_TAKE_HEART: if (gBattleMons[battlerAtk].status1 & STATUS1_ANY || BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) From 2bf88502a7a0185bfc58a4011da354b1c8789be3 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 19 Jun 2023 04:17:24 -0300 Subject: [PATCH 22/22] More corrections --- data/battle_scripts_1.s | 7 ------- include/battle_scripts.h | 1 - include/battle_util.h | 2 +- src/battle_ai_main.c | 15 +++++---------- src/battle_script_commands.c | 6 +++--- src/battle_util.c | 2 +- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index db8e6e221ef4..4c60758184ae 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1513,13 +1513,6 @@ BattleScript_DefDown:: BattleScript_DefDown_Ret: return -BattleScript_ReduceDefenseAndFlinch:: - modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDownAndFlinch_Ret, ANIM_ON - setmoveeffect MOVE_EFFECT_FLINCH - seteffectprimary -BattleScript_DefDownAndFlinch_Ret: - return - BattleScript_EffectPurify: attackcanceler attackstring diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3bf8e5e759e6..3bb4ed4124dc 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -471,7 +471,6 @@ extern const u8 BattleScript_SpikesActivates[]; extern const u8 BattleScript_BerserkGeneRet[]; extern const u8 BattleScript_TargetFormChangeWithStringNoPopup[]; extern const u8 BattleScript_DefDown[]; -extern const u8 BattleScript_ReduceDefenseAndFlinch[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/battle_util.h b/include/battle_util.h index 633bdb610363..79bdfaf9a874 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -236,6 +236,6 @@ bool8 ChangeTypeBasedOnTerrain(u8 battlerId); void RemoveConfusionStatus(u8 battlerId); u8 GetBattlerGender(u8 battlerId); bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2); -u32 CalcMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); +u32 CalcSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b8ab23027406..211fa122796c 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2639,16 +2639,11 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score -= 10; break; case EFFECT_JUNGLE_HEALING: - if (AtMaxHp(battlerAtk) - && AtMaxHp(BATTLE_PARTNER(battlerAtk)) - && !(gBattleMons[battlerAtk].status1 & STATUS1_ANY) - && !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY)) - score -= 10; - else if (gBattleMons[battlerAtk].status1 & STATUS1_ANY - || gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY - || AI_DATA->hpPercents[battlerAtk] >= 90 - || AI_DATA->hpPercents[BATTLE_PARTNER(battlerAtk)] >= 90) - score -= 9; // No point in healing, but should at least do it if there's nothing better or if it's afflicted by a status ailment. + if (AtMaxHp(battlerAtk) + && AtMaxHp(BATTLE_PARTNER(battlerAtk)) + && !(gBattleMons[battlerAtk].status1 & STATUS1_ANY) + && !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY)) + score -= 10; break; case EFFECT_TAKE_HEART: if ((!(gBattleMons[battlerAtk].status1 & STATUS1_ANY) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 86923b86ee5d..c4ea866df9ad 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3864,8 +3864,8 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_TRIPLE_ARROWS: { - u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, CalcMoveSecondaryEffectChance(gBattlerAttacker, 50)); - u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, CalcMoveSecondaryEffectChance(gBattlerAttacker, 30)); + u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, CalcSecondaryEffectChance(gBattlerAttacker, 50)); + u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, CalcSecondaryEffectChance(gBattlerAttacker, 30)); if (randomFlinchChance && battlerAbility != ABILITY_INNER_FOCUS && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH]; @@ -3892,7 +3892,7 @@ static void Cmd_seteffectwithchance(void) { CMD_ARGS(); - u32 percentChance = CalcMoveSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance); + u32 percentChance = CalcSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance); if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleScripting.moveEffect) diff --git a/src/battle_util.c b/src/battle_util.c index a6e123e65e29..ee4e50cf3cf2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10930,7 +10930,7 @@ bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2) return (gender1 != MON_GENDERLESS && gender2 != MON_GENDERLESS && gender1 != gender2); } -u32 CalcMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance) +u32 CalcSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance) { if (GetBattlerAbility(battlerId) == ABILITY_SERENE_GRACE) secondaryEffectChance *= 2;