From 328e951afa573595ae2c6a2784e408f10d74feb2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 20 Apr 2020 20:05:04 +0200 Subject: [PATCH] Ally Switch, tbd --- asm/macros/battle_script.inc | 5 +++++ data/battle_ai_scripts.s | 2 ++ data/battle_scripts_1.s | 13 +++++++++++++ include/constants/battle_move_effects.h | 1 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 6 ++++++ src/data/battle_moves.h | 2 +- 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 6a4680dd2..979d12fb7 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1719,6 +1719,11 @@ .4byte \ptr .endm + .macro jumpifnoally battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_NO_ALLY + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 2c4cc6ad4..73404e589 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -263,6 +263,7 @@ AI_CheckBadMove_CheckEffect: @ 82DC045 if_effect EFFECT_FOLLOW_ME, AI_CBM_FollowMe if_effect EFFECT_GEOMANCY, AI_CBM_QuiverDance if_effect EFFECT_FAIRY_LOCK, AI_CBM_FairyLock + if_effect EFFECT_ALLY_SWITCH, AI_CBM_HelpingHand end AI_CBM_FairyLock: @@ -847,6 +848,7 @@ AI_CBM_WillOWisp: @ 82DC6B4 AI_CBM_HelpingHand: @ 82DC6E3 if_not_double_battle Score_Minus10 + if_battler_absent AI_USER_PARTNER, Score_Minus10 end AI_CBM_TrickAndKnockOff: @ 82DC6EB diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index dd8a1b25e..7ca850a01 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -362,6 +362,19 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectShoreUp .4byte BattleScript_EffectGeomancy .4byte BattleScript_EffectFairyLock + .4byte BattleScript_EffectAllySwitch + +BattleScript_EffectAllySwitch: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + jumpifnoally BS_ATTACKER, BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_ALLYSWITCHPOSITION + waitmessage 0x40 + goto BattleScript_MoveEnd BattleScript_EffectFairyLock: attackcanceler diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index a82ee8b92..7cdc993d2 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -350,5 +350,6 @@ #define EFFECT_SHORE_UP 344 #define EFFECT_GEOMANCY 345 #define EFFECT_FAIRY_LOCK 346 +#define EFFECT_ALLY_SWITCH 347 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index b17523c67..6686446fd 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -155,6 +155,7 @@ #define VARIOUS_TRY_FRISK 92 #define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 #define VARIOUS_TRY_FAIRY_LOCK 94 +#define VARIOUS_JUMP_IF_NO_ALLY 95 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d6148c14b..2bafa7829 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6827,6 +6827,12 @@ static void Cmd_various(void) else gBattlescriptCurrInstr += 7; return; + case VARIOUS_JUMP_IF_NO_ALLY: + if (!IsBattlerAlive(BATTLE_PARTNER(gActiveBattler))) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; case VARIOUS_TRY_FAIRY_LOCK: if (gFieldStatuses & STATUS_FIELD_FAIRY_LOCK) { diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 2bfe9f394..84de4275d 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7041,7 +7041,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_ALLY_SWITCH] = { - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_ALLY_SWITCH, .power = 0, .type = TYPE_PSYCHIC, .accuracy = 0,