Party Size and Num Stats

This commit is contained in:
DizzyEggg 2018-11-18 20:00:36 +01:00
parent 032dd251e6
commit 1b0cfb0757
23 changed files with 84 additions and 85 deletions

View File

@ -74,7 +74,10 @@
#define STAT_SPEED 3 #define STAT_SPEED 3
#define STAT_SPATK 4 #define STAT_SPATK 4
#define STAT_SPDEF 5 #define STAT_SPDEF 5
#define STAT_ACC 6 // only in battles #define STAT_ACC 6 // Only in battles.
#define STAT_EVASION 7 // only in battles #define STAT_EVASION 7 // Only in battles.
#define NUM_STATS 6
#define NUM_BATTLE_STATS 8
#endif // GUARD_CONSTANTS_POKEMON_H #endif // GUARD_CONSTANTS_POKEMON_H

View File

@ -151,7 +151,6 @@
#define STATUS_PRIMARY_FAINTED 0x7 #define STATUS_PRIMARY_FAINTED 0x7
#define MAX_TOTAL_EVS 510 #define MAX_TOTAL_EVS 510
#define NUM_STATS 6
#define UNOWN_FORM_COUNT 28 #define UNOWN_FORM_COUNT 28
struct PokemonSubstruct0 struct PokemonSubstruct0
@ -293,8 +292,6 @@ struct Unknown_806F160_Struct
struct SpriteFrameImage *frameImages; struct SpriteFrameImage *frameImages;
}; };
#define BATTLE_STATS_NO 8
struct BattlePokemon struct BattlePokemon
{ {
/*0x00*/ u16 species; /*0x00*/ u16 species;
@ -312,7 +309,7 @@ struct BattlePokemon
/*0x17*/ u32 spDefenseIV:5; /*0x17*/ u32 spDefenseIV:5;
/*0x17*/ u32 isEgg:1; /*0x17*/ u32 isEgg:1;
/*0x17*/ u32 altAbility:1; /*0x17*/ u32 altAbility:1;
/*0x18*/ s8 statStages[BATTLE_STATS_NO]; /*0x18*/ s8 statStages[NUM_BATTLE_STATS];
/*0x20*/ u8 ability; /*0x20*/ u8 ability;
/*0x21*/ u8 type1; /*0x21*/ u8 type1;
/*0x22*/ u8 type2; /*0x22*/ u8 type2;

View File

@ -310,7 +310,7 @@ static bool8 AreStatsRaised(void)
u8 buffedStatsValue = 0; u8 buffedStatsValue = 0;
s32 i; s32 i;
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
if (gBattleMons[gActiveBattler].statStages[i] > 6) if (gBattleMons[gActiveBattler].statStages[i] > 6)
buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6; buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6;

View File

@ -558,7 +558,7 @@ static void LinkOpponentHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyLinkOpponentMonData(i, monData + size); size += CopyLinkOpponentMonData(i, monData + size);
@ -892,7 +892,7 @@ static void LinkOpponentHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetLinkOpponentMonData(i); SetLinkOpponentMonData(i);

View File

@ -444,7 +444,7 @@ static void LinkPartnerHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyLinkPartnerMonData(i, monData + size); size += CopyLinkPartnerMonData(i, monData + size);
@ -778,7 +778,7 @@ static void LinkPartnerHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetLinkPartnerMonData(i); SetLinkPartnerMonData(i);

View File

@ -541,7 +541,7 @@ static void OpponentHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += GetOpponentMonData(i, monData + size); size += GetOpponentMonData(i, monData + size);
@ -884,7 +884,7 @@ static void OpponentHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetOpponentMonData(i); SetOpponentMonData(i);

View File

@ -1589,7 +1589,7 @@ static void PlayerHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyPlayerMonData(i, monData + size); size += CopyPlayerMonData(i, monData + size);
@ -1932,7 +1932,7 @@ static void PlayerHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetPlayerMonData(i); SetPlayerMonData(i);

View File

@ -632,7 +632,7 @@ static void PlayerPartnerHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyPlayerPartnerMonData(i, monData + size); size += CopyPlayerPartnerMonData(i, monData + size);
@ -966,7 +966,7 @@ static void PlayerPartnerHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetPlayerPartnerMonData(i); SetPlayerPartnerMonData(i);

View File

@ -542,7 +542,7 @@ static void RecordedOpponentHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyRecordedOpponentMonData(i, monData + size); size += CopyRecordedOpponentMonData(i, monData + size);
@ -876,7 +876,7 @@ static void RecordedOpponentHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetRecordedOpponentMonData(i); SetRecordedOpponentMonData(i);

View File

@ -527,7 +527,7 @@ static void RecordedPlayerHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyRecordedPlayerMonData(i, monData + size); size += CopyRecordedPlayerMonData(i, monData + size);
@ -861,7 +861,7 @@ static void RecordedPlayerHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetRecordedPlayerMonData(i); SetRecordedPlayerMonData(i);

View File

@ -442,7 +442,7 @@ static void WallyHandleGetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
size += CopyWallyMonData(i, monData + size); size += CopyWallyMonData(i, monData + size);
@ -776,7 +776,7 @@ static void WallyHandleSetMonData(void)
else else
{ {
monToCheck = gBattleBufferA[gActiveBattler][2]; monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (monToCheck & 1) if (monToCheck & 1)
SetWallyMonData(i); SetWallyMonData(i);

View File

@ -2756,17 +2756,17 @@ static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 natu
s32 i, count; s32 i, count;
u8 bits; u8 bits;
u16 resultingEvs; u16 resultingEvs;
s32 evs[6]; s32 evs[NUM_STATS];
count = 0, bits = evBits; count = 0, bits = evBits;
for (i = 0; i < 6; bits >>= 1, i++) for (i = 0; i < NUM_STATS; bits >>= 1, i++)
{ {
if (bits & 1) if (bits & 1)
count++; count++;
} }
resultingEvs = MAX_TOTAL_EVS / count; resultingEvs = MAX_TOTAL_EVS / count;
for (i = 0; i < 6; bits <<= 1, i++) for (i = 0; i < NUM_STATS; bits <<= 1, i++)
{ {
evs[i] = 0; evs[i] = 0;
if (evBits & bits) if (evBits & bits)
@ -4953,7 +4953,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread;
for (k = 0, j = 0; j < 6; j++) for (k = 0, j = 0; j < NUM_STATS; j++)
{ {
allocatedArray[j] = 0; allocatedArray[j] = 0;
if (evBits & 1) if (evBits & 1)
@ -4962,7 +4962,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
} }
k = MAX_TOTAL_EVS / k; k = MAX_TOTAL_EVS / k;
evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread;
for (j = 0; j < 6; j++) for (j = 0; j < NUM_STATS; j++)
{ {
if (evBits & 1) if (evBits & 1)
allocatedArray[j] = k; allocatedArray[j] = k;

View File

@ -3095,7 +3095,7 @@ void SwitchInClearSetData(void)
if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS)
{ {
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
gBattleMons[gActiveBattler].statStages[i] = 6; gBattleMons[gActiveBattler].statStages[i] = 6;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
@ -3204,7 +3204,7 @@ void FaintClearSetData(void)
s32 i; s32 i;
u8 *ptr; u8 *ptr;
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
gBattleMons[gActiveBattler].statStages[i] = 6; gBattleMons[gActiveBattler].statStages[i] = 6;
gBattleMons[gActiveBattler].status2 = 0; gBattleMons[gActiveBattler].status2 = 0;
@ -3358,7 +3358,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void)
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].altAbility); gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].altAbility);
hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)];
*hpOnSwitchout = gBattleMons[gActiveBattler].hp; *hpOnSwitchout = gBattleMons[gActiveBattler].hp;
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
gBattleMons[gActiveBattler].statStages[i] = 6; gBattleMons[gActiveBattler].statStages[i] = 6;
gBattleMons[gActiveBattler].status2 = 0; gBattleMons[gActiveBattler].status2 = 0;
} }

