Optimized terrain timers
This commit is contained in:
parent
8773e552ac
commit
4e6a459b14
3 changed files with 14 additions and 20 deletions
|
@ -222,10 +222,7 @@ struct FieldTimer
|
||||||
u8 wonderRoomTimer;
|
u8 wonderRoomTimer;
|
||||||
u8 magicRoomTimer;
|
u8 magicRoomTimer;
|
||||||
u8 trickRoomTimer;
|
u8 trickRoomTimer;
|
||||||
u8 grassyTerrainTimer;
|
u8 terrainTimer;
|
||||||
u8 mistyTerrainTimer;
|
|
||||||
u8 electricTerrainTimer;
|
|
||||||
u8 psychicTerrainTimer;
|
|
||||||
u8 gravityTimer;
|
u8 gravityTimer;
|
||||||
u8 fairyLockTimer;
|
u8 fairyLockTimer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7328,19 +7328,19 @@ static void HandleTerrainMove(u32 moveEffect)
|
||||||
switch (moveEffect)
|
switch (moveEffect)
|
||||||
{
|
{
|
||||||
case EFFECT_MISTY_TERRAIN:
|
case EFFECT_MISTY_TERRAIN:
|
||||||
statusFlag = STATUS_FIELD_MISTY_TERRAIN, timer = &gFieldTimers.mistyTerrainTimer;
|
statusFlag = STATUS_FIELD_MISTY_TERRAIN, timer = &gFieldTimers.terrainTimer;
|
||||||
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.grassyTerrainTimer;
|
statusFlag = STATUS_FIELD_GRASSY_TERRAIN, timer = &gFieldTimers.terrainTimer;
|
||||||
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.electricTerrainTimer;
|
statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
|
||||||
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.psychicTerrainTimer;
|
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8937,22 +8937,19 @@ static void Cmd_various(void)
|
||||||
gBattlescriptCurrInstr += 7; // can heal
|
gBattlescriptCurrInstr += 7; // can heal
|
||||||
return;
|
return;
|
||||||
case VARIOUS_REMOVE_TERRAIN:
|
case VARIOUS_REMOVE_TERRAIN:
|
||||||
|
gFieldTimers.terrainTimer = 0;
|
||||||
switch (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
|
switch (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
|
||||||
{
|
{
|
||||||
case STATUS_FIELD_MISTY_TERRAIN:
|
case STATUS_FIELD_MISTY_TERRAIN:
|
||||||
gFieldTimers.mistyTerrainTimer = 0;
|
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||||
break;
|
break;
|
||||||
case STATUS_FIELD_GRASSY_TERRAIN:
|
case STATUS_FIELD_GRASSY_TERRAIN:
|
||||||
gFieldTimers.grassyTerrainTimer = 0;
|
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||||
break;
|
break;
|
||||||
case STATUS_FIELD_ELECTRIC_TERRAIN:
|
case STATUS_FIELD_ELECTRIC_TERRAIN:
|
||||||
gFieldTimers.electricTerrainTimer = 0;
|
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
||||||
break;
|
break;
|
||||||
case STATUS_FIELD_PSYCHIC_TERRAIN:
|
case STATUS_FIELD_PSYCHIC_TERRAIN:
|
||||||
gFieldTimers.psychicTerrainTimer = 0;
|
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2326,7 +2326,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_ELECTRIC_TERRAIN:
|
case ENDTURN_ELECTRIC_TERRAIN:
|
||||||
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN
|
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN
|
||||||
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0))
|
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
|
||||||
{
|
{
|
||||||
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
|
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
|
||||||
TryToRevertMimicry();
|
TryToRevertMimicry();
|
||||||
|
@ -2337,7 +2337,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_MISTY_TERRAIN:
|
case ENDTURN_MISTY_TERRAIN:
|
||||||
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN
|
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN
|
||||||
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0))
|
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
|
||||||
{
|
{
|
||||||
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN);
|
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN);
|
||||||
TryToRevertMimicry();
|
TryToRevertMimicry();
|
||||||
|
@ -2350,7 +2350,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||||
if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
|
if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
|
||||||
{
|
{
|
||||||
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)
|
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)
|
||||||
&& (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0))
|
&& (gFieldTimers.terrainTimer == 0 || --gFieldTimers.terrainTimer == 0))
|
||||||
{
|
{
|
||||||
gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN);
|
gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN);
|
||||||
TryToRevertMimicry();
|
TryToRevertMimicry();
|
||||||
|
@ -2362,7 +2362,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_PSYCHIC_TERRAIN:
|
case ENDTURN_PSYCHIC_TERRAIN:
|
||||||
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN
|
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN
|
||||||
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0))
|
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
|
||||||
{
|
{
|
||||||
gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN);
|
gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN);
|
||||||
TryToRevertMimicry();
|
TryToRevertMimicry();
|
||||||
|
@ -4338,28 +4338,28 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ABILITY_ELECTRIC_SURGE:
|
case ABILITY_ELECTRIC_SURGE:
|
||||||
if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.electricTerrainTimer))
|
if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer))
|
||||||
{
|
{
|
||||||
BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates);
|
BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates);
|
||||||
effect++;
|
effect++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ABILITY_GRASSY_SURGE:
|
case ABILITY_GRASSY_SURGE:
|
||||||
if (TryChangeBattleTerrain(battler, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.grassyTerrainTimer))
|
if (TryChangeBattleTerrain(battler, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.terrainTimer))
|
||||||
{
|
{
|
||||||
BattleScriptPushCursorAndCallback(BattleScript_GrassySurgeActivates);
|
BattleScriptPushCursorAndCallback(BattleScript_GrassySurgeActivates);
|
||||||
effect++;
|
effect++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ABILITY_MISTY_SURGE:
|
case ABILITY_MISTY_SURGE:
|
||||||
if (TryChangeBattleTerrain(battler, STATUS_FIELD_MISTY_TERRAIN, &gFieldTimers.mistyTerrainTimer))
|
if (TryChangeBattleTerrain(battler, STATUS_FIELD_MISTY_TERRAIN, &gFieldTimers.terrainTimer))
|
||||||
{
|
{
|
||||||
BattleScriptPushCursorAndCallback(BattleScript_MistySurgeActivates);
|
BattleScriptPushCursorAndCallback(BattleScript_MistySurgeActivates);
|
||||||
effect++;
|
effect++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ABILITY_PSYCHIC_SURGE:
|
case ABILITY_PSYCHIC_SURGE:
|
||||||
if (TryChangeBattleTerrain(battler, STATUS_FIELD_PSYCHIC_TERRAIN, &gFieldTimers.psychicTerrainTimer))
|
if (TryChangeBattleTerrain(battler, STATUS_FIELD_PSYCHIC_TERRAIN, &gFieldTimers.terrainTimer))
|
||||||
{
|
{
|
||||||
BattleScriptPushCursorAndCallback(BattleScript_PsychicSurgeActivates);
|
BattleScriptPushCursorAndCallback(BattleScript_PsychicSurgeActivates);
|
||||||
effect++;
|
effect++;
|
||||||
|
|
Loading…
Reference in a new issue