Parcourir la source

start rewriting trainer routine

SBird1337 il y a 6 ans
Parent
révision
431a4bd5f7
3 fichiers modifiés avec 92 ajouts et 1 suppressions
  1. 2
    0
      data/moves/move_data.s
  2. 1
    1
      g3headers
  3. 89
    0
      src/overworld/trainerbattle_init.c

+ 2
- 0
data/moves/move_data.s Voir le fichier

@@ -6,6 +6,8 @@
6 6
 
7 7
 .global move_table
8 8
 move_table:
9
+.global pokemon_moves
10
+pokemon_moves:
9 11
 
10 12
 @Move			DATA		.BYTE		EFFECT		DMG		TYPE		ACCUR		PP		EF_ACC		TARGET		PRIO		FLAGS		AGR_1		SPLIT		AGR_2
11 13
 /*Nichts*/		move_data_0:	.byte		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 67148f99854803cb7e03b0efa64b38a1285dc8db
1
+Subproject commit 4f2398d73aba67dfbc4dd396c2b8f3a376c64ea9

+ 89
- 0
src/overworld/trainerbattle_init.c Voir le fichier

@@ -13,4 +13,93 @@ void battle_intro_launch(u8 environment) {
13 13
     for (u8 i = 0; i <= 6; ++i)
14 14
         livingTask->priv[i] = 0;
15 15
     livingTask->priv[1] = environment;
16
+}
17
+
18
+u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
19
+    if(tid == 0x400)
20
+        return 0;
21
+    //ignore some type of battles like old man or trainer tower where the party is determined otherwise
22
+    if ((battle_type_flags & 0x80908) == 8) {
23
+        party_opponent_purge();
24
+        for(u8 i = 0; i < trainer_data[tid].party_size; ++i) {
25
+            u32 personalityValue;
26
+            if(trainer_data[tid].is_double)
27
+                personalityValue = 0x80;
28
+            else if (trainer_data[tid].gender)
29
+                personalityValue = 0x78;
30
+            else
31
+                personalityValue = 0x88;
32
+            u32 nameHash = 0;
33
+            for(u8 j = 0; trainer_data[tid].name[j] != 0xFF; ++j){
34
+                nameHash += trainer_data[tid].name[j];
35
+            }
36
+
37
+            //has custom items etc
38
+            switch(trainer_data[tid].flags)
39
+            {
40
+                case TRAINER_PARTY_NONE:
41
+                {
42
+                    //nothing
43
+                    const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
44
+                    for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
45
+                        nameHash += pokemon_names[pokeData[i].species][j];
46
+                    personalityValue += nameHash << 8;
47
+                    u8 iv = pokeData[i].iv * 31 / 255;
48
+
49
+                    //no idea about the last 2 parameters, just do what the game does I guess
50
+                    pokemon_make_full(&party[i], pokeData[i].species, pokeData[i].level, iv, true, personalityValue, 2, 0);
51
+                    break;
52
+                }
53
+                case TRAINER_PARTY_MOVESET:
54
+                {
55
+                    const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);
56
+                    //custom moveset
57
+                    for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
58
+                        nameHash += pokemon_names[pokeData[i].base.species][j];
59
+                    personalityValue += nameHash << 8;
60
+                    u8 iv = pokeData[i].base.iv * 31 / 255;
61
+                    pokemon_make_full(&party[i], pokeData[i].base.species, pokeData[i].base.level, iv, true, personalityValue, 2, 0);
62
+                    for(u8 j = 0; j < 4; ++j) {
63
+                        pokemon_setattr(&party[i], REQUEST_MOVE1 + j, (void*)&pokeData[i].moves[j]);
64
+                        pokemon_setattr(&party[i], REQUEST_PP1 + j, (void*)&pokemon_moves[pokeData[i].moves[j]].pp);
65
+                    }
66
+                    break;
67
+                }
68
+                case TRAINER_PARTY_HELD_ITEM:
69
+                {
70
+                    //custom item
71
+                    const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
72
+                    for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
73
+                        nameHash += pokemon_names[pokeData[i].species][j];
74
+                    personalityValue += nameHash << 8;
75
+                    u8 iv = pokeData[i].iv * 31 / 255;
76
+                    pokemon_make_full(&party[i], pokeData[i].species, pokeData[i].level, iv, true, personalityValue, 2, 0);
77
+                    
78
+                    pokemon_setattr(&party[i], REQUEST_HELD_ITEM, (void*)&pokeData[i].Item);
79
+                    break;
80
+                }
81
+                case TRAINER_PARTY_HELD_ITEM | TRAINER_PARTY_MOVESET:
82
+                {
83
+                    //custom all the things
84
+                    const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);  
85
+                    for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
86
+                        nameHash += pokemon_names[pokeData[i].base.species][j];
87
+                    personalityValue += nameHash << 8;
88
+                    u8 iv = pokeData[i].base.iv * 31 / 255;
89
+                    pokemon_make_full(&party[i], pokeData[i].base.species, pokeData[i].base.level, iv, true, personalityValue, 2, 0);
90
+                    
91
+                    pokemon_setattr(&party[i], REQUEST_HELD_ITEM, (void*)&pokeData[i].base.Item);
92
+                    for(u8 j = 0; j < 4; ++j) {
93
+                        pokemon_setattr(&party[i], REQUEST_MOVE1 + j, (void*)&pokeData[i].moves[j]);
94
+                        pokemon_setattr(&party[i], REQUEST_PP1 + j, (void*)&pokemon_moves[pokeData[i].moves[j]].pp);
95
+                    }
96
+                    break;
97
+                }
98
+                
99
+            }
100
+        }
101
+        battle_type_flags |= trainer_data[tid].is_double;
102
+    }
103
+    (void) party;
104
+    return trainer_data[tid].party_size;
16 105
 }