|
@@ -31,12 +31,8 @@
|
31
|
31
|
/* === INCLUDE === */
|
32
|
32
|
|
33
|
33
|
#include <agb_debug.h>
|
34
|
|
-#include <callback.h>
|
35
|
34
|
#include <config/core.h>
|
36
|
|
-#include <debug.h>
|
37
|
|
-#include <game_engine.h>
|
38
|
|
-#include <types.h>
|
39
|
|
-
|
|
35
|
+#include <pokeagb/pokeagb.h>
|
40
|
36
|
|
41
|
37
|
/* === ENGINE EXTERNS === */
|
42
|
38
|
extern void battle_init();
|
|
@@ -101,7 +97,7 @@ u32 load_word(void *ptr) {
|
101
|
97
|
* @return flag +1 for medium, flag +2 for hard
|
102
|
98
|
*/
|
103
|
99
|
u16 tb_modify_flag_id(u16 flag) {
|
104
|
|
- u16 difficulty = var_get(0x5052);
|
|
100
|
+ u16 difficulty = var_load(0x5052);
|
105
|
101
|
u16 new_flag = flag;
|
106
|
102
|
switch (difficulty) {
|
107
|
103
|
case 0:
|
|
@@ -186,7 +182,7 @@ void *tb_configure_by_script(void *ptr_script) {
|
186
|
182
|
trainerbattle_message_intro = NULL;
|
187
|
183
|
|
188
|
184
|
trainerbattle_message_defeat = tb_modify_text((char *)load_word(ptr_script), 0);
|
189
|
|
- ptr_script+= 4;
|
|
185
|
+ ptr_script += 4;
|
190
|
186
|
|
191
|
187
|
trainerbattle_message_2 = NULL;
|
192
|
188
|
trainerbattle_message_need_2_poke = NULL;
|
|
@@ -280,6 +276,11 @@ void *tb_configure_by_script(void *ptr_script) {
|
280
|
276
|
battle_80801F0_something();
|
281
|
277
|
|
282
|
278
|
return (void *)(0x081A4EC1); /* some script to execute */
|
|
279
|
+
|
|
280
|
+ case 0xFF:
|
|
281
|
+ /* this is a registered on-spot script */
|
|
282
|
+ /* since this is a trainerbattle configuration we will skip the TB command. */
|
|
283
|
+ return ptr_script + 13;
|
283
|
284
|
default:
|
284
|
285
|
trainerbattle_battle_type = load_byte(ptr_script);
|
285
|
286
|
ptr_script++;
|
|
@@ -307,3 +308,24 @@ void *tb_configure_by_script(void *ptr_script) {
|
307
|
308
|
// assert(0);
|
308
|
309
|
// return NULL;
|
309
|
310
|
}
|
|
311
|
+
|
|
312
|
+void tb_on_spot(u8 npc_id, void *ptr_script) {
|
|
313
|
+ scripting_npc = npc_id;
|
|
314
|
+ var_800F = npc_states[npc_id].local_id;
|
|
315
|
+ u8 tb_battle_type = load_byte(ptr_script + 1);
|
|
316
|
+
|
|
317
|
+ if (tb_battle_type != 0xFF) {
|
|
318
|
+ tb_configure_by_script(ptr_script + 1);
|
|
319
|
+ script_env_init_script((void *)0x081A4EB4);
|
|
320
|
+ script_env_enable();
|
|
321
|
+ } else {
|
|
322
|
+ u16 flag = load_hword(ptr_script + 2);
|
|
323
|
+ void *scr_true = (void *)load_word(ptr_script + 6);
|
|
324
|
+ void *scr_false = (void *)load_word(ptr_script + 10);
|
|
325
|
+ if (flag_check(flag))
|
|
326
|
+ script_env_init_script(scr_true);
|
|
327
|
+ else
|
|
328
|
+ script_env_init_script(scr_false);
|
|
329
|
+ script_env_enable();
|
|
330
|
+ }
|
|
331
|
+}
|