Refactor GF's idiotic coding
This commit is contained in:
parent
88b788bfab
commit
abd518b668
4 changed files with 70 additions and 187 deletions
|
@ -481,12 +481,10 @@ struct BattleStruct
|
|||
{
|
||||
u8 turnEffectsTracker;
|
||||
u8 turnEffectsBattlerId;
|
||||
u8 unused_0;
|
||||
u8 turnCountersTracker;
|
||||
u8 wrappedMove[MAX_BATTLERS_COUNT * 2]; // Leftover from Ruby's ewram access.
|
||||
u16 wrappedMove[MAX_BATTLERS_COUNT];
|
||||
u8 moveTarget[MAX_BATTLERS_COUNT];
|
||||
u8 expGetterMonId;
|
||||
u8 unused_1;
|
||||
u8 wildVictorySong;
|
||||
u8 dynamicMoveType;
|
||||
u8 wrappedBy[MAX_BATTLERS_COUNT];
|
||||
|
@ -507,7 +505,6 @@ struct BattleStruct
|
|||
u8 field_60[4][3];
|
||||
u8 runTries;
|
||||
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
|
||||
u8 unused_2;
|
||||
u8 safariGoNearCounter;
|
||||
u8 safariPkblThrowCounter;
|
||||
u8 safariEscapeFactor;
|
||||
|
@ -517,12 +514,9 @@ struct BattleStruct
|
|||
u8 formToChangeInto;
|
||||
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
|
||||
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
|
||||
u8 unused_3[3];
|
||||
u8 field_8B; // related to player's pokemon switching
|
||||
u8 unused_4[2];
|
||||
u8 stringMoveType;
|
||||
u8 expGetterBattlerId;
|
||||
u8 unused_5;
|
||||
u8 field_91; // related to gAbsentBattlerFlags, possibly absent flags turn ago?
|
||||
u8 field_92; // battle palace related
|
||||
u8 field_93; // related to choosing pokemon?
|
||||
|
@ -530,7 +524,7 @@ struct BattleStruct
|
|||
u8 wallyMovesState;
|
||||
u8 wallyWaitFrames;
|
||||
u8 wallyMoveFrames;
|
||||
u8 lastTakenMove[MAX_BATTLERS_COUNT * 2 * 2]; // Last move that a battler was hit with. This field seems to erroneously take 16 bytes instead of 8.
|
||||
u16 lastTakenMove[MAX_BATTLERS_COUNT]; // Last move that a battler was hit with.
|
||||
u16 hpOnSwitchout[2];
|
||||
u32 savedBattleTypeFlags;
|
||||
u8 abilityPreventingSwitchout;
|
||||
|
@ -539,7 +533,7 @@ struct BattleStruct
|
|||
bool8 anyMonHasTransformed;
|
||||
void (*savedCallback)(void);
|
||||
u16 usedHeldItems[MAX_BATTLERS_COUNT];
|
||||
u8 chosenItem[MAX_BATTLERS_COUNT]; // why is this an u8?
|
||||
u16 chosenItem[MAX_BATTLERS_COUNT];
|
||||
u8 AI_itemType[2];
|
||||
u8 AI_itemFlags[2];
|
||||
u16 choicedMove[MAX_BATTLERS_COUNT];
|
||||
|
@ -548,9 +542,8 @@ struct BattleStruct
|
|||
u8 switchInItemsCounter;
|
||||
u8 arenaTurnCounter;
|
||||
u8 turnSideTracker;
|
||||
u8 unused_6[3];
|
||||
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
|
||||
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
|
||||
u16 lastTakenMoveFrom[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; // a 2-D array [target][attacker]
|
||||
u16 castformPalette[MAX_BATTLERS_COUNT][16];
|
||||
u8 field_180; // weird field, used in battle_main.c, once accessed as an array of u32 overwriting the field below
|
||||
u8 field_181;
|
||||
|
@ -563,7 +556,6 @@ struct BattleStruct
|
|||
u8 atkCancellerTracker;
|
||||
struct BattleTvMovePoints tvMovePoints;
|
||||
struct BattleTv tv;
|
||||
u8 unused_7[0x28];
|
||||
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
|
||||
s8 arenaMindPoints[2];
|
||||
s8 arenaSkillPoints[2];
|
||||
|
|
|
@ -2871,20 +2871,20 @@ static void BattleMainCB1(void)
|
|||
static void BattleStartClearSetData(void)
|
||||
{
|
||||
s32 i;
|
||||
u32 j;
|
||||
u8 *dataPtr;
|
||||
|
||||
TurnValuesCleanUp(FALSE);
|
||||
SpecialStatusesClear();
|
||||
|
||||
memset(&gDisableStructs, 0, sizeof(gDisableStructs));
|
||||
memset(&gFieldTimers, 0, sizeof(gFieldTimers));
|
||||
memset(&gSideStatuses, 0, sizeof(gSideStatuses));
|
||||
memset(&gSideTimers, 0, sizeof(gSideTimers));
|
||||
memset(&gWishFutureKnock, 0, sizeof(gWishFutureKnock));
|
||||
memset(&gBattleResults, 0, sizeof(gBattleResults));
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
gStatuses3[i] = 0;
|
||||
|
||||
dataPtr = (u8 *)&gDisableStructs[i];
|
||||
for (j = 0; j < sizeof(struct DisableStruct); j++)
|
||||
dataPtr[j] = 0;
|
||||
|
||||
gDisableStructs[i].isFirstTurn = 2;
|
||||
gLastMoves[i] = 0;
|
||||
gLastLandedMoves[i] = 0;
|
||||
|
@ -2895,29 +2895,23 @@ static void BattleStartClearSetData(void)
|
|||
gLastPrintedMoves[i] = 0;
|
||||
gBattleResources->flags->flags[i] = 0;
|
||||
gPalaceSelectionBattleScripts[i] = 0;
|
||||
gBattleStruct->lastTakenMove[i] = 0;
|
||||
gBattleStruct->usedHeldItems[i] = 0;
|
||||
gBattleStruct->choicedMove[i] = 0;
|
||||
gBattleStruct->changedItems[i] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][3] = 0;
|
||||
gBattleStruct->AI_monToSwitchIntoId[i] = PARTY_SIZE;
|
||||
}
|
||||
|
||||
gLastUsedMove = 0;
|
||||
gFieldStatuses = 0;
|
||||
memset(&gFieldTimers, 0, sizeof(gFieldTimers));
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
gSideStatuses[i] = 0;
|
||||
|
||||
dataPtr = (u8 *)&gSideTimers[i];
|
||||
for (j = 0; j < sizeof(struct SideTimer); j++)
|
||||
dataPtr[j] = 0;
|
||||
}
|
||||
|
||||
gBattlerAttacker = 0;
|
||||
gBattlerTarget = 0;
|
||||
gBattleWeather = 0;
|
||||
|
||||
dataPtr = (u8 *)&gWishFutureKnock;
|
||||
for (i = 0; i < sizeof(struct WishFutureKnock); i++)
|
||||
dataPtr[i] = 0;
|
||||
|
||||
gHitMarker = 0;
|
||||
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED))
|
||||
|
@ -2926,7 +2920,9 @@ static void BattleStartClearSetData(void)
|
|||
gHitMarker |= HITMARKER_NO_ANIMATIONS;
|
||||
}
|
||||
else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && GetBattleSceneInRecordedBattle())
|
||||
{
|
||||
gHitMarker |= HITMARKER_NO_ANIMATIONS;
|
||||
}
|
||||
|
||||
gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle;
|
||||
gBattleScripting.expOnCatch = (B_EXP_CATCH >= GEN_6);
|
||||
|
@ -2952,37 +2948,16 @@ static void BattleStartClearSetData(void)
|
|||
gBattleStruct->runTries = 0;
|
||||
gBattleStruct->safariGoNearCounter = 0;
|
||||
gBattleStruct->safariPkblThrowCounter = 0;
|
||||
*(&gBattleStruct->safariCatchFactor) = gBaseStats[GetMonData(&gEnemyParty[0], MON_DATA_SPECIES)].catchRate * 100 / 1275;
|
||||
gBattleStruct->safariCatchFactor = gBaseStats[GetMonData(&gEnemyParty[0], MON_DATA_SPECIES)].catchRate * 100 / 1275;
|
||||
gBattleStruct->safariEscapeFactor = 3;
|
||||
gBattleStruct->wildVictorySong = 0;
|
||||
gBattleStruct->moneyMultiplier = 1;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
*((u8 *)gBattleStruct->lastTakenMove + i) = 0;
|
||||
*((u8 *)gBattleStruct->usedHeldItems + i) = 0;
|
||||
*((u8 *)gBattleStruct->choicedMove + i) = 0;
|
||||
*((u8 *)gBattleStruct->changedItems + i) = 0;
|
||||
*(i + 0 * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(i + 1 * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(i + 2 * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(i + 3 * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + i) = PARTY_SIZE;
|
||||
}
|
||||
|
||||
gBattleStruct->givenExpMons = 0;
|
||||
gBattleStruct->field_92 = 0;
|
||||
|
||||
gRandomTurnNumber = Random();
|
||||
|
||||
dataPtr = (u8 *)(&gBattleResults);
|
||||
for (i = 0; i < sizeof(struct BattleResults); i++)
|
||||
dataPtr[i] = 0;
|
||||
|
||||
gBattleResults.shinyWildMon = IsMonShiny(&gEnemyParty[0]);
|
||||
|
||||
gBattleStruct->arenaLostPlayerMons = 0;
|
||||
|
@ -2995,9 +2970,8 @@ static void BattleStartClearSetData(void)
|
|||
|
||||
void SwitchInClearSetData(void)
|
||||
{
|
||||
struct DisableStruct disableStructCopy = gDisableStructs[gActiveBattler];
|
||||
s32 i;
|
||||
u8 *ptr;
|
||||
struct DisableStruct disableStructCopy = gDisableStructs[gActiveBattler];
|
||||
|
||||
if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS)
|
||||
{
|
||||
|
@ -3049,9 +3023,7 @@ void SwitchInClearSetData(void)
|
|||
gActionSelectionCursor[gActiveBattler] = 0;
|
||||
gMoveSelectionCursor[gActiveBattler] = 0;
|
||||
|
||||
ptr = (u8 *)&gDisableStructs[gActiveBattler];
|
||||
for (i = 0; i < sizeof(struct DisableStruct); i++)
|
||||
ptr[i] = 0;
|
||||
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
|
||||
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
|
||||
{
|
||||
|
@ -3072,33 +3044,23 @@ void SwitchInClearSetData(void)
|
|||
gLastPrintedMoves[gActiveBattler] = 0;
|
||||
gLastHitBy[gActiveBattler] = 0xFF;
|
||||
|
||||
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 0) = 0;
|
||||
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 1) = 0;
|
||||
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
gBattleStruct->lastTakenMove[gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
|
||||
|
||||
gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]);
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
|
||||
{
|
||||
*(gBattleStruct->lastTakenMove + i * 2 + 0) = 0;
|
||||
*(gBattleStruct->lastTakenMove + i * 2 + 1) = 0;
|
||||
}
|
||||
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
gBattleStruct->lastTakenMove[i] = 0;
|
||||
|
||||
gBattleStruct->lastTakenMoveFrom[i][gActiveBattler] = 0;
|
||||
}
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0;
|
||||
|
||||
gBattleStruct->choicedMove[gActiveBattler] = 0;
|
||||
gBattleResources->flags->flags[gActiveBattler] = 0;
|
||||
gCurrentMove = 0;
|
||||
gBattleStruct->arenaTurnCounter = 0xFF;
|
||||
|
@ -3110,7 +3072,6 @@ void SwitchInClearSetData(void)
|
|||
void FaintClearSetData(void)
|
||||
{
|
||||
s32 i;
|
||||
u8 *ptr;
|
||||
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
gBattleMons[gActiveBattler].statStages[i] = 6;
|
||||
|
@ -3131,9 +3092,7 @@ void FaintClearSetData(void)
|
|||
gActionSelectionCursor[gActiveBattler] = 0;
|
||||
gMoveSelectionCursor[gActiveBattler] = 0;
|
||||
|
||||
ptr = (u8 *)&gDisableStructs[gActiveBattler];
|
||||
for (i = 0; i < sizeof(struct DisableStruct); i++)
|
||||
ptr[i] = 0;
|
||||
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
|
||||
|
||||
gProtectStructs[gActiveBattler].protected = 0;
|
||||
gProtectStructs[gActiveBattler].spikyShielded = 0;
|
||||
|
@ -3170,31 +3129,21 @@ void FaintClearSetData(void)
|
|||
gLastPrintedMoves[gActiveBattler] = 0;
|
||||
gLastHitBy[gActiveBattler] = 0xFF;
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0;
|
||||
|
||||
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 0) = 0;
|
||||
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 1) = 0;
|
||||
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
gBattleStruct->choicedMove[gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMove[gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
|
||||
|
||||
gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]);
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
|
||||
{
|
||||
*(gBattleStruct->lastTakenMove + i * 2 + 0) = 0;
|
||||
*(gBattleStruct->lastTakenMove + i * 2 + 1) = 0;
|
||||
}
|
||||
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
|
||||
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
|
||||
gBattleStruct->lastTakenMove[i] = 0;
|
||||
|
||||
gBattleStruct->lastTakenMoveFrom[i][gActiveBattler] = 0;
|
||||
}
|
||||
|
||||
gBattleResources->flags->flags[gActiveBattler] = 0;
|
||||
|
@ -4612,7 +4561,6 @@ static void SetActionsAndBattlersTurnOrder(void)
|
|||
static void TurnValuesCleanUp(bool8 var0)
|
||||
{
|
||||
s32 i;
|
||||
u8 *dataPtr;
|
||||
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
{
|
||||
|
@ -4625,9 +4573,7 @@ static void TurnValuesCleanUp(bool8 var0)
|
|||
}
|
||||
else
|
||||
{
|
||||
dataPtr = (u8*)(&gProtectStructs[gActiveBattler]);
|
||||
for (i = 0; i < sizeof(struct ProtectStruct); i++)
|
||||
dataPtr[i] = 0;
|
||||
memset(&gProtectStructs[gActiveBattler], 0, sizeof(struct ProtectStruct));
|
||||
|
||||
if (gDisableStructs[gActiveBattler].isFirstTurn)
|
||||
gDisableStructs[gActiveBattler].isFirstTurn--;
|
||||
|
@ -4652,14 +4598,7 @@ static void TurnValuesCleanUp(bool8 var0)
|
|||
|
||||
static void SpecialStatusesClear(void)
|
||||
{
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
{
|
||||
s32 i;
|
||||
u8 *dataPtr = (u8*)(&gSpecialStatuses[gActiveBattler]);
|
||||
|
||||
for (i = 0; i < sizeof(struct SpecialStatus); i++)
|
||||
dataPtr[i] = 0;
|
||||
}
|
||||
memset(&gSpecialStatuses, 0, sizeof(gSpecialStatuses));
|
||||
}
|
||||
|
||||
static void CheckMegaEvolutionBeforeTurn(void)
|
||||
|
|
|
@ -2383,9 +2383,8 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
|||
else
|
||||
gDisableStructs[gEffectBattler].wrapTurns = ((Random() % 2) + 4);
|
||||
|
||||
*(gBattleStruct->wrappedMove + gEffectBattler * 2 + 0) = gCurrentMove;
|
||||
*(gBattleStruct->wrappedMove + gEffectBattler * 2 + 1) = gCurrentMove >> 8;
|
||||
*(gBattleStruct->wrappedBy + gEffectBattler) = gBattlerAttacker;
|
||||
gBattleStruct->wrappedMove[gEffectBattler] = gCurrentMove;
|
||||
gBattleStruct->wrappedBy[gEffectBattler] = gBattlerAttacker;
|
||||
|
||||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
|
||||
|
@ -2548,8 +2547,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
|||
}
|
||||
else
|
||||
{
|
||||
u16* changedItem = &gBattleStruct->changedItems[gBattlerAttacker];
|
||||
gLastUsedItem = *changedItem = gBattleMons[gBattlerTarget].item;
|
||||
gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item;
|
||||
gBattleMons[gBattlerTarget].item = 0;
|
||||
|
||||
gActiveBattler = gBattlerAttacker;
|
||||
|
@ -2563,8 +2561,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
|||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||
gBattlescriptCurrInstr = BattleScript_ItemSteal;
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 1) = 0;
|
||||
gBattleStruct->choicedMove[gBattlerTarget] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2673,8 +2670,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
|||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||
gBattlescriptCurrInstr = BattleScript_KnockedOff;
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gEffectBattler]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gEffectBattler]) + 1) = 0;
|
||||
gBattleStruct->choicedMove[gEffectBattler] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4228,11 +4224,10 @@ static void atk49_moveend(void)
|
|||
case ATK49_CHANGED_ITEMS: // changed held items
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
u16* changedItem = &gBattleStruct->changedItems[i];
|
||||
if (*changedItem != 0)
|
||||
if (gBattleStruct->changedItems[i] != 0)
|
||||
{
|
||||
gBattleMons[i].item = *changedItem;
|
||||
*changedItem = 0;
|
||||
gBattleMons[i].item = gBattleStruct->changedItems[i];
|
||||
gBattleStruct->changedItems[i] = 0;
|
||||
}
|
||||
}
|
||||
gBattleScripting.atk49_state++;
|
||||
|
@ -4354,18 +4349,8 @@ static void atk49_moveend(void)
|
|||
&& gBattlerAttacker != gBattlerTarget && !(gHitMarker & HITMARKER_FAINTED(gBattlerTarget))
|
||||
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
|
||||
{
|
||||
u8 target, attacker;
|
||||
|
||||
*(gBattleStruct->lastTakenMove + gBattlerTarget * 2 + 0) = gChosenMove;
|
||||
*(gBattleStruct->lastTakenMove + gBattlerTarget * 2 + 1) = gChosenMove >> 8;
|
||||
|
||||
target = gBattlerTarget;
|
||||
attacker = gBattlerAttacker;
|
||||
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = gChosenMove;
|
||||
|
||||
target = gBattlerTarget;
|
||||
attacker = gBattlerAttacker;
|
||||
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = gChosenMove >> 8;
|
||||
gBattleStruct->lastTakenMove[gBattlerTarget] = gChosenMove;
|
||||
gBattleStruct->lastTakenMoveFrom[gBattlerTarget][gBattlerAttacker] = gChosenMove;
|
||||
}
|
||||
gBattleScripting.atk49_state++;
|
||||
break;
|
||||
|
@ -5790,12 +5775,8 @@ static void atk69_setgravity(void)
|
|||
|
||||
static void atk6A_removeitem(void)
|
||||
{
|
||||
u16 *usedHeldItem;
|
||||
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
|
||||
usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler];
|
||||
*usedHeldItem = gBattleMons[gActiveBattler].item;
|
||||
gBattleStruct->usedHeldItems[gActiveBattler] = gBattleMons[gActiveBattler].item;
|
||||
gBattleMons[gActiveBattler].item = 0;
|
||||
|
||||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item);
|
||||
|
@ -6385,22 +6366,18 @@ static void atk76_various(void)
|
|||
case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP:
|
||||
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId)
|
||||
{
|
||||
u16 *choicedMove;
|
||||
|
||||
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId)
|
||||
gActiveBattler = 0;
|
||||
else
|
||||
gActiveBattler = 2;
|
||||
|
||||
choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[gActiveBattler].moves[i] == *choicedMove)
|
||||
if (gBattleMons[gActiveBattler].moves[i] == gBattleStruct->choicedMove[gActiveBattler])
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
*choicedMove = 0;
|
||||
gBattleStruct->choicedMove[gActiveBattler] = 0;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
@ -7371,18 +7348,13 @@ static void atk7C_trymirrormove(void)
|
|||
s32 validMovesCount;
|
||||
s32 i;
|
||||
u16 move;
|
||||
u16 movesArray[4];
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
movesArray[i] = 0;
|
||||
u16 movesArray[4] = {0};
|
||||
|
||||
for (validMovesCount = 0, i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != gBattlerAttacker)
|
||||
{
|
||||
move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0)
|
||||
| (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) << 8);
|
||||
|
||||
move = gBattleStruct->lastTakenMoveFrom[gBattlerAttacker][i];
|
||||
if (move != 0 && move != 0xFFFF)
|
||||
{
|
||||
movesArray[validMovesCount] = move;
|
||||
|
@ -7391,9 +7363,7 @@ static void atk7C_trymirrormove(void)
|
|||
}
|
||||
}
|
||||
|
||||
move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0)
|
||||
| (*(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 1) << 8);
|
||||
|
||||
move = gBattleStruct->lastTakenMove[gBattlerAttacker];
|
||||
if (move != 0 && move != 0xFFFF)
|
||||
{
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
|
@ -9534,13 +9504,7 @@ static void atkBE_rapidspinfree(void)
|
|||
gBattleScripting.battler = gBattlerTarget;
|
||||
gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_WRAPPED);
|
||||
gBattlerTarget = *(gBattleStruct->wrappedBy + gBattlerAttacker);
|
||||
|
||||
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = B_BUFF_MOVE;
|
||||
gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBattlerAttacker * 2 + 0);
|
||||
gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBattlerAttacker * 2 + 1);
|
||||
gBattleTextBuff1[4] = B_BUFF_EOS;
|
||||
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleStruct->wrappedMove[gBattlerAttacker]);
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_WrapFree;
|
||||
}
|
||||
|
@ -9941,11 +9905,8 @@ static void atkD2_tryswapitems(void) // trick
|
|||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item);
|
||||
MarkBattlerForControllerExec(gBattlerTarget);
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 1) = 0;
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerAttacker]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerAttacker]) + 1) = 0;
|
||||
gBattleStruct->choicedMove[gBattlerTarget] = 0;
|
||||
gBattleStruct->choicedMove[gBattlerAttacker] = 0;
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
|
||||
|
|
|
@ -606,7 +606,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
|
|||
u8 moveId = gBattleResources->bufferB[gActiveBattler][2] & ~(RET_MEGA_EVOLUTION);
|
||||
u32 move = gBattleMons[gActiveBattler].moves[moveId];
|
||||
u32 holdEffect = GetBattlerHoldEffect(gActiveBattler, TRUE);
|
||||
u16* choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
|
||||
u16 *choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
|
||||
|
||||
if (gDisableStructs[gActiveBattler].disabledMove == move && move != 0)
|
||||
{
|
||||
|
@ -1496,14 +1496,9 @@ u8 DoBattlerEndTurnEffects(void)
|
|||
{
|
||||
if (--gDisableStructs[gActiveBattler].wrapTurns != 0) // damaged by wrap
|
||||
{
|
||||
// This is the only way I could get this array access to match.
|
||||
gBattleScripting.animArg1 = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0);
|
||||
gBattleScripting.animArg2 = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1);
|
||||
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = B_BUFF_MOVE;
|
||||
gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0);
|
||||
gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1);
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
gBattleScripting.animArg1 = gBattleStruct->wrappedMove[gActiveBattler];
|
||||
gBattleScripting.animArg2 = gBattleStruct->wrappedMove[gActiveBattler] >> 8;
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleStruct->wrappedMove[gActiveBattler]);
|
||||
gBattlescriptCurrInstr = BattleScript_WrapTurnDmg;
|
||||
if (GetBattlerHoldEffect(gBattleStruct->wrappedBy[gActiveBattler], TRUE) == HOLD_EFFECT_BINDING_BAND)
|
||||
gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8;
|
||||
|
@ -1516,11 +1511,7 @@ u8 DoBattlerEndTurnEffects(void)
|
|||
else // broke free
|
||||
{
|
||||
gBattleMons[gActiveBattler].status2 &= ~(STATUS2_WRAPPED);
|
||||
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = B_BUFF_MOVE;
|
||||
gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0);
|
||||
gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1);
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleStruct->wrappedMove[gActiveBattler]);
|
||||
gBattlescriptCurrInstr = BattleScript_WrapEnds;
|
||||
}
|
||||
BattleScriptExecute(gBattlescriptCurrInstr);
|
||||
|
|
Loading…
Reference in a new issue