Merge pull request #125 from AsparagusEduardo/pret/doc/4_MaxMonMoves

Renamed MON_MOVES to MAX_MON_MOVES
This commit is contained in:
Akira Akashi 2023-05-20 15:35:42 +01:00 committed by GitHub
commit 643dfb8c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 54 additions and 53 deletions

View File

@ -3,7 +3,7 @@
// Value and data limits
#define MAX_LEVEL 100
#define MON_MOVES 4
#define MAX_MON_MOVES 4
#define MAX_EV 100
#define MAX_EV_SUM 510

View File

@ -3,6 +3,7 @@
#include "filesystem.h"
#include "seal_case.h"
#include "constants/pokemon.h"
typedef struct BaseStats {
/* 0x00 */ u8 hp;
@ -71,9 +72,9 @@ typedef struct {
} PokemonDataBlockA;
typedef struct {
/* 0x00 */ u16 moves[4];
/* 0x08 */ u8 movePP[4];
/* 0x0C */ u8 movePpUps[4];
/* 0x00 */ u16 moves[MAX_MON_MOVES];
/* 0x08 */ u8 movePP[MAX_MON_MOVES];
/* 0x0C */ u8 movePpUps[MAX_MON_MOVES];
/* 0x10 */ u32 hpIV:5, atkIV:5, defIV:5, spdIV:5, spatkIV:5, spdefIV:5, isEgg:1, isNicknamed:1;
// TODO: Finish HoennRibbonSet
/* 0x14 */ u32 ribbonFlags; // cool, ...
@ -193,9 +194,9 @@ struct UnkPokemonStruct_02072A98 {
/* 0x19 */ u8 spdEV;
/* 0x1A */ u8 spatkEV;
/* 0x1B */ u8 spdefEV;
/* 0x1C */ u16 moves[4];
/* 0x24 */ u8 movePP[4];
/* 0x28 */ u8 movePpUps[4];
/* 0x1C */ u16 moves[MAX_MON_MOVES];
/* 0x24 */ u8 movePP[MAX_MON_MOVES];
/* 0x28 */ u8 movePpUps[MAX_MON_MOVES];
/* 0x2C */ u32 hpIV:5;
u32 atkIV:5;
u32 defIV:5;

View File

@ -20,7 +20,7 @@ typedef struct TrainerHouseMon {
u16 species:11;
u16 forme:5;
u16 item;
u16 moves[MON_MOVES];
u16 moves[MAX_MON_MOVES];
u32 pid;
u32 otid;
u32 hpIv:5;

View File

@ -53,7 +53,7 @@ typedef struct TrainerMonSpeciesMoves {
u8 genderAbilityOverride;
u16 level;
u16 species;
u16 moves[MON_MOVES];
u16 moves[MAX_MON_MOVES];
u16 capsule;
} TRPOKE_NOITEM_CUSTMOVES;
@ -72,7 +72,7 @@ typedef struct TrainerMonSpeciesItemMoves {
u16 level;
u16 species;
u16 item;
u16 moves[MON_MOVES];
u16 moves[MAX_MON_MOVES];
u16 capsule;
} TRPOKE_ITEM_CUSTMOVES;

View File

@ -3879,7 +3879,7 @@ BOOL BtlCmd_TryAssist(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (i != ctx->selectedMonIndex[ctx->battlerIdAttacker]) {
mon = BattleSystem_GetPartyMon(bsys, ctx->battlerIdAttacker, i);
if (GetMonData(mon, MON_DATA_SPECIES2, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) != SPECIES_EGG) {
for (j = 0; j < 4; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
move = GetMonData(mon, MON_DATA_MOVE1 + j, 0);
if (ov12_02252698(move) == FALSE && CheckLegalMetronomeMove(bsys, ctx, ctx->battlerIdAttacker, move) == TRUE) {
avaliableMoves[moveCnt] = move;

View File

@ -14,7 +14,7 @@ void MoveRelearner_delete(struct MoveRelearner *moveRelearner) {
}
u16 *GetEligibleLevelUpMoves(POKEMON *pokemon, HeapID heapId) {
u16 cur_moveset[MON_MOVES]; // sp+10
u16 cur_moveset[MAX_MON_MOVES]; // sp+10
u16 species; // sp+0C
u8 forme; // sp+08
u8 level; // sp+04
@ -25,7 +25,7 @@ u16 *GetEligibleLevelUpMoves(POKEMON *pokemon, HeapID heapId) {
species = GetMonData(pokemon, MON_DATA_SPECIES, NULL);
forme = GetMonData(pokemon, MON_DATA_FORME, NULL);
level = GetMonData(pokemon, MON_DATA_LEVEL, NULL);
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
cur_moveset[i] = GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL);
}
@ -43,12 +43,12 @@ u16 *GetEligibleLevelUpMoves(POKEMON *pokemon, HeapID heapId) {
continue;
} else {
wotbl[i] &= WOTBL_MOVEID_MASK;
for (j = 0; j < MON_MOVES; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
if (wotbl[i] == cur_moveset[j]) {
break;
}
}
if (j == MON_MOVES) {
if (j == MAX_MON_MOVES) {
for (j = 0; j < ct; j++) {
if (ret[j] == wotbl[i]) {
break;

View File

@ -437,9 +437,9 @@ static u8 LoadEggMoves(POKEMON *pokemon, u16 *dest) {
}
struct EggMoveSearch {
int dad_moves[MON_MOVES];
int shared_moves[MON_MOVES];
int mom_moves[MON_MOVES];
int dad_moves[MAX_MON_MOVES];
int shared_moves[MAX_MON_MOVES];
int mom_moves[MAX_MON_MOVES];
u16 baby_learnset[50];
u16 baby_egg_moves[16];
};
@ -461,12 +461,12 @@ static void InheritMoves(POKEMON *egg, BOXMON *dad, BOXMON *mom) {
egg_species = GetMonData(egg, MON_DATA_SPECIES, NULL);
egg_forme = GetMonData(egg, MON_DATA_FORME, NULL);
learnset_size = Species_LoadLearnsetTable(egg_species, egg_forme, search->baby_learnset);
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
search->dad_moves[i] = GetBoxMonData(dad, MON_DATA_MOVE1 + i, NULL);
search->mom_moves[i] = GetBoxMonData(mom, MON_DATA_MOVE1 + i, NULL);
}
r5 = LoadEggMoves(egg, search->baby_egg_moves);
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (search->dad_moves[i] != MOVE_NONE) {
for (j = 0; j < r5; j++) {
if (search->dad_moves[i] == search->baby_egg_moves[j]) {
@ -480,7 +480,7 @@ static void InheritMoves(POKEMON *egg, BOXMON *dad, BOXMON *mom) {
break;
}
}
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (search->dad_moves[i] != MOVE_NONE) {
for (j = 0; j < 100; j++) {
if (search->dad_moves[i] == TMHMGetMove(j + ITEM_TM01)) {
@ -493,17 +493,17 @@ static void InheritMoves(POKEMON *egg, BOXMON *dad, BOXMON *mom) {
}
}
}
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (search->dad_moves[i] == MOVE_NONE) {
break;
}
for (j = 0; j < MON_MOVES; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
if (search->dad_moves[i] == search->mom_moves[j] && search->dad_moves[i] != MOVE_NONE) {
search->shared_moves[sp1C++] = search->dad_moves[i];
}
}
}
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (search->shared_moves[i] == MOVE_NONE) {
break;
}
@ -1005,8 +1005,8 @@ u8 Sav2_DayCare_CalcCompatibility(DAYCARE *dayCare) {
}
static void sub_0206D038(POKEMON *pokemon, HeapID heapId) {
u16 moves[MON_MOVES];
u8 pp[MON_MOVES];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
u32 otId;
u8 ivs[NUM_STATS];
u16 metLoc;
@ -1030,7 +1030,7 @@ static void sub_0206D038(POKEMON *pokemon, HeapID heapId) {
string = String_ctor(PLAYER_NAME_LENGTH + 1, heapId);
tmpMon = AllocMonZeroed(heapId);
species = (u16)GetMonData(pokemon, MON_DATA_SPECIES, NULL);
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
moves[i] = GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL);
pp[i] = GetMonData(pokemon, MON_DATA_MOVE1PP + i, NULL);
}
@ -1055,7 +1055,7 @@ static void sub_0206D038(POKEMON *pokemon, HeapID heapId) {
}
}
CreateMon(tmpMon, species, 1, 32, TRUE, pid, OT_ID_PLAYER_ID, 0);
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
SetMonData(tmpMon, MON_DATA_MOVE1 + i, &moves[i]);
SetMonData(tmpMon, MON_DATA_MOVE1PP + i, &pp[i]);
}

View File

@ -3071,7 +3071,7 @@ u32 TryAppendBoxMonMove(BOXMON *boxmon, u16 move) {
int i;
BOOL decry = AcquireBoxMonLock(boxmon);
u16 cur_move;
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
cur_move = (u16)GetBoxMonData(boxmon, MON_DATA_MOVE1 + i, NULL);
if (cur_move == MOVE_NONE) {
BoxMonSetMoveInSlot(boxmon, move, (u8)i);
@ -3094,11 +3094,11 @@ void DeleteMonFirstMoveAndAppend(POKEMON *pokemon, u16 move_id) {
void DeleteBoxMonFirstMoveAndAppend(BOXMON * boxmon, u16 move) {
BOOL decry = AcquireBoxMonLock(boxmon);
int i;
u16 moves[4];
u8 pp[4];
u8 ppUp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
u8 ppUp[MAX_MON_MOVES];
for (i = 0; i < 3; i++) {
for (i = 0; i < MAX_MON_MOVES - 1; i++) {
moves[i] = (u16)GetBoxMonData(boxmon, MON_DATA_MOVE1 + i + 1, NULL);
pp[i] = (u8)GetBoxMonData(boxmon, MON_DATA_MOVE1PP + i + 1, NULL);
ppUp[i] = (u8)GetBoxMonData(boxmon, MON_DATA_MOVE1PPUP + i + 1, NULL);
@ -3108,7 +3108,7 @@ void DeleteBoxMonFirstMoveAndAppend(BOXMON * boxmon, u16 move) {
pp[3] = (u8)GetMoveAttr(move, MOVEATTR_PP);
ppUp[3] = 0;
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
SetBoxMonData(boxmon, MON_DATA_MOVE1 + i, &moves[i]);
SetBoxMonData(boxmon, MON_DATA_MOVE1PP + i, &pp[i]);
SetBoxMonData(boxmon, MON_DATA_MOVE1PPUP + i, &ppUp[i]);
@ -3198,7 +3198,7 @@ void MonDeleteMoveSlot(POKEMON * pokemon, u32 slot) {
u16 move;
u8 pp;
u8 ppUp;
for (; slot < 3; slot++) {
for (; slot < MAX_MON_MOVES - 1; slot++) {
move = (u16)GetMonData(pokemon, (int)(MON_DATA_MOVE1 + slot + 1), NULL);
pp = (u8)GetMonData(pokemon, (int)(MON_DATA_MOVE1PP + slot + 1), NULL);
ppUp = (u8)GetMonData(pokemon, (int)(MON_DATA_MOVE1PPUP + slot + 1), NULL);
@ -3216,12 +3216,12 @@ void MonDeleteMoveSlot(POKEMON * pokemon, u32 slot) {
BOOL MonHasMove(POKEMON* pokemon, u16 move) {
int i;
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL) == move) {
break;
}
}
if (i != 4) {
if (i != MAX_MON_MOVES) {
return TRUE;
} else {
return FALSE;
@ -3632,7 +3632,7 @@ BOOL Mon_UpdateRotomForme(POKEMON *pokemon, int forme, int defaultSlot) {
}
GetMonData(pokemon, MON_DATA_FORME, NULL);
new_move = forme_moves[forme];
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
cur_move = GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL);
for (j = ROTOM_HEAT; j < (unsigned)ROTOM_FORME_MAX; j++) {
if (cur_move != MOVE_NONE && cur_move == forme_moves[j]) {
@ -3648,13 +3648,13 @@ BOOL Mon_UpdateRotomForme(POKEMON *pokemon, int forme, int defaultSlot) {
}
}
if (new_move != MOVE_NONE) {
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL) == MOVE_NONE) {
MonSetMoveInSlot_ResetPpUp(pokemon, new_move, i);
break;
}
}
if (i == MON_MOVES) {
if (i == MAX_MON_MOVES) {
MonSetMoveInSlot_ResetPpUp(pokemon, new_move, defaultSlot);
}
}
@ -4178,7 +4178,7 @@ void RestoreBoxMonPP(BOXMON * boxmon) {
int i;
u8 pp;
BOOL decry = AcquireBoxMonLock(boxmon);
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (GetBoxMonData(boxmon, MON_DATA_MOVE1 + i, NULL) != MOVE_NONE) {
pp = (u8)GetBoxMonData(boxmon, MON_DATA_MOVE1MAXPP + i, NULL);
SetBoxMonData(boxmon, MON_DATA_MOVE1PP + i, &pp);
@ -4283,7 +4283,7 @@ void sub_02072A98(POKEMON *pokemon, struct UnkPokemonStruct_02072A98 *dest) {
dest->spdefEV = dbA->spdefEV;
dest->originLanguage = dbA->originLanguage;
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
dest->moves[i] = dbB->moves[i];
dest->movePP[i] = dbB->movePP[i];
dest->movePpUps[i] = dbB->movePpUps[i];
@ -4360,7 +4360,7 @@ void sub_02072D64(const struct UnkPokemonStruct_02072A98 *src, POKEMON *pokemon)
dbA->spdefEV = src->spdefEV;
dbA->originLanguage = src->originLanguage;
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
dbB->moves[i] = src->moves[i];
dbB->movePP[i] = src->movePP[i];
dbB->movePpUps[i] = src->movePpUps[i];

View File

@ -1026,14 +1026,14 @@ BOOL ScrCmd_GiveTogepiEgg(SCRIPTCONTEXT *ctx) {
SetEggStats(togepi, SPECIES_TOGEPI, 1, profile, 3, sub_02017FE4(1, 0xd));
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (!GetMonData(togepi, MON_DATA_MOVE1 + i, 0)) {
break;
}
}
if (i == 4) {
i = 3;
if (i == MAX_MON_MOVES) {
i = MAX_MON_MOVES - 1;
}
moveData = MOVE_EXTRASENSORY;
@ -1092,7 +1092,7 @@ BOOL ScrCmd_GiveSpikyEarPichu(SCRIPTCONTEXT *ctx) {
forme = 1;
SetMonData(pichu, MON_DATA_FORME, &forme);
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
SetMonData(pichu, MON_DATA_MOVE1 + i, &sSpikyEarPichuMoveset[i]);
maxPP = GetMonData(pichu, MON_DATA_MOVE1MAXPP + i, 0);
SetMonData(pichu, MON_DATA_MOVE1PP + i, &maxPP);

View File

@ -362,7 +362,7 @@ void CreateNPCTrainerParty(BATTLE_SETUP *enemies, int party_id, HeapID heap_id)
personality = (personality << 8) + pid_gender;
iv = (u8)((monSpeciesMoves[i].difficulty * 31) / 255);
CreateMon(pokemon, species, monSpeciesMoves[i].level, iv, TRUE, (s32)personality, OT_ID_RANDOM_NO_SHINY, 0);
for (j = 0; j < MON_MOVES; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
MonSetMoveInSlot(pokemon, monSpeciesMoves[i].moves[j], (u8)j);
}
SetTrMonCapsule(monSpeciesMoves[i].capsule, pokemon, heap_id);
@ -415,7 +415,7 @@ void CreateNPCTrainerParty(BATTLE_SETUP *enemies, int party_id, HeapID heap_id)
iv = (u8)((monSpeciesItemMoves[i].difficulty * 31) / 255);
CreateMon(pokemon, species, monSpeciesItemMoves[i].level, iv, TRUE, (s32)personality, OT_ID_RANDOM_NO_SHINY, 0);
SetMonData(pokemon, MON_DATA_HELD_ITEM, &monSpeciesItemMoves[i].item);
for (j = 0; j < MON_MOVES; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
MonSetMoveInSlot(pokemon, monSpeciesItemMoves[i].moves[j], (u8)j);
}
SetTrMonCapsule(monSpeciesItemMoves[i].capsule, pokemon, heap_id);
@ -455,7 +455,7 @@ void TrMon_FrustrationCheckAndSetFriendship(POKEMON *pokemon) {
u8 friendship = FRIENDSHIP_MAX;
int i;
for (i = 0; i < MON_MOVES; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (GetMonData(pokemon, MON_DATA_MOVE1 + i, NULL) == MOVE_FRUSTRATION) {
friendship = 0;
}

View File

@ -85,7 +85,7 @@ BOOL CanUseItemOnPokemon(POKEMON *pokemon, u16 itemID, s32 moveIdx, HeapID heapI
}
if (GetItemAttr_PreloadedItemData(itemData, ITEMATTR_PP_RESTORE_ALL)) {
for (int i = 0; i < MON_MOVES; i++) {
for (int i = 0; i < MAX_MON_MOVES; i++) {
if (MonMoveCanRestorePP(pokemon, i) == TRUE) {
FreeToHeap(itemData);
return TRUE;
@ -322,7 +322,7 @@ BOOL UseItemOnPokemon(POKEMON *pokemon, u16 itemID, u16 moveIdx, u16 location, H
effectFound = TRUE;
} else if (GetItemAttr_PreloadedItemData(itemData, ITEMATTR_PP_RESTORE_ALL)) {
sp54 = 0;
for (; sp54 < MON_MOVES; sp54++) {
for (; sp54 < MAX_MON_MOVES; sp54++) {
if (MonMoveRestorePP(pokemon, sp54, GetItemAttr_PreloadedItemData(itemData, ITEMATTR_PP_RESTORE_PARAM)) == 1) {
hadEffect = TRUE;
}
@ -657,7 +657,7 @@ void HealParty(PARTY * party) {
sp8 = 0;
SetMonData(pokemon, MON_DATA_STATUS, &sp8);
for (j = 0; j < MON_MOVES; j++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
if (MonMoveCanRestorePP(pokemon, j) == 1) {
MonMoveRestorePP(pokemon, j, PP_RESTORE_ALL);
}