mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 15:13:42 +01:00
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
@ -46,6 +46,7 @@ enum
|
|||||||
RECORDED_BATTLE_PALACE_ACTION,
|
RECORDED_BATTLE_PALACE_ACTION,
|
||||||
RECORDED_ITEM_ID,
|
RECORDED_ITEM_ID,
|
||||||
RECORDED_ITEM_TARGET,
|
RECORDED_ITEM_TARGET,
|
||||||
|
RECORDED_ITEM_MOVE,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern u32 gRecordedBattleRngSeed;
|
extern u32 gRecordedBattleRngSeed;
|
||||||
|
@ -1442,6 +1442,7 @@ static void RecordedOpponentHandleChooseItem(void)
|
|||||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||||
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
||||||
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
||||||
|
gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler);
|
||||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
||||||
RecordedOpponentBufferExecCompleted();
|
RecordedOpponentBufferExecCompleted();
|
||||||
}
|
}
|
||||||
|
@ -1466,6 +1466,7 @@ static void RecordedPlayerHandleChooseItem(void)
|
|||||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||||
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
||||||
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
||||||
|
gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler);
|
||||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
||||||
RecordedPlayerBufferExecCompleted();
|
RecordedPlayerBufferExecCompleted();
|
||||||
}
|
}
|
||||||
|
@ -16563,8 +16563,7 @@ void BS_ItemIncreaseStat(void) {
|
|||||||
void BS_ItemRestorePP(void) {
|
void BS_ItemRestorePP(void) {
|
||||||
NATIVE_ARGS();
|
NATIVE_ARGS();
|
||||||
const u8 *effect = GetItemEffect(gLastUsedItem);
|
const u8 *effect = GetItemEffect(gLastUsedItem);
|
||||||
u32 i, pp, maxPP, moveId;
|
u32 i, pp, maxPP, moveId, loopEnd;
|
||||||
u32 loopEnd = MAX_MON_MOVES;
|
|
||||||
u32 battlerId = MAX_BATTLERS_COUNT;
|
u32 battlerId = MAX_BATTLERS_COUNT;
|
||||||
struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]];
|
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;
|
i = gChosenMovePos;
|
||||||
loopEnd = gChosenMovePos + 1;
|
loopEnd = gChosenMovePos + 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
loopEnd = MAX_MON_MOVES;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the recipient is an active battler.
|
// Check if the recipient is an active battler.
|
||||||
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
|
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
|
||||||
@ -16583,7 +16587,7 @@ void BS_ItemRestorePP(void) {
|
|||||||
battlerId = BATTLE_PARTNER(gBattlerAttacker);
|
battlerId = BATTLE_PARTNER(gBattlerAttacker);
|
||||||
|
|
||||||
// Heal PP!
|
// Heal PP!
|
||||||
for (i = 0; i < loopEnd; i++)
|
for (; i < loopEnd; i++)
|
||||||
{
|
{
|
||||||
pp = GetMonData(mon, MON_DATA_PP1 + i, NULL);
|
pp = GetMonData(mon, MON_DATA_PP1 + i, NULL);
|
||||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + 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_ACTION_TYPE, B_ACTION_USE_ITEM);
|
||||||
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF);
|
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF);
|
||||||
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF);
|
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF);
|
||||||
if (ctx.explicitPartyIndex)
|
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex);
|
||||||
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex);
|
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_MOVE, i);
|
||||||
else if (ctx.explicitMove)
|
|
||||||
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, i);
|
|
||||||
else
|
|
||||||
PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, 0);
|
|
||||||
DATA.actionBattlers |= 1 << battlerId;
|
DATA.actionBattlers |= 1 << battlerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user