|
@@ -39,6 +39,66 @@ enum evo_source
|
39
|
39
|
STONE_REQUEST
|
40
|
40
|
};
|
41
|
41
|
|
|
42
|
+struct evo_information
|
|
43
|
+{
|
|
44
|
+ u16 method;
|
|
45
|
+ u16 argument;
|
|
46
|
+ u16 evolve_to;
|
|
47
|
+ u8 arg1;
|
|
48
|
+ u8 arg2;
|
|
49
|
+};
|
|
50
|
+
|
|
51
|
+struct evo_result
|
|
52
|
+{
|
|
53
|
+ u8 can_evolve;
|
|
54
|
+ u8 consume_item;
|
|
55
|
+ u8 evolve_to;
|
|
56
|
+};
|
|
57
|
+
|
|
58
|
+#define EVO_NULL {0,0,0,0,0}
|
|
59
|
+#define EVO_LEVEL_UP 4
|
|
60
|
+#define MAX_EVOLUTIONS 3
|
|
61
|
+
|
|
62
|
+struct evo_information evolutions[][MAX_EVOLUTIONS] = {
|
|
63
|
+ {EVO_NULL,EVO_NULL,EVO_NULL},
|
|
64
|
+ {{EVO_LEVEL_UP,16,2,0,0},EVO_NULL,EVO_NULL},
|
|
65
|
+ {{EVO_LEVEL_UP,32,3,0,0},EVO_NULL,EVO_NULL},
|
|
66
|
+};
|
|
67
|
+
|
|
68
|
+struct evo_call_arguments
|
|
69
|
+{
|
|
70
|
+ u16 item;
|
|
71
|
+ u16 level;
|
|
72
|
+ enum evo_source source;
|
|
73
|
+ u16 stoneId;
|
|
74
|
+ struct pokemon* poke;
|
|
75
|
+ struct evo_information evolution;
|
|
76
|
+};
|
|
77
|
+
|
|
78
|
+typedef struct evo_result (*evolution_callback)(struct evo_call_arguments);
|
|
79
|
+
|
|
80
|
+struct evo_result evolve_by_level(struct evo_call_arguments arguments)
|
|
81
|
+{
|
|
82
|
+ if(arguments.source != LEVEL_UP)
|
|
83
|
+ {
|
|
84
|
+ return (struct evo_result){false, false, 0};
|
|
85
|
+ }
|
|
86
|
+ if(arguments.evolution.argument <= arguments.level)
|
|
87
|
+ {
|
|
88
|
+ return (struct evo_result){true, false, arguments.evolution.evolve_to};
|
|
89
|
+ }
|
|
90
|
+ return (struct evo_result){false, false, 0};
|
|
91
|
+}
|
|
92
|
+
|
|
93
|
+static evolution_callback evolution_methods[] =
|
|
94
|
+{
|
|
95
|
+ NULL,
|
|
96
|
+ NULL, //TODO: Happiness
|
|
97
|
+ NULL, //TODO: Happiness DAY
|
|
98
|
+ NULL, //TODO: Happiness NIGHT
|
|
99
|
+ evolve_by_level
|
|
100
|
+};
|
|
101
|
+
|
42
|
102
|
u16 evolution_try_evolve(struct pokemon* pokemon, enum evo_source source, u16 stoneId)
|
43
|
103
|
{
|
44
|
104
|
u16 held_item = pokemon_get_attribute(pokemon, ATTR_HELD_ITEM, NULL);
|
|
@@ -47,6 +107,29 @@ u16 evolution_try_evolve(struct pokemon* pokemon, enum evo_source source, u16 st
|
47
|
107
|
//TODO PID
|
48
|
108
|
dprintf("Species %d tried to evolve.\n", species);
|
49
|
109
|
dprintf("Cause: %d\n", source);
|
50
|
|
- dprintf("Held Item: %d; Level: %d\nBlocking evolution for debug.", held_item, level);
|
|
110
|
+ struct evo_information* current_evolution_structure = evolutions[species];
|
|
111
|
+ struct evo_result result;
|
|
112
|
+ for(int i = 0; i < MAX_EVOLUTIONS; ++i)
|
|
113
|
+ {
|
|
114
|
+ if(current_evolution_structure[i].method != 0)
|
|
115
|
+ {
|
|
116
|
+ dprintf("found valid evolution with method %d for species %d", current_evolution_structure[i].method, species);
|
|
117
|
+ struct evo_call_arguments args = {held_item, level, source, stoneId, pokemon, current_evolution_structure[i]};
|
|
118
|
+ result = evolution_methods[current_evolution_structure[i].method](args);
|
|
119
|
+ if(result.can_evolve)
|
|
120
|
+ break;
|
|
121
|
+ }
|
|
122
|
+ }
|
|
123
|
+ if(result.can_evolve)
|
|
124
|
+ {
|
|
125
|
+ if(result.consume_item)
|
|
126
|
+ {
|
|
127
|
+ //TODO: Consume
|
|
128
|
+ }
|
|
129
|
+ return result.evolve_to;
|
|
130
|
+ }
|
|
131
|
+ else
|
|
132
|
+ return 0;
|
|
133
|
+ /*evolve everything to mewtu for jiggs & giggles*/
|
51
|
134
|
return 150;
|
52
|
135
|
}
|