Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pointless timers from disable struct #2647

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,15 @@ struct DisableStruct
s8 stockpileBeforeDef;
s8 stockpileBeforeSpDef;
u8 substituteHP;
u8 disableTimer:4;
u8 disableTimerStartValue:4;
u8 encoredMovePos;
u8 disableTimer:4;
u8 encoreTimer:4;
u8 encoreTimerStartValue:4;
u8 perishSongTimer:4;
u8 perishSongTimerStartValue:4;
u8 furyCutterCounter;
u8 rolloutTimer:4;
u8 rolloutTimerStartValue:4;
u8 chargeTimer:4;
u8 chargeTimerStartValue:4;
u8 tauntTimer:4;
u8 tauntTimer2:4;
u8 battlerPreventingEscape;
u8 battlerWithSureHit;
u8 isFirstTurn;
Expand All @@ -99,8 +94,8 @@ struct DisableStruct
u8 healBlockTimer;
u8 laserFocusTimer;
u8 throatChopTimer;
u8 usedMoves:4;
u8 wrapTurns;
u8 usedMoves:4;
u8 noRetreat:1;
u8 tarShot:1;
u8 octolock:1;
Expand Down
1 change: 0 additions & 1 deletion src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3124,7 +3124,6 @@ void SwitchInClearSetData(void)
gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP;
gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit;
gDisableStructs[gActiveBattler].perishSongTimer = disableStructCopy.perishSongTimer;
gDisableStructs[gActiveBattler].perishSongTimerStartValue = disableStructCopy.perishSongTimerStartValue;
gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape;
}

Expand Down
31 changes: 14 additions & 17 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
u32 flags = 0;
u16 battlerAbility;

if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT
&& gBattleMons[gBattlerTarget].hp != 0
&& IsFinalStrikeEffect(gCurrentMove))
{
Expand Down Expand Up @@ -2825,7 +2825,7 @@ void SetMoveEffect(bool32 primary, u32 certain)

// Just in case this flag is still set
gBattleScripting.moveEffect &= ~MOVE_EFFECT_CERTAIN;

if ((battlerAbility == ABILITY_SHIELD_DUST
|| GetBattlerHoldEffect(gEffectBattler, TRUE) == HOLD_EFFECT_COVERT_CLOAK)
&& !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
Expand Down Expand Up @@ -9361,7 +9361,7 @@ static void Cmd_various(void)
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) && CanSleep(gBattlerTarget))
gBattleCommunication[MULTISTRING_CHOOSER] = 4;
else
else
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
return;
Expand Down Expand Up @@ -9864,10 +9864,10 @@ static void Cmd_various(void)
gBattlescriptCurrInstr += 4;
return;
}

if (gBattlescriptCurrInstr[3])
gLastUsedItem = gBattleMons[gActiveBattler].item;

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))
return;
Expand Down Expand Up @@ -10065,15 +10065,15 @@ static void Cmd_various(void)
// Check taunt
if (gDisableStructs[gActiveBattler].tauntTimer != 0)
{
gDisableStructs[gActiveBattler].tauntTimer = gDisableStructs[gActiveBattler].tauntTimer2 = 0;
gDisableStructs[gActiveBattler].tauntTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT);
}
// Check encore
if (gDisableStructs[gActiveBattler].encoreTimer != 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
}
// Check torment
Expand All @@ -10091,7 +10091,7 @@ static void Cmd_various(void)
// Check disable
if (gDisableStructs[gActiveBattler].disableTimer != 0)
{
gDisableStructs[gActiveBattler].disableTimer = gDisableStructs[gActiveBattler].disableTimerStartValue = 0;
gDisableStructs[gActiveBattler].disableTimer = 0;
gDisableStructs[gActiveBattler].disabledMove = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE;
}
Expand Down Expand Up @@ -10970,7 +10970,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
{
RecordItemEffectBattle(gActiveBattler, HOLD_EFFECT_CLEAR_AMULET);
}

if (flags == STAT_CHANGE_ALLOW_PTR)
{
if (gSpecialStatuses[gActiveBattler].statLowered)
Expand Down Expand Up @@ -11897,7 +11897,7 @@ static void Cmd_transformdataexecution(void)

for (i = 0; i < offsetof(struct BattlePokemon, pp); i++)
battleMonAttacker[i] = battleMonTarget[i];

gBattleStruct->overwrittenAbilities[gBattlerAttacker] = GetBattlerAbility(gBattlerTarget);
for (i = 0; i < MAX_MON_MOVES; i++)
{
Expand Down Expand Up @@ -12105,7 +12105,6 @@ static void Cmd_disablelastusedattack(void)
#else
gDisableStructs[gBattlerTarget].disableTimer = 4;
#endif
gDisableStructs[gBattlerTarget].disableTimerStartValue = gDisableStructs[gBattlerTarget].disableTimer; // used to save the random amount of turns?
gBattlescriptCurrInstr += 5;
}
else
Expand Down Expand Up @@ -12140,7 +12139,7 @@ static void Cmd_trysetencore(void)
gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].encoredMovePos = i;
gDisableStructs[gBattlerTarget].encoreTimer = 3;
gDisableStructs[gBattlerTarget].encoreTimerStartValue = gDisableStructs[gBattlerTarget].encoreTimer;
gDisableStructs[gBattlerTarget].encoreTimer;
gBattlescriptCurrInstr += 5;
}
else
Expand Down Expand Up @@ -12615,7 +12614,6 @@ static void Cmd_trysetperishsong(void)
{
gStatuses3[i] |= STATUS3_PERISH_SONG;
gDisableStructs[i].perishSongTimer = 3;
gDisableStructs[i].perishSongTimerStartValue = 3;
}
}

