diff --git a/include/recorded_battle.h b/include/recorded_battle.h index ea66096d7f..02bbe8fc3f 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -46,6 +46,7 @@ enum RECORDED_BATTLE_PALACE_ACTION, RECORDED_ITEM_ID, RECORDED_ITEM_TARGET, + RECORDED_ITEM_MOVE, }; extern u32 gRecordedBattleRngSeed; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index bb41b42d65..8255abcab0 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -1442,6 +1442,7 @@ static void RecordedOpponentHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); + gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index efbd60f18b..8350e8594e 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -1466,6 +1466,7 @@ static void RecordedPlayerHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); + gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 07669635e3..31ef4cea75 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16563,8 +16563,7 @@ void BS_ItemIncreaseStat(void) { void BS_ItemRestorePP(void) { NATIVE_ARGS(); const u8 *effect = GetItemEffect(gLastUsedItem); - u32 i, pp, maxPP, moveId; - u32 loopEnd = MAX_MON_MOVES; + u32 i, pp, maxPP, moveId, loopEnd; u32 battlerId = MAX_BATTLERS_COUNT; struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]]; @@ -16574,6 +16573,11 @@ void BS_ItemRestorePP(void) { i = gChosenMovePos; loopEnd = gChosenMovePos + 1; } + else + { + i = 0; + loopEnd = MAX_MON_MOVES; + } // Check if the recipient is an active battler. if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) @@ -16583,7 +16587,7 @@ void BS_ItemRestorePP(void) { battlerId = BATTLE_PARTNER(gBattlerAttacker); // Heal PP! - for (i = 0; i < loopEnd; i++) + for (; i < loopEnd; i++) { pp = GetMonData(mon, MON_DATA_PP1 + i, NULL); moveId = GetMonData(mon, MON_DATA_MOVE1 + i, NULL); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 75e459e49b..f102912620 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1554,12 +1554,8 @@ void UseItem(u32 sourceLine, struct BattlePokemon *battler, struct ItemContext c PushBattlerAction(sourceLine, battlerId, RECORDED_ACTION_TYPE, B_ACTION_USE_ITEM); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF); - if (ctx.explicitPartyIndex) - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex); - else if (ctx.explicitMove) - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, i); - else - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, 0); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_MOVE, i); DATA.actionBattlers |= 1 << battlerId; }