View File

@ -3285,7 +3285,7 @@ static void atk23_getexp(void)
u16 calculatedExp; u16 calculatedExp;
s32 viaSentIn; s32 viaSentIn;
for (viaSentIn = 0, i = 0; i < 6; i++) for (viaSentIn = 0, i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0)
continue; continue;
@ -3543,7 +3543,7 @@ static void atk24(void)
} }
else else
{ {
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i]))) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
@ -3556,7 +3556,7 @@ static void atk24(void)
if (HP_count == 0) if (HP_count == 0)
gBattleOutcome |= B_OUTCOME_LOST; gBattleOutcome |= B_OUTCOME_LOST;
for (HP_count = 0, i = 0; i < 6; i++) for (HP_count = 0, i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i]))) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i])))
@ -4952,7 +4952,7 @@ static void atk4D_switchindataupdate(void)
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
{ {
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i]; gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i];
} }
@ -7406,7 +7406,7 @@ static void atk8A_normalisebuffs(void) // haze
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
for (j = 0; j < BATTLE_STATS_NO; j++) for (j = 0; j < NUM_BATTLE_STATS; j++)
gBattleMons[i].statStages[j] = 6; gBattleMons[i].statStages[j] = 6;
} }
@ -9034,7 +9034,7 @@ static void atkBD_copyfoestats(void) // psych up
{ {
s32 i; s32 i;
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
gBattleMons[gBattlerAttacker].statStages[i] = gBattleMons[gBattlerTarget].statStages[i]; gBattleMons[gBattlerAttacker].statStages[i] = gBattleMons[gBattlerTarget].statStages[i];
} }
@ -9868,7 +9868,7 @@ static void atkE5_pickup(void)
if (InBattlePyramid()) if (InBattlePyramid())
{ {
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
@ -9891,7 +9891,7 @@ static void atkE5_pickup(void)
} }
else else
{ {
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);

View File

@ -2616,7 +2616,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
gBattleStruct->moneyMultiplier = 2; gBattleStruct->moneyMultiplier = 2;
break; break;
case HOLD_EFFECT_RESTORE_STATS: case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
if (gBattleMons[battlerId].statStages[i] < 6) if (gBattleMons[battlerId].statStages[i] < 6)
{ {
@ -2687,7 +2687,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
} }
break; break;
case HOLD_EFFECT_RESTORE_STATS: case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
if (gBattleMons[battlerId].statStages[i] < 6) if (gBattleMons[battlerId].statStages[i] < 6)
{ {
@ -3163,7 +3163,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
} }
break; break;
case HOLD_EFFECT_RESTORE_STATS: case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < BATTLE_STATS_NO; i++) for (i = 0; i < NUM_BATTLE_STATS; i++)
{ {
if (gBattleMons[battlerId].statStages[i] < 6) if (gBattleMons[battlerId].statStages[i] < 6)
{ {

View File

@ -305,7 +305,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
u32 personality, pokerus; u32 personality, pokerus;
u8 i, friendship, language, gameMet, markings, obedience; u8 i, friendship, language, gameMet, markings, obedience;
u16 moves[4]; u16 moves[4];
u32 ivs[6]; u32 ivs[NUM_STATS];
species = GetMonData(egg, MON_DATA_SPECIES); species = GetMonData(egg, MON_DATA_SPECIES);
@ -317,7 +317,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
personality = GetMonData(egg, MON_DATA_PERSONALITY); personality = GetMonData(egg, MON_DATA_PERSONALITY);
for (i = 0; i < 6; i++) for (i = 0; i < NUM_STATS; i++)
{ {
ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i); ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i);
} }
@ -335,7 +335,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]); SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
} }
for (i = 0; i < 6; i++) for (i = 0; i < NUM_STATS; i++)
{ {
SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]); SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]);
} }

