Cleanup HandleTerrainMove

This commit is contained in:
Martin Griffin 2022-12-20 21:28:54 +00:00
parent 23acbb370d
commit 682c59869b

View File

@ -7921,35 +7921,34 @@ static bool32 HasAttackerFaintedTarget(void)
static void HandleTerrainMove(u16 move)
{
u32 statusFlag = 0;
u8 *timer = NULL;
switch (gBattleMoves[move].effect)
{
case EFFECT_MISTY_TERRAIN:
statusFlag = STATUS_FIELD_MISTY_TERRAIN, timer = &gFieldTimers.terrainTimer;
statusFlag = STATUS_FIELD_MISTY_TERRAIN;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
break;
case EFFECT_GRASSY_TERRAIN:
statusFlag = STATUS_FIELD_GRASSY_TERRAIN, timer = &gFieldTimers.terrainTimer;
statusFlag = STATUS_FIELD_GRASSY_TERRAIN;
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
break;
case EFFECT_ELECTRIC_TERRAIN:
statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
break;
case EFFECT_PSYCHIC_TERRAIN:
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN;
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
break;
case EFFECT_DAMAGE_SET_TERRAIN:
switch (gBattleMoves[move].argument)
{
case 0: //genesis supernova
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN;
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
break;
case 1: //splintered stormshards
if (!(gFieldStatuses & (STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN)))
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_ANY))
{
//no terrain to remove -> jump to battle script pointer
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
@ -7957,7 +7956,7 @@ static void HandleTerrainMove(u16 move)
else
{
// remove all terrain
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN);
gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY;
gBattleCommunication[MULTISTRING_CHOOSER] = 4;
gBattlescriptCurrInstr += 7;
}
@ -7977,9 +7976,9 @@ static void HandleTerrainMove(u16 move)
gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY;
gFieldStatuses |= statusFlag;
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER)
*timer = 8;
gFieldTimers.terrainTimer = 8;
else
*timer = 5;
gFieldTimers.terrainTimer = 5;
gBattlescriptCurrInstr += 7;
}
}