From dddefbb0e3ec43595aed88340924f71da6101f4b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 29 Sep 2018 16:41:25 +0200 Subject: [PATCH] Full support for moves hitting all battlers --- asm/macros/battle_script.inc | 1 + data/battle_scripts_1.s | 7 ++++-- include/battle.h | 1 + include/constants/battle_script_commands.h | 1 + src/battle_main.c | 1 + src/battle_script_commands.c | 29 ++++++++++++++++++---- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 7db4856fad..3174166085 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1529,6 +1529,7 @@ .macro setmoveeffect effect setbyte cEFFECT_CHOOSER \effect + setbyte sSAVED_MOVE_EFFECT \effect .endm .macro chosenstatus1animation battler, status diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 125b077f28..a4948dc898 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1395,7 +1395,6 @@ BattleScript_EffectRound: BattleScript_EffectBrine: BattleScript_EffectVenoshock: BattleScript_EffectRetalitate: -BattleScript_EffectBulldoze: BattleScript_EffectFoulPlay: BattleScript_EffectPsyshock: BattleScript_EffectWeatherBall: @@ -3065,13 +3064,16 @@ BattleScript_EffectStomp: setmoveeffect MOVE_EFFECT_FLINCH goto BattleScript_EffectHit -BattleScript_EffectEarthquake:: +BattleScript_EffectBulldoze: + setmoveeffect MOVE_EFFECT_SPD_MINUS_1 +BattleScript_EffectEarthquake: attackcanceler attackstring ppreduce selectfirstvalidtarget BattleScript_HitsAllWithUndergroundBonusLoop:: movevaluescleanup + copybyte cEFFECT_CHOOSER, sSAVED_MOVE_EFFECT jumpifnostatus3 BS_TARGET, STATUS3_UNDERGROUND, BattleScript_HitsAllNoUndergroundBonus orword gHitMarker, HITMARKER_IGNORE_UNDERGROUND goto BattleScript_DoHitAllWithUndergroundBonus @@ -3093,6 +3095,7 @@ BattleScript_DoHitAllWithUndergroundBonus:: waitmessage 0x40 resultmessage waitmessage 0x40 + seteffectwithchance printstring STRINGID_EMPTYSTRING3 waitmessage 0x1 tryfaintmon BS_TARGET, FALSE, NULL diff --git a/include/battle.h b/include/battle.h index f6e3066e18..d46563a760 100644 --- a/include/battle.h +++ b/include/battle.h @@ -677,6 +677,7 @@ struct BattleScripting u8 multiplayerId; bool8 monCaught; s32 savedDmg; + u8 savedMoveEffect; // For moves hitting multiple targets. }; // rom_80A5C6C diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 96503f298d..6f6595e5c8 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -30,6 +30,7 @@ #define sMULTIPLAYER_ID gBattleScripting + 0x25 #define sMON_CAUGHT gBattleScripting + 0x26 #define sSAVED_DMG gBattleScripting + 0x28 +#define sSAVED_MOVE_EFFECT gBattleScripting + 0x2C #define cEFFECT_CHOOSER gBattleCommunication + 3 #define cMULTISTRING_CHOOSER gBattleCommunication + 5 diff --git a/src/battle_main.c b/src/battle_main.c index ce500099f3..ba8752f6c2 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5440,6 +5440,7 @@ static void HandleAction_UseMove(void) gMoveResultFlags = 0; gMultiHitCounter = 0; gBattleCommunication[6] = 0; + gBattleScripting.savedMoveEffect = 0; gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); // choose move diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e1e58616ad..3b16de8ba1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4323,17 +4323,36 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case ATK49_NEXT_TARGET: // For moves hitting two opposing Pokemon. - if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !gProtectStructs[gBattlerAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH + if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) + && gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && !gProtectStructs[gBattlerAttacker].chargingTurn + && (gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH || gBattleMoves[gCurrentMove].target == MOVE_TARGET_FOES_AND_ALLY) && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - u8 battlerId = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); - if (gBattleMons[battlerId].hp != 0) + u8 battlerId; + + if (gBattleMoves[gCurrentMove].target == MOVE_TARGET_FOES_AND_ALLY) + { + for (battlerId = gBattlerTarget + 1; battlerId < gBattlersCount; battlerId++) + { + if (battlerId == gBattlerAttacker) + continue; + if (IsBattlerAlive(battlerId)) + break; + } + } + else + { + battlerId = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gHitMarker |= HITMARKER_NO_ATTACKSTRING; + } + + if (battlerId < gBattlersCount && gBattleMons[battlerId].hp != 0) { gBattlerTarget = battlerId; - gHitMarker |= HITMARKER_NO_ATTACKSTRING; gBattleScripting.atk49_state = 0; MoveValuesCleanUp(); + gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleScripting.savedMoveEffect; BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr = BattleScript_FlushMessageBox; return;