Expand Down Expand Up @@ -13200,7 +13198,6 @@ static void Cmd_setcharge(void)
{
gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP;
gDisableStructs[gBattlerAttacker].chargeTimer = 2;
gDisableStructs[gBattlerAttacker].chargeTimerStartValue = 2;
gBattlescriptCurrInstr++;
}

Expand Down Expand Up @@ -13290,7 +13287,7 @@ static void Cmd_settaunt(void)
u8 turns = 2;
#endif

gDisableStructs[gBattlerTarget].tauntTimer = gDisableStructs[gBattlerTarget].tauntTimer2 = turns;
gDisableStructs[gBattlerTarget].tauntTimer = turns;
gBattlescriptCurrInstr += 5;
}
else
Expand Down Expand Up @@ -15022,7 +15019,7 @@ void BS_JumpIfHoldEffect(void)
{
u8 battler = gBattlescriptCurrInstr[5];
u16 holdEffect = T1_READ_16(gBattlescriptCurrInstr + 6);

if (GetBattlerHoldEffect(battler, TRUE) == holdEffect)
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 8);
Expand Down Expand Up @@ -15070,7 +15067,7 @@ static bool32 CriticalCapture(u32 odds)

bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
{
if (gBattleMoves[move].split != SPLIT_STATUS
if (gBattleMoves[move].split != SPLIT_STATUS
&& !(sForbiddenMoves[move] & FORBIDDEN_PARENTAL_BOND))
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
Expand Down
26 changes: 12 additions & 14 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3814,7 +3814,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{
SetRandomMultiHitCounter();
}

PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0)
}
else if (gBattleMoves[gCurrentMove].flags & FLAG_TWO_STRIKES)
Expand All @@ -3841,7 +3841,7 @@ u8 AtkCanceller_UnableToUseMove(void)
party = gPlayerParty;
else
party = gEnemyParty;

for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&party[i], MON_DATA_HP)
Expand Down Expand Up @@ -5487,7 +5487,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD);
break;
}

gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility;
Expand Down Expand Up @@ -5758,11 +5758,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{
gStatuses3[battler] |= STATUS3_PERISH_SONG;
gDisableStructs[battler].perishSongTimer = 3;
gDisableStructs[battler].perishSongTimerStartValue = 3;
}
gStatuses3[gBattlerAttacker] |= STATUS3_PERISH_SONG;
gDisableStructs[gBattlerAttacker].perishSongTimer = 3;
gDisableStructs[gBattlerAttacker].perishSongTimerStartValue = 3;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PerishBodyActivates;
effect++;
Expand Down Expand Up @@ -6815,7 +6813,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
// Check taunt
if (gDisableStructs[battlerId].tauntTimer != 0)
{
gDisableStructs[battlerId].tauntTimer = gDisableStructs[battlerId].tauntTimer2 = 0;
gDisableStructs[battlerId].tauntTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT);
ret = TRUE;
Expand All @@ -6824,7 +6822,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
if (gDisableStructs[battlerId].encoreTimer != 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
ret = TRUE;
}
Expand All @@ -6845,7 +6843,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
// Check disable
if (gDisableStructs[battlerId].disableTimer != 0)
{
gDisableStructs[battlerId].disableTimer = gDisableStructs[battlerId].disableTimerStartValue = 0;
gDisableStructs[battlerId].disableTimer = 0;
gDisableStructs[battlerId].disabledMove = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE;
ret = TRUE;
Expand All @@ -6858,7 +6856,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
{
u8 effect = 0;
u32 i;

switch (holdEffect)
{
#if B_HP_BERRIES >= GEN_4
Expand Down Expand Up @@ -7027,7 +7025,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
&& !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
{
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
Expand All @@ -7036,7 +7034,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
}
break;
}

return effect;
}

Expand All @@ -7053,7 +7051,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
}

atkItem = gBattleMons[gBattlerAttacker].item;
atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker);
Expand Down Expand Up @@ -8184,7 +8182,7 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating)
return ItemId_GetHoldEffect(gBattleMons[battlerId].item);
}

//
//
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item)
{
if (item == ITEM_ENIGMA_BERRY)
Expand Down Expand Up @@ -8234,7 +8232,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move)
else if (gProtectStructs[battlerId].protected)
return FALSE;
}

if (move == MOVE_TEATIME)
{
return FALSE;
Expand Down