Merge pull request #356 from DizzyEggg/clean_battlestruct

Clean a couple of battlestructs' fields
This commit is contained in:
Diegoisawesome 2018-10-14 13:18:29 -05:00 committed by GitHub
commit 43316ffae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 168 additions and 200 deletions

View File

@ -27,8 +27,8 @@
#define B_ACTION_SAFARI_POKEBLOCK 6
#define B_ACTION_SAFARI_GO_NEAR 7
#define B_ACTION_SAFARI_RUN 8
#define B_ACTION_WALLY_THROW 9
// The exact purposes of these are unclear
#define B_ACTION_WALLY_THROW 9
#define B_ACTION_EXEC_SCRIPT 10 // when executing an action
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_FINISHED 12 // when executing an action
@ -128,42 +128,40 @@ struct UnknownFlags
struct DisableStruct
{
/*0x00*/ u32 transformedMonPersonality;
/*0x04*/ u16 disabledMove;
/*0x06*/ u16 encoredMove;
/*0x08*/ u8 protectUses;
/*0x09*/ u8 stockpileCounter;
/*0x0A*/ u8 substituteHP;
/*0x0B*/ u8 disableTimer1:4;
/*0x0B*/ u8 disableTimer2:4;
/*0x0C*/ u8 encoredMovePos;
/*0x0D*/ u8 unkD;
/*0x0E*/ u8 encoreTimer1:4;
/*0x0E*/ u8 encoreTimer2:4;
/*0x0F*/ u8 perishSongTimer1:4;
/*0x0F*/ u8 perishSongTimer2:4;
/*0x10*/ u8 furyCutterCounter;
/*0x11*/ u8 rolloutCounter1:4;
/*0x11*/ u8 rolloutCounter2:4;
/*0x12*/ u8 chargeTimer1:4;
/*0x12*/ u8 chargeTimer2:4;
/*0x13*/ u8 tauntTimer1:4;
/*0x13*/ u8 tauntTimer2:4;
/*0x14*/ u8 battlerPreventingEscape;
/*0x15*/ u8 battlerWithSureHit;
/*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter:1;
/*0x18*/ u8 truantUnknownBit:1;
/*0x18*/ u8 unk18_a_2:2;
/*0x18*/ u8 unk18_b:4;
/*0x19*/ u8 rechargeCounter;
/*0x1A*/ u8 unk1A[2];
u32 transformedMonPersonality;
u16 disabledMove;
u16 encoredMove;
u8 protectUses;
u8 stockpileCounter;
u8 substituteHP;
u8 disableTimer:4;
u8 disableTimerStartValue:4;
u8 encoredMovePos;
u8 filler_D; // Unused field.
u8 encoreTimer:4;
u8 encoreTimerStartValue:4;
u8 perishSongTimer:4;
u8 perishSongTimerStartValue:4;
u8 furyCutterCounter;
u8 rolloutTimer:4;
u8 rolloutTimerStartValue:4;
u8 chargeTimer:4;
u8 chargeTimerStartValue:4;
u8 tauntTimer:4;
u8 tauntTimer2:4;
u8 battlerPreventingEscape;
u8 battlerWithSureHit;
u8 isFirstTurn;
u8 unk17;
u8 truantCounter:1;
u8 truantUnknownBit:1;
u8 unk18_a_2:2;
u8 unk18_b:4;
u8 rechargeTimer;
};
struct ProtectStruct
{
/* field_0 */
u32 protected:1;
u32 endured:1;
u32 noValidMoves:1;
@ -172,67 +170,54 @@ struct ProtectStruct
u32 stealMove:1;
u32 flag0Unknown:1;
u32 prlzImmobility:1;
/* field_1 */
u32 confusionSelfDmg:1;
u32 targetNotAffected:1;
u32 chargingTurn:1;
u32 fleeFlag:2; // for RunAway and Smoke Ball
u32 fleeFlag:2; // For RunAway and Smoke Ball.
u32 usedImprisionedMove:1;
u32 loveImmobility:1;
u32 usedDisabledMove:1;
/* field_2 */
u32 usedTauntedMove:1; // 0x1
u32 flag2Unknown:1; // 0x2
u32 flinchImmobility:1; // 0x4
u32 notFirstStrike:1; // 0x8
u32 flag_x10:1; // 0x10
u32 flag_x20:1; // 0x20
u32 flag_x40:1; // 0x40
u32 flag_x80:1; // 0x80
/* field_3 */
u32 field3:8;
/* field_4 */ u32 physicalDmg;
/* field_8 */ u32 specialDmg;
/* field_C */ u8 physicalBattlerId;
/* field_D */ u8 specialBattlerId;
/* field_E */ u16 fieldE;
u32 usedTauntedMove:1;
u32 flag2Unknown:1;
u32 flinchImmobility:1;
u32 notFirstStrike:1;
u32 flag_x10:1;
u32 physicalDmg;
u32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
};
struct SpecialStatus
{
u8 statLowered:1; // 0x1
u8 lightningRodRedirected:1; // 0x2
u8 restoredBattlerSprite: 1; // 0x4
u8 intimidatedMon:1; // 0x8
u8 traced:1; // 0x10
u8 flag20:1;
u8 statLowered:1;
u8 lightningRodRedirected:1;
u8 restoredBattlerSprite: 1;
u8 intimidatedMon:1;
u8 traced:1;
u8 ppNotAffectedByPressure:1;
u8 flag40:1;
u8 focusBanded:1;
u8 field1[3];
s32 dmg;
s32 physicalDmg;
s32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
u8 field12;
u8 field13;
};
struct SideTimer
{
/*0x00*/ u8 reflectTimer;
/*0x01*/ u8 reflectBattlerId;
/*0x02*/ u8 lightscreenTimer;
/*0x03*/ u8 lightscreenBattlerId;
/*0x04*/ u8 mistTimer;
/*0x05*/ u8 mistBattlerId;
/*0x06*/ u8 safeguardTimer;
/*0x07*/ u8 safeguardBattlerId;
/*0x08*/ u8 followmeTimer;
/*0x09*/ u8 followmeTarget;
/*0x0A*/ u8 spikesAmount;
/*0x0B*/ u8 fieldB;
u8 reflectTimer;
u8 reflectBattlerId;
u8 lightscreenTimer;
u8 lightscreenBattlerId;
u8 mistTimer;
u8 mistBattlerId;
u8 safeguardTimer;
u8 safeguardBattlerId;
u8 followmeTimer;
u8 followmeTarget;
u8 spikesAmount;
};
struct WishFutureKnock
@ -244,7 +229,7 @@ struct WishFutureKnock
u8 wishCounter[MAX_BATTLERS_COUNT];
u8 wishMonId[MAX_BATTLERS_COUNT];
u8 weatherDuration;
u8 knockedOffPokes[2];
u8 knockedOffMons[2]; // Each battler is represented by a bit. The array entry is dependent on the battler's side.
};
struct AI_ThinkingStruct
@ -317,7 +302,7 @@ struct BattleResults
u8 playerSwitchesCounter; // 0x2
u8 unk3; // 0x3
u8 unk4; // 0x4
u8 unk5_0:1; // 0x5
u8 playerMonWasDamaged:1; // 0x5
u8 usedMasterBall:1; // 0x5
u8 caughtMonBall:4; // 0x5
u8 shinyWildMon:1; // 0x5
@ -428,22 +413,14 @@ struct BattleStruct
u8 turnEffectsBattlerId;
u8 filler2;
u8 turnCountersTracker;
u8 wrappedMove[8]; // ask gamefreak why they declared it that way
u8 moveTarget[4];
u8 wrappedMove[MAX_BATTLERS_COUNT * 2]; // Leftover from Ruby's ewram access.
u8 moveTarget[MAX_BATTLERS_COUNT];
u8 expGetterMonId;
u8 field_11;
u8 wildVictorySong;
u8 dynamicMoveType;
u8 wrappedBy[4];
u16 assistPossibleMoves[5 * 4]; // 5 mons, each of them knowing 4 moves
u8 field_40;
u8 field_41;
u8 field_42;
u8 field_43;
u8 field_44;
u8 field_45;
u8 field_46;
u8 field_47;
u8 wrappedBy[MAX_BATTLERS_COUNT];
u16 assistPossibleMoves[PARTY_SIZE * 4]; // Each of mons can know max 4 moves.
u8 focusPunchBattlerId;
u8 battlerPreventingSwitchout;
u8 moneyMultiplier;
@ -451,7 +428,6 @@ struct BattleStruct
u8 switchInAbilitiesCounter;
u8 faintedActionsState;
u8 faintedActionsBattlerId;
u8 field_4F;
u16 expValue;
u8 field_52;
u8 sentInPokes;
@ -460,7 +436,7 @@ struct BattleStruct
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 field_60[4][3];
u8 runTries;
u8 caughtMonNick[11];
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
u8 field_78;
u8 safariGoNearCounter;
u8 safariPkblThrowCounter;
@ -487,15 +463,7 @@ struct BattleStruct
u8 wallyMovesState;
u8 wallyWaitFrames;
u8 wallyMoveFrames;
u8 mirrorMoves[8]; // ask gamefreak why they declared it that way
u8 field_A0;
u8 field_A1;
u8 field_A2;
u8 field_A3;
u8 field_A4;
u8 field_A5;
u8 field_A6;
u8 field_A7;
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 hpOnSwitchout[2];
u32 savedBattleTypeFlags;
u8 abilityPreventingSwitchout;
@ -504,7 +472,7 @@ struct BattleStruct
bool8 anyMonHasTransformed;
void (*savedCallback)(void);
u16 usedHeldItems[MAX_BATTLERS_COUNT];
u8 chosenItem[4]; // why is this an u8?
u8 chosenItem[MAX_BATTLERS_COUNT]; // why is this an u8?
u8 AI_itemType[2];
u8 AI_itemFlags[2];
u16 choicedMove[MAX_BATTLERS_COUNT];
@ -515,7 +483,7 @@ struct BattleStruct
u8 turnSideTracker;
u8 fillerDC[0xDF-0xDC];
u8 field_DF;
u8 mirrorMoveArrays[32];
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
u16 castformPalette[MAX_BATTLERS_COUNT][16];
u8 field_180;
u8 field_181;

