Bladeren bron

added more evolutions

SBird1337 7 jaren geleden
bovenliggende
commit
0beb54dc72
5 gewijzigde bestanden met toevoegingen van 151 en 45 verwijderingen
  1. 1
    0
      bpre.sym
  2. 140
    43
      src/evolution/evolution_methods.c
  3. 3
    0
      src/include/config.h
  4. 7
    0
      src/include/game_engine.h
  5. 0
    2
      src/interface/textbox_mugshots.c

+ 1
- 0
bpre.sym Bestand weergeven

@@ -161,6 +161,7 @@ party_opponent = 0x0202402C;
161 161
 
162 162
 pokemon_get_attribute = 0x0803FBE8|1;
163 163
 pokemon_set_attribute = 0x0804037C|1;
164
+pokemon_get_gender = 0x0803F720|1;
164 165
 
165 166
 pokemon_evolution_table = 08259754;
166 167
 

+ 140
- 43
src/evolution/evolution_methods.c Bestand weergeven

@@ -31,6 +31,35 @@
31 31
 #include <pkmn_attributes.h>
32 32
 #include <agb_debug.h>
33 33
 #include <math.h>
34
+#include <config.h>
35
+
36
+#define EVO_NULL {0,0,0, {false, 0}}
37
+#define MAX_EVOLUTIONS 5
38
+#define EVO_NO_EVO (struct evo_result){false,false,0}
39
+
40
+#define HAPPY_BOUND 219
41
+#define BEAUTY_BOUND 170
42
+
43
+#define EVO_HAPPINESS 1
44
+#define EVO_LEVEL_UP 4
45
+#define EVO_TRADE 5
46
+#define EVO_TRADE_ITEM 6
47
+#define EVO_STONE 7
48
+#define EVO_ATK 8
49
+#define EVO_DEF 9
50
+#define EVO_ADEQU 10
51
+#define EVO_PERSO_HIGH 11
52
+#define EVO_PERSO_LOW 12
53
+#define EVO_SPAWN 13
54
+#define EVO_SPAWNED 14
55
+#define EVO_BEAUTY 15
56
+#define EVO_WEAR_ITEM 16
57
+#define EVO_WEAR_ITEM_NIGHT 17
58
+#define EVO_WEAR_ITEM_DAY 18
59
+#define EVO_LEVEL_NIGHT 19
60
+#define EVO_LEVEL_DAY 20
61
+#define EVO_LEVEL_VAR 21
62
+#define EVO_LEVEL_MOVE 22
34 63
 
35 64
 enum evo_source
36 65
 {
@@ -45,8 +74,11 @@ struct evo_information
45 74
     u16 method;
46 75
     u16 argument;
47 76
     u16 evolve_to;
48
-    u8 arg1;
49
-    u8 arg2;
77
+    struct
78
+    {
79
+        u16 gender: 2;
80
+        u16 versatile: 14;
81
+    } argument_2;
50 82
 };
51 83
 
52 84
 struct evo_result
@@ -56,31 +88,10 @@ struct evo_result
56 88
     u8 evolve_to;
57 89
 };
58 90
 
