remove pointless timers from disable struct

This commit is contained in:
DizzyEggg 2023-02-07 15:10:20 +01:00
parent 0c4c3fbbb7
commit f762ed728d
4 changed files with 28 additions and 39 deletions

View File

@ -70,20 +70,15 @@ struct DisableStruct
s8 stockpileBeforeDef; s8 stockpileBeforeDef;
s8 stockpileBeforeSpDef; s8 stockpileBeforeSpDef;
u8 substituteHP; u8 substituteHP;
u8 disableTimer:4;
u8 disableTimerStartValue:4;
u8 encoredMovePos; u8 encoredMovePos;
u8 disableTimer:4;
u8 encoreTimer:4; u8 encoreTimer:4;
u8 encoreTimerStartValue:4;
u8 perishSongTimer:4; u8 perishSongTimer:4;
u8 perishSongTimerStartValue:4;
u8 furyCutterCounter; u8 furyCutterCounter;
u8 rolloutTimer:4; u8 rolloutTimer:4;
u8 rolloutTimerStartValue:4; u8 rolloutTimerStartValue:4;
u8 chargeTimer:4; u8 chargeTimer:4;
u8 chargeTimerStartValue:4;
u8 tauntTimer:4; u8 tauntTimer:4;
u8 tauntTimer2:4;
u8 battlerPreventingEscape; u8 battlerPreventingEscape;
u8 battlerWithSureHit; u8 battlerWithSureHit;
u8 isFirstTurn; u8 isFirstTurn;
@ -99,8 +94,8 @@ struct DisableStruct
u8 healBlockTimer; u8 healBlockTimer;
u8 laserFocusTimer; u8 laserFocusTimer;
u8 throatChopTimer; u8 throatChopTimer;
u8 usedMoves:4;
u8 wrapTurns; u8 wrapTurns;
u8 usedMoves:4;
u8 noRetreat:1; u8 noRetreat:1;
u8 tarShot:1; u8 tarShot:1;
u8 octolock:1; u8 octolock:1;

View File

@ -3124,7 +3124,6 @@ void SwitchInClearSetData(void)
gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP; gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP;
gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit; gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit;
gDisableStructs[gActiveBattler].perishSongTimer = disableStructCopy.perishSongTimer; gDisableStructs[gActiveBattler].perishSongTimer = disableStructCopy.perishSongTimer;
gDisableStructs[gActiveBattler].perishSongTimerStartValue = disableStructCopy.perishSongTimerStartValue;
gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape; gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape;
} }

View File

