mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Merge record mixing, pokemon and global with apprentice
This commit is contained in:
parent
74b81bf229
commit
a496a763ca
File diff suppressed because it is too large
Load Diff
@ -576,7 +576,7 @@ _0816266C:
|
||||
b _081626BA
|
||||
.pool
|
||||
_08162698:
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -747,7 +747,7 @@ _081627E8:
|
||||
b _08162836
|
||||
.pool
|
||||
_08162814:
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -1161,7 +1161,7 @@ _08162B64:
|
||||
cmp r0, 0
|
||||
bne _08162BB0
|
||||
ldr r4, =gFacilityClassToPicIndex
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -1184,7 +1184,7 @@ _08162B64:
|
||||
.pool
|
||||
_08162BB0:
|
||||
ldr r5, =gFacilityClassToPicIndex
|
||||
ldr r4, =gUnknown_08610970
|
||||
ldr r4, =gApprentices
|
||||
bl sub_81864A8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
@ -1301,7 +1301,7 @@ _08162CBC:
|
||||
cmp r0, 0
|
||||
beq _08162CF4
|
||||
ldr r5, =gFacilityClassToTrainerClass
|
||||
ldr r4, =gUnknown_08610970
|
||||
ldr r4, =gApprentices
|
||||
bl sub_81864A8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
@ -1316,7 +1316,7 @@ _08162CBC:
|
||||
.pool
|
||||
_08162CF4:
|
||||
ldr r4, =gFacilityClassToTrainerClass
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -1407,7 +1407,7 @@ _08162DC0:
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08162DE8
|
||||
ldr r4, =gUnknown_08610970
|
||||
ldr r4, =gApprentices
|
||||
bl sub_81864A8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
@ -1417,7 +1417,7 @@ _08162DC0:
|
||||
b _08162E08
|
||||
.pool
|
||||
_08162DE8:
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -1648,7 +1648,7 @@ _08162FC0:
|
||||
b _0816300E
|
||||
.pool
|
||||
_08162FEC:
|
||||
ldr r3, =gUnknown_08610970
|
||||
ldr r3, =gApprentices
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0xfffffe70
|
||||
@ -1927,7 +1927,7 @@ _08163230:
|
||||
ldr r1, [r6]
|
||||
adds r1, r5
|
||||
lsrs r2, r4, 24
|
||||
bl sub_8068528
|
||||
bl CreateApprenticeMon
|
||||
movs r2, 0x80
|
||||
lsls r2, 17
|
||||
adds r4, r2
|
||||
@ -6295,7 +6295,7 @@ _08165812:
|
||||
adds r0, r5
|
||||
ldrb r2, [r0]
|
||||
adds r0, r4, 0
|
||||
bl sub_8068528
|
||||
bl CreateApprenticeMon
|
||||
movs r3, 0xC8
|
||||
lsls r3, 1
|
||||
adds r0, r7, r3
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
.align 2 @ struct, eight bytes x6 for names in different languages, then 0x28 more bytes of data
|
||||
gUnknown_08610970:: @ 8610970
|
||||
gApprentices:: @ 8610970
|
||||
.string "サダヒロ$", 8
|
||||
.string "ALANN$", 8
|
||||
.string "ALAIN$", 8
|
||||
|
17
include/apprentice.h
Normal file
17
include/apprentice.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef GUARD_APPRENTICE_H
|
||||
#define GUARD_APPRENTICE_H
|
||||
|
||||
#define APPRENTICE_SPECIES_COUNT 10
|
||||
|
||||
struct ApprenticeTrainer
|
||||
{
|
||||
u8 name[6][PLAYER_NAME_LENGTH + 1]; // For all six languages.
|
||||
u16 otId;
|
||||
u16 facilityClass;
|
||||
u16 species[APPRENTICE_SPECIES_COUNT];
|
||||
u8 rest[14];
|
||||
};
|
||||
|
||||
extern const struct ApprenticeTrainer gApprentices[];
|
||||
|
||||
#endif // GUARD_APPRENTICE_H
|
@ -295,13 +295,21 @@ struct UnknownSaveBlock2Struct
|
||||
u8 field_EB;
|
||||
}; // sizeof = 0xEC
|
||||
|
||||
struct UnkRecordMixingStruct
|
||||
struct ApprenticeMon
|
||||
{
|
||||
u16 species;
|
||||
u16 moves[4];
|
||||
u16 item;
|
||||
};
|
||||
|
||||
struct Apprentice
|
||||
{
|
||||
u8 field_0_0:5;
|
||||
u8 field_0_1:2;
|
||||
u8 field_1;
|
||||
u8 field_2;
|
||||
u8 field_3[37];
|
||||
u8 field_3;
|
||||
struct ApprenticeMon monData[3];
|
||||
u16 unk28[6];
|
||||
u8 playerId[4];
|
||||
u8 playerName[PLAYER_NAME_LENGTH];
|
||||
@ -473,6 +481,15 @@ struct BattleFrontier
|
||||
/*0xEFC*/ struct FrontierMonData field_EFC[3];
|
||||
};
|
||||
|
||||
struct Sav2_B8
|
||||
{
|
||||
u8 unk0_0:2;
|
||||
u8 unk0_1:2;
|
||||
u8 unk0_2:2;
|
||||
u8 unk0_3:2;
|
||||
u16 unk2;
|
||||
};
|
||||
|
||||
struct SaveBlock2
|
||||
{
|
||||
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
|
||||
@ -500,12 +517,14 @@ struct SaveBlock2
|
||||
// TODO: fix and verify labels
|
||||
/*0xB0*/ u8 field_B0;
|
||||
/*0xB1*/ u8 field_B1_0:2;
|
||||
/*0xB1*/ u8 field_B1_1:6;
|
||||
/*0xB1*/ u8 field_B1_1:4;
|
||||
/*0xB1*/ u8 field_B1_2:2;
|
||||
/*0xB2*/ u8 field_B2_0:3;
|
||||
/*0xB2*/ u8 field_B2_1:2;
|
||||
/*0xB3*/ u8 field_B3;
|
||||
/*0xB4*/ u8 field_B4[0x28];
|
||||
/*0xDC*/ struct UnkRecordMixingStruct field_DC[4];
|
||||
/*0xB4*/ u8 field_B4[3];
|
||||
/*0xB8*/ struct Sav2_B8 field_B8[9];
|
||||
/*0xDC*/ struct Apprentice field_DC[4];
|
||||
/*0x1EC*/ struct BerryCrush berryCrush;
|
||||
/*0x1FC*/ struct PokemonJumpResults pokeJump;
|
||||
/*0x20C*/ struct BerryPickingResults berryPick;
|
||||
|
@ -240,32 +240,6 @@ struct PokemonStorage
|
||||
/*0x83C2*/ u8 boxWallpapers[14];
|
||||
};
|
||||
|
||||
struct UnknownPokemonSubStruct2
|
||||
{
|
||||
u16 species;
|
||||
u16 moves[4];
|
||||
u16 item;
|
||||
};
|
||||
|
||||
struct UnknownPokemonStruct2
|
||||
{
|
||||
u8 field_0_0 : 5;
|
||||
u8 field_0_1 : 2;
|
||||
u8 field_1;
|
||||
u8 field_2;
|
||||
u8 field_3;
|
||||
struct UnknownPokemonSubStruct2 mons[3];
|
||||
u8 field_28[23];
|
||||
u8 language;
|
||||
};
|
||||
|
||||
struct UnknownPokemonStruct3
|
||||
{
|
||||
u8 field_0[48];
|
||||
u16 field_30;
|
||||
u8 field_32[38];
|
||||
};
|
||||
|
||||
struct Unknown_806F160_Struct
|
||||
{
|
||||
u8 field_0_0:4;
|
||||
@ -472,7 +446,7 @@ void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u
|
||||
void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread);
|
||||
void sub_806819C(struct Pokemon *mon, struct UnknownPokemonStruct *src);
|
||||
void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lvl50);
|
||||
void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u8 monId);
|
||||
void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId);
|
||||
void CreateMonWithEVSpreadPersonalityOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId);
|
||||
void sub_80686FC(struct Pokemon *mon, struct UnknownPokemonStruct *dest);
|
||||
void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
|
||||
|
@ -13,5 +13,6 @@ s32 convert_pixel_width_to_tile_width(s32);
|
||||
u8 CreateWindowFromRect(u8, u8, u8, u8);
|
||||
void sub_80E2A78(u8);
|
||||
u32 display_text_and_get_width(const u8*, u32);
|
||||
u8 sub_80E2D5C(u8 arg0, u8 tileWidth);
|
||||
|
||||
#endif //GUARD_SCRIPT_MENU_H
|
||||
|
@ -247,6 +247,7 @@ SECTIONS {
|
||||
asm/battle_frontier_1.o(.text);
|
||||
src/menu.o(.text);
|
||||
src/battle_factory.o(.text);
|
||||
src/battle_frontier_2.o(.text);
|
||||
asm/battle_frontier_2.o(.text);
|
||||
src/item_menu.o(.text);
|
||||
src/list_menu.o(.text);
|
||||
|
@ -1,23 +1,53 @@
|
||||
#include "global.h"
|
||||
#include "apprentice.h"
|
||||
#include "string_util.h"
|
||||
#include "script.h"
|
||||
#include "text.h"
|
||||
#include "random.h"
|
||||
#include "main.h"
|
||||
#include "malloc.h"
|
||||
#include "strings.h"
|
||||
#include "menu.h"
|
||||
#include "script_menu.h"
|
||||
#include "party_menu.h"
|
||||
#include "data2.h"
|
||||
#include "constants/items.h"
|
||||
|
||||
struct Unk030062ECStruct
|
||||
{
|
||||
u8 unk0;
|
||||
u16 unk2[3][5];
|
||||
u8 unk20[3][5];
|
||||
};
|
||||
|
||||
struct Unk030062F0Struct
|
||||
{
|
||||
u16 unk0;
|
||||
u16 unk2;
|
||||
u16 unk4;
|
||||
u16 unk6;
|
||||
};
|
||||
|
||||
extern struct Unk030062ECStruct *gUnknown_030062EC;
|
||||
extern struct Unk030062F0Struct *gUnknown_030062F0;
|
||||
|
||||
extern const u8 *const gUnknown_08611330[];
|
||||
extern const u8 gUnknown_08611548[8];
|
||||
extern const u8 gUnknown_086114D3[];
|
||||
extern const bool8 gUnknown_08611370[];
|
||||
|
||||
// text
|
||||
extern const u8 gText_Give[];
|
||||
extern const u8 gText_NoNeed[];
|
||||
extern const u8 gText_Yes[];
|
||||
extern const u8 gText_No[];
|
||||
|
||||
// This file's functions.
|
||||
void sub_81A087C(void);
|
||||
u16 sub_819FF98(u8 arg0);
|
||||
bool8 sub_81A0194(u8 arg0, u16 moveId);
|
||||
void sub_81A0804(u8 arg0, u8 itemsCount, u8 windowId);
|
||||
u8 sub_81A0784(u8 arg0, u8 arg1, u8 arg2, u8 arg3);
|
||||
|
||||
void sub_819F99C(u8 id)
|
||||
{
|
||||
@ -42,15 +72,15 @@ void sub_819FA50(void)
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
void sub_819FA5C(struct UnkRecordMixingStruct *structPtr)
|
||||
void sub_819FA5C(struct Apprentice *apprentice)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
structPtr->unk28[i] |= 0xFFFF;
|
||||
apprentice->unk28[i] |= 0xFFFF;
|
||||
|
||||
structPtr->playerName[0] = EOS;
|
||||
structPtr->field_0_0 = 16;
|
||||
apprentice->playerName[0] = EOS;
|
||||
apprentice->field_0_0 = 16;
|
||||
}
|
||||
|
||||
void sub_819FAA0(void)
|
||||
@ -149,3 +179,385 @@ u8 sub_819FCF8(u8 val, u8 *arg1, u8 *arg2)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sub_819FD64(void)
|
||||
{
|
||||
u8 sp_0[10];
|
||||
u8 sp_C[3];
|
||||
u8 sp_10;
|
||||
u8 i, j;
|
||||
u8 rand1, rand2;
|
||||
u8 id;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
sp_C[i] = i;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
u8 temp;
|
||||
rand1 = Random() % ARRAY_COUNT(sp_C);
|
||||
rand2 = Random() % ARRAY_COUNT(sp_C);
|
||||
SWAP(sp_C[rand1], sp_C[rand2], temp);
|
||||
}
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
sp_0[i] = gUnknown_086114D3[i];
|
||||
for (i = 0; i < 50; i++)
|
||||
{
|
||||
u8 temp;
|
||||
rand1 = Random() % ARRAY_COUNT(sp_0);
|
||||
rand2 = Random() % ARRAY_COUNT(sp_0);
|
||||
SWAP(sp_0[rand1], sp_0[rand2], temp);
|
||||
}
|
||||
|
||||
gUnknown_030062EC = AllocZeroed(sizeof(*gUnknown_030062EC));
|
||||
gUnknown_030062EC->unk0 = 0;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
gUnknown_030062EC->unk20[j][i] = 4;
|
||||
}
|
||||
|
||||
sp_10 = 0;
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
gSaveBlock2Ptr->field_B8[i].unk0_0 = sp_0[i];
|
||||
if (sp_0[i] != 3)
|
||||
{
|
||||
gSaveBlock2Ptr->field_B8[i].unk0_1 = sub_819FCF8(sp_0[i], sp_C, &sp_10);
|
||||
id = gSaveBlock2Ptr->field_B8[i].unk0_1;
|
||||
if (sp_0[i] == 2)
|
||||
{
|
||||
do
|
||||
{
|
||||
rand1 = Random() % 4;
|
||||
for (j = 0; j < gUnknown_030062EC->unk0 + 1; j++)
|
||||
{
|
||||
if (gUnknown_030062EC->unk20[id][j] == rand1)
|
||||
break;
|
||||
}
|
||||
} while (j != gUnknown_030062EC->unk0 + 1);
|
||||
|
||||
gUnknown_030062EC->unk20[id][gUnknown_030062EC->unk0] = rand1;
|
||||
gSaveBlock2Ptr->field_B8[i].unk0_2 = rand1;
|
||||
gSaveBlock2Ptr->field_B8[i].unk2 = sub_819FF98(gSaveBlock2Ptr->field_B8[i].unk0_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FREE_AND_SET_NULL(gUnknown_030062EC);
|
||||
}
|
||||
|
||||
// No idea why a do-while loop is needed, but it will not match without it.
|
||||
|
||||
#define APPRENTICE_SPECIES_ID(speciesArrId, monId) speciesArrId = (gSaveBlock2Ptr->field_B4[monId] >> \
|
||||
(((gSaveBlock2Ptr->field_B2_0 >> monId) & 1) << 2)) & 0xF; \
|
||||
do {} while (0)
|
||||
|
||||
u16 sub_819FF98(u8 arg0)
|
||||
{
|
||||
u8 i, j;
|
||||
u8 id;
|
||||
u8 knownMovesCount;
|
||||
u16 species;
|
||||
const u16 *learnset;
|
||||
bool32 var_24 = FALSE;
|
||||
u16 moveId = 0;
|
||||
bool32 valid;
|
||||
u8 level;
|
||||
|
||||
if (arg0 < 3)
|
||||
{
|
||||
APPRENTICE_SPECIES_ID(id, arg0);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
species = gApprentices[gSaveBlock2Ptr->field_B0].species[id];
|
||||
learnset = gLevelUpLearnsets[species];
|
||||
j = 0;
|
||||
if (gSaveBlock2Ptr->field_B1_0 == 1)
|
||||
level = 50;
|
||||
else
|
||||
level = 60;
|
||||
|
||||
for (j = 0; learnset[j] != 0xFFFF; j++)
|
||||
{
|
||||
if ((learnset[j] & 0xFE00) > (level << 9))
|
||||
break;
|
||||
}
|
||||
|
||||
knownMovesCount = j;
|
||||
i = 0;
|
||||
while (i < 5)
|
||||
{
|
||||
if (Random() % 2 == 0 || var_24 == TRUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
id = Random() % (NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES);
|
||||
valid = CanSpeciesLearnTMHM(species, id);
|
||||
}
|
||||
while (!valid);
|
||||
|
||||
moveId = ItemIdToBattleMoveId(ITEM_TM01 + id);
|
||||
valid = TRUE;
|
||||
|
||||
if (knownMovesCount < 5)
|
||||
j = 0;
|
||||
else
|
||||
j = knownMovesCount - 4;
|
||||
|
||||
for (; j < knownMovesCount; j++)
|
||||
{
|
||||
if ((learnset[j] & 0x1FF) == moveId)
|
||||
{
|
||||
valid = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (valid != TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (knownMovesCount < 5)
|
||||
{
|
||||
var_24 = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
u8 learnsetId = Random() % (knownMovesCount - 4);
|
||||
moveId = learnset[learnsetId] & 0x1FF;
|
||||
valid = TRUE;
|
||||
for (j = knownMovesCount - 4; j < knownMovesCount; j++)
|
||||
{
|
||||
if ((learnset[j] & 0x1FF) == moveId)
|
||||
{
|
||||
valid = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (valid != TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (sub_81A0194(arg0, moveId))
|
||||
{
|
||||
if (gUnknown_08611370[moveId])
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
gUnknown_030062EC->unk0++;
|
||||
return moveId;
|
||||
}
|
||||
|
||||
bool8 sub_81A0194(u8 arg0, u16 moveId)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
if (gUnknown_030062EC->unk2[arg0][i] == moveId)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gUnknown_030062EC->unk2[arg0][gUnknown_030062EC->unk0] = moveId;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void GetLatestLearnedMoves(u16 species, u16 *moves)
|
||||
{
|
||||
u8 i, j;
|
||||
u8 level, knownMovesCount;
|
||||
const u16 *learnset;
|
||||
|
||||
if (gSaveBlock2Ptr->field_B1_0 == 1)
|
||||
level = 50;
|
||||
else
|
||||
level = 60;
|
||||
|
||||
learnset = gLevelUpLearnsets[species];
|
||||
for (i = 0; learnset[i] != 0xFFFF; i++)
|
||||
{
|
||||
if ((learnset[i] & 0xFE00) > (level << 9))
|
||||
break;
|
||||
}
|
||||
|
||||
knownMovesCount = i;
|
||||
if (knownMovesCount > 4)
|
||||
knownMovesCount = 4;
|
||||
|
||||
for (j = 0; j < knownMovesCount; j++)
|
||||
moves[j] = learnset[(i - 1) - j] & 0x1FF;
|
||||
}
|
||||
|
||||
u16 sub_81A0284(u8 arg0, u8 speciesTableId, u8 arg2)
|
||||
{
|
||||
u16 moves[4];
|
||||
u8 i, count;
|
||||
|
||||
if (gSaveBlock2Ptr->field_B1_1 < 3)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
if (gSaveBlock2Ptr->field_B8[i].unk0_0 == 0)
|
||||
break;
|
||||
count++;
|
||||
}
|
||||
|
||||
GetLatestLearnedMoves(gApprentices[gSaveBlock2Ptr->field_B0].species[speciesTableId], moves);
|
||||
for (i = 0; i < count && i < gSaveBlock2Ptr->field_B1_1 - 3; i++)
|
||||
{
|
||||
if (gSaveBlock2Ptr->field_B8[i].unk0_0 == 2
|
||||
&& gSaveBlock2Ptr->field_B8[i].unk0_1 == arg0
|
||||
&& gSaveBlock2Ptr->field_B8[i].unk0_3 != 0)
|
||||
{
|
||||
moves[gSaveBlock2Ptr->field_B8[i].unk0_2] = gSaveBlock2Ptr->field_B8[i].unk2;
|
||||
}
|
||||
}
|
||||
|
||||
return moves[arg2];
|
||||
}
|
||||
|
||||
void sub_81A0390(u8 arg0)
|
||||
{
|
||||
struct ApprenticeMon *apprenticeMons[3];
|
||||
u8 i, j;
|
||||
u32 speciesTableId;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
gSaveBlock2Ptr->field_DC[0].monData[i].species = 0;
|
||||
gSaveBlock2Ptr->field_DC[0].monData[i].item = 0;
|
||||
for (j = 0; j < 4; j++)
|
||||
gSaveBlock2Ptr->field_DC[0].monData[i].moves[j] = 0;
|
||||
}
|
||||
|
||||
j = gSaveBlock2Ptr->field_B1_2;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
apprenticeMons[j] = &gSaveBlock2Ptr->field_DC[0].monData[i];
|
||||
j = (j + 1) % 3;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
APPRENTICE_SPECIES_ID(speciesTableId, i);
|
||||
apprenticeMons[i]->species = gApprentices[gSaveBlock2Ptr->field_B0].species[speciesTableId];
|
||||
GetLatestLearnedMoves(apprenticeMons[i]->species, apprenticeMons[i]->moves);
|
||||
}
|
||||
|
||||
for (i = 0; i < arg0; i++)
|
||||
{
|
||||
u8 var1 = gSaveBlock2Ptr->field_B8[i].unk0_0;
|
||||
u8 monId = gSaveBlock2Ptr->field_B8[i].unk0_1;
|
||||
if (var1 == 1)
|
||||
{
|
||||
if (gSaveBlock2Ptr->field_B8[i].unk0_3 != 0)
|
||||
apprenticeMons[monId]->item = gSaveBlock2Ptr->field_B8[i].unk2;
|
||||
}
|
||||
else if (var1 == 2)
|
||||
{
|
||||
if (gSaveBlock2Ptr->field_B8[i].unk0_3 != 0)
|
||||
{
|
||||
u32 moveSlot = gSaveBlock2Ptr->field_B8[i].unk0_2;
|
||||
apprenticeMons[monId]->moves[moveSlot] = gSaveBlock2Ptr->field_B8[i].unk2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81A04E4(u8 arg0)
|
||||
{
|
||||
u8 i;
|
||||
u8 windowId;
|
||||
const u8 *strings[3];
|
||||
u8 count = 2;
|
||||
u8 tileWidth;
|
||||
u8 r10;
|
||||
u8 r6;
|
||||
s32 pixelWidth;
|
||||
|
||||
switch (arg0)
|
||||
{
|
||||
case 0:
|
||||
r10 = 0x12;
|
||||
r6 = 8;
|
||||
strings[0] = gText_Lv50;
|
||||
strings[1] = gText_OpenLevel;
|
||||
break;
|
||||
case 1:
|
||||
count = 3;
|
||||
r10 = 0x12;
|
||||
r6 = 6;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
u16 species;
|
||||
u32 speciesTableId;
|
||||
|
||||
APPRENTICE_SPECIES_ID(speciesTableId, i);
|
||||
species = gApprentices[gSaveBlock2Ptr->field_B0].species[speciesTableId];
|
||||
strings[i] = gSpeciesNames[species];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
r10 = 0x12;
|
||||
r6 = 8;
|
||||
if (gSaveBlock2Ptr->field_B1_1 > 2)
|
||||
return;
|
||||
strings[1] = gSpeciesNames[gUnknown_030062F0->unk2];
|
||||
strings[0] = gSpeciesNames[gUnknown_030062F0->unk0];
|
||||
break;
|
||||
case 3:
|
||||
r10 = 0x11;
|
||||
r6 = 8;
|
||||
strings[0] = gMoveNames[gUnknown_030062F0->unk4];
|
||||
strings[1] = gMoveNames[gUnknown_030062F0->unk6];
|
||||
break;
|
||||
case 4:
|
||||
r10 = 0x12;
|
||||
r6 = 8;
|
||||
strings[0] = gText_Give;
|
||||
strings[1] = gText_NoNeed;
|
||||
break;
|
||||
case 6:
|
||||
r10 = 0x14;
|
||||
r6 = 8;
|
||||
strings[0] = gText_Yes;
|
||||
strings[1] = gText_No;
|
||||
break;
|
||||
default:
|
||||
r10 = 0;
|
||||
r6 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
pixelWidth = 0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
s32 width = GetStringWidth(1, strings[i], 0);
|
||||
if (width > pixelWidth)
|
||||
pixelWidth = width;
|
||||
}
|
||||
|
||||
tileWidth = convert_pixel_width_to_tile_width(pixelWidth);
|
||||
r10 = sub_80E2D5C(r10, tileWidth);
|
||||
windowId = sub_81A0784(r10, r6, tileWidth, count * 2);
|
||||
SetStandardWindowBorderStyle(windowId, 0);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
AddTextPrinterParameterized(windowId, 1, strings[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL);
|
||||
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, 0);
|
||||
sub_81A0804(1, count, windowId);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "pokenav.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
#include "recorded_battle.h"
|
||||
#include "apprentice.h"
|
||||
|
||||
struct SpeciesItem
|
||||
{
|
||||
@ -69,7 +70,6 @@ extern const union AnimCmd *const *const gMonAnimationsSpriteAnimsPtrTable[];
|
||||
extern const union AnimCmd *const *const gTrainerBackAnimsPtrTable[];
|
||||
extern const union AnimCmd *const *const gTrainerFrontAnimsPtrTable[];
|
||||
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
|
||||
extern const struct UnknownPokemonStruct3 gUnknown_08610970[];
|
||||
extern const struct CompressedSpritePalette gMonPaletteTable[];
|
||||
extern const struct CompressedSpritePalette gMonShinyPaletteTable[];
|
||||
extern const u8 gTrainerClassNames[][13];
|
||||
@ -2873,17 +2873,17 @@ void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lv
|
||||
CalculateMonStats(mon);
|
||||
}
|
||||
|
||||
void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u8 monId)
|
||||
void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId)
|
||||
{
|
||||
s32 i;
|
||||
u16 evAmount;
|
||||
u8 language;
|
||||
u32 otId = gUnknown_08610970[src->field_0_0].field_30;
|
||||
u32 personality = ((gUnknown_08610970[src->field_0_0].field_30 >> 8) | ((gUnknown_08610970[src->field_0_0].field_30 & 0xFF) << 8))
|
||||
+ src->mons[monId].species + src->field_2;
|
||||
u32 otId = gApprentices[src->field_0_0].otId;
|
||||
u32 personality = ((gApprentices[src->field_0_0].otId >> 8) | ((gApprentices[src->field_0_0].otId & 0xFF) << 8))
|
||||
+ src->monData[monId].species + src->field_2;
|
||||
|
||||
CreateMon(mon,
|
||||
src->mons[monId].species,
|
||||
src->monData[monId].species,
|
||||
GetFrontierEnemyMonLevel(src->field_0_1 - 1),
|
||||
0x1F,
|
||||
TRUE,
|
||||
@ -2891,9 +2891,9 @@ void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u
|
||||
TRUE,
|
||||
otId);
|
||||
|
||||
SetMonData(mon, MON_DATA_HELD_ITEM, &src->mons[monId].item);
|
||||
SetMonData(mon, MON_DATA_HELD_ITEM, &src->monData[monId].item);
|
||||
for (i = 0; i < 4; i++)
|
||||
SetMonMoveSlot(mon, src->mons[monId].moves[i], i);
|
||||
SetMonMoveSlot(mon, src->monData[monId].moves[i], i);
|
||||
|
||||
evAmount = MAX_TOTAL_EVS / NUM_STATS;
|
||||
for (i = 0; i < NUM_STATS; i++)
|
||||
|
@ -83,7 +83,7 @@ struct PlayerRecordsEmerald
|
||||
/* 0x1124 */ struct EmeraldBattleTowerRecord battleTowerRecord;
|
||||
/* 0x1210 */ u16 unk_1210;
|
||||
/* 0x1214 */ LilycoveLady lilycoveLady;
|
||||
/* 0x1254 */ struct UnkRecordMixingStruct unk_1254[2];
|
||||
/* 0x1254 */ struct Apprentice apprentice[2];
|
||||
/* 0x12dc */ struct UnkRecordMixingStruct2 unk_12dc;
|
||||
/* 0x1434 */ u8 field_1434[0x10];
|
||||
}; // 0x1444
|
||||
@ -134,8 +134,8 @@ static void sub_80E7B2C(const u8 *);
|
||||
static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *, size_t, u8, TVShow *);
|
||||
static void sub_80E7F68(u16 *item, u8 which);
|
||||
static void sub_80E7FF8(u8 taskId);
|
||||
static void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1);
|
||||
static void sub_80E8468(struct UnkRecordMixingStruct *arg0, size_t arg1, u32 arg2);
|
||||
static void sub_80E8110(struct Apprentice *arg0, struct Apprentice *arg1);
|
||||
static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2);
|
||||
static void sub_80E89AC(struct UnkRecordMixingStruct2 *arg0, size_t arg1, u32 arg2);
|
||||
static void sub_80E89F8(struct RecordMixingDayCareMail *dst);
|
||||
static void SanitizeDayCareMailForRuby(struct RecordMixingDayCareMail *src);
|
||||
@ -265,7 +265,7 @@ static void PrepareExchangePacket(void)
|
||||
if (GetMultiplayerId() == 0)
|
||||
sSentRecord->emerald.unk_1210 = GetRecordMixingGift();
|
||||
|
||||
sub_80E8110(sSentRecord->emerald.unk_1254, gUnknown_03001154);
|
||||
sub_80E8110(sSentRecord->emerald.apprentice, gUnknown_03001154);
|
||||
sub_80E8260(&sSentRecord->emerald.unk_12dc);
|
||||
}
|
||||
}
|
||||
@ -298,7 +298,7 @@ static void ReceiveExchangePacket(u32 which)
|
||||
ReceiveBattleTowerData(&sReceivedRecords->emerald.battleTowerRecord, sizeof(struct PlayerRecordsEmerald), which);
|
||||
sub_80E7F68(&sReceivedRecords->emerald.unk_1210, which);
|
||||
ReceiveLilycoveLadyData(&sReceivedRecords->emerald.lilycoveLady, sizeof(struct PlayerRecordsEmerald), which);
|
||||
sub_80E8468(sReceivedRecords->emerald.unk_1254, sizeof(struct PlayerRecordsEmerald), (u8) which);
|
||||
ReceiveApprenticeData(sReceivedRecords->emerald.apprentice, sizeof(struct PlayerRecordsEmerald), (u8) which);
|
||||
sub_80E89AC(&sReceivedRecords->emerald.unk_12dc, sizeof(struct PlayerRecordsEmerald), (u8) which);
|
||||
}
|
||||
}
|
||||
@ -1551,13 +1551,13 @@ static void sub_80E7FF8(u8 taskId)
|
||||
|
||||
// New Emerald functions
|
||||
|
||||
static void sub_80E8110(struct UnkRecordMixingStruct *dst, struct UnkRecordMixingStruct *src)
|
||||
static void sub_80E8110(struct Apprentice *dst, struct Apprentice *src)
|
||||
{
|
||||
s32 i, id;
|
||||
s32 var_2C, var_28, var_24, r8;
|
||||
|
||||
dst[0].field_38[0] = 0xFF;
|
||||
dst[1].field_38[0] = 0xFF;
|
||||
dst[0].playerName[0] = EOS;
|
||||
dst[1].playerName[0] = EOS;
|
||||
|
||||
dst[0] = src[0];
|
||||
|
||||
@ -1568,7 +1568,7 @@ static void sub_80E8110(struct UnkRecordMixingStruct *dst, struct UnkRecordMixin
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
id = ((i + gSaveBlock2Ptr->field_B2_1) % 3) + 1;
|
||||
if (src[id].field_38[0] != 0xFF)
|
||||
if (src[id].playerName[0] != EOS)
|
||||
{
|
||||
if (ReadUnalignedWord(src[id].playerId) != ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId))
|
||||
{
|
||||
@ -1646,14 +1646,14 @@ void sub_80E8260(struct UnkRecordMixingStruct2 *dst)
|
||||
}
|
||||
}
|
||||
|
||||
static bool32 sub_80E841C(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1)
|
||||
static bool32 sub_80E841C(struct Apprentice *arg0, struct Apprentice *arg1)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (ReadUnalignedWord(arg0->playerId) == ReadUnalignedWord(arg1[i].playerId)
|
||||
&& arg0->field_0[2] == arg1[i].field_0[2])
|
||||
&& arg0->field_2 == arg1[i].field_2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -1662,10 +1662,10 @@ static bool32 sub_80E841C(struct UnkRecordMixingStruct *arg0, struct UnkRecordMi
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void sub_80E8468(struct UnkRecordMixingStruct *arg0, size_t arg1, u32 arg2)
|
||||
static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2)
|
||||
{
|
||||
s32 i, r7, r8;
|
||||
struct UnkRecordMixingStruct *structPtr;
|
||||
struct Apprentice *structPtr;
|
||||
u32 mixIndices[4];
|
||||
u32 structId;
|
||||
|
||||
@ -1675,7 +1675,7 @@ static void sub_80E8468(struct UnkRecordMixingStruct *arg0, size_t arg1, u32 arg
|
||||
r8 = 0;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (structPtr[i].field_38[0] != 0xFF && !sub_80E841C(&structPtr[i], gSaveBlock2Ptr->field_DC))
|
||||
if (structPtr[i].playerName[0] != EOS && !sub_80E841C(&structPtr[i], gSaveBlock2Ptr->field_DC))
|
||||
{
|
||||
r7++;
|
||||
r8 = i;
|
||||
|
Loading…
Reference in New Issue
Block a user