From be0c2fe53556c19f863dc295e6c3b9ed27e1741e Mon Sep 17 00:00:00 2001 From: cawtds Date: Thu, 2 May 2024 00:51:52 +0200 Subject: [PATCH] updated up to Cmd_jumpifnotfirstturn --- src/battle_script_commands.c | 55 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 23ef31c8b..086fef103 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -719,11 +719,11 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_tryhealhalfhealth, //0x7B // done Cmd_trymirrormove, //0x7C // done Cmd_setrain, //0x7D // done - Cmd_setreflect, //0x7E - Cmd_setseeded, //0x7F + Cmd_setreflect, //0x7E // done + Cmd_setseeded, //0x7F // done Cmd_manipulatedamage, //0x80 // done - Cmd_trysetrest, //0x81 - Cmd_jumpifnotfirstturn, //0x82 + Cmd_trysetrest, //0x81 // done + Cmd_jumpifnotfirstturn, //0x82 // done Cmd_nop, //0x83 Cmd_jumpifcantmakeasleep, //0x84 Cmd_stockpile, //0x85 @@ -11380,27 +11380,34 @@ static void Cmd_setrain(void) static void Cmd_setreflect(void) { - if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_REFLECT) + CMD_ARGS(); + + if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_REFLECT) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SIDE_STATUS_FAILED; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_REFLECT; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectBattlerId = gBattlerAttacker; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_REFLECT; + if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIGHT_CLAY) + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectTimer = 8; + else + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectBattlerId = gBattlerAttacker; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_SIDE, gBattlerAttacker) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_REFLECT_DOUBLE; else gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_REFLECT_SINGLE; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_setseeded(void) { + CMD_ARGS(); + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBattlerTarget] & STATUS3_LEECHSEED) { gMoveResultFlags |= MOVE_RESULT_MISSED; @@ -11418,7 +11425,7 @@ static void Cmd_setseeded(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_LEECH_SEED_SET; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_manipulatedamage(void) @@ -11493,13 +11500,23 @@ static void Cmd_manipulatedamage(void) static void Cmd_trysetrest(void) { - const u8 *failJump = T1_READ_PTR(gBattlescriptCurrInstr + 1); + CMD_ARGS(const u8 *failInstr); + + const u8 *failInstr = cmd->failInstr; gActiveBattler = gBattlerTarget = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP * (-1); if (gBattleMons[gBattlerTarget].hp == gBattleMons[gBattlerTarget].maxHP) { - gBattlescriptCurrInstr = failJump; + gBattlescriptCurrInstr = failInstr; + } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_ELECTRIC_TERRAIN)) + { + gBattlescriptCurrInstr = BattleScript_ElectricTerrainPrevents; + } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_MISTY_TERRAIN)) + { + gBattlescriptCurrInstr = BattleScript_MistyTerrainPrevents; } else { @@ -11509,20 +11526,22 @@ static void Cmd_trysetrest(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_REST; gBattleMons[gBattlerTarget].status1 = STATUS1_SLEEP_TURN(3); - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); - MarkBattlerForControllerExec(gActiveBattler); - gBattlescriptCurrInstr += 5; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].status1), &gBattleMons[gBattlerTarget].status1); + MarkBattlerForControllerExec(gBattlerTarget); + gBattlescriptCurrInstr = cmd->nextInstr; } } static void Cmd_jumpifnotfirstturn(void) { - const u8 *failJump = T1_READ_PTR(gBattlescriptCurrInstr + 1); + CMD_ARGS(const u8 *jumpInstr); + + const u8 *jumpInstr = cmd->jumpInstr; if (gDisableStructs[gBattlerAttacker].isFirstTurn) - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; else - gBattlescriptCurrInstr = failJump; + gBattlescriptCurrInstr = jumpInstr; } static void Cmd_nop(void)