Merge pull request #2527 from mrgriffin/rhh-cleanup-handle-terrain-move

Cleanup HandleTerrainMove
This commit is contained in:
Eduardo Quezada D'Ottone 2022-12-21 12:21:46 -03:00 committed by GitHub
commit 42d2bee519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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