Browse Source

rewrite trainer_build_party

SBird1337 6 years ago
parent
commit
6cd2e03b7d

+ 3
- 2
data/trainer/trainer_pkmn_data.s View File

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

+ 1
- 1
g3headers

1
-Subproject commit 4f2398d73aba67dfbc4dd396c2b8f3a376c64ea9
1
+Subproject commit e16cda91fc0c216e41c8a770b5af23a83aba698a

+ 5
- 0
patches/overworlds/trainer.asm View File

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

+ 22
- 22
patches/trainer_sprites/trainer_data.asm View File

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

+ 1
- 1
sots-private

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

+ 12
- 3
src/overworld/trainerbattle_init.c View File

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

+ 1
- 1
src/specials/trainer_battle.c View File

275
 
275
 
276
         battle_80801F0_something();
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
     case 0xFF:
280
     case 0xFF:
281
         /* this is a registered on-spot script */
281
         /* this is a registered on-spot script */