From 1595a66559571b365ece5c8f9275a1bf33e3df34 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 10:18:38 -0300 Subject: [PATCH] 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 200a04461..5be16a0a1 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 c78fcafe4..590a9232c 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 61c3776c6..8bde7d2f1 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 27ad6601f..017320eef 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 12a2f65e2..424ba7dd3 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 64ce24686..32927b82e 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,