summaryrefslogtreecommitdiff
path: root/asm/macros/battle_ai_script.inc
blob: 3aadc1e478717e514630eb3587a8d4a267d5d7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
	.macro if_random_less_than percent:req, ptr:req
	.byte 0x00
	.byte \percent
	.4byte \ptr
	.endm

	@ unused
	.macro if_random_greater_than percent:req, ptr:req
	.byte 0x01
	.byte \percent
	.4byte \ptr
	.endm

	@ unused
	.macro if_random_equal ptr:req
	.byte 0x02
	.4byte \ptr
	.endm

	@ unused
	.macro if_random_not_equal ptr:req
	.byte 0x03
	.4byte \ptr
	.endm

	.macro score score:req
	.byte 0x04
	.byte \score
	.endm

	.macro if_hp_less_than battler:req, percent:req, ptr:req
	.byte 0x05
	.byte \battler
	.byte \percent
	.4byte \ptr
	.endm

	.macro if_hp_more_than battler:req, percent:req, ptr:req
	.byte 0x06
	.byte \battler
	.byte \percent
	.4byte \ptr
	.endm

	.macro if_hp_equal battler:req, percent:req, ptr:req
	.byte 0x07
	.byte \battler
	.byte \percent
	.4byte \ptr
	.endm

	.macro if_hp_not_equal battler:req, percent:req, ptr:req
	.byte 0x08
	.byte \battler
	.byte \percent
	.4byte \ptr
	.endm

	.macro if_status battler:req, status:req, ptr:req
	.byte 0x09
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_not_status battler:req, status:req, ptr:req
	.byte 0x0a
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_status2 battler:req, status:req, ptr:req
	.byte 0x0b
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_not_status2 battler:req, status:req, ptr:req
	.byte 0x0c
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_status3 battler:req, status:req, ptr:req
	.byte 0x0d
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_not_status3 battler:req, status:req, ptr:req
	.byte 0x0e
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_side_affecting battler:req, status:req, ptr:req
	.byte 0x0f
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_not_side_affecting battler:req, status:req, ptr:req
	.byte 0x10
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro if_less_than value:req, ptr:req
	.byte 0x11
	.byte \value
	.4byte \ptr
	.endm

	.macro if_more_than value:req, ptr:req
	.byte 0x12
	.byte \value
	.4byte \ptr
	.endm

	.macro if_equal value:req, ptr:req
	.byte 0x13
	.byte \value
	.4byte \ptr
	.endm

	.macro if_not_equal value:req, ptr:req
	.byte 0x14
	.byte \value
	.4byte \ptr
	.endm

	.macro if_less_than_ptr value:req, ptr:req
	.byte 0x15
	.4byte \value
	.4byte \ptr
	.endm

	.macro if_more_than_ptr value:req, ptr:req
	.byte 0x16
	.4byte \value
	.4byte \ptr
	.endm

	.macro if_equal_ptr value:req, ptr:req
	.byte 0x17
	.4byte \value
	.4byte \ptr
	.endm

	.macro if_not_equal_ptr value:req, ptr:req
	.byte 0x18
	.4byte \value
	.4byte \ptr
	.endm

	.macro if_move move:req, ptr:req
	.byte 0x19
	.2byte \move
	.4byte \ptr
	.endm

	.macro if_not_move move:req, ptr:req
	.byte 0x1a
	.2byte \move
	.4byte \ptr
	.endm

	.macro if_in_bytes list:req, ptr:req
	.byte 0x1b
	.4byte \list
	.4byte \ptr
	.endm

	.macro if_not_in_bytes list:req, ptr:req
	.byte 0x1c
	.4byte \list
	.4byte \ptr
	.endm

	.macro if_in_hwords list:req, ptr:req
	.byte 0x1d
	.4byte \list
	.4byte \ptr
	.endm

	.macro if_not_in_hwords list:req, ptr:req
	.byte 0x1e
	.4byte \list
	.4byte \ptr
	.endm

	.macro if_user_has_attacking_move ptr:req
	.byte 0x1f
	.4byte \ptr
	.endm

	.macro if_user_has_no_attacking_moves ptr:req
	.byte 0x20
	.4byte \ptr
	.endm

	.macro get_turn_count
	.byte 0x21
	.endm

	.macro get_type byte:req
	.byte 0x22
	.byte \byte
	.endm

	@ unused
	.macro get_considered_move_power
	.byte 0x23
	.endm

	.macro get_how_powerful_move_is
	.byte 0x24
	.endm

	.macro get_last_used_move battler:req
	.byte 0x25
	.byte \battler
	.endm

	.macro if_equal_ type:req, ptr:req
	.byte 0x26
	.byte \type
	.4byte \ptr
	.endm

	@ unused
	.macro if_not_equal_ type:req, ptr:req
	.byte 0x27
	.byte \type
	.4byte \ptr
	.endm

	.macro if_would_go_first battler:req, ptr:req
	.byte 0x28
	.byte \battler
	.4byte \ptr
	.endm

	.macro if_would_not_go_first battler:req, ptr:req
	.byte 0x29
	.byte \battler
	.4byte \ptr
	.endm

	@ nullsub
	.macro ai_2a
	.byte 0x2a
	.endm

	@ nullsub
	.macro ai_2b
	.byte 0x2b
	.endm

	.macro count_alive_pokemon battler:req
	.byte 0x2c
	.byte \battler
	.endm

	@ unused
	.macro get_considered_move
	.byte 0x2d
	.endm

	.macro get_considered_move_effect
	.byte 0x2e
	.endm

	.macro get_ability battler:req
	.byte 0x2f
	.byte \battler
	.endm

	@ unused
	.macro get_highest_type_effectiveness
	.byte 0x30
	.endm

	.macro if_type_effectiveness effectiveness:req, ptr:req
	.byte 0x31
	.byte \effectiveness
	.4byte \ptr
	.endm

	@ nullsub
	.macro ai_32
	.byte 0x32
	.endm

	@ nullsub
	.macro ai_33
	.byte 0x33
	.endm

	.macro if_status_in_party battler:req, status:req, ptr:req
	.byte 0x34
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	@ bugged
	.macro if_status_not_in_party battler:req, status:req, ptr:req
	.byte 0x35
	.byte \battler
	.4byte \status
	.4byte \ptr
	.endm

	.macro get_weather
	.byte 0x36
	.endm

	.macro if_effect byte:req, ptr:req
	.byte 0x37
	.byte \byte
	.4byte \ptr
	.endm

	.macro if_not_effect byte:req, ptr:req
	.byte 0x38
	.byte \byte
	.4byte \ptr
	.endm

	.macro if_stat_level_less_than battler:req, stat:req, level:req, ptr:req
	.byte 0x39
	.byte \battler
	.byte \stat
	.byte \level
	.4byte \ptr
	.endm

	.macro if_stat_level_more_than battler:req, stat:req, level:req, ptr:req
	.byte 0x3a
	.byte \battler
	.byte \stat
	.byte \level
	.4byte \ptr
	.endm

	.macro if_stat_level_equal battler:req, stat:req, level:req, ptr:req
	.byte 0x3b
	.byte \battler
	.byte \stat
	.byte \level
	.4byte \ptr
	.endm

	.macro if_stat_level_not_equal battler:req, stat:req, level:req, ptr:req
	.byte 0x3c
	.byte \battler
	.byte \stat
	.byte \level
	.4byte \ptr
	.endm

	.macro if_can_faint ptr:req
	.byte 0x3d
	.4byte \ptr
	.endm

	.macro if_cant_faint ptr:req
	.byte 0x3e
	.4byte \ptr
	.endm

	@ unused
	.macro if_has_move battler:req, move:req, ptr:req
	.byte 0x3f
	.byte \battler
	.2byte \move
	.4byte \ptr
	.endm

	@ unused
	.macro if_doesnt_have_move battler:req, move:req, ptr:req
	.byte 0x40
	.byte \battler
	.2byte \move
	.4byte \ptr
	.endm

	.macro if_has_move_with_effect battler:req, effect:req, ptr:req
	.byte 0x41
	.byte \battler
	.byte \effect
	.4byte \ptr
	.endm

	.macro if_doesnt_have_move_with_effect battler:req, effect:req, ptr:req
	.byte 0x42
	.byte \battler
	.byte \effect
	.4byte \ptr
	.endm

	.macro if_any_move_disabled_or_encored battler:req, byte:req, ptr:req
	.byte 0x43
	.byte \battler
	.byte \byte
	.4byte \ptr
	.endm

	.macro if_curr_move_disabled_or_encored battler:req, ptr:req
	.byte 0x44
	.byte \battler
	.4byte \ptr
	.endm

	.macro flee
	.byte 0x45
	.endm

	.macro if_random_safari_flee ptr:req
	.byte 0x46
	.4byte \ptr
	.endm

	.macro watch
	.byte 0x47
	.endm

	.macro get_hold_effect battler:req
	.byte 0x48
	.byte \battler
	.endm

	.macro get_gender battler:req
	.byte 0x49
	.byte \battler
	.endm

	.macro is_first_turn_for battler:req
	.byte 0x4a
	.byte \battler
	.endm

	.macro get_stockpile_count battler:req
	.byte 0x4b
	.byte \battler
	.endm

	.macro is_double_battle
	.byte 0x4c
	.endm

	.macro get_used_held_item battler:req
	.byte 0x4d
	.byte \battler
	.endm

	.macro get_move_type_from_result
	.byte 0x4e
	.endm

	.macro get_move_power_from_result
	.byte 0x4f
	.endm

	.macro get_move_effect_from_result
	.byte 0x50
	.endm

	.macro get_protect_count battler:req
	.byte 0x51
	.byte \battler
	.endm

	@ nullsub
	.macro ai_52
	.byte 0x52
	.endm

	@ nullsub
	.macro ai_53
	.byte 0x53
	.endm

	@ nullsub
	.macro ai_54
	.byte 0x54
	.endm

	@ nullsub
	.macro ai_55
	.byte 0x55
	.endm

	@ nullsub
	.macro ai_56
	.byte 0x56
	.endm

	@ nullsub
	.macro ai_57
	.byte 0x57
	.endm

	@ unused
	.macro call ptr:req
	.byte 0x58
	.4byte \ptr
	.endm

	.macro goto ptr:req
	.byte 0x59
	.4byte \ptr
	.endm

	.macro end
	.byte 0x5a
	.endm

	.macro if_level_cond cond:req, ptr:req
	.byte 0x5b
	.byte \cond
	.4byte \ptr
	.endm

	.macro if_user_higher_level ptr:req
	if_level_cond 0, \ptr
	.endm

	.macro if_target_higher_level ptr:req
	if_level_cond 1, \ptr
	.endm

	.macro if_equal_levels ptr:req
	if_level_cond 2, \ptr
	.endm

	@ unused
	.macro if_target_taunted ptr:req
	.byte 0x5c
	.4byte \ptr
	.endm

	.macro if_target_not_taunted ptr:req
	.byte 0x5d
	.4byte \ptr
	.endm

@ useful script macros
	.macro get_curr_move_type
	get_type AI_TYPE_MOVE
	.endm
	
	.macro get_user_type1
	get_type AI_TYPE1_USER
	.endm
	
	.macro get_user_type2
	get_type AI_TYPE2_USER
	.endm
	
	.macro get_target_type1
	get_type AI_TYPE1_TARGET
	.endm
	
	.macro get_target_type2
	get_type AI_TYPE2_TARGET
	.endm

	.macro if_target_faster ptr:req
	if_would_go_first 1, \ptr
	.endm
	
	.macro if_user_faster ptr:req
	if_would_go_first 0, \ptr
	.endm

	.macro if_double_battle ptr:req
	is_double_battle
	if_equal 1, \ptr
	.endm
	
	.macro if_not_double_battle ptr:req
	is_double_battle
	if_equal 0, \ptr
	.endm

	.macro if_any_move_disabled battler:req, ptr:req
	if_any_move_disabled_or_encored \battler, 0, \ptr
	.endm
	
	.macro if_any_move_encored battler:req, ptr:req
	if_any_move_disabled_or_encored \battler, 1, \ptr
	.endm