Full support for moves hitting all battlers

This commit is contained in:
DizzyEggg 2018-09-29 16:41:25 +02:00
parent ada76cbe4f
commit dddefbb0e3
6 changed files with 33 additions and 7 deletions

View File

@ -1529,6 +1529,7 @@
.macro setmoveeffect effect
setbyte cEFFECT_CHOOSER \effect
setbyte sSAVED_MOVE_EFFECT \effect
.endm
.macro chosenstatus1animation battler, status

View File

@ -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

View File

@ -677,6 +677,7 @@ struct BattleScripting
u8 multiplayerId;
bool8 monCaught;
s32 savedDmg;
u8 savedMoveEffect; // For moves hitting multiple targets.
};
// rom_80A5C6C

View File

@ -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

View File

@ -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

View File

@ -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;