@ -2790,7 +2790,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
u32 flags = 0; u32 flags = 0;
u16 battlerAbility; u16 battlerAbility;
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT
&& gBattleMons[gBattlerTarget].hp != 0 && gBattleMons[gBattlerTarget].hp != 0
&& IsFinalStrikeEffect(gCurrentMove)) && IsFinalStrikeEffect(gCurrentMove))
{ {
@ -2825,7 +2825,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
// Just in case this flag is still set // Just in case this flag is still set
gBattleScripting.moveEffect &= ~MOVE_EFFECT_CERTAIN; gBattleScripting.moveEffect &= ~MOVE_EFFECT_CERTAIN;
if ((battlerAbility == ABILITY_SHIELD_DUST if ((battlerAbility == ABILITY_SHIELD_DUST
|| GetBattlerHoldEffect(gEffectBattler, TRUE) == HOLD_EFFECT_COVERT_CLOAK) || GetBattlerHoldEffect(gEffectBattler, TRUE) == HOLD_EFFECT_COVERT_CLOAK)
&& !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
@ -9361,7 +9361,7 @@ static void Cmd_various(void)
gBattleCommunication[MULTISTRING_CHOOSER] = 3; gBattleCommunication[MULTISTRING_CHOOSER] = 3;
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) && CanSleep(gBattlerTarget)) else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) && CanSleep(gBattlerTarget))
gBattleCommunication[MULTISTRING_CHOOSER] = 4; gBattleCommunication[MULTISTRING_CHOOSER] = 4;
else else
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
return; return;
@ -9864,10 +9864,10 @@ static void Cmd_various(void)
gBattlescriptCurrInstr += 4; gBattlescriptCurrInstr += 4;
return; return;
} }
if (gBattlescriptCurrInstr[3]) if (gBattlescriptCurrInstr[3])
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID
if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, gActiveBattler, FALSE)) if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, gActiveBattler, FALSE))
return; return;
@ -10065,7 +10065,7 @@ static void Cmd_various(void)
// Check taunt // Check taunt
if (gDisableStructs[gActiveBattler].tauntTimer != 0) if (gDisableStructs[gActiveBattler].tauntTimer != 0)
{ {
gDisableStructs[gActiveBattler].tauntTimer = gDisableStructs[gActiveBattler].tauntTimer2 = 0; gDisableStructs[gActiveBattler].tauntTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT); PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT);
} }
@ -10073,7 +10073,7 @@ static void Cmd_various(void)
if (gDisableStructs[gActiveBattler].encoreTimer != 0) if (gDisableStructs[gActiveBattler].encoreTimer != 0)
{ {
gDisableStructs[gActiveBattler].encoredMove = 0; gDisableStructs[gActiveBattler].encoredMove = 0;
gDisableStructs[gActiveBattler].encoreTimerStartValue = gDisableStructs[gActiveBattler].encoreTimer = 0; gDisableStructs[gActiveBattler].encoreTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_ENCORE; // STRINGID_PKMNENCOREENDED gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_ENCORE; // STRINGID_PKMNENCOREENDED
} }
// Check torment // Check torment
@ -10091,7 +10091,7 @@ static void Cmd_various(void)
// Check disable // Check disable
if (gDisableStructs[gActiveBattler].disableTimer != 0) if (gDisableStructs[gActiveBattler].disableTimer != 0)
{ {
gDisableStructs[gActiveBattler].disableTimer = gDisableStructs[gActiveBattler].disableTimerStartValue = 0; gDisableStructs[gActiveBattler].disableTimer = 0;
gDisableStructs[gActiveBattler].disabledMove = 0; gDisableStructs[gActiveBattler].disabledMove = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE;
} }
@ -10970,7 +10970,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
{ {
RecordItemEffectBattle(gActiveBattler, HOLD_EFFECT_CLEAR_AMULET); RecordItemEffectBattle(gActiveBattler, HOLD_EFFECT_CLEAR_AMULET);
} }
if (flags == STAT_CHANGE_ALLOW_PTR) if (flags == STAT_CHANGE_ALLOW_PTR)
{ {
if (gSpecialStatuses[gActiveBattler].statLowered) if (gSpecialStatuses[gActiveBattler].statLowered)
@ -11897,7 +11897,7 @@ static void Cmd_transformdataexecution(void)
for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) for (i = 0; i < offsetof(struct BattlePokemon, pp); i++)
battleMonAttacker[i] = battleMonTarget[i]; battleMonAttacker[i] = battleMonTarget[i];
gBattleStruct->overwrittenAbilities[gBattlerAttacker] = GetBattlerAbility(gBattlerTarget); gBattleStruct->overwrittenAbilities[gBattlerAttacker] = GetBattlerAbility(gBattlerTarget);
for (i = 0; i < MAX_MON_MOVES; i++) for (i = 0; i < MAX_MON_MOVES; i++)
{ {
@ -12105,7 +12105,6 @@ static void Cmd_disablelastusedattack(void)
#else #else
gDisableStructs[gBattlerTarget].disableTimer = 4; gDisableStructs[gBattlerTarget].disableTimer = 4;
#endif #endif
gDisableStructs[gBattlerTarget].disableTimerStartValue = gDisableStructs[gBattlerTarget].disableTimer; // used to save the random amount of turns?
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -12140,7 +12139,7 @@ static void Cmd_trysetencore(void)
gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i]; gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].encoredMovePos = i; gDisableStructs[gBattlerTarget].encoredMovePos = i;
gDisableStructs[gBattlerTarget].encoreTimer = 3; gDisableStructs[gBattlerTarget].encoreTimer = 3;
gDisableStructs[gBattlerTarget].encoreTimerStartValue = gDisableStructs[gBattlerTarget].encoreTimer; gDisableStructs[gBattlerTarget].encoreTimer;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -12615,7 +12614,6 @@ static void Cmd_trysetperishsong(void)
{ {
gStatuses3[i] |= STATUS3_PERISH_SONG; gStatuses3[i] |= STATUS3_PERISH_SONG;
gDisableStructs[i].perishSongTimer = 3; gDisableStructs[i].perishSongTimer = 3;
gDisableStructs[i].perishSongTimerStartValue = 3;
} }
} }
@ -13200,7 +13198,6 @@ static void Cmd_setcharge(void)
{ {
gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP; gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP;
gDisableStructs[gBattlerAttacker].chargeTimer = 2; gDisableStructs[gBattlerAttacker].chargeTimer = 2;
gDisableStructs[gBattlerAttacker].chargeTimerStartValue = 2;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
@ -13290,7 +13287,7 @@ static void Cmd_settaunt(void)
u8 turns = 2; u8 turns = 2;
#endif #endif
gDisableStructs[gBattlerTarget].tauntTimer = gDisableStructs[gBattlerTarget].tauntTimer2 = turns; gDisableStructs[gBattlerTarget].tauntTimer = turns;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -15022,7 +15019,7 @@ void BS_JumpIfHoldEffect(void)
{ {
u8 battler = gBattlescriptCurrInstr[5]; u8 battler = gBattlescriptCurrInstr[5];
u16 holdEffect = T1_READ_16(gBattlescriptCurrInstr + 6); u16 holdEffect = T1_READ_16(gBattlescriptCurrInstr + 6);
if (GetBattlerHoldEffect(battler, TRUE) == holdEffect) if (GetBattlerHoldEffect(battler, TRUE) == holdEffect)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 8); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 8);
@ -15070,7 +15067,7 @@ static bool32 CriticalCapture(u32 odds)
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId) bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
{ {
if (gBattleMoves[move].split != SPLIT_STATUS if (gBattleMoves[move].split != SPLIT_STATUS
&& !(sForbiddenMoves[move] & FORBIDDEN_PARENTAL_BOND)) && !(sForbiddenMoves[move] & FORBIDDEN_PARENTAL_BOND))
{ {
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)

View File

@ -3814,7 +3814,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{ {
SetRandomMultiHitCounter(); SetRandomMultiHitCounter();
} }
PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0)
} }
else if (gBattleMoves[gCurrentMove].flags & FLAG_TWO_STRIKES) else if (gBattleMoves[gCurrentMove].flags & FLAG_TWO_STRIKES)
@ -3841,7 +3841,7 @@ u8 AtkCanceller_UnableToUseMove(void)
party = gPlayerParty; party = gPlayerParty;
else else
party = gEnemyParty; party = gEnemyParty;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&party[i], MON_DATA_HP) if (GetMonData(&party[i], MON_DATA_HP)
@ -5487,7 +5487,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD); RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD);
break; break;
} }
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability; gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability; gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility; gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility;
@ -5758,11 +5758,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{ {
gStatuses3[battler] |= STATUS3_PERISH_SONG; gStatuses3[battler] |= STATUS3_PERISH_SONG;
gDisableStructs[battler].perishSongTimer = 3; gDisableStructs[battler].perishSongTimer = 3;
gDisableStructs[battler].perishSongTimerStartValue = 3;
} }
gStatuses3[gBattlerAttacker] |= STATUS3_PERISH_SONG; gStatuses3[gBattlerAttacker] |= STATUS3_PERISH_SONG;
gDisableStructs[gBattlerAttacker].perishSongTimer = 3; gDisableStructs[gBattlerAttacker].perishSongTimer = 3;
gDisableStructs[gBattlerAttacker].perishSongTimerStartValue = 3;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PerishBodyActivates; gBattlescriptCurrInstr = BattleScript_PerishBodyActivates;
effect++; effect++;
@ -6815,7 +6813,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
// Check taunt // Check taunt
if (gDisableStructs[battlerId].tauntTimer != 0) if (gDisableStructs[battlerId].tauntTimer != 0)
{ {
gDisableStructs[battlerId].tauntTimer = gDisableStructs[battlerId].tauntTimer2 = 0; gDisableStructs[battlerId].tauntTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT); PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT);
ret = TRUE; ret = TRUE;
@ -6824,7 +6822,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
if (gDisableStructs[battlerId].encoreTimer != 0) if (gDisableStructs[battlerId].encoreTimer != 0)
{ {
gDisableStructs[battlerId].encoredMove = 0; gDisableStructs[battlerId].encoredMove = 0;
gDisableStructs[battlerId].encoreTimerStartValue = gDisableStructs[battlerId].encoreTimer = 0; gDisableStructs[battlerId].encoreTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_ENCORE; // STRINGID_PKMNENCOREENDED gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_ENCORE; // STRINGID_PKMNENCOREENDED
ret = TRUE; ret = TRUE;
} }
@ -6845,7 +6843,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
// Check disable // Check disable
if (gDisableStructs[battlerId].disableTimer != 0) if (gDisableStructs[battlerId].disableTimer != 0)
{ {
gDisableStructs[battlerId].disableTimer = gDisableStructs[battlerId].disableTimerStartValue = 0; gDisableStructs[battlerId].disableTimer = 0;
gDisableStructs[battlerId].disabledMove = 0; gDisableStructs[battlerId].disabledMove = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE;
ret = TRUE; ret = TRUE;
@ -6858,7 +6856,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
{ {
u8 effect = 0; u8 effect = 0;
u32 i; u32 i;
switch (holdEffect) switch (holdEffect)
{ {
#if B_HP_BERRIES >= GEN_4 #if B_HP_BERRIES >= GEN_4
@ -7027,7 +7025,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
&& !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem)) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
{ {
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY; gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleScripting.battler = battlerId; gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId; gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -7036,7 +7034,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
} }
break; break;
} }
return effect; return effect;
} }
@ -7053,7 +7051,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
gLastUsedItem = gBattleMons[battlerId].item; gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
} }
atkItem = gBattleMons[gBattlerAttacker].item; atkItem = gBattleMons[gBattlerAttacker].item;
atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE); atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker); atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker);
@ -8184,7 +8182,7 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating)
return ItemId_GetHoldEffect(gBattleMons[battlerId].item); return ItemId_GetHoldEffect(gBattleMons[battlerId].item);
} }
// //
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item) static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item)
{ {
if (item == ITEM_ENIGMA_BERRY) if (item == ITEM_ENIGMA_BERRY)
@ -8234,7 +8232,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move)
else if (gProtectStructs[battlerId].protected) else if (gProtectStructs[battlerId].protected)
return FALSE; return FALSE;
} }
if (move == MOVE_TEATIME) if (move == MOVE_TEATIME)
{ {
return FALSE; return FALSE;