View File

@ -1306,7 +1306,7 @@ bool8 PartyHasMonWithSurf(void)
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
{ {
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE)
break; break;

View File

@ -2052,26 +2052,26 @@ _08139D7C:\n\
void sub_8139D98(void) void sub_8139D98(void)
{ {
u8 i; u8 i;
u32 ivStorage[6]; u32 ivStorage[NUM_STATS];
ivStorage[0] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV); ivStorage[STAT_HP] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV);
ivStorage[1] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV); ivStorage[STAT_ATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV);
ivStorage[2] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV); ivStorage[STAT_DEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV);
ivStorage[3] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV); ivStorage[STAT_SPEED] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV);
ivStorage[4] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV); ivStorage[STAT_SPATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV);
ivStorage[5] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV); ivStorage[STAT_SPDEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV);
gSpecialVar_0x8005 = 0; gSpecialVar_0x8005 = 0;
for (i = 0; i < ARRAY_COUNT(ivStorage); i++) for (i = 0; i < NUM_STATS; i++)
{ {
gSpecialVar_0x8005 += ivStorage[i]; gSpecialVar_0x8005 += ivStorage[i];
} }
gSpecialVar_0x8006 = 0; gSpecialVar_0x8006 = 0;
gSpecialVar_0x8007 = ivStorage[0]; // HP IV gSpecialVar_0x8007 = ivStorage[STAT_HP];
for (i = 1; i < 6; i++) for (i = 1; i < NUM_STATS; i++)
{ {
if (ivStorage[gSpecialVar_0x8006] < ivStorage[i]) if (ivStorage[gSpecialVar_0x8006] < ivStorage[i])
{ {
@ -2081,7 +2081,7 @@ void sub_8139D98(void)
else if (ivStorage[gSpecialVar_0x8006] == ivStorage[i]) else if (ivStorage[gSpecialVar_0x8006] == ivStorage[i])
{ {
u16 randomNumber = Random(); u16 randomNumber = Random();
if ((randomNumber & 1) != 0) if (randomNumber & 1)
{ {
gSpecialVar_0x8006 = i; gSpecialVar_0x8006 = i;
gSpecialVar_0x8007 = ivStorage[i]; gSpecialVar_0x8007 = ivStorage[i];

View File

@ -438,7 +438,7 @@ static void Task_Hof_InitMonData(u8 taskId)
gTasks[taskId].tMonNumber = 0; // valid pokes gTasks[taskId].tMonNumber = 0; // valid pokes
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u8 nick[POKEMON_NAME_LENGTH + 2]; u8 nick[POKEMON_NAME_LENGTH + 2];
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES))
@ -468,7 +468,7 @@ static void Task_Hof_InitMonData(u8 taskId)
gTasks[taskId].tDisplayedMonId = 0; gTasks[taskId].tDisplayedMonId = 0;
gTasks[taskId].tPlayerSpriteID = 0xFF; gTasks[taskId].tPlayerSpriteID = 0xFF;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = 0xFF;
} }
@ -642,7 +642,7 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
u16 i; u16 i;
BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0); BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0);
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (gTasks[taskId].tMonSpriteId(i) != 0xFF) if (gTasks[taskId].tMonSpriteId(i) != 0xFF)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0; gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0;
@ -665,7 +665,7 @@ static void sub_8173DC0(u8 taskId)
else else
{ {
u16 i; u16 i;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (gTasks[taskId].tMonSpriteId(i) != 0xFF) if (gTasks[taskId].tMonSpriteId(i) != 0xFF)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1;
@ -748,7 +748,7 @@ static void Task_Hof_HandleExit(u8 taskId)
{ {
s32 i; s32 i;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u8 spriteId = gTasks[taskId].tMonSpriteId(i); u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != 0xFF)
@ -844,7 +844,7 @@ void CB2_DoHallOfFamePC(void)
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
taskId = CreateTask(Task_HofPC_CopySaveData, 0); taskId = CreateTask(Task_HofPC_CopySaveData, 0);
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = 0xFF;
} }
@ -901,7 +901,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
gTasks[taskId].tCurrMonId = 0; gTasks[taskId].tCurrMonId = 0;
gTasks[taskId].tMonNo = 0; gTasks[taskId].tMonNo = 0;
for (i = 0; i < 6; i++, currMon++) for (i = 0; i < PARTY_SIZE; i++, currMon++)
{ {
if (currMon->species != 0) if (currMon->species != 0)
gTasks[taskId].tMonNo++; gTasks[taskId].tMonNo++;
@ -909,7 +909,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
currMon = &savedTeams->mon[0]; currMon = &savedTeams->mon[0];
for (i = 0; i < 6; i++, currMon++) for (i = 0; i < PARTY_SIZE; i++, currMon++)
{ {
if (currMon->species != 0) if (currMon->species != 0)
{ {
@ -963,7 +963,7 @@ static void Task_HofPC_PrintMonInfo(u8 taskId)
for (i = 0; i < gTasks[taskId].tCurrTeamNo; i++) for (i = 0; i < gTasks[taskId].tCurrTeamNo; i++)
savedTeams++; savedTeams++;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u16 spriteId = gTasks[taskId].tMonSpriteId(i); u16 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != 0xFF)
@ -1056,7 +1056,7 @@ static void Task_HofPC_HandleExit(u8 taskId)
{ {
u8 i; u8 i;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u16 spriteId = gTasks[taskId].tMonSpriteId(i); u16 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != 0xFF)

View File

@ -7,6 +7,7 @@
#include "constants/species.h" #include "constants/species.h"
#include "string_util.h" #include "string_util.h"
#include "text.h" #include "text.h"
#include "pokemon_storage_system.h"
static EWRAM_DATA u16 sWinNumberDigit = 0; static EWRAM_DATA u16 sWinNumberDigit = 0;
static EWRAM_DATA u16 sOtIdDigit = 0; static EWRAM_DATA u16 sOtIdDigit = 0;
@ -55,23 +56,23 @@ void PickLotteryCornerTicket(void)
gSpecialVar_0x8004 = 0; gSpecialVar_0x8004 = 0;
slot = 0; slot = 0;
box = 0; box = 0;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
struct Pokemon *pkmn = &gPlayerParty[i]; struct Pokemon *mon = &gPlayerParty[i];
// UB: Too few arguments for function GetMonData // UB: Too few arguments for function GetMonData
if (GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE)
{ {
// do not calculate ticket values for eggs. // do not calculate ticket values for eggs.
if (!GetMonData(pkmn, MON_DATA_IS_EGG)) if (!GetMonData(mon, MON_DATA_IS_EGG))
{ {
u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); u32 otId = GetMonData(mon, MON_DATA_OT_ID);
u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId); u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId);
if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1)
{ {
gSpecialVar_0x8004 = numMatchingDigits - 1; gSpecialVar_0x8004 = numMatchingDigits - 1;
box = 14; box = TOTAL_BOXES_COUNT;
slot = i; slot = i;
} }
} }
@ -80,11 +81,9 @@ void PickLotteryCornerTicket(void)
break; break;
} }
// player has 14 boxes. for (i = 0; i < TOTAL_BOXES_COUNT; i++)
for (i = 0; i < 14; i++)
{ {
// player has 30 slots per box. for (j = 0; j < IN_BOX_COUNT; j++)
for (j = 0; j < 30; j++)
{ {
if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SPECIES) != SPECIES_NONE && if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SPECIES) != SPECIES_NONE &&
!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_IS_EGG)) !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_IS_EGG))
@ -106,7 +105,7 @@ void PickLotteryCornerTicket(void)
{ {
gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1];
if (box == 14) if (box == TOTAL_BOXES_COUNT)
{ {
gSpecialVar_0x8006 = 0; gSpecialVar_0x8006 = 0;
GetMonData(&gPlayerParty[slot], MON_DATA_NICKNAME, gStringVar1); GetMonData(&gPlayerParty[slot], MON_DATA_NICKNAME, gStringVar1);

View File

@ -206,13 +206,13 @@ void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
if (index < 11 && ribbonId < 65) if (index < 11 && ribbonId < 65)
{ {
gSaveBlock1Ptr->giftRibbons[index] = ribbonId; gSaveBlock1Ptr->giftRibbons[index] = ribbonId;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
struct Pokemon *pkmn = &gPlayerParty[i]; struct Pokemon *mon = &gPlayerParty[i];
if (GetMonData(pkmn, MON_DATA_SPECIES) != 0 && GetMonData(pkmn, MON_DATA_SANITY_BIT3) == 0) if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_BIT3) == 0)
{ {
SetMonData(pkmn, array[index], &data); SetMonData(mon, array[index], &data);
gotRibbon = TRUE; gotRibbon = TRUE;
} }
} }

View File

@ -43,7 +43,7 @@ int GameClear(void)
ribbonGet = FALSE; ribbonGet = FALSE;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
struct Pokemon *mon = &gPlayerParty[i]; struct Pokemon *mon = &gPlayerParty[i];

View File

@ -1713,8 +1713,8 @@ bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx)
u8 i; u8 i;
u16 moveId = ScriptReadHalfword(ctx); u16 moveId = ScriptReadHalfword(ctx);
gSpecialVar_Result = 6; gSpecialVar_Result = PARTY_SIZE;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL);
if (!species) if (!species)