Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
actor_api.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "battle/battle.h"
4
5extern s32 IsGroupHeal;
6extern s8 ApplyingBuff;
7
8s32 count_targets(Actor* actor, s32 targetHomeIndex, s32 targetSelectionFlags) {
9 BattleStatus* battleStatus = &gBattleStatus;
10
11 battleStatus->sampleTargetHomeIndex = targetHomeIndex;
12 battleStatus->curTargetListFlags = targetSelectionFlags;
14 return actor->targetListLength;
15}
16
17s32 get_nearest_home_index(f32 x, f32 y, f32 z) {
18 s32 row;
19 s32 col;
20
21 if (y < 40.0f) {
22 row = 0;
23 } else if (y < 85.0f) {
24 row = 1;
25 } else if (y < 100.0f) {
26 row = 2;
27 } else {
28 row = 3;
29 }
30
31 if (x < 25.0f) {
32 col = 0;
33 } else if (x < 65.0f) {
34 col = 1;
35 } else if (x < 105.0f) {
36 col = 2;
37 } else {
38 col = 3;
39 }
40
41 return col | (row << 2);
42}
43
44void set_goal_pos_to_part(ActorState* state, s32 actorID, s32 partID) {
45 s32 actorClass = actorID & ACTOR_CLASS_MASK;
46 Actor* actor = get_actor(actorID);
47 ActorPart* part;
48
49 switch (actorClass) {
51 part = get_actor_part(actor, 0);
52 state->goalPos.x = actor->curPos.x + part->partOffset.x * actor->scalingFactor;
53 state->goalPos.y = actor->curPos.y + part->partOffset.y * actor->scalingFactor;
54 state->goalPos.z = actor->curPos.z + 10.0f;
55 if (actor->stoneStatus == STATUS_KEY_STONE) {
56 state->goalPos.y -= actor->scalingFactor * 5.0f;
57 }
58 break;
61 part = get_actor_part(actor, partID);
63 state->goalPos.x = actor->curPos.x + (part->partOffset.x + part->targetOffset.x) * actor->scalingFactor;
64 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
65 state->goalPos.y = actor->curPos.y + (part->partOffset.y + part->targetOffset.y) * actor->scalingFactor;
66 } else {
67 state->goalPos.y = actor->curPos.y + (-part->partOffset.y - part->targetOffset.y) * actor->scalingFactor;
68 }
69 state->goalPos.z = actor->curPos.z + part->partOffset.z + 10.0f;
70 } else {
71 state->goalPos.x = part->absolutePos.x + part->targetOffset.x;
72 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
73 state->goalPos.y = part->absolutePos.y + part->targetOffset.y * actor->scalingFactor;
74 } else {
75 state->goalPos.y = part->absolutePos.y - part->targetOffset.y * actor->scalingFactor;
76 }
77 state->goalPos.z = part->absolutePos.z + 10.0f;
78 }
79 break;
80 }
81}
82
83void set_part_goal_to_actor_part(ActorPartMovement* movement, s32 actorID, s32 partID) {
84 s32 actorClass = actorID & ACTOR_CLASS_MASK;
85 Actor* actor = get_actor(actorID);
86 ActorPart* part;
87
88 switch (actorClass) {
90 part = get_actor_part(actor, 0);
91 part->movement->goalPos.x = actor->curPos.x + part->partOffset.x * actor->scalingFactor;
92 part->movement->goalPos.y = actor->curPos.y + part->partOffset.y * actor->scalingFactor;
93 part->movement->goalPos.z = actor->curPos.z;
94 break;
97 part = get_actor_part(actor, partID);
99 part->movement->goalPos.x = actor->curPos.x + (part->partOffset.x + part->targetOffset.x) * actor->scalingFactor;
100 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
101 part->movement->goalPos.y = actor->curPos.y + (part->partOffset.y + part->targetOffset.y) * actor->scalingFactor;
102 } else {
103 part->movement->goalPos.y = actor->curPos.y + (-part->partOffset.y - part->targetOffset.y) * actor->scalingFactor;
104 }
105 part->movement->goalPos.z = actor->curPos.z + part->partOffset.z;
106 } else {
107 part->movement->goalPos.x = part->absolutePos.x + part->targetOffset.x;
108 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
109 part->movement->goalPos.y = part->absolutePos.y + part->targetOffset.y * actor->scalingFactor;
110 } else {
111 part->movement->goalPos.y = part->absolutePos.y - part->targetOffset.y * actor->scalingFactor;
112 }
113 part->movement->goalPos.z = part->absolutePos.z;
114 }
115 break;
116 }
117}
118
119void set_actor_current_position(s32 actorID, f32 x, f32 y, f32 z) {
120 Actor* actor = get_actor(actorID);
121
122 actor->curPos.x = x;
123 actor->curPos.y = y;
124 actor->curPos.z = z;
125}
126
127void set_part_absolute_position(s32 actorID, s32 partID, f32 x, f32 y, f32 z) {
128 Actor* actor = get_actor(actorID);
129 ActorPart* actorPart;
130
131 switch (actorID & ACTOR_CLASS_MASK) {
133 actor->curPos.x = x;
134 actor->curPos.y = y;
135 actor->curPos.z = z;
136 break;
139 actorPart = get_actor_part(actor, partID);
140 actorPart->absolutePos.x = x;
141 actorPart->absolutePos.y = y;
142 actorPart->absolutePos.z = z;
143 break;
144 }
145}
146
147void set_actor_home_position(s32 actorID, f32 x, f32 y, f32 z) {
148 Actor* actor = get_actor(actorID);
149
150 actor->homePos.x = x;
151 actor->homePos.y = y;
152 actor->homePos.z = z;
153}
154
155Actor* get_actor(s32 actorID) {
156 Actor* ret = NULL;
157 BattleStatus* battleStatus = &gBattleStatus;
158 s32 actorClass = actorID & ACTOR_CLASS_MASK;
159 u32 idIdx = (u8)actorID;
160
161 switch (actorClass) {
163 ret = battleStatus->playerActor;
164 break;
166 ret = battleStatus->partnerActor;
167 break;
169 ret = battleStatus->enemyActors[idIdx];
170 break;
171 }
172 return ret;
173}
174
175API_CALLABLE(LoadBattleSection) {
176 BattleArea* battleArea = &gBattleAreas[evt_get_variable(script, *script->ptrReadPos)];
177
178 dma_copy(battleArea->dmaStart, battleArea->dmaEnd, battleArea->dmaDest);
179 return ApiStatus_DONE1;
180}
181
182
183API_CALLABLE(GetBattlePhase) {
184 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.battlePhase);
185 return ApiStatus_DONE2;
186}
187
188API_CALLABLE(GetLastElement) {
189 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.curAttackElement);
190 return ApiStatus_DONE2;
191}
192
193API_CALLABLE(GetDamageSource) {
194 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.curDamageSource);
195 return ApiStatus_DONE2;
196}
197
198API_CALLABLE(SetDamageSource) {
199 s32 damageSource = *script->ptrReadPos;
200
201 gBattleStatus.curDamageSource = damageSource;
202 return ApiStatus_DONE2;
203}
204
205API_CALLABLE(SetGoalToHome) {
206 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
207 Actor* actor;
208
209 if (actorID == ACTOR_SELF) {
210 actorID = script->owner1.actorID;
211 }
212
213 actor = get_actor(actorID);
214 actor->state.goalPos.x = actor->homePos.x;
215 actor->state.goalPos.y = actor->homePos.y;
216 actor->state.goalPos.z = actor->homePos.z;
217
218 return ApiStatus_DONE2;
219}
220
221API_CALLABLE(SetIdleGoalToHome) {
222 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
223 Actor* actor;
224
225 if (actorID == ACTOR_SELF) {
226 actorID = script->owner1.actorID;
227 }
228
229 actor = get_actor(actorID);
230 actor->fly.goalPos.x = actor->homePos.x;
231 actor->fly.goalPos.y = actor->homePos.y;
232 actor->fly.goalPos.z = actor->homePos.z;
233
234 return ApiStatus_DONE2;
235}
236
237API_CALLABLE(SetGoalToIndex) {
238 s32* args = script->ptrReadPos;
239 s32 actorID = evt_get_variable(script, *args++);
240 s32 index = evt_get_variable(script, *args++);
241 Actor* actor;
242
243 if (actorID == ACTOR_SELF) {
244 actorID = script->owner1.actorID;
245 }
246
247 actor = get_actor(actorID);
251
252 return ApiStatus_DONE2;
253}
254
255API_CALLABLE(GetIndexFromPos) {
256 Bytecode* args = script->ptrReadPos;
257 s32 actorID = evt_get_variable(script, *args++);
258 s32 outVar = *args++;
259 Actor* actor;
260 s32 homeIdx;
261
262 if (actorID == ACTOR_SELF) {
263 actorID = script->owner1.actorID;
264 }
265
266 actor = get_actor(actorID);
267 homeIdx = get_nearest_home_index(actor->curPos.x, actor->curPos.y, actor->curPos.z);
268 evt_set_variable(script, outVar, homeIdx);
269
270 return ApiStatus_DONE2;
271}
272
273API_CALLABLE(GetIndexFromHome) {
274 Bytecode* args = script->ptrReadPos;
275 s32 actorID = evt_get_variable(script, *args++);
276 s32 outVar = *args++;
277 Actor* actor;
278 s32 homeIdx;
279
280 if (actorID == ACTOR_SELF) {
281 actorID = script->owner1.actorID;
282 }
283
284 actor = get_actor(actorID);
285 homeIdx = get_nearest_home_index(actor->homePos.x, actor->homePos.y, actor->homePos.z);
286 evt_set_variable(script, outVar, homeIdx);
287
288 return ApiStatus_DONE2;
289}
290
291API_CALLABLE(CountTargets) {
292 Bytecode* args = script->ptrReadPos;
293 s32 actorID = evt_get_variable(script, *args++);
294 s32 targetSelectionFlags = *args++;
295 s32 outVar = *args++;
296 Actor* actor;
297 s32 homeIdx;
298 s32 numTargets;
299
300 if (actorID == ACTOR_SELF) {
301 actorID = script->owner1.actorID;
302 }
303
304 actor = get_actor(actorID);
305 homeIdx = get_nearest_home_index(actor->curPos.x, actor->curPos.y, actor->curPos.z);
306 numTargets = count_targets(actor, homeIdx, targetSelectionFlags);
307 evt_set_variable(script, outVar, numTargets);
308
309 return ApiStatus_DONE2;
310}
311
312API_CALLABLE(ForceHomePos) {
313 Bytecode* args = script->ptrReadPos;
314 s32 actorID = evt_get_variable(script, *args++);
315 f32 x, y, z;
316 Actor* actor;
317
318 if (actorID == ACTOR_SELF) {
319 actorID = script->owner1.actorID;
320 }
321
322 x = evt_get_variable(script, *args++);
323 y = evt_get_variable(script, *args++);
324 z = evt_get_variable(script, *args++);
325
326 actor = get_actor(actorID);
327 actor->curPos.x = actor->homePos.x = x;
328 actor->curPos.y = actor->homePos.y = y;
329 actor->curPos.z = actor->homePos.z = z;
330
331 return ApiStatus_DONE2;
332}
333
334API_CALLABLE(SetHomePos) {
335 Bytecode* args = script->ptrReadPos;
336 s32 actorID = evt_get_variable(script, *args++);
337 f32 x, y, z;
338 Actor* actor;
339
340 if (actorID == ACTOR_SELF) {
341 actorID = script->owner1.actorID;
342 }
343
344 x = evt_get_variable(script, *args++);
345 y = evt_get_variable(script, *args++);
346 z = evt_get_variable(script, *args++);
347
348 actor = get_actor(actorID);
349 actor->homePos.x = x;
350 actor->homePos.y = y;
351 actor->homePos.z = z;
352
353 return ApiStatus_DONE2;
354}
355
356API_CALLABLE(SetGoalToTarget) {
357 Bytecode* args = script->ptrReadPos;
358 s32 actorID = evt_get_variable(script, *args++);
359 Actor* actor;
360
361 if (actorID == ACTOR_SELF) {
362 actorID = script->owner1.actorID;
363 }
364 actor = get_actor(actorID);
365
366 set_goal_pos_to_part(&actor->state, actor->targetActorID, actor->targetPartID);
367
368 return ApiStatus_DONE2;
369}
370
371API_CALLABLE(SetPartGoalToTarget) {
372 Bytecode* args = script->ptrReadPos;
373 s32 actorID = evt_get_variable(script, *args++);
374 s32 partID = evt_get_variable(script, *args++);
375 Actor* actor;
376
377 if (actorID == ACTOR_SELF) {
378 actorID = script->owner1.actorID;
379 }
380 actor = get_actor(actorID);
381
382 set_part_goal_to_actor_part(get_actor_part(actor, partID)->movement, actor->targetActorID, actor->targetPartID);
383
384 return ApiStatus_DONE2;
385}
386
387API_CALLABLE(SetGoalToFirstTarget) {
388 Bytecode* args = script->ptrReadPos;
389 s32 actorID = evt_get_variable(script, *args++);
390 Actor* actor;
391 SelectableTarget* target;
392
393 if (actorID == ACTOR_SELF) {
394 actorID = script->owner1.actorID;
395 }
396 actor = get_actor(actorID);
397
398 target = &actor->targetData[actor->targetIndexList[0]];
399 set_goal_pos_to_part(&actor->state, target->actorID, target->partID);
400
401 return ApiStatus_DONE2;
402}
403
404API_CALLABLE(SetGoalPos) {
405 Bytecode* args = script->ptrReadPos;
406 s32 actorID = evt_get_variable(script, *args++);
407 Actor* actor;
408 ActorState* walk;
409 f32 x, y, z;
410
411 if (actorID == ACTOR_SELF) {
412 actorID = script->owner1.actorID;
413 }
414 actor = get_actor(actorID);
415 walk = &actor->state;
416
417 if (*args == ACTOR_API_SKIP_ARG) {
418 x = walk->goalPos.x;
419 } else {
420 x = evt_get_variable(script, *args);
421 }
422
423 *args++;
424 if (*args == ACTOR_API_SKIP_ARG) {
425 y = walk->goalPos.y;
426 } else {
427 y = evt_get_variable(script, *args);
428 }
429
430 *args++;
431 if (*args == ACTOR_API_SKIP_ARG) {
432 z = walk->goalPos.z;
433 } else {
434 z = evt_get_variable(script, *args);
435 }
436
437 walk->goalPos.x = x;
438 walk->goalPos.y = y;
439 walk->goalPos.z = z;
440
441 return ApiStatus_DONE2;
442}
443
444API_CALLABLE(SetIdleGoal) {
445 Bytecode* args = script->ptrReadPos;
446 s32 actorID = evt_get_variable(script, *args++);
447 Actor* actor;
448 ActorMovement* fly;
449 f32 x, y, z;
450
451 if (actorID == ACTOR_SELF) {
452 actorID = script->owner1.actorID;
453 }
454 actor = get_actor(actorID);
455 fly = &actor->fly;
456
457 if (*args == ACTOR_API_SKIP_ARG) {
458 x = actor->fly.goalPos.x;
459 } else {
460 x = evt_get_variable(script, *args);
461 }
462
463 *args++;
464 if (*args == ACTOR_API_SKIP_ARG) {
465 y = fly->goalPos.y;
466 } else {
467 y = evt_get_variable(script, *args);
468 }
469
470 *args++;
471 if (*args == ACTOR_API_SKIP_ARG) {
472 z = fly->goalPos.z;
473 } else {
474 z = evt_get_variable(script, *args);
475 }
476
477 fly->goalPos.x = x;
478 fly->goalPos.y = y;
479 fly->goalPos.z = z;
480 return ApiStatus_DONE2;
481}
482
483API_CALLABLE(AddGoalPos) {
484 Bytecode* args = script->ptrReadPos;
485 s32 actorID = evt_get_variable(script, *args++);
486 Actor* actor;
487 f32 x, y, z;
488
489 if (actorID == ACTOR_SELF) {
490 actorID = script->owner1.actorID;
491 }
492
493 x = evt_get_float_variable(script, *args++);
494 y = evt_get_float_variable(script, *args++);
495 z = evt_get_float_variable(script, *args++);
496
497 actor = get_actor(actorID);
498 actor->state.goalPos.x += x;
499 actor->state.goalPos.y += y;
500 actor->state.goalPos.z += z;
501
502 return ApiStatus_DONE2;
503}
504
505API_CALLABLE(GetGoalPos) {
506 Bytecode* args = script->ptrReadPos;
507 s32 actorID = evt_get_variable(script, *args++);
508 Actor* actor;
509 s32 outX, outY, outZ;
510 s32 x, y, z;
511
512 if (actorID == ACTOR_SELF) {
513 actorID = script->owner1.actorID;
514 }
515
516 actor = get_actor(actorID);
517
518 outX = *args++;
519 outY = *args++;
520 outZ = *args++;
521
522 x = actor->state.goalPos.x;
523 y = actor->state.goalPos.y;
524 z = actor->state.goalPos.z;
525
526 evt_set_variable(script, outX, x);
527 evt_set_variable(script, outY, y);
528 evt_set_variable(script, outZ, z);
529
530 return ApiStatus_DONE2;
531}
532
533// should this be renamed to GetFlyGoal ?
534API_CALLABLE(GetIdleGoal) {
535 Bytecode* args = script->ptrReadPos;
536 s32 actorID = evt_get_variable(script, *args++);
537 Actor* actor;
538 s32 outX, outY, outZ;
539 s32 x, y, z;
540
541 if (actorID == ACTOR_SELF) {
542 actorID = script->owner1.actorID;
543 }
544
545 actor = get_actor(actorID);
546
547 outX = *args++;
548 outY = *args++;
549 outZ = *args++;
550
551 x = actor->fly.goalPos.x;
552 y = actor->fly.goalPos.y;
553 z = actor->fly.goalPos.z;
554
555 evt_set_variable(script, outX, x);
556 evt_set_variable(script, outY, y);
557 evt_set_variable(script, outZ, z);
558
559 return ApiStatus_DONE2;
560}
561
562API_CALLABLE(GetPartTarget) {
563 Bytecode* args = script->ptrReadPos;
564 s32 actorID = evt_get_variable(script, *args++);
565 s32 partID = evt_get_variable(script, *args++);
566 Actor* actor;
567 ActorPart* actorPart;
568 s32 outX, outY, outZ;
569 s32 x, y, z;
570
571 if (actorID == ACTOR_SELF) {
572 actorID = script->owner1.actorID;
573 }
574
575 actor = get_actor(actorID);
576 actorPart = get_actor_part(actor, partID);
577
578 outX = *args++;
579 outY = *args++;
580 outZ = *args++;
581
582 x = actorPart->movement->goalPos.x;
583 y = actorPart->movement->goalPos.y;
584 z = actorPart->movement->goalPos.z;
585
586 evt_set_variable(script, outX, x);
587 evt_set_variable(script, outY, y);
588 evt_set_variable(script, outZ, z);
589
590 return ApiStatus_DONE2;
591}
592
593API_CALLABLE(GetActorPos) {
594 Bytecode* args = script->ptrReadPos;
595 s32 actorID = evt_get_variable(script, *args++);
596 Actor* actor;
597 s32 outX, outY, outZ;
598 s32 x, y, z;
599
600 if (actorID == ACTOR_SELF) {
601 actorID = script->owner1.actorID;
602 }
603
604 actor = get_actor(actorID);
605
606 outX = *args++;
607 outY = *args++;
608 outZ = *args++;
609
610 x = actor->curPos.x;
611 y = actor->curPos.y;
612 z = actor->curPos.z;
613
614 evt_set_variable(script, outX, x);
615 evt_set_variable(script, outY, y);
616 evt_set_variable(script, outZ, z);
617
618 return ApiStatus_DONE2;
619}
620
621API_CALLABLE(GetPartOffset) {
622 Bytecode* args = script->ptrReadPos;
623 s32 actorID = evt_get_variable(script, *args++);
624 s32 partID;
625 ActorPart* actorPart;
626 s32 outX, outY, outZ;
627 s32 x, y, z;
628
629 if (actorID == ACTOR_SELF) {
630 actorID = script->owner1.actorID;
631 }
632
633 partID = evt_get_variable(script, *args++);
634 actorPart = get_actor_part(get_actor(actorID), partID);
635
636 outX = *args++;
637 outY = *args++;
638 outZ = *args++;
639
640 if (!(actorPart->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
641 x = actorPart->partOffset.x;
642 y = actorPart->partOffset.y;
643 z = actorPart->partOffset.z;
644 } else {
645 x = actorPart->absolutePos.x;
646 y = actorPart->absolutePos.y;
647 z = actorPart->absolutePos.z;
648 }
649
650 evt_set_variable(script, outX, x);
651 evt_set_variable(script, outY, y);
652 evt_set_variable(script, outZ, z);
653
654 return ApiStatus_DONE2;
655}
656
657API_CALLABLE(GetPartPos) {
658 Bytecode* args = script->ptrReadPos;
659 s32 actorID = evt_get_variable(script, *args++);
660 s32 partID;
661 ActorPart* actorPart;
662 s32 outX, outY, outZ;
663 s32 x, y, z;
664
665 if (actorID == ACTOR_SELF) {
666 actorID = script->owner1.actorID;
667 }
668
669 partID = evt_get_variable(script, *args++);
670 actorPart = get_actor_part(get_actor(actorID), partID);
671
672 outX = *args++;
673 outY = *args++;
674 outZ = *args++;
675
676 x = actorPart->curPos.x;
677 y = actorPart->curPos.y;
678 z = actorPart->curPos.z;
679
680 evt_set_variable(script, outX, x);
681 evt_set_variable(script, outY, y);
682 evt_set_variable(script, outZ, z);
683
684 return ApiStatus_DONE2;
685}
686
687API_CALLABLE(GetHomePos) {
688 Bytecode* args = script->ptrReadPos;
689 s32 actorID = evt_get_variable(script, *args++);
690 Actor* actor;
691 s32 outX, outY, outZ;
692 s32 x, y, z;
693
694 if (actorID == ACTOR_SELF) {
695 actorID = script->owner1.actorID;
696 }
697
698 actor = get_actor(actorID);
699
700 outX = *args++;
701 outY = *args++;
702 outZ = *args++;
703
704 x = actor->homePos.x;
705 y = actor->homePos.y;
706 z = actor->homePos.z;
707
708 evt_set_variable(script, outX, x);
709 evt_set_variable(script, outY, y);
710 evt_set_variable(script, outZ, z);
711
712 return ApiStatus_DONE2;
713}
714
715API_CALLABLE(SetActorPos) {
716 Bytecode* args = script->ptrReadPos;
717 s32 actorID = evt_get_variable(script, *args++);
718 Actor* actor;
719 f32 x, y, z;
720
721 if (actorID == ACTOR_SELF) {
722 actorID = script->owner1.actorID;
723 }
724
725 x = evt_get_variable(script, *args++);
726 y = evt_get_variable(script, *args++);
727 z = evt_get_variable(script, *args++);
728
729 actor = get_actor(actorID);
730 actor->curPos.x = x;
731 actor->curPos.y = y;
732 actor->curPos.z = z;
733
734 return ApiStatus_DONE2;
735}
736
737API_CALLABLE(SetPartPos) {
738 Bytecode* args = script->ptrReadPos;
739 s32 actorID = evt_get_variable(script, *args++);
740 Actor* actor;
741 s32 partID;
742 f32 x, y, z;
743 ActorPart* actorPart;
744
745 if (actorID == ACTOR_SELF) {
746 actorID = script->owner1.actorID;
747 }
748
749 partID = evt_get_variable(script, *args++);
750 x = evt_get_variable(script, *args++);
751 y = evt_get_variable(script, *args++);
752 z = evt_get_variable(script, *args++);
753
754 actor = get_actor(actorID);
755
756 switch (actorID & ACTOR_CLASS_MASK) {
758 actor->curPos.x = x;
759 actor->curPos.y = y;
760 actor->curPos.z = z;
761 break;
764 actorPart = get_actor_part(actor, partID);
765
766 if (!(actorPart->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
767 actorPart->partOffset.x = x;
768 actorPart->partOffset.y = y;
769 actorPart->partOffset.z = z;
770 } else {
771 actorPart->absolutePos.x = x;
772 actorPart->absolutePos.y = y;
773 actorPart->absolutePos.z = z;
774 }
775 break;
776 }
777
778 return ApiStatus_DONE2;
779}
780
781API_CALLABLE(SetEnemyTargetOffset) {
782 Bytecode* args = script->ptrReadPos;
783 s32 actorID = evt_get_variable(script, *args++);
784 Actor* actor;
785 s32 partID;
786 f32 x, y;
787 ActorPart* actorPart;
788
789 if (actorID == ACTOR_SELF) {
790 actorID = script->owner1.actorID;
791 }
792
793 partID = evt_get_variable(script, *args++);
794 x = evt_get_variable(script, *args++);
795 y = evt_get_variable(script, *args++);
796
797 actor = get_actor(actorID);
798
799 switch (actorID & ACTOR_CLASS_MASK) {
801 break;
804 actorPart = get_actor_part(actor, partID);
805 actorPart->targetOffset.x = x;
806 actorPart->targetOffset.y = y;
807 break;
808 }
809
810 return ApiStatus_DONE2;
811}
812
813API_CALLABLE(SetAnimation) {
814 Bytecode* args = script->ptrReadPos;
815 s32 actorID = evt_get_variable(script, *args++);
816 Actor* actor;
817 s32 partID;
818 AnimID animID;
819
820 if (actorID == ACTOR_SELF) {
821 actorID = script->owner1.actorID;
822 }
823
824 partID = evt_get_variable(script, *args++);
825 animID = evt_get_variable(script, *args++);
826
827 set_actor_anim(actorID, partID, animID);
828
829 return ApiStatus_DONE2;
830}
831
832API_CALLABLE(GetAnimation) {
833 Bytecode* args = script->ptrReadPos;
834 s32 actorID = evt_get_variable(script, *args++);
835 s32 partID;
836 ActorPart* actorPart;
837 s32 outVar;
838
839 if (actorID == ACTOR_SELF) {
840 actorID = script->owner1.actorID;
841 }
842 partID = evt_get_variable(script, *args++);
843 outVar = *args++;
844
845 actorPart = get_actor_part(get_actor(actorID), partID);
846
847 if (actorPart != NULL) {
848 evt_set_variable(script, outVar, actorPart->curAnimation);
849 }
850 return ApiStatus_DONE2;
851}
852
853API_CALLABLE(SetAnimationRate) {
854 Bytecode* args = script->ptrReadPos;
855 s32 actorID = evt_get_variable(script, *args++);
856 Actor* actor;
857 s32 partID;
858 f32 rate;
859
860 if (actorID == ACTOR_SELF) {
861 actorID = script->owner1.actorID;
862 }
863
864 partID = evt_get_variable(script, *args++);
865 rate = evt_get_float_variable(script, *args++);
866
867 set_actor_anim_rate(actorID, partID, rate);
868
869 return ApiStatus_DONE2;
870}
871
872API_CALLABLE(SetActorYaw) {
873 Bytecode* args = script->ptrReadPos;
874 s32 actorID = evt_get_variable(script, *args++);
875
876 if (actorID == ACTOR_SELF) {
877 actorID = script->owner1.actorID;
878 }
879
880 set_actor_yaw(actorID, evt_get_variable(script, *args++));
881 return ApiStatus_DONE2;
882}
883
884API_CALLABLE(GetActorYaw) {
885 Bytecode* args = script->ptrReadPos;
886 s32 actorID = evt_get_variable(script, *args++);
887 s32 a1;
888
889 if (actorID == ACTOR_SELF) {
890 actorID = script->owner1.actorID;
891 }
892
893 a1 = *args++;
894
895 evt_set_variable(script, a1, get_actor(actorID)->yaw);
896 return ApiStatus_DONE2;
897}
898
899API_CALLABLE(SetPartYaw) {
900 Bytecode* args = script->ptrReadPos;
901 s32 actorID = evt_get_variable(script, *args++);
902 s32 partID;
903 s32 yaw;
904
905 if (actorID == ACTOR_SELF) {
906 actorID = script->owner1.actorID;
907 }
908
909 partID = evt_get_variable(script, *args++);
910 yaw = evt_get_variable(script, *args++);
911
912 set_part_yaw(actorID, partID, yaw);
913 return ApiStatus_DONE2;
914}
915
916API_CALLABLE(GetPartYaw) {
917 Bytecode* args = script->ptrReadPos;
918 s32 actorID = evt_get_variable(script, *args++);
919 s32 partID;
920 s32 a1;
921
922 if (actorID == ACTOR_SELF) {
923 actorID = script->owner1.actorID;
924 }
925
926 partID = evt_get_variable(script, *args++);
927 a1 = *args++;
928
929 evt_set_variable(script, a1, get_actor_part(get_actor(actorID), partID)->yaw);
930 return ApiStatus_DONE2;
931}
932
933API_CALLABLE(SetActorJumpGravity) {
934 Bytecode* args = script->ptrReadPos;
935 s32 actorID = evt_get_variable(script, *args++);
936 f32 jumpAccel;
937
938 if (actorID == ACTOR_SELF) {
939 actorID = script->owner1.actorID;
940 }
941
942 jumpAccel = evt_get_float_variable(script, *args++);
943 get_actor(actorID)->state.acceleration = jumpAccel;
944 return ApiStatus_DONE2;
945}
946
947API_CALLABLE(SetActorIdleJumpGravity) {
948 Bytecode* args = script->ptrReadPos;
949 s32 actorID = evt_get_variable(script, *args++);
950 f32 flyJumpAccel;
951
952 if (actorID == ACTOR_SELF) {
953 actorID = script->owner1.actorID;
954 }
955
956 flyJumpAccel = evt_get_float_variable(script, *args++);
957 get_actor(actorID)->fly.acceleration = flyJumpAccel;
958 return ApiStatus_DONE2;
959}
960
961API_CALLABLE(SetActorSpeed) {
962 Bytecode* args = script->ptrReadPos;
963 s32 actorID = evt_get_variable(script, *args++);
964 f32 moveSpeed;
965
966 if (actorID == ACTOR_SELF) {
967 actorID = script->owner1.actorID;
968 }
969
970 moveSpeed = evt_get_float_variable(script, *args++);
971 get_actor(actorID)->state.speed = moveSpeed;
972 return ApiStatus_DONE2;
973}
974
975// SetActorFlySpeed?
976API_CALLABLE(SetActorIdleSpeed) {
977 Bytecode* args = script->ptrReadPos;
978 s32 actorID = evt_get_variable(script, *args++);
979 f32 flySpeed;
980
981 if (actorID == ACTOR_SELF) {
982 actorID = script->owner1.actorID;
983 }
984
985 flySpeed = evt_get_float_variable(script, *args++);
986 get_actor(actorID)->fly.speed = flySpeed;
987 return ApiStatus_DONE2;
988}
989
990API_CALLABLE(SetPartJumpGravity) {
991 Bytecode* args = script->ptrReadPos;
992 s32 actorID = evt_get_variable(script, *args++);
993 s32 partID;
994 f32 jumpScale;
995
996 if (actorID == ACTOR_SELF) {
997 actorID = script->owner1.actorID;
998 }
999
1000 partID = evt_get_variable(script, *args++);
1001 jumpScale = evt_get_float_variable(script, *args++);
1002
1003 get_actor_part(get_actor(actorID), partID)->movement->jumpScale = jumpScale;
1004 return ApiStatus_DONE2;
1005}
1006
1007API_CALLABLE(SetPartMoveSpeed) {
1008 Bytecode* args = script->ptrReadPos;
1009 s32 actorID = evt_get_variable(script, *args++);
1010 s32 partID;
1011 f32 moveSpeed;
1012
1013 if (actorID == ACTOR_SELF) {
1014 actorID = script->owner1.actorID;
1015 }
1016
1017 partID = evt_get_variable(script, *args++);
1018 moveSpeed = evt_get_float_variable(script, *args++);
1019
1020 get_actor_part(get_actor(actorID), partID)->movement->moveSpeed = moveSpeed;
1021 return ApiStatus_DONE2;
1022}
1023
1024API_CALLABLE(SetJumpAnimations) {
1025 Bytecode* args = script->ptrReadPos;
1026 s32 actorID = evt_get_variable(script, *args++);
1027 Actor* actor;
1028 s32 jumpPartIndex;
1029 s32 animJumpRise;
1030 s32 animJumpFall;
1031 s32 animJumpLand;
1032
1033 if (actorID == ACTOR_SELF) {
1034 actorID = script->owner1.actorID;
1035 }
1036
1037 jumpPartIndex = evt_get_variable(script, *args++);
1038 animJumpRise = *args++;
1039 animJumpFall = *args++;
1040 animJumpLand = *args++;
1041
1042 actor = get_actor(actorID);
1043 actor->state.jumpPartIndex = jumpPartIndex;
1044 actor->state.animJumpRise = animJumpRise;
1045 actor->state.animJumpFall = animJumpFall;
1046 actor->state.animJumpLand = animJumpLand;
1047
1048 return ApiStatus_DONE2;
1049}
1050
1051API_CALLABLE(AddActorPos) {
1052 Bytecode* args = script->ptrReadPos;
1053 s32 actorID = evt_get_variable(script, *args++);
1054 Actor* actor;
1055 f32 x, y, z;
1056
1057 if (actorID == ACTOR_SELF) {
1058 actorID = script->owner1.actorID;
1059 }
1060
1061 x = evt_get_float_variable(script, *args++);
1062 y = evt_get_float_variable(script, *args++);
1063 z = evt_get_float_variable(script, *args++);
1064
1065 actor = get_actor(actorID);
1066 actor->curPos.x += x;
1067 actor->curPos.y += y;
1068 actor->curPos.z += z;
1069
1070 return ApiStatus_DONE2;
1071}
1072
1073API_CALLABLE(SetActorDispOffset) {
1074 Bytecode* args = script->ptrReadPos;
1075 s32 actorID = evt_get_variable(script, *args++);
1076 Actor* actor;
1077 f32 x, y, z;
1078
1079 if (actorID == ACTOR_SELF) {
1080 actorID = script->owner1.actorID;
1081 }
1082
1083 x = evt_get_float_variable(script, *args++);
1084 y = evt_get_float_variable(script, *args++);
1085 z = evt_get_float_variable(script, *args++);
1086
1087 actor = get_actor(actorID);
1088 actor->headOffset.x = x;
1089 actor->headOffset.y = y;
1090 actor->headOffset.z = z;
1091
1092 return ApiStatus_DONE2;
1093}
1094
1095API_CALLABLE(GetPartDispOffset) {
1096 Bytecode* args = script->ptrReadPos;
1097 s32 actorID = evt_get_variable(script, *args++);
1098 ActorPart* actorPart;
1099 s32 partID;
1100 s32 outX, outY, outZ;
1101 f32 x, y, z;
1102
1103 if (actorID == ACTOR_SELF) {
1104 actorID = script->owner1.actorID;
1105 }
1106
1107 partID = evt_get_variable(script, *args++);
1108 outX = *args++;
1109 outY = *args++;
1110 outZ = *args++;
1111
1112 actorPart = get_actor_part(get_actor(actorID), partID);
1113
1114 if (!(actorPart->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
1115 x = actorPart->partOffset.x;
1116 y = actorPart->partOffset.y;
1117 z = actorPart->partOffset.z;
1118 } else {
1119 x = actorPart->visualOffset.x;
1120 y = actorPart->visualOffset.y;
1121 z = actorPart->visualOffset.z;
1122 }
1123
1124 evt_set_variable(script, outX, x);
1125 evt_set_variable(script, outY, y);
1126 evt_set_variable(script, outZ, z);
1127
1128 return ApiStatus_DONE2;
1129}
1130
1131API_CALLABLE(SetPartDispOffset) {
1132 Bytecode* args = script->ptrReadPos;
1133 s32 actorID = evt_get_variable(script, *args++);
1134 ActorPart* actorPart;
1135 s32 partID;
1136 f32 x, y, z;
1137
1138 if (actorID == ACTOR_SELF) {
1139 actorID = script->owner1.actorID;
1140 }
1141
1142 partID = evt_get_variable(script, *args++);
1143
1144 x = evt_get_float_variable(script, *args++);
1145 y = evt_get_float_variable(script, *args++);
1146 z = evt_get_float_variable(script, *args++);
1147 actorPart = get_actor_part(get_actor(actorID), partID);
1148
1149 if (!(actorPart->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
1150 actorPart->partOffset.x = x;
1151 actorPart->partOffset.y = y;
1152 actorPart->partOffset.z = z;
1153 } else {
1154 actorPart->visualOffset.x = x;
1155 actorPart->visualOffset.y = y;
1156 actorPart->visualOffset.z = z;
1157 }
1158
1159 return ApiStatus_DONE2;
1160}
1161
1162API_CALLABLE(AddPartDispOffset) {
1163 Bytecode* args = script->ptrReadPos;
1164 s32 actorID = evt_get_variable(script, *args++);
1165 ActorPart* actorPart;
1166 s32 partID;
1167 f32 x, y, z;
1168
1169 if (actorID == ACTOR_SELF) {
1170 actorID = script->owner1.actorID;
1171 }
1172
1173 partID = evt_get_variable(script, *args++);
1174
1175 x = evt_get_float_variable(script, *args++);
1176 y = evt_get_float_variable(script, *args++);
1177 z = evt_get_float_variable(script, *args++);
1178 actorPart = get_actor_part(get_actor(actorID), partID);
1179
1180 if (!(actorPart->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
1181 actorPart->partOffset.x += x;
1182 actorPart->partOffset.y += y;
1183 actorPart->partOffset.z += z;
1184 } else {
1185 actorPart->visualOffset.x += x;
1186 actorPart->visualOffset.y += y;
1187 actorPart->visualOffset.z += z;
1188 }
1189
1190 return ApiStatus_DONE2;
1191}
1192
1193API_CALLABLE(FreezeBattleState) {
1194 BattleStatus* battleStatus = &gBattleStatus;
1195 BattleStatus* battleStatus2 = &gBattleStatus;
1196 Bytecode* args = script->ptrReadPos;
1197 b32 increaseFreeze = evt_get_variable(script, *args++);
1198
1199 if (increaseFreeze) {
1200 battleStatus->stateFreezeCount++;
1201 } else if (battleStatus->stateFreezeCount > 0) {
1202 battleStatus2->stateFreezeCount--;
1203 }
1204
1205 return ApiStatus_DONE2;
1206}
1207
1208API_CALLABLE(GetActorVar) {
1209 Bytecode* args = script->ptrReadPos;
1210 s32 actorID = evt_get_variable(script, *args++);
1211 s32 var1;
1212 s32 a2;
1213
1214 if (actorID == ACTOR_SELF) {
1215 actorID = script->owner1.actorID;
1216 }
1217
1218 var1 = evt_get_variable(script, *args++);
1219 a2 = *args++;
1220
1221 evt_set_variable(script, a2, get_actor(actorID)->state.varTable[var1]);
1222
1223 return ApiStatus_DONE2;
1224}
1225
1226API_CALLABLE(SetActorVar) {
1227 Bytecode* args = script->ptrReadPos;
1228 s32 actorID = evt_get_variable(script, *args++);
1229 s32 index;
1230 s32 val;
1231
1232 if (actorID == ACTOR_SELF) {
1233 actorID = script->owner1.actorID;
1234 }
1235
1236 index = evt_get_variable(script, *args++);
1237 val = evt_get_variable(script, *args++);
1238
1239 get_actor(actorID)->state.varTable[index] = val;
1240
1241 return ApiStatus_DONE2;
1242}
1243
1244API_CALLABLE(AddActorVar) {
1245 Bytecode* args = script->ptrReadPos;
1246 s32 actorID = evt_get_variable(script, *args++);
1247 s32 index;
1248 s32 val;
1249 ActorState* state;
1250
1251 if (actorID == ACTOR_SELF) {
1252 actorID = script->owner1.actorID;
1253 }
1254
1255 index = evt_get_variable(script, *args++);
1256 val = evt_get_variable(script, *args++);
1257
1258 state = &get_actor(actorID)->state;
1259 state->varTable[index] += val;
1260
1261 return ApiStatus_DONE2;
1262}
1263
1264API_CALLABLE(GetPartMovementVar) {
1265 Bytecode* args = script->ptrReadPos;
1266 s32 actorID = evt_get_variable(script, *args++);
1267 s32 partID;
1268 s32 tableIndex;
1269 s32 outVar;
1270
1271 if (actorID == ACTOR_SELF) {
1272 actorID = script->owner1.actorID;
1273 }
1274
1275 partID = evt_get_variable(script, *args++);
1276 tableIndex = evt_get_variable(script, *args++);
1277 outVar = *args++;
1278
1279 evt_set_variable(script, outVar, get_actor_part(get_actor(actorID), partID)->movement->varTable[tableIndex]);
1280
1281 return ApiStatus_DONE2;
1282}
1283
1284API_CALLABLE(SetPartMovementVar) {
1285 Bytecode* args = script->ptrReadPos;
1286 s32 actorID = evt_get_variable(script, *args++);
1287 s32 partID;
1288 s32 tableIndex;
1289 s32 val;
1290
1291 if (actorID == ACTOR_SELF) {
1292 actorID = script->owner1.actorID;
1293 }
1294
1295 partID = evt_get_variable(script, *args++);
1296 tableIndex = evt_get_variable(script, *args++);
1297 val = evt_get_variable(script, *args++);
1298
1299 get_actor_part(get_actor(actorID), partID)->movement->varTable[tableIndex] = val;
1300
1301 return ApiStatus_DONE2;
1302}
1303
1304API_CALLABLE(AddPartMovementVar) {
1305 Bytecode* args = script->ptrReadPos;
1306 s32 actorID = evt_get_variable(script, *args++);
1307 s32 partID;
1308 s32 tableIndex;
1309 s32 val;
1310
1311 if (actorID == ACTOR_SELF) {
1312 actorID = script->owner1.actorID;
1313 }
1314
1315 partID = evt_get_variable(script, *args++);
1316 tableIndex = evt_get_variable(script, *args++);
1317 val = evt_get_variable(script, *args++);
1318
1319 get_actor_part(get_actor(actorID), partID)->movement->varTable[tableIndex] += val;
1320
1321 return ApiStatus_DONE2;
1322}
1323
1324API_CALLABLE(SetActorRotation) {
1325 Bytecode* args = script->ptrReadPos;
1326 s32 actorID = evt_get_variable(script, *args++);
1327 Actor* actor;
1328 s32 x, y, z;
1329
1330 if (actorID == ACTOR_SELF) {
1331 actorID = script->owner1.actorID;
1332 }
1333
1334 x = evt_get_float_variable(script, *args++);
1335 y = evt_get_float_variable(script, *args++);
1336 z = evt_get_float_variable(script, *args++);
1337
1338 actor = get_actor(actorID);
1339
1340 if (x != EVT_IGNORE_ARG) {
1341 actor->rot.x = x;
1342 }
1343
1344 if (y != EVT_IGNORE_ARG) {
1345 actor->rot.y = y;
1346 }
1347
1348 if (z != EVT_IGNORE_ARG) {
1349 actor->rot.z = z;
1350 }
1351
1352 return ApiStatus_DONE2;
1353}
1354
1355API_CALLABLE(SetActorRotationOffset) {
1356 Bytecode* args = script->ptrReadPos;
1357 s32 actorID = evt_get_variable(script, *args++);
1358 Actor* actor;
1359 s32 x, y, z;
1360
1361 if (actorID == ACTOR_SELF) {
1362 actorID = script->owner1.actorID;
1363 }
1364
1365 x = evt_get_float_variable(script, *args++);
1366 y = evt_get_float_variable(script, *args++);
1367 z = evt_get_float_variable(script, *args++);
1368
1369 actor = get_actor(actorID);
1370
1371 actor->rotPivotOffset.x = x;
1372 actor->rotPivotOffset.y = y;
1373 actor->rotPivotOffset.z = z;
1374
1375 return ApiStatus_DONE2;
1376}
1377
1378API_CALLABLE(GetActorRotation) {
1379 Bytecode* args = script->ptrReadPos;
1380 s32 actorID = evt_get_variable(script, *args++);
1381 Actor* actor;
1382 s32 x, y, z;
1383
1384 if (actorID == ACTOR_SELF) {
1385 actorID = script->owner1.actorID;
1386 }
1387
1388 x = *args++;
1389 y = *args++;
1390 z = *args++;
1391
1392 actor = get_actor(actorID);
1393
1394 evt_set_variable(script, x, actor->rot.x);
1395 evt_set_variable(script, y, actor->rot.y);
1396 evt_set_variable(script, z, actor->rot.z);
1397
1398 return ApiStatus_DONE2;
1399}
1400
1401API_CALLABLE(SetPartRotation) {
1402 Bytecode* args = script->ptrReadPos;
1403 s32 actorID = evt_get_variable(script, *args++);
1404 s32 partID = evt_get_variable(script, *args++);
1405 ActorPart* actorPart;
1406 s32 x, y, z;
1407
1408 if (actorID == ACTOR_SELF) {
1409 actorID = script->owner1.actorID;
1410 }
1411
1412 x = evt_get_float_variable(script, *args++);
1413 y = evt_get_float_variable(script, *args++);
1414 z = evt_get_float_variable(script, *args++);
1415
1416 actorPart = get_actor_part(get_actor(actorID), partID);
1417
1418 actorPart->rot.x = x;
1419 actorPart->rot.y = y;
1420 actorPart->rot.z = z;
1421
1422 return ApiStatus_DONE2;
1423}
1424
1425API_CALLABLE(SetPartRotationOffset) {
1426 Bytecode* args = script->ptrReadPos;
1427 s32 actorID = evt_get_variable(script, *args++);
1428 s32 partID = evt_get_variable(script, *args++);
1429 ActorPart* actorPart;
1430 s32 x, y, z;
1431
1432 if (actorID == ACTOR_SELF) {
1433 actorID = script->owner1.actorID;
1434 }
1435
1436 x = evt_get_float_variable(script, *args++);
1437 y = evt_get_float_variable(script, *args++);
1438 z = evt_get_float_variable(script, *args++);
1439
1440 actorPart = get_actor_part(get_actor(actorID), partID);
1441
1442 actorPart->rotPivotOffset.x = x;
1443 actorPart->rotPivotOffset.y = y;
1444 actorPart->rotPivotOffset.z = z;
1445
1446 return ApiStatus_DONE2;
1447}
1448
1449API_CALLABLE(GetPartRotation) {
1450 Bytecode* args = script->ptrReadPos;
1451 s32 actorID = evt_get_variable(script, *args++);
1452 s32 partID = evt_get_variable(script, *args++);
1453 ActorPart* actorPart;
1454 s32 x, y, z;
1455
1456 if (actorID == ACTOR_SELF) {
1457 actorID = script->owner1.actorID;
1458 }
1459
1460 x = *args++;
1461 y = *args++;
1462 z = *args++;
1463
1464 actorPart = get_actor_part(get_actor(actorID), partID);
1465
1466 evt_set_float_variable(script, x, actorPart->rot.x);
1467 evt_set_float_variable(script, y, actorPart->rot.y);
1468 evt_set_float_variable(script, z, actorPart->rot.z);
1469
1470 return ApiStatus_DONE2;
1471}
1472
1473API_CALLABLE(SetActorScale) {
1474 Bytecode* args = script->ptrReadPos;
1475 s32 actorID = evt_get_variable(script, *args++);
1476 Actor* actor;
1477 f32 x, y, z;
1478
1479 if (actorID == ACTOR_SELF) {
1480 actorID = script->owner1.actorID;
1481 }
1482
1483 x = evt_get_float_variable(script, *args++);
1484 y = evt_get_float_variable(script, *args++);
1485 z = evt_get_float_variable(script, *args++);
1486
1487 actor = get_actor(actorID);
1488
1489 actor->scale.x = x;
1490 actor->scale.y = y;
1491 actor->scale.z = z;
1492
1493 return ApiStatus_DONE2;
1494}
1495
1496API_CALLABLE(SetActorScaleModifier) {
1497 Bytecode* args = script->ptrReadPos;
1498 s32 actorID = evt_get_variable(script, *args++);
1499 Actor* actor;
1500 f32 x, y, z;
1501
1502 if (actorID == ACTOR_SELF) {
1503 actorID = script->owner1.actorID;
1504 }
1505
1506 x = evt_get_float_variable(script, *args++);
1507 y = evt_get_float_variable(script, *args++);
1508 z = evt_get_float_variable(script, *args++);
1509
1510 actor = get_actor(actorID);
1511
1512 actor->scaleModifier.x = x;
1513 actor->scaleModifier.y = y;
1514 actor->scaleModifier.z = z;
1515
1516 return ApiStatus_DONE2;
1517}
1518
1519API_CALLABLE(GetActorScale) {
1520 Bytecode* args = script->ptrReadPos;
1521 s32 actorID = evt_get_variable(script, *args++);
1522 Actor* actor;
1523 f32 x, y, z;
1524
1525 if (actorID == ACTOR_SELF) {
1526 actorID = script->owner1.actorID;
1527 }
1528
1529 x = *args++;
1530 y = *args++;
1531 z = *args++;
1532
1533 actor = get_actor(actorID);
1534
1535 evt_set_float_variable(script, x, actor->scale.x);
1536 evt_set_float_variable(script, y, actor->scale.y);
1537 evt_set_float_variable(script, z, actor->scale.z);
1538
1539 return ApiStatus_DONE2;
1540}
1541
1542API_CALLABLE(SetPartScale) {
1543 Bytecode* args = script->ptrReadPos;
1544 s32 actorID = evt_get_variable(script, *args++);
1545 s32 partID = evt_get_variable(script, *args++);
1546 ActorPart* actorPart;
1547 f32 x, y, z;
1548
1549 if (actorID == ACTOR_SELF) {
1550 actorID = script->owner1.actorID;
1551 }
1552
1553 x = evt_get_float_variable(script, *args++);
1554 y = evt_get_float_variable(script, *args++);
1555 z = evt_get_float_variable(script, *args++);
1556
1557 actorPart = get_actor_part(get_actor(actorID), partID);
1558
1559 actorPart->scale.x = x;
1560 actorPart->scale.y = y;
1561 actorPart->scale.z = z;
1562
1563 return ApiStatus_DONE2;
1564}
1565
1566API_CALLABLE(GetPartScale) {
1567 Bytecode* args = script->ptrReadPos;
1568 s32 actorID = evt_get_variable(script, *args++);
1569 s32 partID = evt_get_variable(script, *args++);
1570 ActorPart* actorPart;
1571 s32 x, y, z;
1572
1573 if (actorID == ACTOR_SELF) {
1574 actorID = script->owner1.actorID;
1575 }
1576
1577 x = *args++;
1578 y = *args++;
1579 z = *args++;
1580
1581 actorPart = get_actor_part(get_actor(actorID), partID);
1582
1583 evt_set_float_variable(script, x, actorPart->scale.x);
1584 evt_set_float_variable(script, y, actorPart->scale.y);
1585 evt_set_float_variable(script, z, actorPart->scale.z);
1586
1587 return ApiStatus_DONE2;
1588}
1589
1590API_CALLABLE(GetBattleFlags) {
1591 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.flags1);
1592 return ApiStatus_DONE2;
1593}
1594
1595API_CALLABLE(SetBattleFlagBits) {
1596 Bytecode* args = script->ptrReadPos;
1597 s32 bits = *args++;
1598 s32 mode = evt_get_variable(script, *args++);
1599
1600 if (mode) {
1601 gBattleStatus.flags1 |= bits;
1602 } else {
1603 gBattleStatus.flags1 &= ~bits;
1604 }
1605
1606 return ApiStatus_DONE2;
1607}
1608
1609API_CALLABLE(GetBattleFlags2) {
1610 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.flags2);
1611 return ApiStatus_DONE2;
1612}
1613
1614API_CALLABLE(SetBattleFlagBits2) {
1615 Bytecode* args = script->ptrReadPos;
1616 s32 bits = *args++;
1617 s32 mode = evt_get_variable(script, *args++);
1618
1619 if (mode) {
1620 gBattleStatus.flags2 |= bits;
1621 } else {
1622 gBattleStatus.flags2 &= ~bits;
1623 }
1624
1625 return ApiStatus_DONE2;
1626}
1627
1628API_CALLABLE(SetActorFlags) {
1629 Bytecode* args = script->ptrReadPos;
1630 s32 actorID = evt_get_variable(script, *args++);
1631 s32 flagBits;
1632
1633 if (actorID == ACTOR_SELF) {
1634 actorID = script->owner1.actorID;
1635 }
1636
1637 flagBits = *args++;
1638 get_actor(actorID)->flags = flagBits;
1639
1640 return ApiStatus_DONE2;
1641}
1642
1643API_CALLABLE(SetActorFlagBits) {
1644 Bytecode* args = script->ptrReadPos;
1645 s32 actorID = evt_get_variable(script, *args++);
1646 s32 bits;
1647 s32 mode;
1648 Actor* actor;
1649
1650 if (actorID == ACTOR_SELF) {
1651 actorID = script->owner1.actorID;
1652 }
1653
1654 bits = *args++;
1655 mode = evt_get_variable(script, *args++);
1656 actor = get_actor(actorID);
1657
1658 if (mode) {
1659 actor->flags |= bits;
1660 } else {
1661 actor->flags &= ~bits;
1662 }
1663
1664 return ApiStatus_DONE2;
1665}
1666
1667API_CALLABLE(GetActorFlags) {
1668 Bytecode* args = script->ptrReadPos;
1669 s32 actorID = evt_get_variable(script, *args++);
1670 s32 outVar;
1671
1672 if (actorID == ACTOR_SELF) {
1673 actorID = script->owner1.actorID;
1674 }
1675
1676 outVar = *args++;
1677
1678 evt_set_variable(script, outVar, get_actor(actorID)->flags);
1679
1680 return ApiStatus_DONE2;
1681}
1682
1683API_CALLABLE(SetPartFlags) {
1684 Bytecode* args = script->ptrReadPos;
1685 s32 actorID = evt_get_variable(script, *args++);
1686 s32 flagBits;
1687 s32 partID;
1688
1689 if (actorID == ACTOR_SELF) {
1690 actorID = script->owner1.actorID;
1691 }
1692
1693 partID = evt_get_variable(script, *args++);
1694 flagBits = *args++;
1695
1696 get_actor_part(get_actor(actorID), partID)->flags = flagBits;
1697
1698 return ApiStatus_DONE2;
1699}
1700
1701API_CALLABLE(SetPartFlagBits) {
1702 Bytecode* args = script->ptrReadPos;
1703 s32 actorID = evt_get_variable(script, *args++);
1704 ActorPart* actorPart;
1705 s32 bits;
1706 s32 partID;
1707 s32 mode;
1708
1709 if (actorID == ACTOR_SELF) {
1710 actorID = script->owner1.actorID;
1711 }
1712
1713 partID = evt_get_variable(script, *args++);
1714 bits = *args++;
1715 mode = evt_get_variable(script, *args++);
1716
1717 actorPart = get_actor_part(get_actor(actorID), partID);
1718
1719 if (mode) {
1720 actorPart->flags |= bits;
1721 } else {
1722 actorPart->flags &= ~bits;
1723 }
1724
1725 return ApiStatus_DONE2;
1726}
1727
1728API_CALLABLE(SetPartTargetFlags) {
1729 Bytecode* args = script->ptrReadPos;
1730 s32 actorID = evt_get_variable(script, *args++);
1731 ActorPart* actorPart;
1732 s32 flagBits;
1733 s32 partID;
1734
1735 if (actorID == ACTOR_SELF) {
1736 actorID = script->owner1.actorID;
1737 }
1738
1739 partID = evt_get_variable(script, *args++);
1740 flagBits = *args++;
1741
1742 get_actor_part(get_actor(actorID), partID)->targetFlags = flagBits;
1743
1744 return ApiStatus_DONE2;
1745}
1746
1747API_CALLABLE(SetPartTargetFlagBits) {
1748 Bytecode* args = script->ptrReadPos;
1749 s32 actorID = evt_get_variable(script, *args++);
1750 ActorPart* actorPart;
1751 s32 partID;
1752 s32 bits;
1753 s32 mode;
1754
1755 if (actorID == ACTOR_SELF) {
1756 actorID = script->owner1.actorID;
1757 }
1758
1759 partID = evt_get_variable(script, *args++);
1760 bits = *args++;
1761 mode = evt_get_variable(script, *args++);
1762
1763 actorPart = get_actor_part(get_actor(actorID), partID);
1764
1765 if (mode) {
1766 actorPart->targetFlags |= bits;
1767 } else {
1768 actorPart->targetFlags &= ~bits;
1769 }
1770
1771 return ApiStatus_DONE2;
1772}
1773
1774API_CALLABLE(GetPartFlags) {
1775 Bytecode* args = script->ptrReadPos;
1776 s32 actorID = evt_get_variable(script, *args++);
1777 s32 partID;
1778 ActorPart* actorPart;
1779 s32 outVar;
1780
1781 if (actorID == ACTOR_SELF) {
1782 actorID = script->owner1.actorID;
1783 }
1784
1785 partID = evt_get_variable(script, *args++);
1786 outVar = *args++;
1787
1788 evt_set_variable(script, outVar, get_actor_part(get_actor(actorID), partID)->flags);
1789
1790 return ApiStatus_DONE2;
1791}
1792
1793API_CALLABLE(GetPartTargetFlags) {
1794 Bytecode* args = script->ptrReadPos;
1795 s32 actorID = evt_get_variable(script, *args++);
1796 s32 partID;
1797 ActorPart* actorPart;
1798 s32 outVar;
1799
1800 if (actorID == ACTOR_SELF) {
1801 actorID = script->owner1.actorID;
1802 }
1803
1804 partID = evt_get_variable(script, *args++);
1805 outVar = *args++;
1806
1807 evt_set_variable(script, outVar, get_actor_part(get_actor(actorID), partID)->targetFlags);
1808
1809 return ApiStatus_DONE2;
1810}
1811
1812API_CALLABLE(SetPartEventFlags) {
1813 Bytecode* args = script->ptrReadPos;
1814 s32 actorID = evt_get_variable(script, *args++);
1815 ActorPart* actorPart;
1816 s32 flagBits;
1817 s32 partID;
1818
1819 if (actorID == ACTOR_SELF) {
1820 actorID = script->owner1.actorID;
1821 }
1822
1823 partID = evt_get_variable(script, *args++);
1824 flagBits = *args++;
1825
1826 get_actor_part(get_actor(actorID), partID)->eventFlags = flagBits;
1827
1828 return ApiStatus_DONE2;
1829}
1830
1831API_CALLABLE(SetPartEventBits) {
1832 Bytecode* args = script->ptrReadPos;
1833 s32 actorID = evt_get_variable(script, *args++);
1834 Actor* actor;
1835 ActorPart* part;
1836 s32 partID;
1837 s32 bits;
1838 s32 mode;
1839
1840 if (actorID == ACTOR_SELF) {
1841 actorID = script->owner1.actorID;
1842 }
1843
1844 partID = evt_get_variable(script, *args++);
1845 bits = *args++;
1846 mode = evt_get_variable(script, *args++);
1847
1848 actor = get_actor(actorID);
1849 part = get_actor_part(actor, partID);
1850
1851 if (mode) {
1852 part->eventFlags |= bits;
1853 } else {
1854 part->eventFlags &= ~bits;
1855 }
1856
1857 return ApiStatus_DONE2;
1858}
1859
1860API_CALLABLE(GetPartEventFlags) {
1861 Bytecode* args = script->ptrReadPos;
1862 s32 actorID = evt_get_variable(script, *args++);
1863 s32 partID;
1864 Actor* actor;
1865 ActorPart* part;
1866 s32 outVar;
1867
1868 if (actorID == ACTOR_SELF) {
1869 actorID = script->owner1.actorID;
1870 }
1871
1872 partID = evt_get_variable(script, *args++);
1873 outVar = *args++;
1874
1875 actor = get_actor(actorID);
1876 part = get_actor_part(actor, partID);
1877 evt_set_variable(script, outVar, part->eventFlags);
1878
1879 return ApiStatus_DONE2;
1880}
1881
1882API_CALLABLE(SetPartImmunityFlags) {
1883 Bytecode* args = script->ptrReadPos;
1884 s32 actorID = evt_get_variable(script, *args++);
1885 ActorPart* actorPart;
1886 s32 flagBits;
1887 s32 partID;
1888
1889 if (actorID == ACTOR_SELF) {
1890 actorID = script->owner1.actorID;
1891 }
1892
1893 partID = evt_get_variable(script, *args++);
1894 flagBits = *args++;
1895
1896 get_actor_part(get_actor(actorID), partID)->elementalImmunities = flagBits;
1897
1898 return ApiStatus_DONE2;
1899}
1900
1901API_CALLABLE(SetPartImmunityBits) {
1902 Bytecode* args = script->ptrReadPos;
1903 s32 actorID = evt_get_variable(script, *args++);
1904 Actor* actor;
1905 ActorPart* part;
1906 s32 partID;
1907 s32 bits;
1908 s32 mode;
1909
1910 if (actorID == ACTOR_SELF) {
1911 actorID = script->owner1.actorID;
1912 }
1913
1914 partID = evt_get_variable(script, *args++);
1915 bits = *args++;
1916 mode = evt_get_variable(script, *args++);
1917
1918 actor = get_actor(actorID);
1919 part = get_actor_part(actor, partID);
1920
1921 if (mode) {
1922 part->elementalImmunities |= bits;
1923 } else {
1924 part->elementalImmunities &= ~bits;
1925 }
1926
1927 return ApiStatus_DONE2;
1928}
1929
1930API_CALLABLE(HPBarToHome) {
1931 Bytecode* args = script->ptrReadPos;
1932 s32 actorID = evt_get_variable(script, *args++);
1933 Actor* actor;
1934
1935 if (actorID == ACTOR_SELF) {
1936 actorID = script->owner1.actorID;
1937 }
1938
1939 actor = get_actor(actorID);
1940 actor->healthBarPos.x = actor->homePos.x + actor->actorBlueprint->healthBarOffset.x;
1941 actor->healthBarPos.y = actor->homePos.y + actor->actorBlueprint->healthBarOffset.y;
1942 actor->healthBarPos.z = actor->homePos.z;
1943
1944 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
1945 actor->healthBarPos.y = actor->homePos.y - actor->size.y - actor->actorBlueprint->healthBarOffset.y;
1946 }
1947
1948 actor->healthFraction = (actor->curHP * 25) / actor->maxHP;
1949
1950 return ApiStatus_DONE2;
1951}
1952
1953API_CALLABLE(HPBarToCurrent) {
1954 Bytecode* args = script->ptrReadPos;
1955 s32 actorID = evt_get_variable(script, *args++);
1956 Actor* actor;
1957
1958 if (actorID == ACTOR_SELF) {
1959 actorID = script->owner1.actorID;
1960 }
1961
1962 actor = get_actor(actorID);
1963 actor->healthBarPos.x = actor->curPos.x + actor->actorBlueprint->healthBarOffset.x;
1964 actor->healthBarPos.y = actor->curPos.y + actor->actorBlueprint->healthBarOffset.y;
1965 actor->healthBarPos.z = actor->curPos.z;
1966
1967 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
1968 actor->healthBarPos.y = actor->curPos.y - actor->size.y - actor->actorBlueprint->healthBarOffset.y;
1969 }
1970
1971 actor->healthFraction = (actor->curHP * 25) / actor->maxHP;
1972
1973 return ApiStatus_DONE2;
1974}
1975
1976API_CALLABLE(HideHPBar) {
1977 Bytecode* args = script->ptrReadPos;
1978 s32 actorID = evt_get_variable(script, *args++);
1979
1980 if (actorID == ACTOR_SELF) {
1981 actorID = script->owner1.actorID;
1982 }
1983
1985
1986 return ApiStatus_DONE2;
1987}
1988
1989API_CALLABLE(SetHPBarOffset) {
1990 Bytecode* args = script->ptrReadPos;
1991 s32 actorID = evt_get_variable(script, *args++);
1992 Actor* actor;
1993 s32 x, y;
1994
1995 if (actorID == ACTOR_SELF) {
1996 actorID = script->owner1.actorID;
1997 }
1998
1999 x = evt_get_variable(script, *args++);
2000 y = evt_get_variable(script, *args++);
2001
2002 actor = get_actor(actorID);
2003
2004 actor->healthBarOffset.x = x;
2005 actor->healthBarOffset.y = y;
2006 actor->healthBarPos.x = actor->homePos.x + actor->actorBlueprint->healthBarOffset.x + actor->healthBarOffset.x;
2007 actor->healthBarPos.y = actor->homePos.y + actor->actorBlueprint->healthBarOffset.y + actor->healthBarOffset.y;
2008 actor->healthBarPos.z = actor->homePos.z;
2009
2010 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
2011 actor->healthBarPos.y = actor->homePos.y - actor->size.y;
2012 }
2013
2014 return ApiStatus_DONE2;
2015}
2016
2017API_CALLABLE(SetActorStatusOffsets) {
2018 Bytecode* args = script->ptrReadPos;
2019 s32 actorID = evt_get_variable(script, *args++);
2020 Actor* actor;
2021 s32 iconX, iconY, textX, textY;
2022
2023 if (actorID == ACTOR_SELF) {
2024 actorID = script->owner1.actorID;
2025 }
2026
2027 iconX = evt_get_variable(script, *args++);
2028 iconY = evt_get_variable(script, *args++);
2029 textX = evt_get_variable(script, *args++);
2030 textY = evt_get_variable(script, *args++);
2031
2032 actor = get_actor(actorID);
2033 actor->statusIconOffset.x = iconX;
2034 actor->statusIconOffset.y = iconY;
2035 actor->statusTextOffset.x = textX;
2036 actor->statusTextOffset.y = textY;
2037
2038 return ApiStatus_DONE2;
2039}
2040
2041API_CALLABLE(SummonEnemy) {
2042 BattleStatus* battleStatus = &gBattleStatus;
2043 s32* args = script->ptrReadPos;
2044 Actor* actor1;
2045 Actor* actor2;
2046 s16* enemyIDs;
2047 s32 numEnemies;
2048 s32 i, j;
2049 u16 enemyID1, enemyID2;
2050 s32 priority1, priority2;
2051 s32 basePriority;
2052
2053 if (isInitialCall) {
2054 script->functionTemp[0] = 0;
2055 }
2056
2057 switch (script->functionTemp[0]) {
2058 case 0:
2059 script->functionTempPtr[1] = create_actor((FormationRow*)evt_get_variable(script, *args++));
2060 script->functionTemp[2] = evt_get_variable(script, *args++); // isLowPriority
2061 script->functionTemp[0] = 1;
2062 break;
2063 case 1:
2064 actor2 = script->functionTempPtr[1];
2065 if (does_script_exist(actor2->takeTurnScriptID)) {
2066 break;
2067 }
2068
2069 enemyIDs = battleStatus->enemyIDs;
2070 if (battleStatus->nextEnemyIndex == 0) {
2071 numEnemies = 0;
2072 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2073 if (battleStatus->enemyActors[i]) {
2074 battleStatus->enemyIDs[numEnemies++] = i | ACTOR_CLASS_ENEMY;
2075 }
2076 }
2077 battleStatus->numEnemyActors = numEnemies;
2078 if (script->functionTemp[2]) {
2079 basePriority = -1000;
2080 } else {
2081 basePriority = 1000;
2082 }
2083 enemyIDs = battleStatus->enemyIDs;
2084 for (i = 0; i < numEnemies - 1; i++) {
2085 for (j = i + 1; j < numEnemies; j++) {
2086 enemyID1 = enemyIDs[i];
2087 actor1 = battleStatus->enemyActors[enemyID1 & 0xFF];
2088 priority1 = actor1->turnPriority;
2089 if (actor1 == actor2) {
2090 priority1 += basePriority;
2091 }
2092 enemyID2 = enemyIDs[j];
2093 actor1 = battleStatus->enemyActors[enemyID2 & 0xFF];
2094 priority2 = actor1->turnPriority;
2095 if (actor1 == actor2) {
2096 priority2 += basePriority;
2097 }
2098 if (priority1 < priority2) {
2099 enemyIDs[i] = enemyID2;
2100 enemyIDs[j] = enemyID1;
2101 }
2102 }
2103 }
2104 } else {
2105 numEnemies = battleStatus->numEnemyActors;
2106 for (i = 0; i < numEnemies; i++){
2107 if (battleStatus->enemyActors[enemyIDs[i] & 0xFF] == actor2) {
2108 enemyIDs[i] = -1;
2109 }
2110 }
2111 if (script->functionTemp[2] == 0) {
2112 for (i = numEnemies; i >= battleStatus->nextEnemyIndex; i--) {
2113 battleStatus->enemyIDs[i] = battleStatus->enemyIDs[i - 1];
2114 }
2115 battleStatus->enemyIDs[battleStatus->nextEnemyIndex - 1] = actor2->actorID;
2116 battleStatus->numEnemyActors++;
2117 battleStatus->nextEnemyIndex++;
2118 } else {
2119 battleStatus->enemyIDs[battleStatus->numEnemyActors] = actor2->actorID;
2120 battleStatus->numEnemyActors++;
2121 }
2122 }
2123 script->varTable[0] = actor2->actorID;
2124 return ApiStatus_DONE2;
2125 }
2126 return ApiStatus_BLOCK;
2127}
2128
2129API_CALLABLE(GetOwnerID) {
2130 Bytecode* args = script->ptrReadPos;
2131 s32 outVar = *args++;
2132
2133 evt_set_variable(script, outVar, script->owner1.actorID);
2134 return ApiStatus_DONE2;
2135}
2136
2137API_CALLABLE(SetOwnerID) {
2138 Bytecode* args = script->ptrReadPos;
2139 s32 actorID = evt_get_variable(script, *args++);
2140
2141 script->owner1.actorID = actorID;
2142 return ApiStatus_DONE2;
2143}
2144
2145API_CALLABLE(ActorExists) {
2146 Actor* partner = gBattleStatus.partnerActor;
2147 Bytecode* args = script->ptrReadPos;
2148 s32 actorID = evt_get_variable(script, *args++);
2149 b32 exists;
2150
2151 if (actorID == ACTOR_SELF) {
2152 actorID = script->owner1.actorID;
2153 }
2154
2155 exists = get_actor(actorID) != NULL;
2156 if ((actorID == ACTOR_PARTNER) && (partner == NULL)) {
2157 exists = FALSE;
2158 }
2159
2160 evt_set_variable(script, *args++, exists);
2161 return ApiStatus_DONE2;
2162}
2163
2164API_CALLABLE(GetPartAnimInstanceID) {
2165 Bytecode* args = script->ptrReadPos;
2166 s32 actorID = evt_get_variable(script, *args++);
2167 s32 partID = evt_get_variable(script, *args++);
2168 s32 outVar = *args++;
2169 Actor* actor;
2170 ActorPart* part;
2171
2172 if (actorID == ACTOR_SELF) {
2173 actorID = script->owner1.actorID;
2174 }
2175
2176 actor = get_actor(actorID);
2177 part = get_actor_part(actor, partID);
2178 evt_set_variable(script, outVar, part->spriteInstanceID);
2179
2180 return ApiStatus_DONE2;
2181}
2182
2183API_CALLABLE(GetPartAnimNotify) {
2184 Bytecode* args = script->ptrReadPos;
2185 s32 actorID = evt_get_variable(script, *args++);
2186 s32 partID = evt_get_variable(script, *args++);
2187 s32 outVar = *args++;
2188 Actor* actor;
2189 ActorPart* part;
2190
2191 if (actorID == ACTOR_SELF) {
2192 actorID = script->owner1.actorID;
2193 }
2194
2195 actor = get_actor(actorID);
2196 part = get_actor_part(actor, partID);
2197 evt_set_variable(script, outVar, part->animNotifyValue);
2198
2199 return ApiStatus_DONE2;
2200}
2201
2202API_CALLABLE(SetBattleMenuEnabledFlags) {
2203 Bytecode* args = script->ptrReadPos;
2204 s32 flagsValue = *args++;
2205
2206 gBattleStatus.enabledMenusFlags = flagsValue;
2207 return ApiStatus_DONE2;
2208}
2209
2210API_CALLABLE(SetEnabledStarPowers) {
2211 Bytecode* args = script->ptrReadPos;
2212 s32 enabled = *args++;
2213
2215 return ApiStatus_DONE2;
2216}
2217
2218API_CALLABLE(SetBattleInputMask) {
2219 Bytecode* args = script->ptrReadPos;
2220 s32 mask = *args++;
2221
2223 return ApiStatus_DONE2;
2224}
2225
2226API_CALLABLE(SetBattleInputButtons) {
2227 Bytecode* args = script->ptrReadPos;
2228 BattleStatus* battleStatus = &gBattleStatus;
2229 s32 currentButtonsDown = *args++;
2230 s32 currentButtonsPressed = *args++;
2231 s32 currentButtonsHeld = *args++;
2232
2233 battleStatus->curButtonsDown = currentButtonsDown;
2234 battleStatus->curButtonsPressed = currentButtonsPressed;
2235 battleStatus->curButtonsHeld = currentButtonsHeld;
2236
2237 return ApiStatus_DONE2;
2238}
2239
2240API_CALLABLE(CheckButtonPress) {
2241 Bytecode* args = script->ptrReadPos;
2242 Bytecode buttons = *args++;
2243 Bytecode outVar = *args++;
2244 s32 buttonsPressed = gBattleStatus.curButtonsPressed;
2245
2246 evt_set_variable(script, outVar, (buttonsPressed & buttons) != 0);
2247 return ApiStatus_DONE2;
2248}
2249
2250API_CALLABLE(CheckButtonHeld) {
2251 Bytecode* args = script->ptrReadPos;
2252 Bytecode buttons = *args++;
2253 Bytecode outVar = *args++;
2254 s32 buttonsHeld = gBattleStatus.curButtonsHeld;
2255
2256 evt_set_variable(script, outVar, (buttonsHeld & buttons) != 0);
2257 return ApiStatus_DONE2;
2258}
2259
2260API_CALLABLE(CheckButtonDown) {
2261 Bytecode* args = script->ptrReadPos;
2262 Bytecode buttons = *args++;
2263 Bytecode outVar = *args++;
2264 s32 buttonsDown = gBattleStatus.curButtonsDown;
2265
2266 evt_set_variable(script, outVar, (buttonsDown & buttons) != 0);
2267 return ApiStatus_DONE2;
2268}
2269
2270API_CALLABLE(GetBattleState) {
2271 Bytecode* args = script->ptrReadPos;
2272 s32 outVar = *args++;
2273
2274 evt_set_variable(script, outVar, gBattleState);
2275 return ApiStatus_DONE2;
2276}
2277
2278API_CALLABLE(SetBattleState) {
2279 Bytecode* args = script->ptrReadPos;
2280 s32 state = evt_get_variable(script, *args++);
2281
2282 btl_set_state(state);
2283 return ApiStatus_DONE2;
2284}
2285
2286API_CALLABLE(WaitForState) {
2287 Bytecode* args = script->ptrReadPos;
2288 BattleStatus* battleStatus = &gBattleStatus;
2289 s32 waitForState;
2290
2291 if (isInitialCall) {
2292 waitForState = evt_get_variable(script, *args++);
2293 if (waitForState == BATTLE_STATE_0) {
2294 battleStatus->waitForState = BATTLE_STATE_0;
2295 return ApiStatus_DONE2;
2296 }
2297 battleStatus->waitForState = waitForState;
2298 }
2299
2300 waitForState = battleStatus->waitForState;
2301 if (waitForState == BATTLE_STATE_0) {
2302 return ApiStatus_DONE2;
2303 }
2304
2305 if (gBattleState == waitForState) {
2306 return ApiStatus_DONE2;
2307 } else {
2308 return ApiStatus_BLOCK;
2309 }
2310}
2311
2312API_CALLABLE(CancelEnemyTurn) {
2313 Bytecode* args = script->ptrReadPos;
2314 BattleStatus* battleStatus = &gBattleStatus;
2315 s32 cancelMode = evt_get_variable(script, *args++);
2316
2317 switch (cancelMode) {
2318 case 0:
2319 battleStatus->unk_94 = 1;
2320 break;
2321 case 1:
2322 battleStatus->unk_94 = -1;
2323 break;
2324 }
2325
2326 return ApiStatus_DONE2;
2327}
2328
2329API_CALLABLE(func_8026E260) {
2330 Bytecode* args = script->ptrReadPos;
2331 s32 actorID = evt_get_variable(script, *args++);
2332
2333 evt_get_variable(script, *args++);
2334 if (actorID == ACTOR_SELF) {
2335 actorID = script->owner1.actorID;
2336 }
2337 get_actor(actorID);
2338
2339 return ApiStatus_DONE2;
2340}
2341
2342API_CALLABLE(CreateCurrentPosTargetList) {
2343 Bytecode* args = script->ptrReadPos;
2344 Actor* actor = get_actor(script->owner1.actorID);
2345
2348
2349 return ApiStatus_DONE2;
2350}
2351
2352API_CALLABLE(CreateHomeTargetList) {
2353 Bytecode* args = script->ptrReadPos;
2354 Actor* actor = get_actor(script->owner1.actorID);
2355
2358
2359 return ApiStatus_DONE2;
2360}
2361
2362API_CALLABLE(InitTargetIterator) {
2363 Bytecode* args = script->ptrReadPos;
2364 Actor* actor = get_actor(script->owner1.actorID);
2365 SelectableTarget* selectableTarget = &actor->targetData[actor->targetIndexList[actor->selectedTargetIndex]];
2366
2367 actor->targetActorID = selectableTarget->actorID;
2368 actor->targetPartID = selectableTarget->partID;
2369
2370 return ApiStatus_DONE2;
2371}
2372
2373API_CALLABLE(SetOwnerTarget) {
2374 Bytecode* args = script->ptrReadPos;
2375 Actor* actor = get_actor(script->owner1.enemyID);
2376 s16 actorID = evt_get_variable(script, *args++);
2377
2378 actor->targetPartID = evt_get_variable(script, *args++);
2379 actor->targetActorID = actorID;
2380
2381 return ApiStatus_DONE2;
2382}
2383
2384API_CALLABLE(ChooseNextTarget) {
2385 Bytecode* args = script->ptrReadPos;
2386 Actor* actor = get_actor(script->owner1.actorID);
2387 s32 mode = evt_get_variable(script, *args++);
2388 s32 temp = *args++;
2389 SelectableTarget* target;
2390 s32 length;
2391 s32 curIdx;
2392 s32 retVal;
2393
2394 if (mode == ITER_FIRST) {
2395 actor->selectedTargetIndex = 0;
2396 target = &actor->targetData[actor->targetIndexList[0]];
2397 actor->targetActorID = target->actorID;
2398 actor->targetPartID = target->partID;
2399 return ApiStatus_DONE2;
2400 }
2401
2402 if (mode == ITER_LAST) {
2403 actor->selectedTargetIndex = actor->targetListLength - 1;
2404 target = &actor->targetData[actor->targetIndexList[actor->selectedTargetIndex]];
2405 actor->targetActorID = target->actorID;
2406 actor->targetPartID = target->partID;
2407 return ApiStatus_DONE2;
2408 }
2409
2410 curIdx = actor->selectedTargetIndex;
2411 length = actor->targetListLength;
2412 retVal = ITER_HAS_MORE;
2413
2414 if (mode == ITER_NEXT) {
2415 curIdx++;
2416 } else {
2417 curIdx--;
2418 }
2419
2420 if (curIdx < 0) {
2421 curIdx = length - 1;
2422 retVal = ITER_NO_MORE;
2423 }
2424
2425 if (curIdx >= length) {
2426 curIdx = 0;
2427 retVal = ITER_NO_MORE;
2428 }
2429
2430 actor->selectedTargetIndex = curIdx;
2431 target = &actor->targetData[actor->targetIndexList[actor->selectedTargetIndex]];
2432 actor->targetActorID = target->actorID;
2433 actor->targetPartID = target->partID;
2434 evt_set_variable(script, temp, retVal);
2435
2436 return ApiStatus_DONE2;
2437}
2438
2439API_CALLABLE(func_8026E558) {
2440 Bytecode* args = script->ptrReadPos;
2441 SelectableTarget* target;
2442 s32 mode;
2443 s32 outVar;
2444 Actor* actor;
2445 f32 x, y, z;
2446 s32 outVal;
2447 s32 row;
2448 s32 column;
2449 s32 layer;
2450 s32 i;
2451
2452 i = evt_get_variable(script, *args++);
2453 mode = evt_get_variable(script, *args++);
2454 outVar = *args++;
2455
2456 if (i == ACTOR_SELF) {
2457 i = script->owner1.actorID;
2458 }
2459
2460 actor = get_actor(i);
2461 x = actor->curPos.x;
2462 y = actor->curPos.y;
2463 z = actor->curPos.z;
2464
2465 outVal = -1;
2466
2467 if (y < 40.0f) {
2468 row = 0;
2469 } else if (y < 85.0f) {
2470 row = 1;
2471 } else if (y < 100.0f) {
2472 row = 2;
2473 } else {
2474 row = 3;
2475 }
2476
2477 if (x < 25.0f) {
2478 column = 0;
2479 } else if (x < 65.0f) {
2480 column = 1;
2481 } else if (x < 105.0f) {
2482 column = 2;
2483 } else {
2484 column = 3;
2485 }
2486
2487 if (z < -30.0f) {
2488 layer = 0;
2489 } else {
2490 layer = 1;
2491 }
2492
2493 switch (mode) {
2494 case 0:
2495 for (i = 0; i < actor->targetListLength; i++) {
2496 target = &actor->targetData[actor->targetIndexList[i]];
2497
2498 if (target->column == column && target->layer == layer && target->row < row) {
2499 actor->targetActorID = target->actorID;
2500 actor->targetPartID = target->partID;
2501 outVal = 0;
2502 }
2503 }
2504 break;
2505 case 1:
2506 for (i = 0; i < actor->targetListLength; i++) {
2507 target = &actor->targetData[actor->targetIndexList[i]];
2508
2509 if (target->column == column && target->layer == layer && target->row < row) {
2510 actor->targetActorID = target->actorID;
2511 actor->targetPartID = target->partID;
2512 outVal = 0;
2513 }
2514 }
2515 break;
2516 case -1:
2517 for (i = 0; i < actor->targetListLength; i++) {
2518 target = &actor->targetData[actor->targetIndexList[i]];
2519
2520 if (target->column == column && target->layer == layer && target->row < row) {
2521 actor->targetActorID = target->actorID;
2522 actor->targetPartID = target->partID;
2523 outVal = 0;
2524 }
2525 }
2526 break;
2527 }
2528 evt_set_variable(script, outVar, outVal);
2529 return ApiStatus_DONE2;
2530}
2531
2532API_CALLABLE(GetTargetListLength) {
2533 Bytecode* args = script->ptrReadPos;
2534
2535 evt_set_variable(script, *args++, get_actor(script->owner1.actorID)->targetListLength);
2536 return ApiStatus_DONE2;
2537}
2538
2539API_CALLABLE(GetOwnerTarget) {
2540 Bytecode* args = script->ptrReadPos;
2541 Actor* actor = get_actor(script->owner1.enemyID);
2542 s32 actorID = *args++;
2543 s32 partID = *args++;
2544
2545 evt_set_variable(script, actorID, actor->targetActorID);
2546 evt_set_variable(script, partID, actor->targetPartID);
2547
2548 return ApiStatus_DONE2;
2549}
2550
2551API_CALLABLE(func_8026E914) {
2552 Bytecode* args = script->ptrReadPos;
2553 s32 temp_v0 = *args++;
2554 s32 temp_s1 = *args++;
2555
2558
2559 return ApiStatus_DONE2;
2560}
2561
2562API_CALLABLE(GetPlayerActorID) {
2563 evt_set_variable(script, *script->ptrReadPos, gBattleStatus.attackerActorID);
2564 return ApiStatus_DONE2;
2565}
2566
2567API_CALLABLE(func_8026E9A0) {
2568 Bytecode* args = script->ptrReadPos;
2569 s32 actorID;
2570 s32 partID;
2571
2572 actorID = evt_get_variable(script, *args++);
2573 partID = evt_get_variable(script, *args++);
2574
2576 gBattleStatus.curTargetID2 = actorID;
2577
2578 return ApiStatus_DONE2;
2579}
2580
2581API_CALLABLE(GetDistanceToGoal) {
2582 Bytecode* args = script->ptrReadPos;
2583 s32 actorID = evt_get_variable(script, *args++);
2584 s32 outVar = *args++;
2585 Actor* actor;
2586 f32 dist;
2587
2588 if (actorID == ACTOR_SELF) {
2589 actorID = script->owner1.actorID;
2590 }
2591 actor = get_actor(actorID);
2592
2593 dist = dist2D(actor->curPos.x, actor->curPos.z, actor->state.goalPos.x, actor->state.goalPos.z);
2594 evt_set_variable(script, outVar, dist);
2595 return ApiStatus_DONE2;
2596}
2597
2598API_CALLABLE(SetActorPaletteEffect) {
2599 Bytecode* args = script->ptrReadPos;
2600 s32 actorID = evt_get_variable(script, *args++);
2601 s32 partID = evt_get_variable(script, *args++);
2602 s32 palAdjustment = evt_get_variable(script, *args++);
2603 Actor* actor;
2604 ActorPart* actorPart;
2605
2606 if (actorID == ACTOR_SELF) {
2607 actorID = script->owner1.actorID;
2608 }
2609 actor = get_actor(actorID);
2610 actorPart = get_actor_part(actor, partID);
2611
2612 set_part_pal_adjustment(actorPart, palAdjustment);
2613 return ApiStatus_DONE2;
2614}
2615
2616API_CALLABLE(SetActorPaletteSwapTimes) {
2617 Bytecode* args = script->ptrReadPos;
2618 s32 actorID = evt_get_variable(script, *args++);
2619 s32 partID = evt_get_variable(script, *args++);
2620 Actor* actor;
2621 ActorPart* actorPart;
2622 DecorationTable* decorations;
2623
2624 if (actorID == ACTOR_SELF) {
2625 actorID = script->owner1.actorID;
2626 }
2627 actor = get_actor(actorID);
2628 actorPart = get_actor_part(actor, partID);
2629 decorations = actorPart->decorationTable;
2630
2631 decorations->blendPalA = evt_get_variable(script, *args++);
2632 decorations->blendPalB = evt_get_variable(script, *args++);
2633 decorations->palswapTimeHoldA = evt_get_variable(script, *args++);
2634 decorations->palswapTimeAtoB = evt_get_variable(script, *args++);
2635
2636 return ApiStatus_DONE2;
2637}
2638
2639API_CALLABLE(SetActorPaletteSwapParams) {
2640 Bytecode* args = script->ptrReadPos;
2641 s32 actorID = evt_get_variable(script, *args++);
2642 s32 partID = evt_get_variable(script, *args++);
2643 Actor* actor;
2644 ActorPart* actorPart;
2645 DecorationTable* table;
2646
2647 if (actorID == ACTOR_SELF) {
2648 actorID = script->owner1.actorID;
2649 }
2650 actor = get_actor(actorID);
2651 actorPart = get_actor_part(actor, partID);
2652 table = actorPart->decorationTable;
2653
2654 table->blendPalA = evt_get_variable(script, *args++);
2655 table->blendPalB = evt_get_variable(script, *args++);
2656 table->palswapTimeHoldA = evt_get_variable(script, *args++);
2657 table->palswapTimeAtoB = evt_get_variable(script, *args++);
2658 table->palswapTimeHoldB = evt_get_variable(script, *args++);
2659 table->palswapTimeBtoA = evt_get_variable(script, *args++);
2660 table->palswapUnused1 = evt_get_variable(script, *args++);
2661 table->palswapUnused2 = evt_get_variable(script, *args++);
2662
2663 return ApiStatus_DONE2;
2664}
2665
2666API_CALLABLE(EnableActorPaletteEffects) {
2667 Bytecode* args = script->ptrReadPos;
2668 s32 actorID = evt_get_variable(script, *args++);
2669 s32 partID = evt_get_variable(script, *args++);
2670 s32 enable = evt_get_variable(script, *args++);
2671 Actor* actor;
2672 ActorPart* actorPart;
2673
2674 if (actorID == ACTOR_SELF) {
2675 actorID = script->owner1.actorID;
2676 }
2677 actor = get_actor(actorID);
2678 actorPart = get_actor_part(actor, partID);
2679
2680 if (enable) {
2682 } else {
2683 actorPart->flags &= ~ACTOR_PART_FLAG_HAS_PAL_EFFECT;
2684 }
2685
2686 return ApiStatus_DONE2;
2687}
2688
2689API_CALLABLE(func_8026EDE4) {
2690 Bytecode* args = script->ptrReadPos;
2691 s32 actorID = evt_get_variable(script, *args++);
2692 s32 partID = evt_get_variable(script, *args++);
2693 s32 temp_s3 = evt_get_variable(script, *args++);
2694 Actor* actor;
2695 ActorPart* actorPart;
2696
2697 if (actorID == ACTOR_SELF) {
2698 actorID = script->owner1.actorID;
2699 }
2700 actor = get_actor(actorID);
2701 actorPart = get_actor_part(actor, partID);
2702
2703 set_part_glow_pal(actorPart, temp_s3);
2704
2705 return ApiStatus_DONE2;
2706}
2707
2708API_CALLABLE(AddActorDecoration) {
2709 Bytecode* args = script->ptrReadPos;
2710 s32 actorID = evt_get_variable(script, *args++);
2711 s32 partID = evt_get_variable(script, *args++);
2712 s32 decorationIndex = evt_get_variable(script, *args++);
2713 s32 decorationType = evt_get_variable(script, *args++);
2714 Actor* actor;
2715 ActorPart* actorPart;
2716
2717 if (actorID == ACTOR_SELF) {
2718 actorID = script->owner1.actorID;
2719 }
2720 actor = get_actor(actorID);
2721 actorPart = get_actor_part(actor, partID);
2722
2723 add_part_decoration(actorPart, decorationIndex, decorationType);
2724 return ApiStatus_DONE2;
2725}
2726
2727API_CALLABLE(RemoveActorDecoration) {
2728 Bytecode* args = script->ptrReadPos;
2729 s32 actorID = evt_get_variable(script, *args++);
2730 s32 partID = evt_get_variable(script, *args++);
2731 s32 decorationIndex = evt_get_variable(script, *args++);
2732 Actor* actor;
2733 ActorPart* actorPart;
2734
2735 if (actorID == ACTOR_SELF) {
2736 actorID = script->owner1.enemyID;
2737 }
2738 actor = get_actor(actorID);
2739 actorPart = get_actor_part(actor, partID);
2740
2741 remove_part_decoration(actorPart, decorationIndex);
2742 return ApiStatus_DONE2;
2743}
2744
2745API_CALLABLE(ModifyActorDecoration) {
2746 Bytecode* args = script->ptrReadPos;
2747 s32 actorID = evt_get_variable(script, *args++);
2748 s32 partID = evt_get_variable(script, *args++);
2749 s32 idx = evt_get_variable(script, *args++);
2750 ActorPart* actorPart;
2751 DecorationTable* decorationtable;
2752 Actor* actor;
2753
2754 if (actorID == ACTOR_SELF) {
2755 actorID = script->owner1.actorID;
2756 }
2757 actor = get_actor(actorID);
2758 actorPart = get_actor_part(actor, partID);
2759 decorationtable = actorPart->decorationTable;
2760
2761 decorationtable->decorData[idx].raw[0] = evt_get_variable(script, *args++);
2762 decorationtable->decorData[idx].raw[1] = evt_get_variable(script, *args++);
2763 decorationtable->decorData[idx].raw[2] = evt_get_variable(script, *args++);
2764 decorationtable->decorData[idx].raw[3] = evt_get_variable(script, *args++);
2765 return ApiStatus_DONE2;
2766}
2767
2768API_CALLABLE(UseIdleAnimation) {
2769 Actor* actor;
2770 s32* args = script->ptrReadPos;
2771 s32 actorID = evt_get_variable(script, *args++);
2772 s32 useIdle = evt_get_variable(script, *args++);
2773
2774 if (actorID == ACTOR_SELF) {
2775 actorID = script->owner1.actorID;
2776 }
2777
2778 actor = get_actor(actorID);
2779 if (!useIdle) {
2780 actor->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
2781 actor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2783 } else {
2785 }
2786
2787 return ApiStatus_DONE2;
2788}
2789
2790API_CALLABLE(func_8026F1A0) {
2791 Bytecode* args = script->ptrReadPos;
2792 s32 actorID = evt_get_variable(script, *args++);
2793 s32 temp_s0_3 = evt_get_variable(script, *args++);
2794 Actor* actor;
2795
2796 if (actorID == ACTOR_SELF) {
2797 actorID = script->owner1.actorID;
2798 }
2799
2800 actor = get_actor(actorID);
2801
2802 if (temp_s0_3 == 0) {
2803 actor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2805 }
2806
2807 return ApiStatus_DONE2;
2808}
2809
2810API_CALLABLE(GetStatusFlags) {
2811 Bytecode* args = script->ptrReadPos;
2812 BattleStatus* battleStatus = &gBattleStatus;
2813 s32 actorID = evt_get_variable(script, *args++);
2814 s32 outVar = *args++;
2815 Actor* actor;
2816 s32 actorClass;
2817 s8 debuff;
2818 s8 staticStatus;
2819 s8 stoneStatus;
2820 s8 koStatus;
2821 s8 transStatus;
2822 ActorPart* partsTable;
2823 s32 flags;
2824
2825 if (actorID == ACTOR_SELF) {
2826 actorID = script->owner1.actorID;
2827 }
2828 actor = get_actor(actorID);
2829 debuff = actor->debuff;
2830 actorClass = actor->actorID & ACTOR_CLASS_MASK;
2831 flags = 0;
2832
2833 if (debuff != 0) {
2834 if (debuff == STATUS_KEY_STOP) {
2836 }
2837 if (debuff == STATUS_KEY_FROZEN) {
2839 }
2840 if (debuff == STATUS_KEY_SLEEP) {
2842 }
2843 if (debuff == STATUS_KEY_PARALYZE) {
2845 }
2846 if (debuff == STATUS_KEY_DIZZY) {
2848 }
2849 if (debuff == STATUS_KEY_FEAR) {
2851 }
2852 if (debuff == STATUS_KEY_POISON) {
2854 }
2855 if (debuff == STATUS_KEY_SHRINK) {
2857 }
2858 }
2859
2860 switch (actor->staticStatus) {
2861 case 0:
2862 break;
2863 case STATUS_KEY_STATIC:
2865 break;
2866 }
2867
2868 switch (actor->stoneStatus) {
2869 case 0:
2870 break;
2871 case STATUS_KEY_STONE:
2873 break;
2874 }
2875
2876 switch (actor->koStatus) {
2877 case 0:
2878 break;
2879 case STATUS_KEY_DAZE:
2881 break;
2882 }
2883
2884 switch (actor->transparentStatus) {
2885 case 0:
2886 break;
2889 break;
2890 }
2891
2892 for (partsTable = actor->partsTable; partsTable != NULL; partsTable = partsTable->nextPart) {
2893 if (partsTable->flags & ACTOR_PART_FLAG_TRANSPARENT) {
2895 }
2896 if (partsTable->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY) {
2898 }
2899 }
2900
2901 switch (actorClass) {
2902 case ACTOR_CLASS_PLAYER:
2904 if (battleStatus->outtaSightActive) {
2906 }
2907 break;
2908 case ACTOR_CLASS_ENEMY:
2909 break;
2910 }
2911
2912 if (actor->isGlowing) {
2914 }
2915
2916 if (actor->attackBoost) {
2918 }
2919
2920 if (actor->defenseBoost) {
2922 }
2923
2924 if (actor->chillOutAmount) {
2926 }
2927
2930 }
2931
2932 evt_set_variable(script, outVar, flags);
2933 return ApiStatus_DONE2;
2934}
2935
2936API_CALLABLE(RemovePlayerBuffs) {
2937 remove_player_buffs(*script->ptrReadPos);
2938 return ApiStatus_DONE2;
2939}
2940
2941API_CALLABLE(SetPartAlpha) {
2942 Actor* actor;
2943 s32* args = script->ptrReadPos;
2944 s32 actorID = evt_get_variable(script, *args++);
2945 s32 partID = evt_get_variable(script, *args++);
2946 s32 opacity = evt_get_variable(script, *args++);
2947
2948 if (actorID == ACTOR_SELF) {
2949 actorID = script->owner1.actorID;
2950 }
2951
2952 actor = get_actor(actorID);
2953 get_actor_part(actor, partID)->opacity = opacity;
2954
2956 return ApiStatus_DONE2;
2957}
2958
2959API_CALLABLE(CreatePartShadow) {
2960 Bytecode* args = script->ptrReadPos;
2961 s32 actorID = evt_get_variable(script, *args++);
2962 s32 partID = evt_get_variable(script, *args++);
2963
2964 if (actorID == ACTOR_SELF) {
2965 actorID = script->owner1.actorID;
2966 }
2967
2968 create_part_shadow(actorID, partID);
2969 return ApiStatus_DONE2;
2970}
2971
2972API_CALLABLE(RemovePartShadow) {
2973 Bytecode* args = script->ptrReadPos;
2974 s32 actorID = evt_get_variable(script, *args++);
2975 s32 partID = evt_get_variable(script, *args++);
2976
2977 if (actorID == ACTOR_SELF) {
2978 actorID = script->owner1.actorID;
2979 }
2980
2981 remove_part_shadow(actorID, partID);
2982 return ApiStatus_DONE2;
2983}
2984
2985API_CALLABLE(SetEndBattleFadeOutRate) {
2986 gBattleStatus.endBattleFadeOutRate = evt_get_variable(script, *script->ptrReadPos);
2987 return ApiStatus_DONE2;
2988}
2989
2990API_CALLABLE(SetBattleVar) {
2991 Bytecode* args = script->ptrReadPos;
2992 s32 varIdx = evt_get_variable(script, *args++);
2993
2994 gBattleStatus.varTable[varIdx] = evt_get_variable(script, *args++);
2995
2996 return ApiStatus_DONE2;
2997}
2998
2999API_CALLABLE(GetBattleVar) {
3000 Bytecode* args = script->ptrReadPos;
3001 s32 varIdx = evt_get_variable(script, *args++);
3002
3003 evt_set_variable(script, *args++, gBattleStatus.varTable[varIdx]);
3004 return ApiStatus_DONE2;
3005}
3006
3007API_CALLABLE(ResetAllActorSounds) {
3008 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3009
3010 if (actorID == ACTOR_SELF) {
3011 actorID = script->owner1.actorID;
3012 }
3013
3015 return ApiStatus_DONE2;
3016}
3017
3018API_CALLABLE(SetActorSounds) {
3019 Bytecode* args = script->ptrReadPos;
3020 s32 actorID = evt_get_variable(script, *args++);
3021 Actor* actor;
3022 s32 soundType;
3023 s32 sound1;
3024 s32 sound2;
3025
3026 if (actorID == ACTOR_SELF) {
3027 actorID = script->owner1.actorID;
3028 }
3029
3030 soundType = evt_get_variable(script, *args++);
3031 sound1 = evt_get_variable(script, *args++);
3032 sound2 = evt_get_variable(script, *args++);
3033 actor = get_actor(actorID);
3034
3035 switch (soundType) {
3036 case ACTOR_SOUND_WALK:
3037 actor->actorTypeData1[0] = sound1;
3038 actor->actorTypeData1[1] = sound2;
3039 break;
3040 case ACTOR_SOUND_FLY:
3041 actor->actorTypeData1[2] = sound1;
3042 actor->actorTypeData1[3] = sound2;
3043 break;
3044 case ACTOR_SOUND_JUMP:
3045 actor->actorTypeData1[4] = sound1;
3046 break;
3047 case ACTOR_SOUND_HURT:
3048 actor->actorTypeData1[5] = sound1;
3049 break;
3051 actor->actorTypeData1b[0] = sound1;
3052 break;
3054 actor->actorTypeData1b[1] = sound1;
3055 break;
3056 }
3057
3058 return ApiStatus_DONE2;
3059}
3060
3061API_CALLABLE(ResetActorSounds) {
3062 Bytecode* args = script->ptrReadPos;
3063 s32 actorID = evt_get_variable(script, *args++);
3064 Actor* actor;
3065 s32 soundType;
3066 s32 sound1;
3067 s32 sound2;
3068
3069 if (actorID == ACTOR_SELF) {
3070 actorID = script->owner1.actorID;
3071 }
3072
3073 soundType = evt_get_variable(script, *args++);
3074 sound1 = evt_get_variable(script, *args++);
3075 sound2 = evt_get_variable(script, *args++);
3076 actor = get_actor(actorID);
3077
3078 switch (soundType) {
3079 case ACTOR_SOUND_WALK:
3080 actor->actorTypeData1[0] = bActorSoundTable[actor->actorType].walk[0];
3081 actor->actorTypeData1[1] = bActorSoundTable[actor->actorType].walk[1];
3082 break;
3083 case ACTOR_SOUND_FLY:
3084 actor->actorTypeData1[2] = bActorSoundTable[actor->actorType].fly[0];
3085 actor->actorTypeData1[3] = bActorSoundTable[actor->actorType].fly[1];
3086 break;
3087 case ACTOR_SOUND_JUMP:
3088 actor->actorTypeData1[4] = bActorSoundTable[actor->actorType].jump;
3089 break;
3090 case ACTOR_SOUND_HURT:
3091 actor->actorTypeData1[5] = bActorSoundTable[actor->actorType].hurt;
3092 break;
3094 actor->actorTypeData1b[0] = bActorSoundTable[actor->actorType].delay[0];
3095 break;
3097 actor->actorTypeData1b[1] = bActorSoundTable[actor->actorType].delay[1];
3098 break;
3099 }
3100
3101 return ApiStatus_DONE2;
3102}
3103
3104API_CALLABLE(SetPartSounds) {
3105 Bytecode* args = script->ptrReadPos;
3106 s32 actorID = evt_get_variable(script, *args++);
3107 ActorPart* actorPart;
3108 s32 partID;
3109 s32 soundType;
3110 s32 sound1;
3111 s32 sound2;
3112
3113 if (actorID == ACTOR_SELF) {
3114 actorID = script->owner1.actorID;
3115 }
3116
3117 partID = evt_get_variable(script, *args++);
3118 soundType = evt_get_variable(script, *args++);
3119 sound1 = evt_get_variable(script, *args++);
3120 sound2 = evt_get_variable(script, *args++);
3121 actorPart = get_actor_part(get_actor(actorID), partID);
3122
3123 switch (soundType) {
3124 case ACTOR_SOUND_WALK:
3125 actorPart->partTypeData[0] = sound1;
3126 actorPart->partTypeData[1] = sound2;
3127 break;
3128 case ACTOR_SOUND_FLY:
3129 actorPart->partTypeData[2] = sound1;
3130 actorPart->partTypeData[3] = sound2;
3131 break;
3132 case ACTOR_SOUND_JUMP:
3133 actorPart->partTypeData[4] = sound1;
3134 break;
3135 case ACTOR_SOUND_HURT:
3136 actorPart->partTypeData[5] = sound1;
3137 break;
3139 actorPart->actorTypeData2b[0] = sound1;
3140 break;
3142 actorPart->actorTypeData2b[1] = sound1;
3143 break;
3144 }
3145
3146 return ApiStatus_DONE2;
3147}
3148
3149API_CALLABLE(SetActorType) {
3150 Bytecode* args = script->ptrReadPos;
3151 s32 actorID = evt_get_variable(script, *args++);
3152 Actor* enemy;
3153 s32 actorType;
3154
3155 if (actorID == ACTOR_SELF) {
3156 actorID = script->owner1.actorID;
3157 }
3158
3159 actorType = evt_get_variable(script, *args++);
3160 enemy = get_actor(actorID);
3161
3162 if (is_actor_health_bar_visible(enemy)) {
3163 load_tattle_flags(actorType);
3164 }
3165
3166 enemy->actorType = actorType;
3167 return ApiStatus_DONE2;
3168}
3169
3170API_CALLABLE(ShowShockEffect) {
3171 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3172
3173 if (actorID == ACTOR_SELF) {
3174 actorID = script->owner1.actorID;
3175 }
3176
3177 apply_shock_effect(get_actor(actorID));
3178 return ApiStatus_DONE2;
3179}
3180
3181API_CALLABLE(GetActorAttackBoost) {
3182 Bytecode* args = script->ptrReadPos;
3183 s32 enemyID = evt_get_variable(script, *args++);
3184 Bytecode attackBoost;
3185
3186 if (enemyID == ACTOR_SELF) {
3187 enemyID = script->owner1.enemyID;
3188 }
3189
3190 attackBoost = *args++;
3191 evt_set_variable(script, attackBoost, get_actor(enemyID)->attackBoost);
3192 return ApiStatus_DONE2;
3193}
3194
3195API_CALLABLE(GetActorDefenseBoost) {
3196 Bytecode* args = script->ptrReadPos;
3197 s32 enemyID = evt_get_variable(script, *args++);
3198 Bytecode defenseBoost;
3199
3200 if (enemyID == ACTOR_SELF) {
3201 enemyID = script->owner1.enemyID;
3202 }
3203
3204 defenseBoost = *args++;
3205 evt_set_variable(script, defenseBoost, get_actor(enemyID)->defenseBoost);
3206 return ApiStatus_DONE2;
3207}
3208
3209API_CALLABLE(BoostAttack) {
3210 Bytecode* args = script->ptrReadPos;
3211 s32 actorID;
3212 Actor* actor;
3213 s32 flags;
3214 s32 flags2;
3215 f32 x1, y1, z1;
3216 f32 x2, y2, z2;
3217 s32 attackBoost;
3218
3219 if (isInitialCall) {
3220 script->functionTemp[0] = 0;
3221 }
3222
3223 if (script->functionTemp[0] == 0) {
3224 actorID = evt_get_variable(script, *args++);
3225 if (actorID == ACTOR_SELF) {
3226 actorID = script->owner1.actorID;
3227 }
3228 attackBoost = evt_get_variable(script, *args++);
3229 actor = get_actor(actorID);
3230 script->functionTempPtr[1] = actor;
3231 script->functionTemp[2] = attackBoost;
3232
3236 btl_cam_set_zoom(250);
3237 btl_cam_move(10);
3239 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
3241 }
3242 ApplyingBuff = TRUE;
3243 script->functionTemp[3] = 5;
3244 script->functionTemp[0] = 1;
3245 }
3246 get_actor(script->owner1.actorID);
3247 actor = script->functionTempPtr[1];
3248 attackBoost = script->functionTemp[2];
3249
3250 flags = actor->flags;
3251 x1 = actor->curPos.x + actor->headOffset.x;
3253 y1 = actor->curPos.y + actor->headOffset.y - actor->size.y / 2;
3254 } else if (!(flags & ACTOR_FLAG_HALF_HEIGHT)) {
3255 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y / 2;
3256 } else {
3257 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3258 }
3259 z1 = actor->curPos.z + actor->headOffset.z + 10.0f;
3260
3261 flags2 = actor->flags;
3262 x2 = actor->curPos.x + actor->headOffset.x + actor->size.x / 2;
3263 if (flags2 & ACTOR_FLAG_UPSIDE_DOWN) {
3264 y2 = actor->curPos.y + actor->headOffset.y - actor->size.y;
3265 } else if (!(flags2 & ACTOR_FLAG_HALF_HEIGHT)) {
3266 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3267 } else {
3268 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y * 2;
3269 }
3270 z2 = actor->curPos.z + actor->headOffset.z + 10.0f;
3271
3272 switch (script->functionTemp[0]) {
3273 case 1:
3274 if (script->functionTemp[3] == 0) {
3275 fx_radial_shimmer(2, x1, y1, z1, 1.0f, 30);
3277 script->functionTemp[3] = 30;
3278 script->functionTemp[0] = 2;
3279 } else {
3280 script->functionTemp[3]--;
3281 break;
3282 }
3283 break;
3284 case 2:
3285 if (script->functionTemp[3] == 0) {
3288 btl_cam_move(15);
3289 actor->isGlowing = TRUE;
3290 actor->attackBoost += attackBoost;
3291 if (actor->attackBoost > 20) {
3292 actor->attackBoost = 20;
3293 }
3294 fx_stat_change(attackBoost - 1, x2, y2, z2, 1.0f, 60);
3295 script->functionTemp[3] = 15;
3296 script->functionTemp[0] = 3;
3297 } else {
3298 script->functionTemp[3]--;
3299 break;
3300 }
3301 break;
3302 case 3:
3303 if (script->functionTemp[3] == 0) {
3305 script->functionTemp[0] = 4;
3306 } else {
3307 script->functionTemp[3]--;
3308 break;
3309 }
3310 break;
3311 case 4:
3312 if (btl_is_popup_displayed() == 0) {
3314 script->functionTemp[3] = 10;
3315 script->functionTemp[0] = 5;
3316 }
3317 break;
3318 case 5:
3319 if (script->functionTemp[3] != 0) {
3320 script->functionTemp[3]--;
3321 break;
3322 }
3323 if ((actor->handleEventScript != NULL) && does_script_exist(actor->handleEventScriptID)) {
3324 break;
3325 }
3326 ApplyingBuff = FALSE;
3327 return ApiStatus_DONE2;
3328 }
3329 return ApiStatus_BLOCK;
3330}
3331
3332API_CALLABLE(BoostDefense) {
3333 Bytecode* args = script->ptrReadPos;
3334 s32 actorID;
3335 Actor* actor;
3336 f32 x1, y1, z1;
3337 f32 x2, y2, z2;
3338 s32 defenseBoost;
3339 s32 flags;
3340 s32 flags2;
3341
3342 if (isInitialCall) {
3343 script->functionTemp[0] = 0;
3344 }
3345
3346 if (script->functionTemp[0] == 0) {
3347 actorID = evt_get_variable(script, *args++);
3348 if (actorID == ACTOR_SELF) {
3349 actorID = script->owner1.actorID;
3350 }
3351 defenseBoost = evt_get_variable(script, *args++);
3352 actor = get_actor(actorID);
3353 script->functionTempPtr[1] = actor;
3354 script->functionTemp[2] = defenseBoost;
3355
3359 btl_cam_set_zoom(250);
3360 btl_cam_move(10);
3362 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
3364 }
3365
3366 ApplyingBuff = TRUE;
3367 script->functionTemp[3] = 5;
3368 script->functionTemp[0] = 1;
3369 }
3370 get_actor(script->owner1.actorID);
3371 actor = script->functionTempPtr[1];
3372 defenseBoost = script->functionTemp[2];
3373
3374 flags = actor->flags;
3375 x1 = actor->curPos.x + actor->headOffset.x;
3377 y1 = actor->curPos.y + actor->headOffset.y - actor->size.y / 2;
3378 } else if (!(flags & ACTOR_FLAG_HALF_HEIGHT)) {
3379 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y / 2;
3380 } else {
3381 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3382 }
3383 z1 = actor->curPos.z + actor->headOffset.z + 10.0f;
3384
3385 flags2 = actor->flags;
3386 x2 = actor->curPos.x + actor->headOffset.x + actor->size.x / 2;
3387 if (flags2 & ACTOR_FLAG_UPSIDE_DOWN) {
3388 y2 = actor->curPos.y + actor->headOffset.y - actor->size.y;
3389 } else if (!(flags2 & ACTOR_FLAG_HALF_HEIGHT)) {
3390 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3391 } else {
3392 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y * 2;
3393 }
3394 z2 = actor->curPos.z + actor->headOffset.z + 10.0f;
3395
3396 switch (script->functionTemp[0]) {
3397 case 1:
3398 if (script->functionTemp[3] == 0) {
3399 fx_radial_shimmer(2, x1, y1, z1, 1.0f, 30);
3401 script->functionTemp[3] = 30;
3402 script->functionTemp[0] = 2;
3403 } else {
3404 script->functionTemp[3]--;
3405 break;
3406 }
3407 break;
3408 case 2:
3409 if (script->functionTemp[3] == 0) {
3412 btl_cam_move(15);
3413 actor->isGlowing = TRUE;
3414 actor->defenseBoost += defenseBoost;
3415 if (actor->defenseBoost > 20) {
3416 actor->defenseBoost = 20;
3417 }
3418 fx_stat_change(defenseBoost + 5, x2, y2, z2, 1.0f, 60);
3419 script->functionTemp[3] = 15;
3420 script->functionTemp[0] = 3;
3421 } else {
3422 script->functionTemp[3]--;
3423 break;
3424 }
3425 break;
3426 case 3:
3427 if (script->functionTemp[3] == 0) {
3429 script->functionTemp[0] = 4;
3430 } else {
3431 script->functionTemp[3]--;
3432 break;
3433 }
3434 break;
3435 case 4:
3436 if (btl_is_popup_displayed() == 0) {
3438 script->functionTemp[3] = 10;
3439 script->functionTemp[0] = 5;
3440 }
3441 break;
3442 case 5:
3443 if (script->functionTemp[3] != 0) {
3444 script->functionTemp[3]--;
3445 break;
3446 }
3447 if ((actor->handleEventScript != NULL) && does_script_exist(actor->handleEventScriptID)) {
3448 break;
3449 }
3450 ApplyingBuff = FALSE;
3451 return ApiStatus_DONE2;
3452 }
3453 return ApiStatus_BLOCK;
3454}
3455
3456API_CALLABLE(VanishActor) {
3457 Bytecode* args = script->ptrReadPos;
3458 s32 actorID;
3459 Actor* actor;
3460 f32 x, y, z;
3461 s32 vanished;
3462 s32 flags;
3463
3464 if (isInitialCall) {
3465 script->functionTemp[0] = 0;
3466 }
3467
3468 if (script->functionTemp[0] == 0) {
3469 actorID = evt_get_variable(script, *args++);
3470 if (actorID == ACTOR_SELF) {
3471 actorID = script->owner1.actorID;
3472 }
3473 vanished = evt_get_variable(script, *args++);
3474 actor = get_actor(actorID);
3475 script->functionTemp[1] = (s32) actor;
3476 script->functionTemp[2] = vanished;
3477
3481 btl_cam_set_zoom(250);
3482 btl_cam_move(10);
3484 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
3486 }
3487
3488 ApplyingBuff = TRUE;
3489 script->functionTemp[3] = 5;
3490 script->functionTemp[0] = 1;
3491 }
3492 get_actor(script->owner1.actorID);
3493 actor = script->functionTempPtr[1];
3494 vanished = script->functionTemp[2];
3495
3496 flags = actor->flags;
3497 x = actor->curPos.x + actor->headOffset.x;
3499 y = actor->curPos.y + actor->headOffset.y - actor->size.y / 2;
3500 } else if (!(flags & ACTOR_FLAG_HALF_HEIGHT)) {
3501 y = actor->curPos.y + actor->headOffset.y + actor->size.y / 2;
3502 } else {
3503 y = actor->curPos.y + actor->headOffset.y + actor->size.y;
3504 }
3505 z = actor->curPos.z + actor->headOffset.z + 10.0f;
3506
3507 switch (script->functionTemp[0]) {
3508 case 1:
3509 if (script->functionTemp[3] == 0) {
3510 fx_radial_shimmer(3, x, y, z, 1.0f, 30);
3512 script->functionTemp[3] = 30;
3513 script->functionTemp[0] = 2;
3514 } else {
3515 script->functionTemp[3]--;
3516 break;
3517 }
3518 break;
3519 case 2:
3520 if (script->functionTemp[3] == 0) {
3523 btl_cam_move(15);
3524 inflict_status(actor, STATUS_KEY_TRANSPARENT, vanished);
3525 script->functionTemp[3] = 15;
3526 script->functionTemp[0] = 3;
3527 } else {
3528 script->functionTemp[3]--;
3529 break;
3530 }
3531 break;
3532 case 3:
3533 if (script->functionTemp[3] == 0) {
3535 script->functionTemp[0] = 4;
3536 } else {
3537 script->functionTemp[3]--;
3538 break;
3539 }
3540 break;
3541 case 4:
3542 if (btl_is_popup_displayed() == 0) {
3544 script->functionTemp[3] = 10;
3545 script->functionTemp[0] = 5;
3546 }
3547 break;
3548 case 5:
3549 if (script->functionTemp[3] != 0) {
3550 script->functionTemp[3]--;
3551 break;
3552 }
3553 if ((actor->handleEventScript != NULL) && does_script_exist(actor->handleEventScriptID)) {
3554 break;
3555 }
3556 ApplyingBuff = FALSE;
3557 return ApiStatus_DONE2;
3558 }
3559 return ApiStatus_BLOCK;
3560}
3561
3562API_CALLABLE(ElectrifyActor) {
3563 Bytecode* args = script->ptrReadPos;
3564 s32 actorID;
3565 Actor* actor;
3566 f32 x, y, z;
3567 s32 electrified;
3568 s32 flags;
3569
3570 if (isInitialCall) {
3571 script->functionTemp[0] = 0;
3572 }
3573
3574 if (script->functionTemp[0] == 0) {
3575 actorID = evt_get_variable(script, *args++);
3576 if (actorID == ACTOR_SELF) {
3577 actorID = script->owner1.actorID;
3578 }
3579 electrified = evt_get_variable(script, *args++);
3580 actor = get_actor(actorID);
3581 script->functionTempPtr[1] = actor;
3582 script->functionTemp[2] = electrified;
3583
3587 btl_cam_set_zoom(250);
3588 btl_cam_move(10);
3590 if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
3592 }
3593
3594 ApplyingBuff = TRUE;
3595 script->functionTemp[3] = 5;
3596 script->functionTemp[0] = 1;
3597 }
3598 get_actor(script->owner1.actorID);
3599 actor = script->functionTempPtr[1];
3600 electrified = script->functionTemp[2];
3601
3602 flags = actor->flags;
3603 x = actor->curPos.x + actor->headOffset.x;
3605 y = actor->curPos.y + actor->headOffset.y - actor->size.y / 2;
3606 } else if (!(flags & ACTOR_FLAG_HALF_HEIGHT)) {
3607 y = actor->curPos.y + actor->headOffset.y + actor->size.y / 2;
3608 } else {
3609 y = actor->curPos.y + actor->headOffset.y + actor->size.y;
3610 }
3611 z = actor->curPos.z + actor->headOffset.z + 10.0f;
3612
3613 switch (script->functionTemp[0]) {
3614 case 1:
3615 if (script->functionTemp[3] == 0) {
3616 fx_snaking_static(8, x, y, z, 1.0f, 30);
3618 script->functionTemp[3] = 30;
3619 script->functionTemp[0] = 2;
3620 } else {
3621 script->functionTemp[3]--;
3622 break;
3623 }
3624 break;
3625 case 2:
3626 if (script->functionTemp[3] == 0) {
3629 btl_cam_move(15);
3630 inflict_status(actor, STATUS_KEY_STATIC, electrified);
3631 script->functionTemp[3] = 15;
3632 script->functionTemp[0] = 3;
3633 } else {
3634 script->functionTemp[3]--;
3635 break;
3636 }
3637 break;
3638 case 3:
3639 if (script->functionTemp[3] == 0) {
3641 script->functionTemp[0] = 4;
3642 } else {
3643 script->functionTemp[3]--;
3644 break;
3645 }
3646 break;
3647 case 4:
3648 if (btl_is_popup_displayed() == 0) {
3650 script->functionTemp[3] = 10;
3651 script->functionTemp[0] = 5;
3652 }
3653 break;
3654 case 5:
3655 if (script->functionTemp[3] != 0) {
3656 script->functionTemp[3]--;
3657 break;
3658 }
3659 if ((actor->handleEventScript != NULL) && does_script_exist(actor->handleEventScriptID)) {
3660 break;
3661 }
3662 ApplyingBuff = FALSE;
3663 return ApiStatus_DONE2;
3664 }
3665 return ApiStatus_BLOCK;
3666}
3667
3668API_CALLABLE(HealActor) {
3669 Bytecode* args = script->ptrReadPos;
3670 s32 actorID;
3671 Actor* actor;
3672 f32 x1, y1, z1;
3673 f32 x2, y2, z2;
3674 s32 hpBoost;
3675 s32 flags;
3676 s32 flags2;
3677 s32 message;
3678
3679 if (isInitialCall) {
3680 script->functionTemp[0] = 0;
3681 }
3682
3683 if (script->functionTemp[0] == 0) {
3684 actorID = evt_get_variable(script, *args++);
3685 if (actorID == ACTOR_SELF) {
3686 actorID = script->owner1.enemyID;
3687 }
3688 hpBoost = evt_get_variable(script, *args++);
3689 IsGroupHeal = evt_get_variable(script, *args++);
3690 actor = get_actor(actorID);
3691 script->functionTempPtr[1] = actor;
3692 script->functionTemp[2] = hpBoost;
3693
3697 btl_cam_move(10);
3699
3700 ApplyingBuff = TRUE;
3701 script->functionTemp[3] = 5;
3702 script->functionTemp[0] = 1;
3703 }
3704 get_actor(script->owner1.enemyID);
3705 actor = script->functionTempPtr[1];
3706 hpBoost = script->functionTemp[2];
3707
3708 flags = actor->flags;
3709 x1 = actor->curPos.x + actor->headOffset.x;
3711 y1 = actor->curPos.y + actor->headOffset.y - actor->size.y / 2;
3712 } else if (!(flags & ACTOR_FLAG_HALF_HEIGHT)) {
3713 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y / 2;
3714 } else {
3715 y1 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3716 }
3717 z1 = actor->curPos.z + actor->headOffset.z + 10.0f;
3718
3719 flags2 = actor->flags;
3720 x2 = actor->curPos.x + actor->headOffset.x + actor->size.x / 2;
3721 if (flags2 & ACTOR_FLAG_UPSIDE_DOWN) {
3722 y2 = actor->curPos.y + actor->headOffset.y - actor->size.y;
3723 } else if (!(flags2 & ACTOR_FLAG_HALF_HEIGHT)) {
3724 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y;
3725 } else {
3726 y2 = actor->curPos.y + actor->headOffset.y + actor->size.y * 2;
3727 }
3728 z2 = actor->curPos.z + actor->headOffset.z + 10.0f;
3729
3730 switch (script->functionTemp[0]) {
3731 case 1:
3732 if (script->functionTemp[3] == 0) {
3734 fx_recover(0, x2, y2, z2, hpBoost);
3735 show_start_recovery_shimmer(x1, y1, z1, hpBoost);
3736 script->functionTemp[3] = 30;
3737 script->functionTemp[0] = 2;
3738 } else {
3739 script->functionTemp[3]--;
3740 break;
3741 }
3742 break;
3743 case 2:
3744 if (script->functionTemp[3] == 0) {
3746 btl_cam_move(15);
3747 actor->curHP += hpBoost;
3748 if (actor->maxHP < actor->curHP) {
3749 actor->curHP = actor->maxHP;
3750 }
3751 show_recovery_shimmer(x1, y1, z1, hpBoost);
3752 script->functionTemp[3] = 15;
3753 script->functionTemp[0] = 3;
3754 } else {
3755 script->functionTemp[3]--;
3756 break;
3757 }
3758 break;
3759 case 3:
3760 if (script->functionTemp[3] == 0) {
3761 message = BTL_MSG_HEAL_ALL;
3762 if (!IsGroupHeal) {
3763 message = BTL_MSG_HEAL_ONE;
3764 }
3765 btl_show_variable_battle_message(message, 60, hpBoost);
3766 script->functionTemp[0] = 4;
3767 } else {
3768 script->functionTemp[3]--;
3769 break;
3770 }
3771 break;
3772 case 4:
3773 if (btl_is_popup_displayed() == 0) {
3774 script->functionTemp[3] = 10;
3775 script->functionTemp[0] = 5;
3776 }
3777 break;
3778 case 5:
3779 if (script->functionTemp[3] != 0) {
3780 script->functionTemp[3]--;
3781 break;
3782 }
3783 if ((actor->handleEventScript != NULL) && does_script_exist(actor->handleEventScriptID)) {
3784 break;
3785 }
3786 ApplyingBuff = FALSE;
3787 return ApiStatus_DONE2;
3788 }
3789 return ApiStatus_BLOCK;
3790}
3791
3792API_CALLABLE(WaitForBuffDone) {
3793 if (!ApplyingBuff) {
3794 return ApiStatus_DONE2;
3795 } else {
3796 return ApiStatus_BLOCK;
3797 }
3798}
3799
3800API_CALLABLE(CopyBuffs) {
3801 Bytecode* args = script->ptrReadPos;
3802 s32 actorID = evt_get_variable(script, *args++);
3803 Actor* actorFrom;
3804 Actor* actorTo;
3805
3806 if (actorID == ACTOR_SELF) {
3807 actorID = script->owner1.enemyID;
3808 }
3809 actorFrom = get_actor(actorID);
3810
3811 actorID = evt_get_variable(script, *args++);
3812 if (actorID == ACTOR_SELF) {
3813 actorID = script->owner1.enemyID;
3814 }
3815 actorTo = get_actor(actorID);
3816
3817 actorTo->isGlowing = actorFrom->isGlowing;
3818 actorTo->attackBoost = actorFrom->attackBoost;
3819 actorTo->defenseBoost = actorFrom->defenseBoost;
3820 actorTo->chillOutAmount = actorFrom->chillOutAmount;
3821 actorTo->chillOutTurns = actorFrom->chillOutTurns;
3822
3823 return ApiStatus_DONE2;
3824}
Actor * create_actor(Formation formation)
Definition 190B20.c:1676
void set_actor_home_position(s32 actorID, f32 x, f32 y, f32 z)
Definition actor_api.c:147
s32 count_targets(Actor *actor, s32 targetHomeIndex, s32 targetSelectionFlags)
Definition actor_api.c:8
void set_part_absolute_position(s32 actorID, s32 partID, f32 x, f32 y, f32 z)
Definition actor_api.c:127
void set_part_goal_to_actor_part(ActorPartMovement *movement, s32 actorID, s32 partID)
Definition actor_api.c:83
s32 IsGroupHeal
Definition action_cmd.c:85
void set_actor_current_position(s32 actorID, f32 x, f32 y, f32 z)
Definition actor_api.c:119
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void set_goal_pos_to_part(ActorState *state, s32 actorID, s32 partID)
Definition actor_api.c:44
s32 get_nearest_home_index(f32 x, f32 y, f32 z)
Definition actor_api.c:17
s8 ApplyingBuff
Definition action_cmd.c:86
BattleArea gBattleAreas[]
Definition battle.c:50
Vec2b statusIconOffset
s8 transparentStatus
struct ActorPartMovement * movement
Vec2b statusTextOffset
Vec2b healthBarOffset
struct ActorBlueprint * actorBlueprint
s32 elementalImmunities
s32 actorTypeData1[6]
s8 healthFraction
s8 selectedTargetIndex
Vec3s headOffset
f32 scalingFactor
ActorState state
s32 partTypeData[6]
struct Evt * handleEventScript
struct ActorPart * partsTable
s32 takeTurnScriptID
s16 actorTypeData1b[2]
struct SelectableTarget targetData[24]
Vec3s rotPivotOffset
s16 targetActorID
Vec3f scaleModifier
Vec3s healthBarPos
s8 chillOutAmount
s32 b32
Vec3f homePos
Vec2bu size
s32 handleEventScriptID
ActorMovement fly
Vec3f curPos
s8 targetIndexList[24]
s16 actorTypeData2b[2]
s8 targetListLength
struct ActorPart * nextPart
struct DecorationTable * decorationTable
Vec3s rotPivotOffset
DecorationData decorData[2]
u32 AnimID
Vec3f scale
s8 flags
Definition demo_api.c:15
@ ACTOR_CLASS_ENEMY
Definition enums.h:2079
@ ACTOR_CLASS_PLAYER
Definition enums.h:2077
@ ACTOR_CLASS_PARTNER
Definition enums.h:2078
@ ACTOR_CLASS_MASK
Definition enums.h:2080
@ ACTOR_SOUND_WALK
Definition enums.h:2034
@ ACTOR_SOUND_WALK_INCREMENT
Definition enums.h:2038
@ ACTOR_SOUND_FLY
Definition enums.h:2035
@ ACTOR_SOUND_HURT
Definition enums.h:2037
@ ACTOR_SOUND_FLY_INCREMENT
Definition enums.h:2039
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BTL_MSG_HEAL_ONE
Definition enums.h:4089
@ BTL_MSG_HEAL_ALL
Definition enums.h:4090
@ BTL_MSG_DEFENCE_UP
Definition enums.h:4088
@ BTL_MSG_ATTACK_UP
Definition enums.h:4087
@ BTL_MSG_ENEMY_TRANSPARENT
Definition enums.h:4091
@ BTL_MSG_ENEMY_CHARGED
Definition enums.h:4092
@ ITER_FIRST
Definition enums.h:2024
@ ITER_HAS_MORE
Definition enums.h:2029
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ ITER_LAST
Definition enums.h:2027
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
Definition enums.h:3374
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_KEY_DAZE
Definition enums.h:2209
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_ACTOR_SIMPLE
Definition enums.h:4830
@ BTL_CAM_REPOSITION
Definition enums.h:4841
@ BATTLE_STATE_0
Definition enums.h:3631
@ STATUS_FLAG_FEAR
Definition enums.h:2815
@ STATUS_FLAG_STOP
Definition enums.h:2821
@ STATUS_FLAG_RIGHT_ON
Definition enums.h:2829
@ STATUS_FLAG_FROZEN
Definition enums.h:2814
@ STATUS_FLAG_ATTACK_BOOST
Definition enums.h:2826
@ STATUS_FLAG_DEFENSE_BOOST
Definition enums.h:2827
@ STATUS_FLAG_STATIC
Definition enums.h:2813
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ STATUS_FLAG_PARALYZE
Definition enums.h:2816
@ STATUS_FLAG_STONE
Definition enums.h:2820
@ STATUS_FLAG_KO
Definition enums.h:2823
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ STATUS_FLAG_CHILL_OUT
Definition enums.h:2828
@ STATUS_FLAG_TRANSPARENT
Definition enums.h:2825
@ STATUS_FLAG_SLEEP
Definition enums.h:2812
@ STATUS_FLAG_POISON
Definition enums.h:2817
@ STATUS_FLAG_GLOWING
Definition enums.h:2824
@ ABILITY_RIGHT_ON
Definition enums.h:458
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3299
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ ACTOR_PARTNER
Definition enums.h:2086
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_HALF_HEIGHT
Definition enums.h:3335
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3331
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3342
@ EVENT_RECEIVE_BUFF
Definition enums.h:2178
@ ACTOR_PART_FLAG_HAS_PAL_EFFECT
Definition enums.h:3363
@ ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION
Definition enums.h:3361
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3357
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
void btl_show_variable_battle_message(s32, s32, s32)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
void show_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3)
Definition fx_api.c:8
void reset_all_actor_sounds(Actor *)
Definition 190B20.c:2938
void remove_player_buffs(s32)
Definition 190B20.c:2806
void btl_cam_use_preset_immediately(s32)
Definition camera.c:1912
void hide_actor_health_bar(Actor *)
Definition 190B20.c:2510
void btl_cam_set_zoom(s16)
Definition camera.c:1984
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
Definition evt.c:1977
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
void clear_actor_static_pal_adjustments(Actor *)
Definition 190B20.c:2624
void add_part_decoration(ActorPart *part, s32 decorationIndex, s32 decorationType)
Definition 190B20.c:2727
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
void load_tattle_flags(s32)
Definition 181810.c:571
void set_part_glow_pal(ActorPart *, s32)
Definition 190B20.c:2642
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void btl_cam_disable_clamp_x(void)
Definition camera.c:2006
void create_home_target_list(Actor *actor)
Definition 190B20.c:476
void btl_cam_use_preset(s32)
Definition camera.c:1919
void btl_cam_target_actor(s32)
Definition camera.c:1926
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
void btl_cam_set_zoffset(s16)
Definition camera.c:1996
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
void show_start_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3)
Definition fx_api.c:4
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:1005
void set_actor_anim_rate(s32 actorID, s32 partID, f32 rate)
Definition 190B20.c:1068
void btl_cam_move(s16)
Definition camera.c:1953
void set_part_yaw(s32 actorID, s32 partID, s32 value)
Definition 190B20.c:1095
void set_actor_yaw(s32 actorID, s32 yaw)
Definition 190B20.c:1091
void remove_part_shadow(s32 actorID, s32 partID)
Definition 190B20.c:2793
s32 does_script_exist(s32 id)
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
void set_part_pal_adjustment(ActorPart *, s32)
Definition 190B20.c:2595
void btl_set_state(s32 battleState)
s32 btl_is_popup_displayed(void)
void apply_shock_effect(Actor *)
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472
s32 is_actor_health_bar_visible(Actor *)
Definition 181810.c:503
void remove_part_decoration(ActorPart *part, s32 decorationIndex)
Definition 190B20.c:2750
void create_part_shadow(s32 actorID, s32 partID)
Definition 190B20.c:2785
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define EVT_IGNORE_ARG
Definition macros.h:46
#define ACTOR_API_SKIP_ARG
Definition battle.h:264
s32 walk[2]
Definition battle.h:235
ActorSounds bActorSoundTable[]
void * dmaDest
Definition battle.h:217
s16 delay[2]
Number of frames to wait between walk/fly sounds. Negative values are in distance.
Definition battle.h:239
s32 fly[2]
Definition battle.h:236
Vec2b healthBarOffset
Definition battle.h:149
void * dmaEnd
Definition battle.h:216
void * dmaStart
Definition battle.h:215
struct Actor * partnerActor
struct Actor * playerActor
struct Actor * enemyActors[24]
s32 gBattleState
Definition battle.c:10
BattleStatus gBattleStatus
Definition battle.c:11
Vec3s StandardActorHomePositions[]
Definition actors.c:188