Bladeren bron

rewrite trainer_build_party

SBird1337 6 jaren geleden
bovenliggende
commit
6cd2e03b7d

+ 3
- 2
data/trainer/trainer_pkmn_data.s Bestand weergeven

@@ -3,8 +3,8 @@
3 3
 .align 2
4 4
 .text
5 5
 .thumb
6
-.global trainer_pkmn_data
7
-trainer_pkmn_data:
6
+.global trainer_data
7
+trainer_data:
8 8
 
9 9
 .byte 0x0
10 10
 .byte 0x0
@@ -21,6 +21,7 @@ trainer_pkmn_data:
21 21
 .hword 0x0, 0x0
22 22
 .byte 0x0
23 23
 .byte 0x0, 0x0, 0x0
24
+.word 0x00000000 @@this is actually important, because otherwise the structure offset will be off
24 25
 
25 26
 .byte MOVE_NEIN_ITEM_NEIN
26 27
 .byte TRAINERCLASS_PKMN_TRAINER

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 4f2398d73aba67dfbc4dd396c2b8f3a376c64ea9
1
+Subproject commit e16cda91fc0c216e41c8a770b5af23a83aba698a

+ 5
- 0
patches/overworlds/trainer.asm Bestand weergeven

@@ -11,4 +11,9 @@ bx r2
11 11
 .org 0x080BC3A0
12 12
 ldr r1, =battle_intro_launch+1
13 13
 bx r1
14
+.pool
15
+
16
+.org 0x080112E0
17
+ldr r2, =battle_trainer_build_party+1
18
+bx r2
14 19
 .pool

+ 22
- 22
patches/trainer_sprites/trainer_data.asm Bestand weergeven

@@ -1,67 +1,67 @@
1 1
 //Point to trainer data, which is 4 bytes prior to the first name
2 2
 
3 3
 .org 0x0800FC00
4
-.word trainer_pkmn_data -4
4
+.word trainer_data
5 5
 
6 6
 .org 0x0800FC80
7
-.word trainer_pkmn_data -4
7
+.word trainer_data
8 8
 
9 9
 .org 0x0801133C
10
-.word trainer_pkmn_data -4
10
+.word trainer_data
11 11
 
12 12
 .org 0x080113BC
13
-.word trainer_pkmn_data -4
13
+.word trainer_data
14 14
 
15 15
 .org 0x080116C4
16
-.word trainer_pkmn_data -4
16
+.word trainer_data
17 17
 
18 18
 .org 0x08015728
19
-.word trainer_pkmn_data -4
19
+.word trainer_data
20 20
 
21 21
 .org 0x08025920
22
-.word trainer_pkmn_data -4
22
+.word trainer_data
23 23
 
24 24
 .org 0x080259DC
25
-.word trainer_pkmn_data -4
25
+.word trainer_data
26 26
 
27 27
 .org 0x08037E6C
28
-.word trainer_pkmn_data -4
28
+.word trainer_data
29 29
 
30 30
 .org 0x08038040
31
-.word trainer_pkmn_data -4
31
+.word trainer_data
32 32
 
33 33
 .org 0x08043694
34
-.word trainer_pkmn_data -4
34
+.word trainer_data
35 35
 
36 36
 .org 0x08043884
37
-.word trainer_pkmn_data -4
37
+.word trainer_data
38 38
 
39 39
 .org 0x08044028
40
-.word trainer_pkmn_data -4
40
+.word trainer_data
41 41
 
42 42
 .org 0x0807FE88
43
-.word trainer_pkmn_data -4
43
+.word trainer_data
44 44
 
45 45
 .org 0x0807FFB8
46
-.word trainer_pkmn_data -4
46
+.word trainer_data
47 47
 
48 48
 .org 0x080C6F40
49
-.word trainer_pkmn_data -4
49
+.word trainer_data
50 50
 
51 51
 .org 0x080D809C
52
-.word trainer_pkmn_data -4
52
+.word trainer_data
53 53
 
54 54
 .org 0x080D8158
55
-.word trainer_pkmn_data -4
55
+.word trainer_data
56 56
 
57 57
 .org 0x08113810
58
-.word trainer_pkmn_data -4
58
+.word trainer_data
59 59
 
60 60
 .org 0x08115230
61
-.word trainer_pkmn_data -4
61
+.word trainer_data
62 62
 
63 63
 .org 0x0812C048
64
-.word trainer_pkmn_data -4
64
+.word trainer_data
65 65
 
