diff options
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r-- | src/battle_script_commands.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3b77df294..690b26d49 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3518,7 +3518,7 @@ static void Cmd_unknown_24(void) if (HP_count == 0) gBattleOutcome |= B_OUTCOME_LOST; - + HP_count = 0; for (i = 0; i < PARTY_SIZE; i++) @@ -3535,14 +3535,17 @@ static void Cmd_unknown_24(void) if (gBattleOutcome == 0 && (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) { - s32 foundPlayer = 0, foundOpponent; + s32 foundPlayer = 0; + s32 foundOpponent; + for (i = 0; i < gBattlersCount; i += 2) { if ((gHitMarker & HITMARKER_FAINTED2(i)) && (!gSpecialStatuses[i].flag40)) foundPlayer++; } - + foundOpponent = 0; + for (i = 1; i < gBattlersCount; i += 2) { if ((gHitMarker & HITMARKER_FAINTED2(i)) && (!gSpecialStatuses[i].flag40)) @@ -3552,14 +3555,14 @@ static void Cmd_unknown_24(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { if (foundOpponent + foundPlayer > 1) - gBattlescriptCurrInstr = (u8*) T2_READ_32(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; } else { if (foundOpponent != 0 && foundPlayer != 0) - gBattlescriptCurrInstr = (u8*) T2_READ_32(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; } @@ -4660,10 +4663,8 @@ static void Cmd_jumpifcantswitch(void) || (gStatuses3[gActiveBattler] & STATUS3_ROOTED))) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); - return; } - - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { #ifndef NONMATCHING asm("":::"r5"); @@ -5361,21 +5362,21 @@ static void Cmd_yesnoboxlearnmove(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (JOY_NEW(A_BUTTON)) + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); if (gBattleCommunication[1] == 0) @@ -5389,7 +5390,7 @@ static void Cmd_yesnoboxlearnmove(void) gBattleScripting.learnMoveState = 5; } } - else if (JOY_NEW(B_BUTTON)) + else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); gBattleScripting.learnMoveState = 5; @@ -5478,21 +5479,21 @@ static void Cmd_yesnoboxstoplearningmove(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (JOY_NEW(A_BUTTON)) + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -5503,7 +5504,7 @@ static void Cmd_yesnoboxstoplearningmove(void) HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR); } - else if (JOY_NEW(B_BUTTON)) + else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -5536,8 +5537,8 @@ static void Cmd_hitanimation(void) static u32 GetTrainerMoneyToGive(u16 trainerId) { u32 i = 0; + u32 lastMonLevel = 0; u32 moneyReward; - u8 lastMonLevel = 0; if (trainerId == TRAINER_SECRET_BASE) { @@ -5773,28 +5774,28 @@ static void Cmd_yesnobox(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (JOY_NEW(B_BUTTON)) + if (gMain.newKeys & B_BUTTON) { gBattleCommunication[CURSOR_POSITION] = 1; PlaySE(SE_SELECT); HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); gBattlescriptCurrInstr++; } - else if (JOY_NEW(A_BUTTON)) + else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); @@ -6037,7 +6038,7 @@ static void PutLevelAndGenderOnLvlUpBox(void) printerTemplate.currentY = 0; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.style = 0; + printerTemplate.unk = 0; printerTemplate.fgColor = TEXT_COLOR_WHITE; printerTemplate.bgColor = TEXT_COLOR_TRANSPARENT; printerTemplate.shadowColor = TEXT_COLOR_DARK_GREY; @@ -7128,6 +7129,7 @@ static void Cmd_forcerandomswitch(void) s32 i; s32 battler1PartyId = 0; s32 battler2PartyId = 0; + s32 firstMonId; s32 lastMonId = 0; // + 1 s32 monsCount; @@ -7249,10 +7251,11 @@ static void Cmd_forcerandomswitch(void) { i = Random() % monsCount; i += firstMonId; - } while (i == battler2PartyId || i == battler1PartyId); + } + while (i == battler2PartyId || i == battler1PartyId); } while (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE - || GetMonData(&party[i], MON_DATA_HP) == 0); // Should be one while loop, conjoined by an ||, but that doesn't match. Equivalent logic though + || GetMonData(&party[i], MON_DATA_HP) == 0); //should be one while loop, but that doesn't match. } *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i; @@ -10071,21 +10074,21 @@ static void Cmd_trygivecaughtmonnick(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (JOY_NEW(A_BUTTON)) + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); if (gBattleCommunication[CURSOR_POSITION] == 0) @@ -10098,7 +10101,7 @@ static void Cmd_trygivecaughtmonnick(void) gBattleCommunication[MULTIUSE_STATE] = 4; } } - else if (JOY_NEW(B_BUTTON)) + else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); gBattleCommunication[MULTIUSE_STATE] = 4; |