diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 5ca2b979e..49410fd02 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -947,26 +947,26 @@ .byte 0xae .endm - .macro cursetarget param0:req + .macro cursetarget failInstr:req .byte 0xaf - .4byte \param0 + .4byte \failInstr .endm - .macro trysetspikes param0:req + .macro trysetspikes failInstr:req .byte 0xb0 - .4byte \param0 + .4byte \failInstr .endm .macro setforesight .byte 0xb1 .endm - .macro trysetperishsong param0:req + .macro trysetperishsong failInstr:req .byte 0xb2 - .4byte \param0 + .4byte \failInstr .endm - .macro rolloutdamagecalculation + .macro handlerollout .byte 0xb3 .endm @@ -976,12 +976,13 @@ .4byte \ptr .endm - .macro furycuttercalc + .macro handlefurycutter .byte 0xb5 .endm - .macro friendshiptodamagecalculation + .macro setembargo failInstr:req .byte 0xb6 + .4byte \failInstr .endm .macro presentdamagecalculation @@ -996,9 +997,9 @@ .byte 0xb9 .endm - .macro jumpifnopursuitswitchdmg param0:req + .macro jumpifnopursuitswitchdmg jumpInstr:req .byte 0xba - .4byte \param0 + .4byte \jumpInstr .endm .macro setsunny diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 1728dbd2d..c90f0c5fc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1330,7 +1330,7 @@ BattleScript_EffectFuryCutter:: ppreduce accuracycheck BattleScript_FuryCutterHit, ACC_CURR_MOVE BattleScript_FuryCutterHit:: - furycuttercalc + handlefurycutter critcalc damagecalc typecalc @@ -1350,13 +1350,6 @@ BattleScript_EffectAttract:: waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd -BattleScript_EffectReturn:: -BattleScript_EffectFrustration:: - attackcanceler - accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - friendshiptodamagecalculation - goto BattleScript_HitFromAtkString - BattleScript_EffectPresent:: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE @@ -6388,3 +6381,15 @@ BattleScript_NotAffectedAbilityPopUp:: waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd +BattleScript_EffectRollout:: + attackcanceler + attackstring + jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_RolloutCheckAccuracy + ppreduce +BattleScript_RolloutCheckAccuracy:: + accuracycheck BattleScript_RolloutHit, ACC_CURR_MOVE +BattleScript_RolloutHit:: + typecalc + handlerollout + goto BattleScript_HitFromCritCalc + diff --git a/include/battle_scripts.h b/include/battle_scripts.h index a8fda9b16..5985f0b0e 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -334,7 +334,6 @@ extern const u8 BattleScript_EffectSketch[]; extern const u8 BattleScript_EffectHit[]; extern const u8 BattleScript_EffectSleepTalk[]; extern const u8 BattleScript_EffectDestinyBond[]; -extern const u8 BattleScript_EffectFlail[]; extern const u8 BattleScript_EffectSpite[]; extern const u8 BattleScript_EffectHit[]; extern const u8 BattleScript_EffectHealBell[]; diff --git a/include/battle_util.h b/include/battle_util.h index 46434745b..2c3d69b8b 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -119,9 +119,7 @@ enum u8 GetBattlerForBattleScript(u8 caseId); -void PressurePPLose(u8 target, u8 attacker, u16 move); void PressurePPLoseOnUsingImprison(u8 attacker); -void PressurePPLoseOnUsingPerishSong(u8 attacker); void MarkBattlerForControllerExec(u8 battlerId); void MarkBattlerReceivedLinkData(u8 battlerId); const u8* CancelMultiTurnMoves(u32 battler); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3d5308bf1..547512c8c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -520,10 +520,10 @@ static void Cmd_cursetarget(void); static void Cmd_trysetspikes(void); static void Cmd_setforesight(void); static void Cmd_trysetperishsong(void); -static void Cmd_rolloutdamagecalculation(void); +static void Cmd_handlerollout(void); static void Cmd_jumpifconfusedandstatmaxed(void); -static void Cmd_furycuttercalc(void); -static void Cmd_friendshiptodamagecalculation(void); +static void Cmd_handlefurycutter(void); +static void Cmd_setembargo(void); static void Cmd_presentdamagecalculation(void); static void Cmd_setsafeguard(void); static void Cmd_magnitudedamagecalculation(void); @@ -767,20 +767,20 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_trysetdestinybondtohappen, //0xAB // done Cmd_settailwind, //0xAC // done Cmd_tryspiteppreduce, //0xAD // done - Cmd_healpartystatus, //0xAE - Cmd_cursetarget, //0xAF - Cmd_trysetspikes, //0xB0 - Cmd_setforesight, //0xB1 - Cmd_trysetperishsong, //0xB2 - Cmd_rolloutdamagecalculation, //0xB3 - Cmd_jumpifconfusedandstatmaxed, //0xB4 - Cmd_furycuttercalc, //0xB5 - Cmd_friendshiptodamagecalculation, //0xB6 - Cmd_presentdamagecalculation, //0xB7 - Cmd_setsafeguard, //0xB8 - Cmd_magnitudedamagecalculation, //0xB9 - Cmd_jumpifnopursuitswitchdmg, //0xBA - Cmd_setsunny, //0xBB + Cmd_healpartystatus, //0xAE // done + Cmd_cursetarget, //0xAF // done + Cmd_trysetspikes, //0xB0 // done + Cmd_setforesight, //0xB1 // done + Cmd_trysetperishsong, //0xB2 // done + Cmd_handlerollout, //0xB3 // done + Cmd_jumpifconfusedandstatmaxed, //0xB4 // done + Cmd_handlefurycutter, //0xB5 // done + Cmd_setembargo, //0xB6 // done + Cmd_presentdamagecalculation, //0xB7 // done + Cmd_setsafeguard, //0xB8 // done + Cmd_magnitudedamagecalculation, //0xB9 // done + Cmd_jumpifnopursuitswitchdmg, //0xBA // done + Cmd_setsunny, //0xBB // done Cmd_maxattackhalvehp, //0xBC Cmd_copyfoestats, //0xBD Cmd_rapidspinfree, //0xBE @@ -13435,22 +13435,20 @@ static void Cmd_tryspiteppreduce(void) static void Cmd_healpartystatus(void) { + CMD_ARGS(); + u32 zero = 0; + u32 battler; u8 toHeal = 0; if (gCurrentMove == MOVE_HEAL_BELL) { - struct Pokemon *party; + struct Pokemon *party = GetBattlerParty(gBattlerAttacker); s32 i; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BELL; - if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) - party = gPlayerParty; - else - party = gEnemyParty; - - if (gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF) + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SOUNDPROOF) { gBattleMons[gBattlerAttacker].status1 = 0; gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; @@ -13461,19 +13459,19 @@ static void Cmd_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] |= B_MSG_BELL_SOUNDPROOF_ATTACKER; } - gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); + battler = gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) + && !(gAbsentBattlerFlags & gBitTable[battler])) { - if (gBattleMons[gActiveBattler].ability != ABILITY_SOUNDPROOF) + if (GetBattlerAbility(battler) != ABILITY_SOUNDPROOF) { - gBattleMons[gActiveBattler].status1 = 0; - gBattleMons[gActiveBattler].status2 &= ~STATUS2_NIGHTMARE; + gBattleMons[battler].status1 = 0; + gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE; } else { - RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); + RecordAbilityBattle(battler, gBattleMons[battler].ability); gBattleCommunication[MULTISTRING_CHOOSER] |= B_MSG_BELL_SOUNDPROOF_PARTNER; } } @@ -13490,11 +13488,11 @@ static void Cmd_healpartystatus(void) u16 ability; if (gBattlerPartyIndexes[gBattlerAttacker] == i) - ability = gBattleMons[gBattlerAttacker].ability; + ability = GetBattlerAbility(gBattlerAttacker); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && gBattlerPartyIndexes[gActiveBattler] == i - && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) - ability = gBattleMons[gActiveBattler].ability; + && gBattlerPartyIndexes[battler] == i + && !(gAbsentBattlerFlags & gBitTable[battler])) + ability = GetBattlerAbility(battler); else ability = GetAbilityBySpecies(species, abilityNum); @@ -13511,75 +13509,84 @@ static void Cmd_healpartystatus(void) gBattleMons[gBattlerAttacker].status1 = 0; gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; - gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); + battler = gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) + && !(gAbsentBattlerFlags & gBitTable[battler])) { - gBattleMons[gActiveBattler].status1 = 0; - gBattleMons[gActiveBattler].status2 &= ~STATUS2_NIGHTMARE; + gBattleMons[battler].status1 = 0; + gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE; } } if (toHeal) { - gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, toHeal, sizeof(zero), &zero); - MarkBattlerForControllerExec(gActiveBattler); + MarkBattlerForControllerExec(gBattlerAttacker); } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_cursetarget(void) { + CMD_ARGS(const u8 *failInstr); + if (gBattleMons[gBattlerTarget].status2 & STATUS2_CURSED) { - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = cmd->failInstr; } else { gBattleMons[gBattlerTarget].status2 |= STATUS2_CURSED; + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 2; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } } static void Cmd_trysetspikes(void) { - u8 targetSide = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; + CMD_ARGS(const u8 *failInstr); + + u8 targetSide = BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker)); if (gSideTimers[targetSide].spikesAmount == 3) { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = cmd->failInstr; } else { gSideStatuses[targetSide] |= SIDE_STATUS_SPIKES; gSideTimers[targetSide].spikesAmount++; - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } } static void Cmd_setforesight(void) { + CMD_ARGS(); + gBattleMons[gBattlerTarget].status2 |= STATUS2_FORESIGHT; - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_trysetperishsong(void) { + CMD_ARGS(const u8 *failInstr); + s32 i; s32 notAffectedCount = 0; for (i = 0; i < gBattlersCount; i++) { if (gStatuses3[i] & STATUS3_PERISH_SONG - || gBattleMons[i].ability == ABILITY_SOUNDPROOF) + || GetBattlerAbility(i) == ABILITY_SOUNDPROOF + || BlocksPrankster(gCurrentMove, gBattlerAttacker, i, TRUE)) { notAffectedCount++; } @@ -13587,20 +13594,19 @@ static void Cmd_trysetperishsong(void) { gStatuses3[i] |= STATUS3_PERISH_SONG; gDisableStructs[i].perishSongTimer = 3; - // gDisableStructs[i].perishSongTimerStartValue = 3; } } - PressurePPLoseOnUsingPerishSong(gBattlerAttacker); - if (notAffectedCount == gBattlersCount) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = cmd->failInstr; else - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } -static void Cmd_rolloutdamagecalculation(void) +static void Cmd_handlerollout(void) { + CMD_ARGS(); + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { CancelMultiTurnMoves(gBattlerAttacker); @@ -13608,43 +13614,37 @@ static void Cmd_rolloutdamagecalculation(void) } else { - s32 i; - - if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit + if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) // First hit. { gDisableStructs[gBattlerAttacker].rolloutTimer = 5; gDisableStructs[gBattlerAttacker].rolloutTimerStartValue = 5; gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gBattlerAttacker] = gCurrentMove; } - if (--gDisableStructs[gBattlerAttacker].rolloutTimer == 0) // last hit + if (--gDisableStructs[gBattlerAttacker].rolloutTimer == 0) // Last hit. { gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_MULTIPLETURNS; } - gDynamicBasePower = gMovesInfo[gCurrentMove].power; - - for (i = 1; i < (5 - gDisableStructs[gBattlerAttacker].rolloutTimer); i++) - gDynamicBasePower *= 2; - - if (gBattleMons[gBattlerAttacker].status2 & STATUS2_DEFENSE_CURL) - gDynamicBasePower *= 2; - - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } } static void Cmd_jumpifconfusedandstatmaxed(void) { + CMD_ARGS(u8 stat, const u8 *jumpInstr); + if (gBattleMons[gBattlerTarget].status2 & STATUS2_CONFUSION - && gBattleMons[gBattlerTarget].statStages[gBattlescriptCurrInstr[1]] == MAX_STAT_STAGE) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); + && !CompareStat(gBattlerTarget, cmd->stat, MAX_STAT_STAGE, CMP_LESS_THAN)) + gBattlescriptCurrInstr = cmd->jumpInstr; // Fails if we're confused AND stat cannot be raised else - gBattlescriptCurrInstr += 6; + gBattlescriptCurrInstr = cmd->nextInstr; } -static void Cmd_furycuttercalc(void) +static void Cmd_handlefurycutter(void) { + CMD_ARGS(); + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gDisableStructs[gBattlerAttacker].furyCutterCounter = 0; @@ -13652,51 +13652,76 @@ static void Cmd_furycuttercalc(void) } else { - s32 i; - - if (gDisableStructs[gBattlerAttacker].furyCutterCounter != 5) + if (gDisableStructs[gBattlerAttacker].furyCutterCounter != 5 + && gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT) // Don't increment counter on first hit gDisableStructs[gBattlerAttacker].furyCutterCounter++; - gDynamicBasePower = gMovesInfo[gCurrentMove].power; - - for (i = 1; i < gDisableStructs[gBattlerAttacker].furyCutterCounter; i++) - gDynamicBasePower *= 2; - - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } } -static void Cmd_friendshiptodamagecalculation(void) +static void Cmd_setembargo(void) { - if (gMovesInfo[gCurrentMove].effect == EFFECT_RETURN) - gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25; - else // EFFECT_FRUSTRATION - gDynamicBasePower = 10 * (255 - gBattleMons[gBattlerAttacker].friendship) / 25; + CMD_ARGS(const u8 *failInstr); - gBattlescriptCurrInstr++; + if (gStatuses3[gBattlerTarget] & STATUS3_EMBARGO) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else + { + gStatuses3[gBattlerTarget] |= STATUS3_EMBARGO; + gDisableStructs[gBattlerTarget].embargoTimer = 5; + gBattlescriptCurrInstr = cmd->nextInstr; + } } static void Cmd_presentdamagecalculation(void) { - s32 rand = Random() & 0xFF; + CMD_ARGS(); - if (rand < 102) - gDynamicBasePower = 40; - else if (rand < 178) - gDynamicBasePower = 80; - else if (rand < 204) - gDynamicBasePower = 120; - else + u32 rand = Random() & 0xFF; + + /* Don't reroll present effect/power for the second hit of Parental Bond. + * Not sure if this is the correct behaviour, but bulbapedia states + * that if present heals the foe, it doesn't strike twice, and if it deals + * damage, the second strike will always deal damage too. This is a simple way + * to replicate that effect. + */ + if (gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_2ND_HIT) { - gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - gBattleMoveDamage *= -1; + if (rand < 102) + { + gBattleStruct->presentBasePower = 40; + } + else if (rand < 178) + { + gBattleStruct->presentBasePower = 80; + } + else if (rand < 204) + { + gBattleStruct->presentBasePower = 120; + } + else + { + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerTarget) / 4; + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + gBattleStruct->presentBasePower = 0; + } } - if (rand < 204) + + if (gBattleStruct->presentBasePower) + { gBattlescriptCurrInstr = BattleScript_HitFromCritCalc; + } else if (gBattleMons[gBattlerTarget].maxHP == gBattleMons[gBattlerTarget].hp) + { gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; + } else { gMoveResultFlags &= ~MOVE_RESULT_DOESNT_AFFECT_FOE; @@ -13706,59 +13731,63 @@ static void Cmd_presentdamagecalculation(void) static void Cmd_setsafeguard(void) { - if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) + CMD_ARGS(); + + if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SIDE_STATUS_FAILED; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_SAFEGUARD; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardBattlerId = gBattlerAttacker; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_SAFEGUARD; + gSideTimers[GetBattlerSide(gBattlerAttacker)].safeguardTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].safeguardBattlerId = gBattlerAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_SAFEGUARD; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_magnitudedamagecalculation(void) { - s32 magnitude = Random() % 100; + CMD_ARGS(); + + u32 magnitude = Random() % 100; if (magnitude < 5) { - gDynamicBasePower = 10; + gBattleStruct->magnitudeBasePower = 10; magnitude = 4; } else if (magnitude < 15) { - gDynamicBasePower = 30; + gBattleStruct->magnitudeBasePower = 30; magnitude = 5; } else if (magnitude < 35) { - gDynamicBasePower = 50; + gBattleStruct->magnitudeBasePower = 50; magnitude = 6; } else if (magnitude < 65) { - gDynamicBasePower = 70; + gBattleStruct->magnitudeBasePower = 70; magnitude = 7; } else if (magnitude < 85) { - gDynamicBasePower = 90; + gBattleStruct->magnitudeBasePower = 90; magnitude = 8; } else if (magnitude < 95) { - gDynamicBasePower = 110; + gBattleStruct->magnitudeBasePower = 110; magnitude = 9; } else { - gDynamicBasePower = 150; + gBattleStruct->magnitudeBasePower = 150; magnitude = 10; } @@ -13768,15 +13797,17 @@ static void Cmd_magnitudedamagecalculation(void) { if (gBattlerTarget == gBattlerAttacker) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // a valid target was found + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // A valid target was found. break; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_jumpifnopursuitswitchdmg(void) { + CMD_ARGS(const u8 *jumpInstr); + if (gMultiHitCounter == 1) { if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) @@ -13797,7 +13828,7 @@ static void Cmd_jumpifnopursuitswitchdmg(void) && !(gBattleMons[gBattlerTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) && gBattleMons[gBattlerAttacker].hp && !gDisableStructs[gBattlerTarget].truantCounter - && gChosenMoveByBattler[gBattlerTarget] == MOVE_PURSUIT) + && gMovesInfo[gChosenMoveByBattler[gBattlerTarget]].effect == EFFECT_PURSUIT) { s32 i; @@ -13807,33 +13838,33 @@ static void Cmd_jumpifnopursuitswitchdmg(void) gActionsByTurnOrder[i] = B_ACTION_TRY_FINISH; } - gCurrentMove = MOVE_PURSUIT; + gCurrentMove = gChosenMoveByBattler[gBattlerTarget]; gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerTarget); - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; gBattleScripting.animTurn = 1; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; } else { - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = cmd->jumpInstr; } } static void Cmd_setsunny(void) { - if (gBattleWeather & B_WEATHER_SUN) + CMD_ARGS(); + + if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_SUN, FALSE)) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED; } else { - gBattleWeather = B_WEATHER_SUN_TEMPORARY; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SUNLIGHT; - gWishFutureKnock.weatherDuration = 5; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } // Belly Drum diff --git a/src/battle_util.c b/src/battle_util.c index 9e65bcb29..69d6ee0c9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -112,33 +112,6 @@ u8 GetBattlerForBattleScript(u8 caseId) return ret; } -void PressurePPLose(u8 target, u8 attacker, u16 move) -{ - int moveIndex; - - if (gBattleMons[target].ability != ABILITY_PRESSURE) - return; - - for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) - { - if (gBattleMons[attacker].moves[moveIndex] == move) - break; - } - - if (moveIndex == MAX_MON_MOVES) - return; - - if (gBattleMons[attacker].pp[moveIndex] != 0) - gBattleMons[attacker].pp[moveIndex]--; - - if (MOVE_IS_PERMANENT(attacker, moveIndex)) - { - gActiveBattler = attacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + moveIndex, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); - MarkBattlerForControllerExec(gActiveBattler); - } -} - void PressurePPLoseOnUsingImprison(u8 attacker) { int i, j; @@ -171,54 +144,6 @@ void PressurePPLoseOnUsingImprison(u8 attacker) } } -void PressurePPLoseOnUsingPerishSong(u8 attacker) -{ - int i, j; - int perishSongPos = MAX_MON_MOVES; - - for (i = 0; i < gBattlersCount; i++) - { - if (gBattleMons[i].ability == ABILITY_PRESSURE && i != attacker) - { - for (j = 0; j < MAX_MON_MOVES; j++) - { - if (gBattleMons[attacker].moves[j] == MOVE_PERISH_SONG) - break; - } - if (j != MAX_MON_MOVES) - { - perishSongPos = j; - if (gBattleMons[attacker].pp[j] != 0) - gBattleMons[attacker].pp[j]--; - } - } - } - - if (perishSongPos != MAX_MON_MOVES && MOVE_IS_PERMANENT(attacker, perishSongPos)) - { - gActiveBattler = attacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBattler].pp[perishSongPos]); - MarkBattlerForControllerExec(gActiveBattler); - } -} - -// Unused -static void MarkAllBattlersForControllerExec(void) -{ - int i; - - if (gBattleTypeFlags & BATTLE_TYPE_LINK) - { - for (i = 0; i < gBattlersCount; i++) - gBattleControllerExecFlags |= gBitTable[i] << (32 - MAX_BATTLERS_COUNT); - } - else - { - for (i = 0; i < gBattlersCount; i++) - gBattleControllerExecFlags |= gBitTable[i]; - } -} - void MarkBattlerForControllerExec(u8 battlerId) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) diff --git a/src/data/battle_move_effects.h b/src/data/battle_move_effects.h index 963ced6c5..ca8711333 100644 --- a/src/data/battle_move_effects.h +++ b/src/data/battle_move_effects.h @@ -518,7 +518,7 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_ROLLOUT] = { - .battleScript = BattleScript_EffectHit, + .battleScript = BattleScript_EffectRollout, }, [EFFECT_SWAGGER] =