59
-#define EVO_NULL {0,0,0,0,0}
60
-#define MAX_EVOLUTIONS 5
61
-#define EVO_NO_EVO (struct evo_result){false,false,0}
62
-
63
-#define HAPPY_BOUND 219
64
-#define BEAUTY_BOUND 170
65
-
66
-#define EVO_HAPPINESS 1
67
-#define EVO_LEVEL_UP 4
68
-#define EVO_TRADE 5
69
-#define EVO_TRADE_ITEM 6
70
-#define EVO_STONE 7
71
-#define EVO_ATK 8
72
-#define EVO_DEF 9
73
-#define EVO_ADEQU 10
74
-#define EVO_PERSO_HIGH 11
75
-#define EVO_PERSO_LOW 12
76
-#define EVO_SPAWN 13
77
-#define EVO_SPAWNED 14
78
-#define EVO_BEAUTY 15
79
-
80 91
 struct evo_information evolutions[][MAX_EVOLUTIONS] = {
81 92
     {EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},               //Nothing
82
-    {{EVO_BEAUTY,7,2,0,0},{EVO_SPAWNED,7,150,0,0},EVO_NULL,EVO_NULL,EVO_NULL},   //BISASAM
83
-    {{EVO_LEVEL_UP,32,3,0,0},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},//BISAKNOSP
93
+    {{EVO_LEVEL_MOVE,7,2,{0, 336}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},   //BISASAM
94
+    {{EVO_LEVEL_UP,32,3,{0, 0}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},//BISAKNOSP
84 95
 };
85 96
 
86 97
 struct evo_call_arguments
@@ -97,6 +108,20 @@ typedef struct evo_result (*evolution_callback)(struct evo_call_arguments);
97 108
 
98 109
 struct evo_result evolve_by_level(struct evo_call_arguments arguments)
99 110
 {
111
+    u8 gender = pokemon_get_gender(arguments.poke);
112
+    u8 gender_arg = arguments.evolution.argument_2.gender;
113
+    dprintf("A pokemon with gender value %d\n", gender);
114
+    if(gender_arg == 1)
115
+    {
116
+        if(gender)
117
+            return EVO_NO_EVO;
118
+    }
119
+    if(gender_arg == 2)
120
+    {
121
+        if(!gender)
122
+            return EVO_NO_EVO;
123
+    }
124
+    
100 125
     if(arguments.evolution.argument <= arguments.level && arguments.source == LEVEL_UP)
101 126
     {
102 127
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
@@ -111,7 +136,7 @@ struct evo_result evolve_by_trade_group(struct evo_call_arguments arguments)
111 136
 {
112 137
     if(arguments.source != TRADE)
113 138
     {
114
-        return (struct evo_result){false, false, 0};
139
+        return EVO_NO_EVO;
115 140
     }
116 141
     if(arguments.evolution.method == EVO_TRADE_ITEM)
117 142
     {
@@ -132,7 +157,7 @@ struct evo_result evolve_by_trade_group(struct evo_call_arguments arguments)
132 157
 }
133 158
 
134 159
 struct evo_result evolve_random(struct evo_call_arguments arguments)
135
-{
160
+{  
136 161
     if(arguments.source != LEVEL_UP)
137 162
     {
138 163
         return EVO_NO_EVO;
@@ -159,6 +184,20 @@ struct evo_result evolve_random(struct evo_call_arguments arguments)
159 184
 
160 185
 struct evo_result evolve_by_stone(struct evo_call_arguments arguments)
161 186
 {
187
+    u8 gender = pokemon_get_gender(arguments.poke);
188
+    u8 gender_arg = arguments.evolution.argument_2.gender;
189
+    
190
+    if(gender_arg == 1)
191
+    {
192
+        if(gender)
193
+            return EVO_NO_EVO;
194
+    }
195
+    if(gender_arg == 2)
196
+    {
197
+        if(!gender)
198
+            return EVO_NO_EVO;
199
+    }
200
+
162 201
     if(arguments.source != STONE_EVOLUTION && arguments.source != STONE_REQUEST)
163 202
     {
164 203
         return (struct evo_result){false,false, 0};
@@ -221,6 +260,17 @@ struct evo_result evolve_by_happiness(struct evo_call_arguments arguments)
221 260
     }
222 261
 }
223 262
 
263
+struct evo_result evolve_by_special_place(struct evo_call_arguments arguments)
264
+{
265
+    u16 value = var_get(EVO_VAR);
266
+    dprintf("A pokemon tried to evolve using the var evo method: value: %d needed: %d\n", value, arguments.evolution.argument_2.versatile);
267
+    if(arguments.evolution.argument_2.versatile != value)
268
+    {
269
+        return EVO_NO_EVO;
270
+    }
271
+    return evolve_by_level(arguments);
272
+}
273
+
224 274
 struct evo_result evolve_by_beauty(struct evo_call_arguments arguments)
225 275
 {
226 276
     u32 beauty = pokemon_get_attribute(arguments.poke, ATTR_BEAUTY, NULL);
@@ -230,6 +280,46 @@ struct evo_result evolve_by_beauty(struct evo_call_arguments arguments)
230 280
     return EVO_NO_EVO;
231 281
 }
232 282
 
283
+struct evo_result evolve_by_worn_item(struct evo_call_arguments arguments)
284
+{
285
+    
286
+    struct evo_result level_result = evolve_by_level(arguments);
287
+    if(!level_result.can_evolve)
288
+        return EVO_NO_EVO;
289
+    u16 item_to_wear = arguments.evolution.argument_2.versatile;
290
+    dprintf("A pokemon tried to evolve by item. pkmn_item: %d; argument item: %d", arguments.item, item_to_wear);
291
+    if(arguments.item != item_to_wear)
292
+        return EVO_NO_EVO;
293
+    
294
+    return (struct evo_result){true, false, arguments.evolution.evolve_to};
295
+}
296
+
297
+struct evo_result evolve_by_worn_item_day(struct evo_call_arguments arguments)
298
+{
299
+    dprintf("A pokemon tried to use the (not implmented) evolve_by_worn_item_day evo method.\n");
300
+    return evolve_by_worn_item(arguments);
301
+}
302
+
303
+struct evo_result evolve_by_worn_item_night(struct evo_call_arguments arguments)
304
+{
305
+    dprintf("A pokemon tried to use the (not implmented) evolve_by_worn_item_night evo method.\n");
306
+    return evolve_by_worn_item(arguments);
307
+}
308
+
309
+struct evo_result evolve_by_move(struct evo_call_arguments arguments)
310
+{
311
+    u16 move_one = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_1, NULL);
312
+    u16 move_two = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_2, NULL);
313
+    u16 move_three = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_3, NULL);
314
+    u16 move_four = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_4, NULL);
315
+    u16 move_needed = arguments.evolution.argument_2.versatile;
316
+    dprintf("A pokemon tried to evolve using evolve_by_move: needed: %d, one: %d, two: %d, three: %d, four: %d\n", move_needed, move_one, move_two, move_three, move_four);
317
+    if((move_one == move_needed) || (move_two == move_needed) || (move_three == move_needed) || (move_four == move_needed))
318
+        return evolve_by_level(arguments);
319
+    else
320
+        return EVO_NO_EVO;
321
+}
322
+
233 323
 struct evo_result evolve_no_method(struct evo_call_arguments arguments)
234 324
 {
235 325
     //For shedninja
@@ -244,22 +334,29 @@ struct evo_result evolve_invalid_method(struct evo_call_arguments arguments)
244 334
 
245 335
 static evolution_callback evolution_methods[] =
246 336
 {
247
-    evolve_invalid_method,
248
-    evolve_by_happiness,
249
-    evolve_invalid_method, //TODO: Happiness DAY
250
-    evolve_invalid_method, //TODO: Happiness NIGHT
251
-    evolve_by_level,
252
-    evolve_by_trade_group,
253
-    evolve_by_trade_group,
254
-    evolve_by_stone,
255
-    evolve_by_atk_def,
256
-    evolve_by_atk_def,
257
-    evolve_by_atk_def,
258
-    evolve_random,
259
-    evolve_random,
260
-    evolve_by_level,   //Shedninja SPAWN
261
-    evolve_no_method, //Shedninja SPAWNED
262
-    evolve_by_beauty
337
+    evolve_invalid_method,                            //Method 0 INVALID
338
+    evolve_by_happiness,                              //Method 1
339
+    evolve_invalid_method, //TODO: Happiness DAY        Method 2
340
+    evolve_invalid_method, //TODO: Happiness NIGHT      Method 3
341
+    evolve_by_level,                                  //Method 4
342
+    evolve_by_trade_group,                            //Method 5
343
+    evolve_by_trade_group,                            //Method 6
344
+    evolve_by_stone,                                  //Method 7
345
+    evolve_by_atk_def,                                //Method 8
346
+    evolve_by_atk_def,                                //Method 9
347
+    evolve_by_atk_def,                                //Method 10
348
+    evolve_random,                                    //Method 11
349
+    evolve_random,                                    //Method 12
350
+    evolve_by_level,   //Shedninja SPAWN                Method 13
351
+    evolve_no_method, //Shedninja SPAWNED             //Method 14
352
+    evolve_by_beauty,                                 //Method 15
353
+    evolve_by_worn_item,                              //Method 16
354
+    evolve_by_worn_item_day, //TODO implement day       Method 17
355
+    evolve_by_worn_item_night, //TODO implement night   Method 18
356
+    evolve_invalid_method, //TODO implement level night Method 19
357
+    evolve_invalid_method, //TODO implement level day   Method 20
358
+    evolve_by_special_place,                          //Method 21
359
+    evolve_by_move                                    //Method 22
263 360
 };
264 361
 
265 362
 u16 evolution_try_evolve(struct pokemon* pokemon, enum evo_source source, u16 stoneId)

+ 3
- 0
src/include/config.h Bestand weergeven

@@ -36,6 +36,9 @@
36 36
 /*Variable for custom text*/
37 37
 #define TEXT_VAR 0x500C
38 38
 
39
+/*Variable for controlling evolutions*/
40
+#define EVO_VAR 0x500D
41
+
39 42
 /*Variables to control the music overrides*/
40 43
 #define VAR_FROM_1 0x51FA
41 44
 #define VAR_FROM_2 0x51FB

+ 7
- 0
src/include/game_engine.h Bestand weergeven

@@ -93,6 +93,13 @@ extern u32 pokemon_get_attribute(struct pokemon* poke_address, u8 request, void*
93 93
 void pokemon_set_attribute(struct pokemon* poke_address, u8 request, void* new_value);
94 94
 
95 95
 /**
96
+ * @brief gets the gender of the selected pokemon
97
+ * @param poke_address address to pokémon structure
98
+ * @return true if the pokémon is female, false otherwise
99
+ */
100
+extern u8 pokemon_get_gender(struct pokemon* poke_address);
101
+
102
+/**
96 103
  * @brief gets x12 value of item
97 104
  * @param item_id item to get value of
98 105
  * @return corresponding x12 value 

+ 0
- 2
src/interface/textbox_mugshots.c Bestand weergeven

@@ -63,8 +63,6 @@ typedef struct mug_mugshot {
63 63
     void *pal;
64 64
 } mug_mugshot;
65 65
 
66
-/* TODO: USE GRIT AND ASM SYMBOL */
67
-
68 66
 /* === STATIC GLOBALS === */
69 67
 
70 68
 extern mug_mugshot *mugshots;