66 66
 .org 0x080D80A0
67 67
 .word trainerclasses
@@ -74,4 +74,4 @@
74 74
 
75 75
 //Point to new trainer item data
76 76
 .org 0x080C6D9C
77
-.word trainer_pkmn_data +12
77
+.word trainer_data +12

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit 38779228bdfb681bd4b274a1dd367be12099dd73
1
+Subproject commit 5b270e614e3c0d2eda30f62bfe4818c579b3d55d

+ 12
- 3
src/overworld/trainerbattle_init.c Bestand weergeven

@@ -1,4 +1,5 @@
1 1
 #include <pokeagb/pokeagb.h>
2
+#include <agb_debug.h>
2 3
 
3 4
 void battle_intro_launch(u8 environment) {
4 5
     TaskCallback introTask;
@@ -19,13 +20,14 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
19 20
     if(tid == 0x400)
20 21
         return 0;
21 22
     //ignore some type of battles like old man or trainer tower where the party is determined otherwise
23
+    dprintf("battle_type_flags: %x, tid: %d\n", battle_type_flags, tid);
22 24
     if ((battle_type_flags & 0x80908) == 8) {
23 25
         party_opponent_purge();
24 26
         for(u8 i = 0; i < trainer_data[tid].party_size; ++i) {
25 27
             u32 personalityValue;
26 28
             if(trainer_data[tid].is_double)
27 29
                 personalityValue = 0x80;
28
-            else if (trainer_data[tid].gender)
30
+            else if (trainer_data[tid].gender & 0x80)
29 31
                 personalityValue = 0x78;
30 32
             else
31 33
                 personalityValue = 0x88;
@@ -41,8 +43,11 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
41 43
                 {
42 44
                     //nothing
43 45
                     const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
44
-                    for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
46
+                    dprintf("making pokemon with species: %d, struct: 0x%x\n", pokeData[i].species, pokeData);
47
+                    for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j) {
45 48
                         nameHash += pokemon_names[pokeData[i].species][j];
49
+                    }
50
+                    
46 51
                     personalityValue += nameHash << 8;
47 52
                     u8 iv = pokeData[i].iv * 31 / 255;
48 53
 
@@ -53,6 +58,7 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
53 58
                 case TRAINER_PARTY_MOVESET:
54 59
                 {
55 60
                     const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);
61
+                    dprintf("making pokemon with species: %d\n", pokeData[i].base.species);
56 62
                     //custom moveset
57 63
                     for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
58 64
                         nameHash += pokemon_names[pokeData[i].base.species][j];
@@ -68,7 +74,9 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
68 74
                 case TRAINER_PARTY_HELD_ITEM:
69 75
                 {
70 76
                     //custom item
77
+                    
71 78
                     const struct TrainerPokemonBase *pokeData = (const struct TrainerPokemonBase*)(trainer_data[tid].party);
79
+                    dprintf("making pokemon with species: %d\n", pokeData[i].species);
72 80
                     for(u8 j = 0; pokemon_names[pokeData[i].species][j] != 0xFF; ++j)
73 81
                         nameHash += pokemon_names[pokeData[i].species][j];
74 82
                     personalityValue += nameHash << 8;
@@ -81,7 +89,8 @@ u8 battle_trainer_build_party(struct Pokemon *party, u16 tid) {
81 89
                 case TRAINER_PARTY_HELD_ITEM | TRAINER_PARTY_MOVESET:
82 90
                 {
83 91
                     //custom all the things
84
-                    const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);  
92
+                    const struct TrainerPokemonMoves *pokeData = (const struct TrainerPokemonMoves*)(trainer_data[tid].party);
93
+                    dprintf("making pokemon with species: %d\n", pokeData[i].base.species);  
85 94
                     for(u8 j = 0; pokemon_names[pokeData[i].base.species][j] != 0xFF; ++j)
86 95
                         nameHash += pokemon_names[pokeData[i].base.species][j];
87 96
                     personalityValue += nameHash << 8;

+ 1
- 1
src/specials/trainer_battle.c Bestand weergeven

@@ -275,7 +275,7 @@ void *tb_configure_by_script(void *ptr_script) {
275 275
 
276 276
         battle_80801F0_something();
277 277
 
278
-        return (void *)(0x081A4EC1); /* some script to execute */
278
+        return (void *)(0x081A4F21); /* some script to execute */
279 279
 
280 280
     case 0xFF:
281 281
         /* this is a registered on-spot script */