fix gChosenMovePos not being assigned correctly for battle items
thanks griffin <3 Co-Authored-By: Martin Griffin <838573+mrgriffin@users.noreply.github.com>
This commit is contained in:
parent
9f2589e159
commit
a2809acfd1
5 changed files with 12 additions and 9 deletions
|
@ -46,6 +46,7 @@ enum
|
|||
RECORDED_BATTLE_PALACE_ACTION,
|
||||
RECORDED_ITEM_ID,
|
||||
RECORDED_ITEM_TARGET,
|
||||
RECORDED_ITEM_MOVE,
|
||||
};
|
||||
|
||||
extern u32 gRecordedBattleRngSeed;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue