|
@@ -1,5 +1,6 @@
|
1
|
1
|
#include <pokeagb/pokeagb.h>
|
2
|
2
|
#include <agb_debug.h>
|
|
3
|
+#include "trainer_rival_encounters.h"
|
3
|
4
|
|
4
|
5
|
void battle_intro_launch(u8 environment) {
|
5
|
6
|
TaskCallback introTask;
|
|
@@ -16,6 +17,43 @@ void battle_intro_launch(u8 environment) {
|
16
|
17
|
livingTask->priv[1] = environment;
|
17
|
18
|
}
|
18
|
19
|
|
|
20
|
+union TrainerPokemonPtr battle_trainer_get_rival(u8 chosenStarterValue, u8 encounterNumber, enum TrainerPartyFlag flag) {
|
|
21
|
+ u8 partyCount = rival_encounters[encounterNumber].partyCount;
|
|
22
|
+ u8 structureSize = 0;
|
|
23
|
+ switch(flag)
|
|
24
|
+ {
|
|
25
|
+ case TRAINER_PARTY_NONE:
|
|
26
|
+ structureSize = sizeof(struct TrainerPokemonBase);
|
|
27
|
+ break;
|
|
28
|
+ case TRAINER_PARTY_HELD_ITEM:
|
|
29
|
+ structureSize = sizeof(struct TrainerPokemonItem);
|
|
30
|
+ break;
|
|
31
|
+ case TRAINER_PARTY_MOVESET:
|
|
32
|
+ structureSize = sizeof(struct TrainerPokemonMoves);
|
|
33
|
+ break;
|
|
34
|
+ case TRAINER_PARTY_HELD_ITEM_MOVESET:
|
|
35
|
+ structureSize = sizeof(struct TrainerPokemonItemMoves);
|
|
36
|
+ break;
|
|
37
|
+ default:
|
|
38
|
+ structureSize = sizeof(struct TrainerPokemonBase);
|
|
39
|
+ break;
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ return (union TrainerPokemonPtr)(rival_encounters[encounterNumber].partyArray.undefinedStructure + (chosenStarterValue * partyCount * structureSize));
|
|
43
|
+}
|
|
44
|
+
|
|
45
|
+#define VAR_STARTER 0x5052
|
|
46
|
+
|
|
47
|
+union TrainerPokemonPtr battle_trainer_get_rival_or_null(u8 tid) {
|
|
48
|
+ for(u16 i = 0; i < RIVAL_ENCOUNTER_COUNT; ++i) {
|
|
49
|
+ if(rival_encounters[i].trainerId == tid) {
|
|
50
|
+ return battle_trainer_get_rival(var_load(VAR_STARTER), i, trainer_data[tid].flags);
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ union TrainerPokemonPtr nullPokemon = {.undefinedStructure = NULL};
|
|
54
|
+ return nullPokemon;
|
|
55
|
+}
|
|
56
|
+
|
19
|
57
|
u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
|
20
|
58
|
if(tid == 0x400)
|
21
|
59
|
return 0;
|
|
@@ -35,14 +73,15 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
|
35
|
73
|
for(u8 j = 0; trainer_data[tid].name[j] != 0xFF; ++j){
|
36
|
74
|
nameHash += trainer_data[tid].name[j];
|
37
|
75
|
}
|
38
|
|
-
|
39
|
76
|
//has custom items etc
|
40
|
77
|
switch(trainer_data[tid].flags)
|
41
|
78
|
{
|
42
|
79
|
case TRAINER_PARTY_NONE:
|
43
|
80
|
{
|
44
|
81
|
//nothing
|
45
|
|
- const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
|
|
82
|
+ const struct TrainerPokemonBase *pokeData = battle_trainer_get_rival_or_null(tid).noItemDefaultMoves;
|
|
83
|
+ if(pokeData == NULL)
|
|
84
|
+ pokeData = trainer_data[tid].party.noItemDefaultMoves;
|
46
|
85
|
dprintf("making pokemon with species: %d, struct: 0x%x\n", pokeData[i].species, pokeData);
|
47
|
86
|
for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j) {
|
48
|
87
|
nameHash += pokemon_names[pokeData[i].species][j];
|
|
@@ -57,14 +96,17 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
|
57
|
96
|
}
|
58
|
97
|
case TRAINER_PARTY_MOVESET:
|
59
|
98
|
{
|
60
|
|
- const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);
|
61
|
|
- dprintf("making pokemon with species: %d\n", pokeData[i].base.species);
|
|
99
|
+ const struct TrainerPokemonMoves *pokeData = battle_trainer_get_rival_or_null(tid).noItemCustomMoves;
|
|
100
|
+ if(pokeData == NULL)
|
|
101
|
+ pokeData = trainer_data[tid].party.noItemCustomMoves;
|
|
102
|
+
|
|
103
|
+ dprintf("making pokemon with species: %d\n", pokeData[i].species);
|
62
|
104
|
//custom moveset
|
63
|
|
- for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
|
64
|
|
- nameHash += pokemon_names[pokeData[i].base.species][j];
|
|
105
|
+ for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
|
|
106
|
+ nameHash += pokemon_names[pokeData[i].species][j];
|
65
|
107
|
personalityValue += nameHash << 8;
|
66
|
|
- u8 iv = pokeData[i].base.iv * 31 / 255;
|
67
|
|
- pokemon_make_full(&party[i], pokeData[i].base.species, pokeData[i].base.level, iv, true, personalityValue, 2, 0);
|
|
108
|
+ u8 iv = pokeData[i].iv * 31 / 255;
|
|
109
|
+ pokemon_make_full(&party[i], pokeData[i].species, pokeData[i].level, iv, true, personalityValue, 2, 0);
|
68
|
110
|
for(u8 j = 0; j < 4; ++j) {
|
69
|
111
|
pokemon_setattr(&party[i], REQUEST_MOVE1 + j, (void*)&pokeData[i].moves[j]);
|
70
|
112
|
pokemon_setattr(&party[i], REQUEST_PP1 + j, (void*)&pokemon_moves[pokeData[i].moves[j]].pp);
|
|
@@ -75,7 +117,10 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
|
75
|
117
|
{
|
76
|
118
|
//custom item
|
77
|
119
|
|
78
|
|
- const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
|
|
120
|
+ const struct TrainerPokemonItem *pokeData = battle_trainer_get_rival_or_null(tid).itemDefaultMoves;
|
|
121
|
+ if(pokeData == NULL)
|
|
122
|
+ pokeData = trainer_data[tid].party.itemDefaultMoves;
|
|
123
|
+
|
79
|
124
|
dprintf("making pokemon with species: %d\n", pokeData[i].species);
|
80
|
125
|
for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
|
81
|
126
|
nameHash += pokemon_names[pokeData[i].species][j];
|
|
@@ -89,15 +134,18 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
|
89
|
134
|
case TRAINER_PARTY_HELD_ITEM | TRAINER_PARTY_MOVESET:
|
90
|
135
|
{
|
91
|
136
|
//custom all the things
|
92
|
|
- const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);
|
93
|
|
- dprintf("making pokemon with species: %d\n", pokeData[i].base.species);
|
94
|
|
- for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
|
95
|
|
- nameHash += pokemon_names[pokeData[i].base.species][j];
|
|
137
|
+ const struct TrainerPokemonItemMoves *pokeData = battle_trainer_get_rival_or_null(tid).customItemCustomMoves;
|
|
138
|
+ if(pokeData == NULL)
|
|
139
|
+ pokeData = trainer_data[tid].party.customItemCustomMoves;
|
|
140
|
+
|
|
141
|
+ dprintf("making pokemon with species: %d\n", pokeData[i].species);
|
|
142
|
+ for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
|
|
143
|
+ nameHash += pokemon_names[pokeData[i].species][j];
|
96
|
144
|
personalityValue += nameHash << 8;
|
97
|
|
- u8 iv = pokeData[i].base.iv * 31 / 255;
|
98
|
|
- pokemon_make_full(&party[i], pokeData[i].base.species, pokeData[i].base.level, iv, true, personalityValue, 2, 0);
|
|
145
|
+ u8 iv = pokeData[i].iv * 31 / 255;
|
|
146
|
+ pokemon_make_full(&party[i], pokeData[i].species, pokeData[i].level, iv, true, personalityValue, 2, 0);
|
99
|
147
|
|
100
|
|
- pokemon_setattr(&party[i], REQUEST_HELD_ITEM, (void*)&pokeData[i].base.Item);
|
|
148
|
+ pokemon_setattr(&party[i], REQUEST_HELD_ITEM, (void*)&pokeData[i].Item);
|
101
|
149
|
for(u8 j = 0; j < 4; ++j) {
|
102
|
150
|
pokemon_setattr(&party[i], REQUEST_MOVE1 + j, (void*)&pokeData[i].moves[j]);
|
103
|
151
|
pokemon_setattr(&party[i], REQUEST_PP1 + j, (void*)&pokemon_moves[pokeData[i].moves[j]].pp);
|