ソースを参照

finalize evolutions

SBird1337 7 年 前
コミット
dda960e8db
共有4 個のファイルを変更した141 個の追加3 個の削除を含む
  1. 90
    3
      src/evolution/evolution_methods.c
  2. 3
    0
      src/include/game_engine.h
  3. 18
    0
      src/include/moves.h
  4. 30
    0
      src/include/pokemon.h

+ 90
- 3
src/evolution/evolution_methods.c ファイルの表示

@@ -32,6 +32,9 @@
32 32
 #include <agb_debug.h>
33 33
 #include <math.h>
34 34
 #include <config.h>
35
+#include <moves.h>
36
+#include <pokemon.h>
37
+#include <pkmn_types.h>
35 38
 
36 39
 #define EVO_NULL {0,0,0, {false, 0}}
37 40
 #define MAX_EVOLUTIONS 5
@@ -40,6 +43,10 @@
40 43
 #define HAPPY_BOUND 219
41 44
 #define BEAUTY_BOUND 170
42 45
 
46
+#define GENDER_DC 0
47
+#define GENDER_MALE 1
48
+#define GENDER_FEMALE 2
49
+
43 50
 #define EVO_HAPPINESS 1
44 51
 #define EVO_LEVEL_UP 4
45 52
 #define EVO_TRADE 5
@@ -60,6 +67,12 @@
60 67
 #define EVO_LEVEL_DAY 20
61 68
 #define EVO_LEVEL_VAR 21
62 69
 #define EVO_LEVEL_MOVE 22
70
+#define EVO_LEVEL_POKEMON 23
71
+#define EVO_LEVEL_TYPE  24
72
+#define EVO_LEVEL_MOVE_TYPE 25
73
+#define EVO_MEGA_ONE 26
74
+#define EVO_MEGA_TWO 27
75
+#define EVO_PROTO 28
63 76
 
64 77
 enum evo_source
