diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index c29d8f7c4..0301a3517 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2037,6 +2037,11 @@ various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES .endm + .macro jumpifnovalidtargets ptr:req + various BS_ATTACKER, VARIOUS_JUMP_IF_NO_VALID_TARGETS + .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_scripts_1.s b/data/battle_scripts_1.s index de1aa536a..bbbb7d9b7 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8479,6 +8479,7 @@ BattleScript_TryAdrenalineOrbRet: return BattleScript_IntimidateActivates:: + jumpifnovalidtargets BattleScript_IntimidateEnd showabilitypopup BS_ATTACKER pause B_WAIT_TIME_LONG destroyabilitypopup diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index a13423bcb..fdf703c1a 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -254,6 +254,7 @@ #define VARIOUS_TRY_WIND_RIDER_POWER 163 #define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 164 #define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 165 +#define VARIOUS_JUMP_IF_NO_VALID_TARGETS 166 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 42a1fd56e..b45684b9b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10216,6 +10216,21 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 3; AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); return; + case VARIOUS_JUMP_IF_NO_VALID_TARGETS: + { + u32 count = 0; + + for (i = 0; i < gBattlersCount; i++) + { + if (GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) && IsBattlerAlive(i)) + count++; + } + if (count == 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + } + return; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3;