View File

@ -2191,7 +2191,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
if (gDisableStructs[gBattlerTarget].tauntTimer != 0)
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -2199,7 +2199,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
if (gDisableStructs[gBattlerTarget].tauntTimer == 0)
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;

View File

@ -17,7 +17,7 @@ static bool8 ShouldUseItem(void);
static bool8 ShouldSwitchIfPerishSong(void)
{
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG
&& gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
&& gDisableStructs[gActiveBattler].perishSongTimer == 0)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);

View File

@ -3061,14 +3061,14 @@ static void BattleStartClearSetData(void)
for (i = 0; i < 8; i++)
{
*((u8 *)gBattleStruct->mirrorMoves + i) = 0;
*((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->mirrorMoveArrays) + 0) = 0;
*(i + 1 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(i + 2 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(i + 3 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 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++)
@ -3153,8 +3153,8 @@ void SwitchInClearSetData(void)
{
gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP;
gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit;
gDisableStructs[gActiveBattler].perishSongTimer1 = disableStructCopy.perishSongTimer1;
gDisableStructs[gActiveBattler].perishSongTimer2 = disableStructCopy.perishSongTimer2;
gDisableStructs[gActiveBattler].perishSongTimer = disableStructCopy.perishSongTimer;
gDisableStructs[gActiveBattler].perishSongTimerStartValue = disableStructCopy.perishSongTimerStartValue;
gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape;
}
@ -3168,16 +3168,16 @@ void SwitchInClearSetData(void)
gLastPrintedMoves[gActiveBattler] = 0;
gLastHitBy[gActiveBattler] = 0xFF;
*(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 0) = 0;
*(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 1) = 0;
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 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->field_92 &= ~(gBitTable[gActiveBattler]);
@ -3185,11 +3185,11 @@ void SwitchInClearSetData(void)
{
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
{
*(gBattleStruct->mirrorMoves + i * 2 + 0) = 0;
*(gBattleStruct->mirrorMoves + i * 2 + 1) = 0;
*(gBattleStruct->lastTakenMove + i * 2 + 0) = 0;
*(gBattleStruct->lastTakenMove + i * 2 + 1) = 0;
}
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
}
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0;
@ -3263,16 +3263,16 @@ void FaintClearSetData(void)
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0;
*(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 0) = 0;
*(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 1) = 0;
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 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->field_92 &= ~(gBitTable[gActiveBattler]);
@ -3280,11 +3280,11 @@ void FaintClearSetData(void)
{
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
{
*(gBattleStruct->mirrorMoves + i * 2 + 0) = 0;
*(gBattleStruct->mirrorMoves + i * 2 + 1) = 0;
*(gBattleStruct->lastTakenMove + i * 2 + 0) = 0;
*(gBattleStruct->lastTakenMove + i * 2 + 1) = 0;
}
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
*(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
}
gBattleResources->flags->flags[gActiveBattler] = 0;
@ -4879,10 +4879,10 @@ static void TurnValuesCleanUp(bool8 var0)
if (gDisableStructs[gActiveBattler].isFirstTurn)
gDisableStructs[gActiveBattler].isFirstTurn--;
if (gDisableStructs[gActiveBattler].rechargeCounter)
if (gDisableStructs[gActiveBattler].rechargeTimer)
{
gDisableStructs[gActiveBattler].rechargeCounter--;
if (gDisableStructs[gActiveBattler].rechargeCounter == 0)
gDisableStructs[gActiveBattler].rechargeTimer--;
if (gDisableStructs[gActiveBattler].rechargeTimer == 0)
gBattleMons[gActiveBattler].status2 &= ~(STATUS2_RECHARGE);
}
}
@ -5318,7 +5318,7 @@ static void HandleAction_UseMove(void)
gCurrentMove = gChosenMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos];
gDisableStructs[gBattlerAttacker].encoredMove = MOVE_NONE;
gDisableStructs[gBattlerAttacker].encoredMovePos = 0;
gDisableStructs[gBattlerAttacker].encoreTimer1 = 0;
gDisableStructs[gBattlerAttacker].encoreTimer = 0;
*(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(gCurrentMove, 0);
}
else if (gBattleMons[gBattlerAttacker].moves[gCurrMovePos] != gChosenMoveByBattler[gBattlerAttacker])

View File

@ -1229,7 +1229,7 @@ static void atk03_ppreduce(void)
if (gBattleControllerExecFlags)
return;
if (!gSpecialStatuses[gBattlerAttacker].flag20)
if (!gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure)
{
switch (gBattleMoves[gCurrentMove].target)
{
@ -1858,7 +1858,7 @@ static void atk0B_healthbarupdate(void)
MarkBattlerForControllerExec(gActiveBattler);
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleMoveDamage > 0)
gBattleResults.unk5_0 = 1;
gBattleResults.playerMonWasDamaged = TRUE;
}
}
@ -2730,7 +2730,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
break;
case MOVE_EFFECT_RECHARGE:
gBattleMons[gEffectBattler].status2 |= STATUS2_RECHARGE;
gDisableStructs[gEffectBattler].rechargeCounter = 2;
gDisableStructs[gEffectBattler].rechargeTimer = 2;
gLockedMoves[gEffectBattler] = gCurrentMove;
gBattlescriptCurrInstr++;
break;
@ -2763,7 +2763,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
| BATTLE_TYPE_LINK
| BATTLE_TYPE_x2000000
| BATTLE_TYPE_SECRET_BASE))
&& (gWishFutureKnock.knockedOffPokes[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]))
&& (gWishFutureKnock.knockedOffMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]))
{
gBattlescriptCurrInstr++;
}
@ -2885,7 +2885,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
gLastUsedItem = gBattleMons[gEffectBattler].item;
gBattleMons[gEffectBattler].item = 0;
gWishFutureKnock.knockedOffPokes[side] |= gBitTable[gBattlerPartyIndexes[gEffectBattler]];
gWishFutureKnock.knockedOffMons[side] |= gBitTable[gBattlerPartyIndexes[gEffectBattler]];
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_KnockedOff;
@ -4752,16 +4752,16 @@ static void atk49_moveend(void)
{
u8 target, attacker;
*(gBattleStruct->mirrorMoves + gBattlerTarget * 2 + 0) = gChosenMove;
*(gBattleStruct->mirrorMoves + gBattlerTarget * 2 + 1) = gChosenMove >> 8;
*(gBattleStruct->lastTakenMove + gBattlerTarget * 2 + 0) = gChosenMove;
*(gBattleStruct->lastTakenMove + gBattlerTarget * 2 + 1) = gChosenMove >> 8;
target = gBattlerTarget;
attacker = gBattlerAttacker;
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = gChosenMove;
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = gChosenMove;
target = gBattlerTarget;
attacker = gBattlerAttacker;
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = gChosenMove >> 8;
*(attacker * 2 + target * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = gChosenMove >> 8;
}
gBattleScripting.atk49_state++;
break;
@ -4948,7 +4948,7 @@ static void atk4D_switchindataupdate(void)
// check knocked off item
i = GetBattlerSide(gActiveBattler);
if (gWishFutureKnock.knockedOffPokes[i] & gBitTable[gBattlerPartyIndexes[gActiveBattler]])
if (gWishFutureKnock.knockedOffMons[i] & gBitTable[gBattlerPartyIndexes[gActiveBattler]])
{
gBattleMons[gActiveBattler].item = 0;
}
@ -6937,8 +6937,8 @@ static void atk7C_trymirrormove(void)
{
if (i != gBattlerAttacker)
{
move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0)
| (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8);
move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0)
| (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) << 8);
if (move != 0 && move != 0xFFFF)
{
@ -6948,8 +6948,8 @@ static void atk7C_trymirrormove(void)
}
}
move = *(gBattleStruct->mirrorMoves + gBattlerAttacker * 2 + 0)
| (*(gBattleStruct->mirrorMoves + gBattlerAttacker * 2 + 1) << 8);
move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0)
| (*(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 1) << 8);
if (move != 0 && move != 0xFFFF)
{
@ -6968,7 +6968,7 @@ static void atk7C_trymirrormove(void)
}
else
{
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
gBattlescriptCurrInstr++;
}
}
@ -8033,7 +8033,7 @@ static void atk9B_transformdataexecution(void)
gBattleMons[gBattlerAttacker].status2 |= STATUS2_TRANSFORMED;
gDisableStructs[gBattlerAttacker].disabledMove = 0;
gDisableStructs[gBattlerAttacker].disableTimer1 = 0;
gDisableStructs[gBattlerAttacker].disableTimer = 0;
gDisableStructs[gBattlerAttacker].transformedMonPersonality = gBattleMons[gBattlerTarget].personality;
gDisableStructs[gBattlerAttacker].unk18_b = 0;
@ -8207,7 +8207,7 @@ static void atkA1_counterdamagecalculator(void)
}
else
{
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
}
@ -8230,7 +8230,7 @@ static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the p
}
else
{
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
}
@ -8250,8 +8250,8 @@ static void atkA3_disablelastusedattack(void)
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerTarget].moves[i])
gDisableStructs[gBattlerTarget].disabledMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].disableTimer1 = (Random() & 3) + 2;
gDisableStructs[gBattlerTarget].disableTimer2 = gDisableStructs[gBattlerTarget].disableTimer1; // used to save the random amount of turns?
gDisableStructs[gBattlerTarget].disableTimer = (Random() & 3) + 2;
gDisableStructs[gBattlerTarget].disableTimerStartValue = gDisableStructs[gBattlerTarget].disableTimer; // used to save the random amount of turns?
gBattlescriptCurrInstr += 5;
}
else
@ -8282,8 +8282,8 @@ static void atkA4_trysetencore(void)
{
gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].encoredMovePos = i;
gDisableStructs[gBattlerTarget].encoreTimer1 = (Random() & 3) + 3;
gDisableStructs[gBattlerTarget].encoreTimer2 = gDisableStructs[gBattlerTarget].encoreTimer1;
gDisableStructs[gBattlerTarget].encoreTimer = (Random() & 3) + 3;
gDisableStructs[gBattlerTarget].encoreTimerStartValue = gDisableStructs[gBattlerTarget].encoreTimer;
gBattlescriptCurrInstr += 5;
}
else
@ -8727,7 +8727,7 @@ static void atkB0_trysetspikes(void)
if (gSideTimers[targetSide].spikesAmount == 3)
{
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
else
@ -8759,8 +8759,8 @@ static void atkB2_trysetperishsong(void)
else
{
gStatuses3[i] |= STATUS3_PERISH_SONG;
gDisableStructs[i].perishSongTimer1 = 3;
gDisableStructs[i].perishSongTimer2 = 3;
gDisableStructs[i].perishSongTimer = 3;
gDisableStructs[i].perishSongTimerStartValue = 3;
}
}
@ -8785,19 +8785,19 @@ static void atkB3_rolloutdamagecalculation(void)
if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit
{
gDisableStructs[gBattlerAttacker].rolloutCounter1 = 5;
gDisableStructs[gBattlerAttacker].rolloutCounter2 = 5;
gDisableStructs[gBattlerAttacker].rolloutTimer = 5;
gDisableStructs[gBattlerAttacker].rolloutTimerStartValue = 5;
gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gBattlerAttacker] = gCurrentMove;
}
if (--gDisableStructs[gBattlerAttacker].rolloutCounter1 == 0) // last hit
if (--gDisableStructs[gBattlerAttacker].rolloutTimer == 0) // last hit
{
gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_MULTIPLETURNS);
}
gDynamicBasePower = gBattleMoves[gCurrentMove].power;
for (i = 1; i < (5 - gDisableStructs[gBattlerAttacker].rolloutCounter1); i++)
for (i = 1; i < (5 - gDisableStructs[gBattlerAttacker].rolloutTimer); i++)
gDynamicBasePower *= 2;
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_DEFENSE_CURL)
@ -9320,8 +9320,8 @@ static void atkCA_setforcedtarget(void) // follow me
static void atkCB_setcharge(void)
{
gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP;
gDisableStructs[gBattlerAttacker].chargeTimer1 = 2;
gDisableStructs[gBattlerAttacker].chargeTimer2 = 2;
gDisableStructs[gBattlerAttacker].chargeTimer = 2;
gDisableStructs[gBattlerAttacker].chargeTimerStartValue = 2;
gBattlescriptCurrInstr++;
}
@ -9373,9 +9373,9 @@ static void atkCF_jumpifnodamage(void)
static void atkD0_settaunt(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
if (gDisableStructs[gBattlerTarget].tauntTimer == 0)
{
gDisableStructs[gBattlerTarget].tauntTimer1 = 2;
gDisableStructs[gBattlerTarget].tauntTimer = 2;
gDisableStructs[gBattlerTarget].tauntTimer2 = 2;
gBattlescriptCurrInstr += 5;
}
@ -9427,8 +9427,8 @@ static void atkD2_tryswapitems(void) // trick
| BATTLE_TYPE_FRONTIER
| BATTLE_TYPE_SECRET_BASE
| BATTLE_TYPE_x2000000))
&& (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]
|| gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]]))
&& (gWishFutureKnock.knockedOffMons[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]
|| gWishFutureKnock.knockedOffMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]]))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
@ -9751,7 +9751,7 @@ static void atkDE_asistattackselect(void)
static void atkDF_trysetmagiccoat(void)
{
gBattlerTarget = gBattlerAttacker;
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
@ -9765,7 +9765,7 @@ static void atkDF_trysetmagiccoat(void)
static void atkE0_trysetsnatch(void) // snatch
{
gSpecialStatuses[gBattlerAttacker].flag20 = 1;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);

View File

@ -659,7 +659,7 @@ void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruc
tvPtr->side[atkSide].usedMoveSlot = moveSlot;
AddMovePoints(0, moveSlot, gBattleMoves[move].effect, 0);
AddPointsBasedOnWeather(weatherFlags, move, moveSlot);
if (disableStructPtr->chargeTimer1 != 0)
if (disableStructPtr->chargeTimer != 0)
AddMovePoints(7, move, moveSlot, 0);
if (move == MOVE_WISH)

View File

@ -216,7 +216,7 @@ void CancelMultiTurnMoves(u8 battler)
gStatuses3[battler] &= ~(STATUS3_SEMI_INVULNERABLE);
gDisableStructs[battler].rolloutCounter1 = 0;
gDisableStructs[battler].rolloutTimer = 0;
gDisableStructs[battler].furyCutterCounter = 0;
}
@ -345,7 +345,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
}
}
if (gDisableStructs[gActiveBattler].tauntTimer1 != 0 && gBattleMoves[move].power == 0)
if (gDisableStructs[gActiveBattler].tauntTimer != 0 && gBattleMoves[move].power == 0)
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
@ -436,11 +436,11 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
unusableMoves |= gBitTable[i];
if (gBattleMons[battlerId].moves[i] == gLastMoves[battlerId] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[battlerId].status2 & STATUS2_TORMENT)
unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].tauntTimer1 && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0)
if (gDisableStructs[battlerId].tauntTimer && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0)
unusableMoves |= gBitTable[i];
if (GetImprisonedMovesCount(battlerId, gBattleMons[battlerId].moves[i]) && check & MOVE_LIMITATION_IMPRISION)
unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].encoreTimer1 && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i])
if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i])
unusableMoves |= gBitTable[i];
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[battlerId].moves[i])
unusableMoves |= gBitTable[i];
@ -1018,7 +1018,7 @@ u8 DoBattlerEndTurnEffects(void)
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_DISABLE: // disable
if (gDisableStructs[gActiveBattler].disableTimer1 != 0)
if (gDisableStructs[gActiveBattler].disableTimer != 0)
{
s32 i;
for (i = 0; i < 4; i++)
@ -1029,9 +1029,9 @@ u8 DoBattlerEndTurnEffects(void)
if (i == 4) // pokemon does not have the disabled move anymore
{
gDisableStructs[gActiveBattler].disabledMove = 0;
gDisableStructs[gActiveBattler].disableTimer1 = 0;
gDisableStructs[gActiveBattler].disableTimer = 0;
}
else if (--gDisableStructs[gActiveBattler].disableTimer1 == 0) // disable ends
else if (--gDisableStructs[gActiveBattler].disableTimer == 0) // disable ends
{
gDisableStructs[gActiveBattler].disabledMove = 0;
BattleScriptExecute(BattleScript_DisabledNoMore);
@ -1041,18 +1041,18 @@ u8 DoBattlerEndTurnEffects(void)
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_ENCORE: // encore
if (gDisableStructs[gActiveBattler].encoreTimer1 != 0)
if (gDisableStructs[gActiveBattler].encoreTimer != 0)
{
if (gBattleMons[gActiveBattler].moves[gDisableStructs[gActiveBattler].encoredMovePos] != gDisableStructs[gActiveBattler].encoredMove) // pokemon does not have the encored move anymore
{
gDisableStructs[gActiveBattler].encoredMove = 0;
gDisableStructs[gActiveBattler].encoreTimer1 = 0;
gDisableStructs[gActiveBattler].encoreTimer = 0;
}
else if (--gDisableStructs[gActiveBattler].encoreTimer1 == 0
else if (--gDisableStructs[gActiveBattler].encoreTimer == 0
|| gBattleMons[gActiveBattler].pp[gDisableStructs[gActiveBattler].encoredMovePos] == 0)
{
gDisableStructs[gActiveBattler].encoredMove = 0;
gDisableStructs[gActiveBattler].encoreTimer1 = 0;
gDisableStructs[gActiveBattler].encoreTimer = 0;
BattleScriptExecute(BattleScript_EncoredNoMore);
effect++;
}
@ -1065,13 +1065,13 @@ u8 DoBattlerEndTurnEffects(void)
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_CHARGE: // charge
if (gDisableStructs[gActiveBattler].chargeTimer1 && --gDisableStructs[gActiveBattler].chargeTimer1 == 0)
if (gDisableStructs[gActiveBattler].chargeTimer && --gDisableStructs[gActiveBattler].chargeTimer == 0)
gStatuses3[gActiveBattler] &= ~STATUS3_CHARGED_UP;
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_TAUNT: // taunt
if (gDisableStructs[gActiveBattler].tauntTimer1)
gDisableStructs[gActiveBattler].tauntTimer1--;
if (gDisableStructs[gActiveBattler].tauntTimer)
gDisableStructs[gActiveBattler].tauntTimer--;
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_YAWN: // yawn
@ -1167,8 +1167,8 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
gBattleStruct->wishPerishSongBattlerId++;
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG)
{
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBattler].perishSongTimer1);
if (gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBattler].perishSongTimer);
if (gDisableStructs[gActiveBattler].perishSongTimer == 0)
{
gStatuses3[gActiveBattler] &= ~STATUS3_PERISH_SONG;
gBattleMoveDamage = gBattleMons[gActiveBattler].hp;
@ -1176,7 +1176,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
}
else
{
gDisableStructs[gActiveBattler].perishSongTimer1--;
gDisableStructs[gActiveBattler].perishSongTimer--;
gBattlescriptCurrInstr = BattleScript_PerishSongCountGoesDown;
}
BattleScriptExecute(gBattlescriptCurrInstr);
@ -1420,7 +1420,7 @@ u8 AtkCanceller_UnableToUseMove(void)
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_RECHARGE)
{
gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RECHARGE);
gDisableStructs[gBattlerAttacker].rechargeCounter = 0;
gDisableStructs[gBattlerAttacker].rechargeTimer = 0;
CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -1453,7 +1453,7 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_TAUNTED: // taunt
if (gDisableStructs[gBattlerAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0)
if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0)
{
gProtectStructs[gBattlerAttacker].usedTauntedMove = 1;
CancelMultiTurnMoves(gBattlerAttacker);

View File

@ -936,7 +936,7 @@ void GabbyAndTyBeforeInterview(void)
{
gSaveBlock1Ptr->gabbyAndTyData.battleNum ++;
}
gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn = gBattleResults.unk5_0;
gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn = gBattleResults.playerMonWasDamaged;
if (gBattleResults.playerFaintCounter != 0)
{
gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon = TRUE;