diff --git a/include/battle.h b/include/battle.h index 110c252bce..79413441c8 100644 --- a/include/battle.h +++ b/include/battle.h @@ -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; @@ -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; diff --git a/src/battle_main.c b/src/battle_main.c index f316846c61..90540fa922 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -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; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ccec3f6a64..478608cd84 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -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)) { @@ -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) @@ -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; @@ -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; @@ -10065,7 +10065,7 @@ 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); } @@ -10073,7 +10073,7 @@ static void Cmd_various(void) 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 @@ -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; } @@ -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) @@ -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++) { @@ -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 @@ -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 @@ -12615,7 +12614,6 @@ static void Cmd_trysetperishsong(void) { gStatuses3[i] |= STATUS3_PERISH_SONG; gDisableStructs[i].perishSongTimer = 3; - gDisableStructs[i].perishSongTimerStartValue = 3; } } @@ -13200,7 +13198,6 @@ static void Cmd_setcharge(void) { gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP; gDisableStructs[gBattlerAttacker].chargeTimer = 2; - gDisableStructs[gBattlerAttacker].chargeTimerStartValue = 2; gBattlescriptCurrInstr++; } @@ -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 @@ -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); @@ -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) diff --git a/src/battle_util.c b/src/battle_util.c index 4333d0b44f..2bbd2f530f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -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) @@ -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) @@ -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; @@ -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++; @@ -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; @@ -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; } @@ -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; @@ -6858,7 +6856,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) { u8 effect = 0; u32 i; - + switch (holdEffect) { #if B_HP_BERRIES >= GEN_4 @@ -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(); @@ -7036,7 +7034,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) } break; } - + return effect; } @@ -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); @@ -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) @@ -8234,7 +8232,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) else if (gProtectStructs[battlerId].protected) return FALSE; } - + if (move == MOVE_TEATIME) { return FALSE;