Skip to content

Commit

Permalink
Post cherrypick corrections and improvements
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
LOuroboros committed Mar 28, 2023
1 parent 000077f commit ed9e860
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
18 changes: 3 additions & 15 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3527,6 +3514,7 @@ BattleScript_AbsorbHealBlock::
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd

BattleScript_EffectInfernalParade::
BattleScript_EffectBurnHit::
setmoveeffect MOVE_EFFECT_BURN
goto BattleScript_EffectHit
Expand Down
2 changes: 1 addition & 1 deletion include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
13 changes: 12 additions & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
{
Expand Down
1 change: 1 addition & 0 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 7 additions & 11 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3802,23 +3801,20 @@ 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);
gBattlescriptCurrInstr = BattleScript_DefDown;
}
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
{
Expand Down
5 changes: 1 addition & 4 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/data/battle_moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit ed9e860

Please sign in to comment.