65 78
 {
@@ -90,8 +103,8 @@ struct evo_result
90 103
 
91 104
 struct evo_information evolutions[][MAX_EVOLUTIONS] = {
92 105
     {EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},               //Nothing
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
106
+    {{EVO_LEVEL_MOVE_TYPE,7,20,{GENDER_DC, TYPE_GRASS}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},   //BISASAM
107
+    {{EVO_LEVEL_UP,32,3,{GENDER_DC, 0}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},//BISAKNOSP
95 108
 };
96 109
 
97 110
 struct evo_call_arguments
@@ -212,6 +225,26 @@ struct evo_result evolve_by_stone(struct evo_call_arguments arguments)
212 225
     }
213 226
 }
214 227
 
228
+struct evo_result evolve_by_pokemon(struct evo_call_arguments arguments)
229
+{
230
+    u8 has_required_pokemon = false;
231
+    u16 species_required = arguments.evolution.argument_2.versatile;
232
+    dprintf("Required: %d\n", species_required);
233
+    for(int i = 0; i < 6; ++i)
234
+    {
235
+        u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
236
+        dprintf("Found pkmn: %d\n", current_species);
237
+        if(current_species == species_required)
238
+        {
239
+            has_required_pokemon = true;
240
+            break;
241
+        }
242
+    }
243
+    if(!has_required_pokemon)
244
+        return EVO_NO_EVO;
245
+    return evolve_by_level(arguments);
246
+}
247
+
215 248
 struct evo_result evolve_by_atk_def(struct evo_call_arguments arguments)
216 249
 {
217 250
     u32 atk = pokemon_get_attribute(arguments.poke, ATTR_ATTACK, NULL);
@@ -245,6 +278,30 @@ struct evo_result evolve_by_atk_def(struct evo_call_arguments arguments)
245 278
     return EVO_NO_EVO;
246 279
 }
247 280
 
281
+struct evo_result evolve_by_type(struct evo_call_arguments arguments)
282
+{
283
+    u8 has_required_pokemon = false;
284
+    u16 type_required = arguments.evolution.argument_2.versatile;
285
+    dprintf("Required: %d\n", type_required);
286
+    for(int i = 0; i < 6; ++i)
287
+    {
288
+        u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
289
+        if(current_species == 0)
290
+            continue;
291
+        u8 type_one = pokemon_stats[current_species].type_one;
292
+        u8 type_two = pokemon_stats[current_species].type_two;
293
+        dprintf("Found type: %d/%d\n", type_one, type_two);
294
+        if(type_one == type_required || type_two == type_required)
295
+        {
296
+            has_required_pokemon = true;
297
+            break;
298
+        }
299
+    }
300
+    if(!has_required_pokemon)
301
+        return EVO_NO_EVO;
302
+    return evolve_by_level(arguments);
303
+}
304
+
248 305
 struct evo_result evolve_by_happiness(struct evo_call_arguments arguments)
249 306
 {
250 307
     u32 happiness = pokemon_get_attribute(arguments.poke, ATTR_HAPPINESS, NULL);
@@ -320,6 +377,29 @@ struct evo_result evolve_by_move(struct evo_call_arguments arguments)
320 377
         return EVO_NO_EVO;
321 378
 }
322 379
 
380
+struct evo_result evolve_by_move_type(struct evo_call_arguments arguments)
381
+{
382
+    u16 needed_type = arguments.evolution.argument_2.versatile;
383
+    u8 knows_required_move = false;
384
+    for(int i = ATTR_ATTACK_1; i <= ATTR_ATTACK_4; ++i)
385
+    {
386
+        u16 current_move = pokemon_get_attribute(arguments.poke, i, NULL);
387
+        if(current_move == 0)
388
+            continue;
389
+        u8 current_type = move_table[current_move].type;
390
+        dprintf("found move type: %d on move %d\n", current_type, current_move);
391
+        if(current_type == needed_type)
392
+        {
393
+            knows_required_move = true;
394
+            break;
395
+        }
396
+    }
397
+    if(knows_required_move)
398
+        return evolve_by_level(arguments);
399
+    else
400
+        return EVO_NO_EVO;
401
+}
402
+
323 403
 struct evo_result evolve_no_method(struct evo_call_arguments arguments)
324 404
 {
325 405
     //For shedninja
@@ -356,7 +436,14 @@ static evolution_callback evolution_methods[] =
356 436
     evolve_invalid_method, //TODO implement level night Method 19
357 437
     evolve_invalid_method, //TODO implement level day   Method 20
358 438
     evolve_by_special_place,                          //Method 21
359
-    evolve_by_move                                    //Method 22
439
+    evolve_by_move,                                   //Method 22
440
+    evolve_by_pokemon,                                //Method 23
441
+    evolve_by_type,                                   //Method 24
442
+    evolve_by_move_type,                              //Method 25
443
+    evolve_no_method,                                 //Method 26
444
+    evolve_no_method,                                 //Method 26
445
+    evolve_no_method,                                 //Method 26
446
+    evolve_no_method,                                 //Method 26
360 447
 };
361 448
 
362 449
 u16 evolution_try_evolve(struct pokemon* pokemon, enum evo_source source, u16 stoneId)

+ 3
- 0
src/include/game_engine.h ファイルの表示

@@ -106,5 +106,8 @@ extern u8 pokemon_get_gender(struct pokemon* poke_address);
106 106
  */
107 107
 extern u8 item_get_x12(u16 item_id);
108 108
 
109
+/* TODO: Implement without macros */
110
+#define pokemon_party_player ((struct pokemon*) 0x02024284)
111
+
109 112
 #endif /* GAME_ENGINE_H */
110 113
 

+ 18
- 0
src/include/moves.h ファイルの表示

@@ -631,4 +631,22 @@
631 631
 #define MOVE_ZAP_CANNON 0xC0
632 632
 #define MOVE_ZEN_HEADBUTT 0x1AC
633 633
 
634
+struct move_data
635
+{
636
+    u8 effect;
637
+    u8 damage;
638
+    u8 type;
639
+    u8 accuracy;
640
+    u8 pp;
641
+    u8 effect_accuracy;
642
+    u8 target;
643
+    s8 priority;
644
+    u8 flags;
645
+    u8 arg1;
646
+    u8 split;
647
+    u8 arg3;
648
+};
649
+
650
+extern struct move_data move_table[676];
651
+
634 652
 #endif /* MOVE_IDS_H */

+ 30
- 0
src/include/pokemon.h ファイルの表示

@@ -15,4 +15,34 @@
15 15
 #define POKE_PALKIA 0x219
16 16
 #define POKE_GIRATINA 0x21C || 0x21C //for that another form
17 17
 
18
+struct pokemon_data
19
+{
20
+    u8 hp;
21
+    u8 attack;
22
+    u8 defence;
23
+    u8 speed;
24
+    u8 sp_attack;
25
+    u8 sp_defence;
26
+    u8 type_one;
27
+    u8 type_two;
28
+    u8 catch_rate;
29
+    u8 base_exp_yield;
30
+    u16 effort_yield;
31
+    u16 item_one;
32
+    u16 item_two;
33
+    u8 gender;
34
+    u8 egg_cycles;
35
+    u8 base_friendship;
36
+    u8 level_type;
37
+    u8 egg_group_one;
38
+    u8 egg_group_two;
39
+    u8 ability_one;
40
+    u8 ability_two;
41
+    u8 safari_rate;
42
+    u8 color_flip;
43
+    u16 padding;
44
+};
45
+
46
+extern struct pokemon_data pokemon_stats[1300];
47
+
18 48
 #endif /* POKE_INDICES_H */