Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
1A5830.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "hud_element.h"
5#include "sprite.h"
6
9 s32 ret = false;
10
11 while (partIt != nullptr) {
13 ret = true;
14 break;
15 } else {
17 }
18 }
19
20 return ret;
21}
22
24 switch (actor->actorID & ACTOR_CLASS_MASK) {
27 break;
30 break;
33 break;
34 }
35}
36
37void play_hit_sound(Actor* actor, f32 x, f32 y, f32 z, u32 hitSound) {
39
40 switch (hitSound) {
41 case HIT_SOUND_MISS:
43 break;
44 case HIT_SOUND_BONES:
46 break;
48 switch (actorClass) {
51 break;
54 break;
57 break;
58 }
59 break;
60 case HIT_SOUND_FIRE:
61 switch (actorClass) {
64 break;
67 break;
70 break;
71 }
72 break;
73 case HIT_SOUND_ICE:
74 switch (actorClass) {
77 break;
80 break;
83 break;
84 }
85 break;
86 case HIT_SOUND_SHOCK:
87 switch (actorClass) {
90 break;
93 break;
96 break;
97 }
98 break;
99 }
100}
101
103 Evt* handleEventScript = actor->handleEventScript;
105
106 if (actor->handleEventSource != nullptr) {
107 Evt* newScript;
108
109 actor->lastEventType = event;
112 actor->handleEventScriptID = newScript->id;
113 newScript->owner1.actorID = actor->actorID;
114 }
115
116 if (actor->takeTurnScript != nullptr) {
119 actor->takeTurnScript = nullptr;
120 }
121
122 if (handleEventScript != nullptr) {
124 }
125}
126
131 s32 targetPartIdx = battleStatus->curTargetPart;
132 Actor* target;
133 Actor* target2;
137
138 battleStatus->curTargetID2 = battleStatus->curTargetID;
139 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
140
142 if (target == nullptr) {
143 return HIT_RESULT_HIT;
144 }
145
147 ASSERT(targetPart != nullptr);
148
150 switch (actorClass) {
152 target->curHP = playerData->curHP;
153 break;
155 target->curHP = 127;
156 break;
158 break;
159 }
160
161 if (battleStatus->curAttackElement & DAMAGE_TYPE_TRIGGER_LUCKY) {
163 return HIT_RESULT_HIT;
164 }
165
167 target2 = target;
168 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY || battleStatus->outtaSightActive || target2->transparentStatus == STATUS_KEY_TRANSPARENT) {
169 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_MAGIC)) {
171 }
172 }
173
174 if (hitResult == HIT_RESULT_MISS) {
175 return HIT_RESULT_MISS;
176 }
178 switch (actorClass) {
180 if (battleStatus->cloudNineTurnsLeft) {
181 if (rand_int(100) < battleStatus->cloudNineDodgeChance) {
183 break;
184 }
185 } else {
187 if (rand_int(100) < 10) {
189 break;
190 }
191 }
193 if (rand_int(100) < 30) {
195 break;
196 }
197 }
199 if (rand_int(100) < 20) {
201 break;
202 }
203 }
204 }
205 break;
207 break;
209 break;
210 }
211
212 if (hitResult == HIT_RESULT_MISS) {
213 return HIT_RESULT_MISS;
214 }
215
217 return HIT_RESULT_LUCKY;
218 }
219
220 if (target2->stoneStatus == STATUS_KEY_STONE) {
221 return HIT_RESULT_IMMUNE;
222 }
223
224 if (target2->staticStatus == STATUS_KEY_STATIC) {
226 }
227
228 return HIT_RESULT_HIT;
229}
230
233 ActorState* state = &attacker->state;
234 s32 targetID = battleStatus->curTargetID;
235 s32 targetPartIdx = battleStatus->curTargetPart;
237 Actor* target;
240 b32 wasSpecialHit = false;
241 b32 statusInflicted = false;
242 b32 isFire = false;
243 b32 isWater = false;
244 b32 isIce = false;
245 b32 isElectric = false;
246 b32 madeElectricContact = false;
248 s32 defense;
249 s32 event;
250 s32 damage;
251 Evt* script;
252
253 battleStatus->wasStatusInflicted = false;
254 battleStatus->lastAttackDamage = 0;
255
256 battleStatus->attackerActorID = attacker->actorID;
257 battleStatus->curTargetID2 = targetID;
258 battleStatus->curTargetPart2 = targetPartIdx;
259
261 if (target == nullptr) {
262 return HIT_RESULT_HIT;
263 }
264
266 ASSERT(targetPart != nullptr);
267
269 target->lastDamageTaken = 0;
270
271 switch (actorClass) {
273 target->curHP = gPlayerData.curHP;
274 break;
276 target->curHP = 127;
277 break;
279 break;
280 }
281
282 // handle defender status
283
284 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY) {
285 return HIT_RESULT_MISS;
286 }
287
288 if (target->transparentStatus == STATUS_KEY_TRANSPARENT
289 || ((targetPart->eventFlags & ACTOR_EVENT_FLAG_BURIED) && !(battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE))
290 ) {
291 return HIT_RESULT_MISS;
292 }
293
294 if (target->stoneStatus == STATUS_KEY_STONE) {
295 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, -1);
296 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 0);
297 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 0);
299 return HIT_RESULT_HIT;
300 }
301
302 // handle attack element
303
304 if (battleStatus->curAttackElement & DAMAGE_TYPE_BLAST) {
305 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
307 ) {
308 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 3);
310 return HIT_RESULT_BACKFIRE;
311 }
312 }
313 if ((battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE) && (target->flags & ACTOR_FLAG_FLYING)) {
314 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 1);
316 }
317 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
318 fx_ring_blast(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
319 isFire = true;
320 }
321 if (battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK) {
323 isElectric = true;
324 }
325 if (battleStatus->curAttackElement & DAMAGE_TYPE_WATER) {
326 fx_water_splash(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
327 isWater = true;
328 }
329 if (battleStatus->curAttackElement & DAMAGE_TYPE_ICE) {
330 fx_big_snowflakes(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f);
331 isIce = true;
332 }
333
334 if (!(attacker->staticStatus == STATUS_KEY_STATIC)
335 && ((target->staticStatus == STATUS_KEY_STATIC) || (targetPart->eventFlags & ACTOR_EVENT_FLAG_ELECTRIFIED))
336 && !(battleStatus->curAttackElement & (DAMAGE_TYPE_SHOCK | DAMAGE_TYPE_NO_CONTACT))
337 && !(battleStatus->curAttackEventSuppression & SUPPRESS_EVENT_SHOCK_CONTACT)
338 && !has_enchanted_part(attacker)) // enchanted attacks ignore electrified defenders
339 {
340 madeElectricContact = true;
342 }
343
344 // ------------------------------------------------------------------------
345 // damage calculation
346
348
349 // determine target defense
350
351 defense = get_defense(target, targetPart->defenseTable, battleStatus->curAttackElement);
352
353 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_IGNORE_DEFENSE)) {
354 defense += target->defenseBoost;
355
357 if (battleStatus->waterBlockTurnsLeft > 0) {
358 if ((battleStatus->curAttackElement & (DAMAGE_TYPE_BLAST | DAMAGE_TYPE_FIRE))) {
359 defense += 2;
360 } else {
361 defense += 1;
362 }
363 }
364
366 defense += 1;
367 }
368 }
369 }
370
371 // apply attacker damage modifiers
372
373 damage = battleStatus->curAttackDamage;
374
375 switch (actorClass) {
377 damage -= battleStatus->merleeDefenseBoost;
378 break;
381 break;
382 }
383
384 damage += attacker->attackBoost;
385
386 if (attacker->chillOutTurns != 0) {
387 damage -= attacker->chillOutAmount;
388 }
389
390 if (attacker->debuff == STATUS_KEY_SHRINK) {
391 if (damage > 0) {
392 damage /= 2;
393 }
394 }
395
396 if (damage > 99) {
397 damage = 99;
398 }
399 if (damage < 1) {
400 defense = 0;
401 }
402
403 target->hpChangeCounter = 0;
404 damage -= defense;
405
406 // apply damage mitigation from defensive badges
407
409 if (isPlayer) {
411 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
412 damage--;
413 }
414 }
415
419
420 if (target->curHP <= 5) {
422 damage /= 2;
423 }
424 }
425 }
426
427 // apply damage mitigation from blocking
428
429 switch (actorClass) {
431 // TODO figure out how to better write target->debuff >= STATUS_KEY_POISON
432 if ((target->debuff == 0 || target->debuff >= STATUS_KEY_POISON)
433 && (target->stoneStatus == 0)
434 && !(battleStatus->curAttackElement & DAMAGE_TYPE_UNBLOCKABLE)
435 ) {
436 s32 blocked;
437
439 blocked = rand_int(1);
440 } else {
441 blocked = check_block_input(BUTTON_A);
442 }
443
444 if (blocked) {
445 damage--;
450 break;
451 }
453 }
454 break;
456 if (target->stoneStatus == 0) {
457 if (target->koStatus == 0 && !(battleStatus->curAttackElement & DAMAGE_TYPE_UNBLOCKABLE)) {
459 damage = 0;
463 break;
464 }
466 }
467 }
468 break;
469 }
470
473 }
474
475 // deal damage and determine resulting battle event
476
477 event = EVENT_HIT_COMBO;
478 if (damage < 1) {
479 target->hpChangeCounter = 0;
480 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS)) {
482 event = EVENT_ZERO_DAMAGE;
483 } else {
485 event = EVENT_ZERO_DAMAGE;
486 if (target->curHP < 1) {
487 event = EVENT_DEATH;
488 }
489 }
490 battleStatus->lastAttackDamage = 0;
491 } else {
492 target->damageCounter += damage;
493 target->hpChangeCounter -= damage;
494 battleStatus->lastAttackDamage = 0;
498 ) {
499 if (!(target->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
500 target->curHP -= damage;
501 }
502
503 if (target->curHP < 1) {
504 target->curHP = 0;
505 event = EVENT_DEATH;
506 }
507 }
508 battleStatus->lastAttackDamage += damage;
509 target->lastDamageTaken = battleStatus->lastAttackDamage;
510 target->hpChangeCounter = 0;
511
513 battleStatus->damageTaken += damage;
514 gPlayerData.curHP = target->curHP;
515 }
516 }
517
519 if (event == EVENT_HIT_COMBO) {
520 event = EVENT_HIT;
521 }
522 if (event == EVENT_ZERO_DAMAGE) {
523 event = EVENT_IMMUNE;
524 }
525 if (target->curHP < 1 && event == EVENT_IMMUNE) {
526 event = EVENT_DEATH;
527 }
528 } else if (event == EVENT_DEATH) {
529 event = EVENT_HIT_COMBO;
530 }
531
534 }
535
538 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_FLIPABLE)
539 ) {
540 if (event == EVENT_HIT) {
541 event = EVENT_FLIP_TRIGGER;
542 }
543 if (event == EVENT_IMMUNE) {
544 event = EVENT_FLIP_TRIGGER;
545 }
546 }
547
550 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_FLIPABLE)
551 ) {
552 if (event == EVENT_HIT_COMBO) {
553 event = EVENT_FLIP_TRIGGER;
554 }
555 if (event == EVENT_ZERO_DAMAGE) {
556 event = EVENT_FLIP_TRIGGER;
557 }
558 }
559
562 ) {
563 if (event == EVENT_HIT) {
564 event = EVENT_BURN_HIT;
565 }
566 if (event == EVENT_DEATH) {
567 event = EVENT_FIRE_DEATH;
568 }
569 isFire = true;
570 }
571
573 if (event == EVENT_HIT_COMBO) {
574 event = EVENT_18;
575 }
576 if (event == EVENT_HIT) {
577 event = EVENT_BLOCK;
578 }
579 if (event == EVENT_ZERO_DAMAGE) {
580 event = EVENT_18;
581 }
582 if (event == EVENT_IMMUNE) {
583 event = EVENT_BLOCK;
584 }
585 if (event == EVENT_BURN_HIT) {
586 event = EVENT_BLOCK;
587 }
588 }
589
590 // try inflicting status effect
591
593 && battleStatus->lastAttackDamage >= 0
594 && event != EVENT_DEATH
600 {
602 statusInflicted = true;
603 wasSpecialHit = true;
604 }
606 statusInflicted = true;
607 wasSpecialHit = true;
608 }
610 statusInflicted = true;
611 wasSpecialHit = true;
612 }
614 statusInflicted = true;
615 wasSpecialHit = true;
616 }
618 statusInflicted = true;
619 wasSpecialHit = true;
620 }
622 statusInflicted = true;
623 wasSpecialHit = true;
624 }
626 statusInflicted = true;
627 wasSpecialHit = true;
628 }
630 statusInflicted = true;
631 wasSpecialHit = true;
632 }
634 statusInflicted = true;
635 wasSpecialHit = true;
636 }
638 statusInflicted = true;
639 wasSpecialHit = true;
640 }
641
642 if (statusInflicted) {
643 if (event == EVENT_ZERO_DAMAGE) {
644 event = EVENT_HIT_COMBO;
645 }
646 if (event == EVENT_IMMUNE) {
647 event = EVENT_HIT;
648 }
649 }
650 }
651
652 // dispatch events and play damage effects
653
654 battleStatus->wasStatusInflicted = statusInflicted;
655
656 switch (actorClass) {
659 break;
662 break;
665 break;
666 }
667
669 && battleStatus->lastAttackDamage > 0
671 && !(target->flags & ACTOR_FLAG_NO_DMG_APPLY))
672 {
674 }
675
676 if (!(target->flags & ACTOR_FLAG_NO_DMG_POPUP)) {
677 switch (actorClass) {
680 if (battleStatus->lastAttackDamage == 0) {
682 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, -3);
683 }
684 } else if (battleStatus->curAttackElement & (DAMAGE_TYPE_MULTIPLE_POPUPS | DAMAGE_TYPE_SMASH)) {
685 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 1);
686 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
687 } else {
688 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 1);
689 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
690 break;
691 }
692 break;
694 if (battleStatus->lastAttackDamage == 0) {
696 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
697 }
698 } else if (battleStatus->curAttackElement & (DAMAGE_TYPE_MULTIPLE_POPUPS | DAMAGE_TYPE_SMASH)) {
699 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
700 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
701 } else {
702 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
703 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
704 }
705 break;
706 }
707 }
708
709 if (battleStatus->lastAttackDamage > 0) {
711
713
714 if (attacker->actorTypeData1[5] != SOUND_NONE) {
715 sfx_play_sound_at_position(attacker->actorTypeData1[5], SOUND_SPACE_DEFAULT, state->goalPos.x, state->goalPos.y, state->goalPos.z);
716 }
717
718 if (isFire) {
720 } else if (!isElectric) {
722 } else {
724 }
725
726 play_hit_sound(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, hitSound);
727 }
728
729 if ((battleStatus->lastAttackDamage < 1 && !wasSpecialHit && !madeElectricContact) || targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE) {
731 }
732
733 if ((battleStatus->curAttackStatus & STATUS_FLAG_SLEEP) && statusInflicted) {
735 script->varTable[0] = state->goalPos.x;
736 script->varTable[1] = state->goalPos.y;
737 script->varTable[2] = state->goalPos.z;
739 }
740 if ((battleStatus->curAttackStatus & STATUS_FLAG_DIZZY) && statusInflicted) {
742 script->varTable[0] = state->goalPos.x;
743 script->varTable[1] = state->goalPos.y;
744 script->varTable[2] = state->goalPos.z;
746 }
747 if ((battleStatus->curAttackStatus & STATUS_FLAG_PARALYZE) && statusInflicted) {
749 script->varTable[0] = state->goalPos.x;
750 script->varTable[1] = state->goalPos.y;
751 script->varTable[2] = state->goalPos.z;
753 }
754 if ((battleStatus->curAttackStatus & STATUS_FLAG_POISON) && statusInflicted) {
756 script->varTable[0] = state->goalPos.x;
757 script->varTable[1] = state->goalPos.y;
758 script->varTable[2] = state->goalPos.z;
760 }
761 if ((battleStatus->curAttackStatus & STATUS_FLAG_STOP) && statusInflicted) {
763 script->varTable[0] = state->goalPos.x;
764 script->varTable[1] = state->goalPos.y;
765 script->varTable[2] = state->goalPos.z;
767 }
768 if ((battleStatus->curAttackStatus & STATUS_FLAG_FROZEN) && statusInflicted) {
770 script->varTable[0] = state->goalPos.x;
771 script->varTable[1] = state->goalPos.y;
772 script->varTable[2] = state->goalPos.z;
773 script->varTablePtr[3] = target;
775 }
776 if ((battleStatus->curAttackStatus & STATUS_FLAG_SHRINK) && statusInflicted) {
778 script->varTable[0] = state->goalPos.x;
779 script->varTable[1] = state->goalPos.y;
780 script->varTable[2] = state->goalPos.z;
781 script->varTablePtr[3] = target;
783 }
784
785 if ((battleStatus->curAttackElement & DAMAGE_TYPE_SMASH) && target->actorType == ACTOR_TYPE_GOOMNUT_TREE) {
787 }
788
790
791 if (attacker->staticStatus != STATUS_KEY_STATIC
792 && (target->staticStatus == STATUS_KEY_STATIC || targetPart->eventFlags & ACTOR_EVENT_FLAG_ELECTRIFIED)
793 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
794 && !(battleStatus->curAttackEventSuppression & SUPPRESS_EVENT_SHOCK_CONTACT)
795 && (attacker->transparentStatus != STATUS_KEY_TRANSPARENT)
797 {
801 return HIT_RESULT_BACKFIRE;
802 }
803
804 return hitResult;
805}
806
809 ActorState* state = &actor->state;
812 s32 new_var;
813
814 battleStatus->curAttackDamage = damageAmount;
816 actor->hpChangeCounter += hpChange;
817 new_var = actor->hpChangeCounter;
819 actor->damageCounter += hpChange;
820 actor->hpChangeCounter -= hpChange;
821 battleStatus->lastAttackDamage = 0;
822 actor->curHP -= hpChange;
823
824 if (actor->curHP <= 0) {
826 battleStatus->lastAttackDamage += actor->curHP;
827 actor->curHP = 0;
828 }
829
830 battleStatus->lastAttackDamage += hpChange;
831 actor->lastDamageTaken = battleStatus->lastAttackDamage;
832 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
836 }
839 }
840 }
841 if (dispatchEvent == EVENT_DEATH) {
844 }
847 }
848 }
849
850 if (!stopMotion) {
852
853 if (func_80263230(actor, actor) != 0) {
854 show_next_damage_popup(actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage, 0);
855 show_damage_fx(actor, actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage);
856 }
858
859 } else {
860 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
861 show_damage_fx(actor, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
862 }
863
864 if (battleStatus->lastAttackDamage > 0) {
865 set_actor_flash_mode(actor, 1);
866 }
869 return 0;
870}
871
875
879
880API_CALLABLE(BindTakeTurn) {
881 Bytecode* args = script->ptrReadPos;
882 s32 actorID = evt_get_variable(script, *args++);
883 EvtScript* takeTurnScript;
884
885 if (actorID == ACTOR_SELF) {
886 actorID = script->owner1.actorID;
887 }
888
889 takeTurnScript = (EvtScript*) evt_get_variable(script, *args++);
890 get_actor(actorID)->takeTurnSource = takeTurnScript;
891 return ApiStatus_DONE2;
892}
893
894API_CALLABLE(PauseTakeTurn) {
895 Bytecode* args = script->ptrReadPos;
896 s32 actorID = evt_get_variable(script, *args++);
897
898 if (actorID == ACTOR_SELF) {
899 actorID = script->owner1.actorID;
900 }
901
902 evt_get_variable(script, *args++);
903 suspend_all_script(get_actor(actorID)->takeTurnScriptID);
904 return ApiStatus_DONE2;
905}
906
907API_CALLABLE(ResumeTakeTurn) {
908 Bytecode* args = script->ptrReadPos;
909 s32 actorID = evt_get_variable(script, *args++);
910
911 if (actorID == ACTOR_SELF) {
912 actorID = script->owner1.actorID;
913 }
914
915 evt_get_variable(script, *args++);
916 resume_all_script(get_actor(actorID)->takeTurnScriptID);
917 return ApiStatus_DONE2;
918}
919
920API_CALLABLE(BindIdle) {
921 Bytecode* args = script->ptrReadPos;
922 s32 actorID = evt_get_variable(script, *args++);
924 Actor* actor;
926
927 if (actorID == ACTOR_SELF) {
928 actorID = script->owner1.actorID;
929 }
930
932 actor = get_actor(actorID);
933
934 if (actor->idleScript != 0) {
936 actor->idleScript = 0;
937 }
938
939 actor->idleSource = idleCode;
942 actor->idleScriptID = newScriptContext->id;
943 newScriptContext->owner1.actorID = actorID;
944 return ApiStatus_DONE2;
945}
946
947API_CALLABLE(EnableIdleScript) {
948 Bytecode* args = script->ptrReadPos;
949 s32 actorID = evt_get_variable(script, *args++);
950 s32 var1;
951 Actor* actor;
952
953 if (actorID == ACTOR_SELF) {
954 actorID = script->owner1.actorID;
955 }
956
957 var1 = evt_get_variable(script, *args++);
958 actor = get_actor(actorID);
959
960 if (actor->idleScript != nullptr) {
961 switch (var1) {
965 break;
968 break;
971 break;
972 }
973 }
974
975 return ApiStatus_DONE2;
976}
977
978API_CALLABLE(BindHandleEvent) {
979 Bytecode* args = script->ptrReadPos;
980 s32 actorID = evt_get_variable(script, *args++);
981 EvtScript* src;
982
983 if (actorID == ACTOR_SELF) {
984 actorID = script->owner1.actorID;
985 }
986
987 src = (EvtScript*) evt_get_variable(script, *args++);
988 get_actor(actorID)->handleEventSource = src;
989 return ApiStatus_DONE2;
990}
991
992API_CALLABLE(BindHandlePhase) {
993 Bytecode* args = script->ptrReadPos;
994 s32 actorID = evt_get_variable(script, *args++);
995 EvtScript* src;
996
997 if (actorID == ACTOR_SELF) {
998 actorID = script->owner1.actorID;
999 }
1000
1001 src = (EvtScript*) evt_get_variable(script, *args++);
1002 get_actor(actorID)->handlePhaseSource = src;
1003 return ApiStatus_DONE2;
1004}
1005
1006API_CALLABLE(JumpToGoal) {
1007 Bytecode* args = script->ptrReadPos;
1008 Actor* actor;
1010 s32 actorID;
1011 f32 posX, posY, posZ;
1012 f32 goalX, goalY, goalZ;
1013 f32 moveDist;
1014
1015 if (isInitialCall) {
1016 script->functionTemp[0] = 0;
1017 }
1018
1019 if (script->functionTemp[0] == 0) {
1020 actorID = evt_get_variable(script, *args++);
1021 if (actorID == ACTOR_SELF) {
1022 actorID = script->owner1.enemyID;
1023 }
1024 script->functionTempPtr[1] = actor = get_actor(actorID);
1025 actorState = &actor->state;
1027 script->functionTemp[2] = evt_get_variable(script, *args++);
1028 script->functionTemp[3] = 0;
1029 if (evt_get_variable(script, *args++) != 0) {
1030 script->functionTemp[3] |= 1;
1031 }
1032 if (evt_get_variable(script, *args++) != 0) {
1033 script->functionTemp[3] |= 2;
1034 }
1035
1036 actorState->curPos.x = actor->curPos.x;
1037 actorState->curPos.y = actor->curPos.y;
1038 actorState->curPos.z = actor->curPos.z;
1039
1040 posX = actorState->curPos.x;
1041 posY = actorState->curPos.y;
1042 posZ = actorState->curPos.z;
1043 goalX = actorState->goalPos.x;
1044 goalY = actorState->goalPos.y;
1045 goalZ = actorState->goalPos.z;
1046 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1047 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1048
1049 // make relative
1050 posX = (goalX - posX);
1051 posY = (goalY - posY);
1052 posZ = (goalZ - posZ);
1053
1054 if (actorState->moveTime == 0) {
1055 actorState->moveTime = actorState->dist / actorState->speed;
1056 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1057 } else {
1058 actorState->speed = actorState->dist / actorState->moveTime;
1059 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1060 }
1061
1062 if (actorState->moveTime == 0) {
1063 return ApiStatus_DONE2;
1064 }
1065
1066 actorState->vel = (actorState->acceleration * actorState->moveTime * 0.5f) + (posY / actorState->moveTime);
1067 actorState->speed += (moveDist / actorState->moveTime);
1068
1069 if (script->functionTemp[2] != 0) {
1070 set_actor_anim(actor->actorID, (s8) actor->state.jumpPartIndex, actor->state.animJumpRise);
1071 }
1072 if (!(script->functionTemp[3] & 2) && (actor->actorTypeData1[4] != 0)) {
1074 }
1075 script->functionTemp[0] = 1;
1076 }
1077
1078 actor = script->functionTempPtr[1];
1079 actorState = &actor->state;
1080
1081 actorState->curPos.y += actorState->vel;
1082 actorState->vel -= actorState->acceleration;
1083
1084 if ((script->functionTemp[2] != 0) && (actorState->vel < 0.0f)) {
1085 set_actor_anim(actor->actorID, (s8) actorState->jumpPartIndex, actorState->animJumpFall);
1086 }
1087 if (actorState->vel < 0.0f) {
1088 if (actorState->curPos.y < actorState->goalPos.y) {
1089 actorState->curPos.y = actorState->goalPos.y;
1090 }
1091 }
1092
1093 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1094 actor->curPos.x = actorState->curPos.x;
1095 actor->curPos.y = actorState->curPos.y;
1096 actor->curPos.z = actorState->curPos.z;
1097
1098 actorState->moveTime--;
1099 if (actorState->moveTime > 0) {
1100 return ApiStatus_BLOCK;
1101 }
1102
1103 if (script->functionTemp[3] & 1) {
1104 play_movement_dust_effects(2, actorState->goalPos.x, actorState->goalPos.y, actorState->goalPos.z, actorState->angle);
1105 }
1106 actor->curPos.x = actorState->goalPos.x;
1107 actor->curPos.y = actorState->goalPos.y;
1108 actor->curPos.z = actorState->goalPos.z;
1109 if (script->functionTemp[2] != 0) {
1110 set_actor_anim(actor->actorID, (s8) actorState->jumpPartIndex, actorState->animJumpLand);
1111 }
1112 return ApiStatus_DONE1;
1113}
1114
1115API_CALLABLE(IdleJumpToGoal) {
1116 Bytecode* args = script->ptrReadPos;
1117 Actor* actor;
1118 ActorMovement* movement;
1119 f32 posX, posY, posZ;
1120 f32 goalX, goalY, goalZ;
1121 f32 moveDist;
1122
1123 if (isInitialCall) {
1124 script->functionTemp[0] = false;
1125 }
1126
1127 if (!script->functionTemp[0]) {
1128 s32 actorID = evt_get_variable(script, *args++);
1129
1130 if (actorID == ACTOR_SELF) {
1131 actorID = script->owner1.actorID;
1132 }
1133
1134 script->functionTempPtr[1] = actor = get_actor(actorID);
1135 movement = &actor->fly;
1136
1137 actor->fly.flyTime = evt_get_variable(script, *args++);
1138 script->functionTemp[2] = evt_get_variable(script, *args++);
1139 script->functionTemp[3] = evt_get_variable(script, *args++);
1140
1141 movement->curPos.x = actor->curPos.x;
1142 movement->curPos.y = actor->curPos.y;
1143 movement->curPos.z = actor->curPos.z;
1144
1145 posX = movement->curPos.x;
1146 posY = movement->curPos.y;
1147 posZ = movement->curPos.z;
1148 goalX = movement->goalPos.x;
1149 goalY = movement->goalPos.y;
1150 goalZ = movement->goalPos.z;
1151 movement->angle = atan2(posX, posZ, goalX, goalZ);
1152 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1153
1154 // make relative
1155 posX = (goalX - posX);
1156 posY = (goalY - posY);
1157 posZ = (goalZ - posZ);
1158
1159 if (movement->flyTime == 0) {
1160 movement->flyTime = movement->dist / movement->speed;
1161 moveDist = movement->dist - (movement->flyTime * movement->speed);
1162 } else {
1163 movement->speed = movement->dist / movement->flyTime;
1164 moveDist = movement->dist - (movement->flyTime * movement->speed);
1165 }
1166
1167 if (movement->flyTime == 0) {
1168 return ApiStatus_DONE2;
1169 }
1170
1171 movement->vel = (movement->acceleration * movement->flyTime * 0.5f) + (posY / movement->flyTime);
1172 movement->speed += moveDist / movement->flyTime;
1173 script->functionTemp[0] = true;
1174 }
1175
1176 actor = script->functionTempPtr[1];
1177 movement = &actor->fly;
1178
1179 movement->curPos.y += movement->vel;
1180 movement->vel -= movement->acceleration;
1181 if (movement->vel < 0.0f && movement->goalPos.y > movement->curPos.y) {
1182 movement->curPos.y = movement->goalPos.y;
1183 }
1184 add_xz_vec3f_copy2(&movement->curPos, movement->speed, movement->angle);
1185 actor->curPos.x = movement->curPos.x;
1186 actor->curPos.y = movement->curPos.y;
1187 actor->curPos.z = movement->curPos.z;
1188
1189 movement->flyTime--;
1190 if (movement->flyTime <= 0) {
1191 if (script->functionTemp[3] != 0) {
1192 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1193 }
1194 actor->curPos.x = movement->goalPos.x;
1195 actor->curPos.y = movement->goalPos.y;
1196 actor->curPos.z = movement->goalPos.z;
1197 return ApiStatus_DONE1;
1198 }
1199
1200 return ApiStatus_BLOCK;
1201}
1202
1203API_CALLABLE(JumpToGoalSimple2) {
1204 Bytecode* args = script->ptrReadPos;
1205 ActorState* state;
1206 f32 posX, posY, posZ;
1207 f32 goalX, goalY, goalZ;
1208 f32 moveDist;
1209 Actor* actor;
1210
1211 if (isInitialCall) {
1212 script->functionTemp[0] = false;
1213 }
1214
1215 if (!script->functionTemp[0]) {
1216 s32 actorID = evt_get_variable(script, *args++);
1217
1218 if (actorID == ACTOR_SELF) {
1219 actorID = script->owner1.actorID;
1220 }
1221
1222 script->functionTempPtr[1] = actor = get_actor(actorID);
1223 state = &actor->state;
1224
1225 state->moveTime = evt_get_variable(script, *args++);
1226 state->curPos.x = actor->curPos.x;
1227 state->curPos.y = actor->curPos.y;
1228 state->curPos.z = actor->curPos.z;
1229
1230 posX = state->curPos.x;
1231 posY = state->curPos.y;
1232 posZ = state->curPos.z;
1233 goalX = state->goalPos.x;
1234 goalY = state->goalPos.y;
1235 goalZ = state->goalPos.z;
1236 state->angle = atan2(posX, posZ, goalX, goalZ);
1237 state->dist = dist2D(posX, posZ, goalX, goalZ);
1238
1239 // make relative (note: negated)
1240 posX = (posX - goalX);
1241 posY = (posY - goalY);
1242 posZ = (posZ - goalZ);
1243
1244 if (state->moveTime == 0) {
1245 state->moveTime = state->dist / state->speed;
1246 moveDist = state->dist - (state->moveTime * state->speed);
1247 } else {
1248 state->speed = state->dist / state->moveTime;
1249 moveDist = state->dist - (state->moveTime * state->speed);
1250 }
1251
1252 if (state->moveTime == 0) {
1253 return ApiStatus_DONE2;
1254 }
1255
1256 state->vel = ((state->acceleration * state->moveTime) * 0.5f) + (posY / state->moveTime);
1257 state->speed += moveDist / state->moveTime;
1258 if (actor->actorTypeData1[4] != 0) {
1260 }
1261 script->functionTemp[0] = true;
1262 }
1263
1264 actor = script->functionTempPtr[1];
1265 state = &actor->state;
1266
1267 state->curPos.y -= state->vel;
1268 state->vel -= state->acceleration;
1269 if (state->vel > 0.0f && state->goalPos.y < state->curPos.y) {
1270 state->curPos.y = state->goalPos.y;
1271 }
1272 add_xz_vec3f(&state->curPos, state->speed, state->angle);
1273 actor->curPos.x = state->curPos.x;
1274 actor->curPos.y = state->curPos.y;
1275 actor->curPos.z = state->curPos.z;
1276
1277 state->moveTime--;
1278 if (state->moveTime <= 0) {
1279 play_movement_dust_effects(2, state->goalPos.x, state->goalPos.y, state->goalPos.z, state->angle);
1280 actor->curPos.x = state->goalPos.x;
1281 actor->curPos.y = state->goalPos.y;
1282 actor->curPos.z = state->goalPos.z;
1283 return ApiStatus_DONE1;
1284 }
1285
1286 return ApiStatus_BLOCK;
1287}
1288
1289API_CALLABLE(JumpWithBounce) {
1290 Bytecode* args = script->ptrReadPos;
1291 Actor* actor;
1293 s32 actorID;
1294 f32 posX, posY, posZ;
1295 f32 goalX, goalY, goalZ;
1296 f32 moveDist;
1297
1298 if (isInitialCall) {
1299 script->functionTemp[0] = false;
1300 }
1301
1302 if (!script->functionTemp[0]) {
1303 actorID = evt_get_variable(script, *args++);
1304 if (actorID == ACTOR_SELF) {
1305 actorID = script->owner1.enemyID;
1306 }
1307 script->functionTempPtr[1] = actor = get_actor(actorID);
1308 actorState = &actor->state;
1309
1311 actorState->bounceDivisor = evt_get_float_variable(script, *args++);
1312
1313 actorState->curPos.x = actor->curPos.x;
1314 actorState->curPos.y = actor->curPos.y;
1315 actorState->curPos.z = actor->curPos.z;
1316
1317 posX = actorState->curPos.x;
1318 posY = actorState->curPos.y;
1319 posZ = actorState->curPos.z;
1320 goalX = actorState->goalPos.x;
1321 goalZ = actorState->goalPos.z;
1322 goalY = actorState->goalPos.y;
1323 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1324 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1325
1326 // make relative
1327 posX = (goalX - posX);
1328 posY = (goalY - posY);
1329 posZ = (goalZ - posZ);
1330
1331 if (actorState->moveTime == 0) {
1332 actorState->moveTime = (s32) (actorState->dist / actorState->speed);
1333 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1334 } else {
1335 actorState->speed = actorState->dist / actorState->moveTime;
1336 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1337 }
1338
1339 if (actorState->moveTime == 0) {
1340 return ApiStatus_DONE2;
1341 }
1342
1343 actorState->vel = (actorState->acceleration * actorState->moveTime * 0.5f) + (posY / actorState->moveTime);
1344 actorState->speed += moveDist / actorState->moveTime;
1345
1346 if (actor->actorTypeData1[4] != 0) {
1348 }
1349 script->functionTemp[0] = true;
1350 }
1351
1352 actor = script->functionTempPtr[1];
1353 actorState = &actor->state;
1354
1355 switch (script->functionTemp[0]) {
1356 case 1:
1357 actorState->curPos.y += actorState->vel;
1358 actorState->vel -= actorState->acceleration;
1359 if ((actorState->vel < 0.0f) && (actorState->curPos.y < actorState->goalPos.y)) {
1360 actorState->acceleration = -actorState->acceleration;
1361 actorState->vel /= actorState->bounceDivisor;
1362 script->functionTemp[0] = 2;
1363 }
1364 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1365 break;
1366 case 2:
1367 actorState->curPos.y += actorState->vel;
1368 actorState->vel -= actorState->acceleration;
1369 if (actorState->vel > 0.0f) {
1370 if (actorState->goalPos.y < actorState->curPos.y) {
1371 actorState->curPos.y = actorState->goalPos.y;
1372 script->functionTemp[0] = 3;
1373 }
1374 }
1375 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1376 actor->curPos.x = actorState->curPos.x;
1377 actor->curPos.y = actorState->curPos.y;
1378 actor->curPos.z = actorState->curPos.z;
1379 break;
1380
1381 case 3:
1382 return ApiStatus_DONE2;
1383 }
1384
1385 actor->curPos.x = actorState->curPos.x;
1386 actor->curPos.y = actorState->curPos.y;
1387 actor->curPos.z = actorState->curPos.z;
1388 return ApiStatus_BLOCK;
1389}
1390
1391API_CALLABLE(LandJump) {
1392 Bytecode* args = script->ptrReadPos;
1393 Actor* actor;
1394
1395 if (isInitialCall) {
1396 script->functionTemp[0] = false;
1397 }
1398
1399 if (!script->functionTemp[0]) {
1400 s32 actorID = evt_get_variable(script, *args++);
1401
1402 if (actorID == ACTOR_SELF) {
1403 actorID = script->owner1.actorID;
1404 }
1405
1406 actor = get_actor(actorID);
1407 script->functionTempPtr[1] = actor;
1408 actor->state.curPos.x = actor->curPos.x;
1409 actor->state.curPos.y = actor->curPos.y;
1410 actor->state.curPos.z = actor->curPos.z;
1411 script->functionTemp[0] = true;
1412 }
1413
1414 actor = script->functionTempPtr[1];
1415 actor->state.curPos.y += actor->state.vel;
1416 actor->state.vel -= actor->state.acceleration;
1417
1418 add_xz_vec3f(&actor->state.curPos, actor->state.speed, actor->state.angle);
1419 actor->curPos.x = actor->state.curPos.x;
1420 actor->curPos.y = actor->state.curPos.y;
1421 actor->curPos.z = actor->state.curPos.z;
1422
1423 if (actor->curPos.y < 0.0f) {
1424 actor->curPos.y = 0.0f;
1425 play_movement_dust_effects(2, actor->curPos.x, actor->curPos.y, actor->curPos.z, actor->yaw);
1426 return ApiStatus_DONE1;
1427 }
1428
1429 return ApiStatus_BLOCK;
1430}
1431
1432API_CALLABLE(FallToGoal) {
1433 Bytecode* args = script->ptrReadPos;
1434 Actor* actor;
1435 ActorState* state;
1436 f32 posX, posY, posZ;
1437 f32 goalX, goalY, goalZ;
1438
1439 if (isInitialCall) {
1440 script->functionTemp[0] = 0;
1441 }
1442
1443 if (script->functionTemp[0] == 0) {
1444 s32 actorID = evt_get_variable(script, *args++);
1445
1446 if (actorID == ACTOR_SELF) {
1447 actorID = script->owner1.enemyID;
1448 }
1449 actor = get_actor(actorID);
1450 state = &actor->state;
1451 script->functionTempPtr[1] = actor;
1452
1453 actor->state.moveTime = evt_get_variable(script, *args++);
1454
1455 actor->state.curPos.x = actor->curPos.x;
1456 actor->state.curPos.y = actor->curPos.y;
1457 actor->state.curPos.z = actor->curPos.z;
1458
1459 posX = actor->state.curPos.x;
1460 posY = actor->state.curPos.y;
1461 posZ = actor->state.curPos.z;
1462 goalX = actor->state.goalPos.x;
1463 goalY = actor->state.goalPos.y;
1464 goalZ = actor->state.goalPos.z;
1465
1466 actor->state.angle = atan2(posX, posZ, goalX, goalZ);
1467 actor->state.dist = dist2D(posX, posZ, goalX, goalZ);
1468
1469 // make relative
1470 posX = (goalX - posX);
1471 posY = (goalY - posY);
1472 posZ = (goalZ - posZ);
1473
1474 if (actor->state.moveTime == 0) {
1475 actor->state.moveTime = actor->state.dist / actor->state.speed;
1476 } else {
1477 actor->state.speed = actor->state.dist / actor->state.moveTime;
1478 }
1479
1480 state->vel = 0.0f;
1481 state->acceleration = (posY / state->moveTime - state->vel) / (-state->moveTime * 0.5);
1482
1483 if (actor->actorTypeData1[4] != 0) {
1485 }
1486 script->functionTemp[0] = 1;
1487 }
1488
1489 actor = script->functionTempPtr[1];
1490 actor->state.curPos.y += actor->state.vel;
1491 actor->state.vel -= actor->state.acceleration;
1492 add_xz_vec3f(&actor->state.curPos, actor->state.speed, actor->state.angle);
1493 actor->curPos.x = actor->state.curPos.x;
1494 actor->curPos.y = actor->state.curPos.y;
1495 actor->curPos.z = actor->state.curPos.z;
1496 actor->state.moveTime--;
1497
1498 if (actor->state.moveTime <= 0) {
1499 play_movement_dust_effects(2, actor->state.goalPos.x, actor->state.goalPos.y, actor->state.goalPos.z, actor->state.angle);
1500 actor->curPos.x = actor->state.goalPos.x;
1501 actor->curPos.y = actor->state.goalPos.y;
1502 actor->curPos.z = actor->state.goalPos.z;
1503 return ApiStatus_DONE1;
1504 } else {
1505 return ApiStatus_BLOCK;
1506 }
1507}
1508
1509API_CALLABLE(RunToGoal) {
1510 Bytecode* args = script->ptrReadPos;
1511 Actor* actor;
1513 s32 actorID;
1514 f32 posX, posY, posZ;
1515 f32 goalX, goalY, goalZ;
1516
1517 if (isInitialCall) {
1518 script->functionTemp[0] = false;
1519 }
1520
1521 if (!script->functionTemp[0]) {
1522 actorID = evt_get_variable(script, *args++);
1523 if (actorID == ACTOR_SELF) {
1524 actorID = script->owner1.enemyID;
1525 }
1526 script->functionTempPtr[1] = actor = get_actor(actorID);
1527 actorState = &actor->state;
1528
1530 script->functionTemp[2] = evt_get_variable(script, *args++);
1531
1532 actorState->curPos.x = actor->curPos.x;
1533 actorState->curPos.y = actor->curPos.y;
1534 actorState->curPos.z = actor->curPos.z;
1535
1536 goalX = actorState->goalPos.x;
1537 goalY = actorState->goalPos.y;
1538 goalZ = actorState->goalPos.z;
1539 posX = actorState->curPos.x;
1540 posY = actorState->curPos.y;
1541 posZ = actorState->curPos.z;
1542
1543 actorState->unk_18.x = goalX;
1544 actorState->unk_18.y = goalY;
1545 actorState->unk_18.z = goalZ;
1546
1547 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1548 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1549
1550 if (actorState->moveTime == 0) {
1551 actorState->moveTime = actorState->dist / actorState->speed;
1552 if (actorState->moveTime == 0) {
1553 actorState->moveTime = 1;
1554 }
1555 actorState->speed += (actorState->dist - (actorState->moveTime * actorState->speed)) / actorState->moveTime;
1556 } else {
1557 actorState->speed = actorState->dist / actorState->moveTime;
1558 }
1559
1560 if (actor->actorTypeData1b[0] >= 0) {
1561 actorState->dist = actor->actorTypeData1b[0] + 1;
1562 } else {
1563 actorState->dist = -(actor->actorTypeData1b[0] + 1);
1564 }
1565 if ((actor->actorTypeData1[0] != 0) && (actor->actorTypeData1[1] == 0)) {
1567 }
1568 script->functionTemp[0] = true;
1569 }
1570
1571 actor = script->functionTempPtr[1];
1572 actorState = &actor->state;
1573
1574 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1575 if (script->functionTemp[2] == 0) {
1576 if (actorState->speed < 4.0f) {
1577 play_movement_dust_effects(0, actorState->curPos.x, actorState->curPos.y, actorState->curPos.z, actorState->angle);
1578 } else {
1579 play_movement_dust_effects(1, actorState->curPos.x, actorState->curPos.y, actorState->curPos.z, actorState->angle);
1580 }
1581 }
1582 actor->curPos.x = actorState->curPos.x;
1583 actor->curPos.z = actorState->curPos.z;
1584
1585 if ((actor->actorTypeData1[0] != 0) && (actor->actorTypeData1[1] != 0)) {
1586 if (actor->actorTypeData1b[0] >= 0) {
1587 actorState->dist += actorState->speed;
1588 if (actor->actorTypeData1b[0] < actorState->dist) {
1589 actor->footStepCounter++;
1590 actorState->dist = 0.0f;
1591 if (actor->footStepCounter & 1) {
1592 if (actor->actorTypeData1[0] != 0) {
1594 }
1595 } else {
1596 if (actor->actorTypeData1[1] != 0) {
1598 }
1599 }
1600 }
1601 } else {
1602 actorState->dist += 1.0f;
1603 if (-actor->actorTypeData1b[0] <= actorState->dist) {
1604 actor->footStepCounter++;
1605 actorState->dist = 0.0f;
1606 if (actor->footStepCounter & 1) {
1607 if (actor->actorTypeData1[0] != 0) {
1609 }
1610 } else {
1611 if (actor->actorTypeData1[1] != 0) {
1613 }
1614 }
1615 }
1616 }
1617 }
1618
1619 actorState->moveTime--;
1620 if (actorState->moveTime > 0) {
1621 return ApiStatus_BLOCK;
1622 }
1623
1624 actor->curPos.x = actorState->unk_18.x;
1625 actor->curPos.z = actorState->unk_18.z;
1626 if (actor->actorTypeData1[0] != 0) {
1627 if (actor->actorTypeData1[1] == 0) {
1628 snd_stop_sound(actor->actorTypeData1[0]);
1629 }
1630 }
1631 return ApiStatus_DONE1;
1632}
1633
1634API_CALLABLE(IdleRunToGoal) {
1635 Bytecode* args = script->ptrReadPos;
1636 Actor* actor;
1637 ActorMovement* movement;
1638 f32 posX, posY, posZ;
1639 f32 goalX, goalY, goalZ;
1640 s32 actorID;
1641
1642 if (isInitialCall) {
1643 script->functionTemp[0] = false;
1644 }
1645
1646 if (!script->functionTemp[0]) {
1647 actorID = evt_get_variable(script, *args++);
1648 if (actorID == ACTOR_SELF) {
1649 actorID = script->owner1.actorID;
1650 }
1651 script->functionTempPtr[1] = actor = get_actor(actorID);
1652 movement = &actor->fly;
1653
1654 movement->flyTime = evt_get_variable(script, *args++);
1655
1656 movement->curPos.x = actor->curPos.x;
1657 movement->curPos.y = actor->curPos.y;
1658 movement->curPos.z = actor->curPos.z;
1659
1660 goalX = movement->goalPos.x;
1661 goalY = movement->goalPos.y;
1662 goalZ = movement->goalPos.z;
1663
1664 posX = movement->curPos.x;
1665 posY = movement->curPos.y;
1666 posZ = movement->curPos.z;
1667
1668 movement->unk_18.x = goalX;
1669 movement->unk_18.y = goalY;
1670 movement->unk_18.z = goalZ;
1671
1672 movement->angle = atan2(posX, posZ, goalX, goalZ);
1673 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1674
1675 if (movement->flyTime == 0) {
1676 movement->flyTime = movement->dist / movement->speed;
1677 if (movement->flyTime == 0) {
1678 movement->flyTime = 1;
1679 }
1680 // this simplifies to: flyMotion->speed = flyMotion->distance / flyMotion->flyTime
1681 movement->speed += (movement->dist - movement->flyTime * movement->speed) / movement->flyTime;
1682 } else {
1683 movement->speed = movement->dist / movement->flyTime;
1684 }
1685
1686 if (actor->actorTypeData1b[0] >= 0) {
1687 movement->dist = actor->actorTypeData1b[0] + 1;
1688 } else {
1689 movement->dist = -(actor->actorTypeData1b[0] + 1);
1690 }
1691 script->functionTemp[0] = true;
1692 }
1693
1694 actor = script->functionTempPtr[1];
1695 movement = &actor->fly;
1696
1697 add_xz_vec3f_copy2(&movement->curPos, movement->speed, movement->angle);
1698 if (movement->speed < 4.0f) {
1699 play_movement_dust_effects(0, movement->curPos.x, movement->curPos.y, movement->curPos.z, movement->angle);
1700 } else {
1701 play_movement_dust_effects(1, movement->curPos.x, movement->curPos.y, movement->curPos.z, movement->angle);
1702 }
1703 actor->curPos.x = movement->curPos.x;
1704 actor->curPos.z = movement->curPos.z;
1705
1706 movement->flyTime--;
1707 if (movement->flyTime > 0) {
1708 return ApiStatus_BLOCK;
1709 }
1710
1711 actor->curPos.x = movement->unk_18.x;
1712 actor->curPos.z = movement->unk_18.z;
1713 if (actor->actorTypeData1[0] != 0 && actor->actorTypeData1[1] == 0) {
1714 snd_stop_sound(actor->actorTypeData1[0]);
1715 }
1716 return ApiStatus_DONE1;
1717}
1718
1719API_CALLABLE(JumpPartTo) {
1720 Bytecode* args = script->ptrReadPos;
1721 Actor* actor;
1722 ActorPart* part;
1723 ActorPartMovement* movement;
1724 s32 actorID, partID;
1725 f32 posX, posY, posZ;
1726 f32 goalX, goalY, goalZ;
1727 f32 deltaDist;
1728
1729 if (isInitialCall) {
1730 script->functionTemp[0] = 0;
1731 }
1732
1733 if (script->functionTemp[0] == 0) {
1734 actorID = evt_get_variable(script, *args++);
1735 if (actorID == ACTOR_SELF) {
1736 actorID = script->owner1.actorID;
1737 }
1738 partID = evt_get_variable(script, *args++);
1739
1740 actor = get_actor(actorID);
1741 part = get_actor_part(actor, partID);
1742 script->functionTempPtr[1] = actor;
1743 script->functionTempPtr[2] = part;
1744 movement = part->movement;
1745
1746 posX = evt_get_variable(script, *args++);
1747 posY = evt_get_variable(script, *args++);
1748 posZ = evt_get_variable(script, *args++);
1749 movement->goalPos.x = posX;
1750 movement->goalPos.y = posY;
1751 movement->goalPos.z = posZ;
1752 movement->moveTime = evt_get_variable(script, *args++);
1753 script->functionTemp[3] = evt_get_variable(script, *args++);
1754
1755 goalX = movement->goalPos.x;
1756 goalY = movement->goalPos.y;
1757 goalZ = movement->goalPos.z;
1758
1759 movement->absolutePos.x = part->absolutePos.x;
1760 movement->absolutePos.y = part->absolutePos.y;
1761 movement->absolutePos.z = part->absolutePos.z;
1762
1763 posX = movement->absolutePos.x;
1764 posY = movement->absolutePos.y;
1765 posZ = movement->absolutePos.z;
1766
1767 movement->angle = atan2(posX, posZ, goalX, goalZ);
1768 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1769
1770 // make relative
1771 posX = (goalX - posX);
1772 posY = (goalY - posY);
1773 posZ = (goalZ - posZ);
1774
1775 if (movement->moveTime == 0) {
1776 movement->moveTime = movement->dist / movement->moveSpeed;
1777 deltaDist = movement->dist - movement->moveTime * movement->moveSpeed;
1778 } else {
1779 movement->moveSpeed = movement->dist / movement->moveTime;
1780 deltaDist = movement->dist - movement->moveTime * movement->moveSpeed;
1781 }
1782 movement->moveSpeed += deltaDist / movement->moveTime;
1783 movement->unk_2C = movement->jumpScale * movement->moveTime * 0.5f + posY / movement->moveTime;
1784 if (part->partTypeData[4] != 0) {
1785 sfx_play_sound_at_position(part->partTypeData[4], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
1786 }
1787 script->functionTemp[0] = 1;
1788 }
1789
1790 part = script->functionTempPtr[2];
1791 movement = part->movement;
1792 movement->absolutePos.y += movement->unk_2C;
1793 movement->unk_2C -= movement->jumpScale;
1794 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1795 part->absolutePos.x = movement->absolutePos.x;
1796 part->absolutePos.y = movement->absolutePos.y;
1797 part->absolutePos.z = movement->absolutePos.z;
1798 movement->moveTime--;
1799
1800 if (movement->moveTime <= 0) {
1801 if (script->functionTemp[3] != 0) {
1802 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1803 }
1804 part->absolutePos.x = movement->goalPos.x;
1805 part->absolutePos.y = movement->goalPos.y;
1806 part->absolutePos.z = movement->goalPos.z;
1807 return ApiStatus_DONE1;
1808 } else {
1809 return ApiStatus_BLOCK;
1810 }
1811}
1812
1813API_CALLABLE(FallPartTo) {
1814 Bytecode* args = script->ptrReadPos;
1815 Actor* actor;
1816 ActorPart* part;
1817 ActorPartMovement* movement;
1818 s32 actorID, partID;
1819 f32 posX, posY, posZ;
1820 f32 goalX, goalY, goalZ;
1821
1822 if (isInitialCall) {
1823 script->functionTemp[0] = 0;
1824 }
1825
1826 if (script->functionTemp[0] == 0) {
1827 actorID = evt_get_variable(script, *args++);
1828 if (actorID == ACTOR_SELF) {
1829 actorID = script->owner1.actorID;
1830 }
1831 partID = evt_get_variable(script, *args++);
1832
1833 actor = get_actor(actorID);
1834 part = get_actor_part(actor, partID);
1835 script->functionTempPtr[1] = actor;
1836 script->functionTempPtr[2] = part;
1837 movement = part->movement;
1838
1839 posX = evt_get_variable(script, *args++);
1840 posY = evt_get_variable(script, *args++);
1841 posZ = evt_get_variable(script, *args++);
1842 movement->goalPos.x = posX;
1843 movement->goalPos.y = posY;
1844 movement->goalPos.z = posZ;
1845 movement->moveTime = evt_get_variable(script, *args++);
1846
1847 goalX = movement->goalPos.x;
1848 goalY = movement->goalPos.y;
1849 goalZ = movement->goalPos.z;
1850
1851 movement->absolutePos.x = part->absolutePos.x;
1852 movement->absolutePos.y = part->absolutePos.y;
1853 movement->absolutePos.z = part->absolutePos.z;
1854
1855 posX = movement->absolutePos.x;
1856 posY = movement->absolutePos.y;
1857 posZ = movement->absolutePos.z;
1858
1859 movement->angle = atan2(posX, posZ, goalX, goalZ);
1860 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1861
1862 // make relative
1863 posX = (goalX - posX);
1864 posY = (goalY - posY);
1865 posZ = (goalZ - posZ);
1866
1867 if (movement->moveTime == 0) {
1868 movement->moveTime = movement->dist / movement->moveSpeed;
1869 } else {
1870 movement->moveSpeed = movement->dist / movement->moveTime;
1871 }
1872
1873 movement->unk_2C = 0.0f;
1874 movement->jumpScale = (posY / movement->moveTime - movement->unk_2C) / (-movement->moveTime * 0.5);
1875 if (part->partTypeData[4] != 0) {
1876 sfx_play_sound_at_position(part->partTypeData[4], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
1877 }
1878 script->functionTemp[0] = 1;
1879 }
1880
1881 part = script->functionTempPtr[2];
1882 movement = part->movement;
1883 movement->absolutePos.y += movement->unk_2C;
1884 movement->unk_2C -= movement->jumpScale;
1885 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1886 part->absolutePos.x = movement->absolutePos.x;
1887 part->absolutePos.y = movement->absolutePos.y;
1888 part->absolutePos.z = movement->absolutePos.z;
1889 movement->moveTime--;
1890
1891 if (movement->moveTime <= 0) {
1892 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1893 part->absolutePos.x = movement->goalPos.x;
1894 part->absolutePos.y = movement->goalPos.y;
1895 part->absolutePos.z = movement->goalPos.z;
1896 return ApiStatus_DONE1;
1897 } else {
1898 return ApiStatus_BLOCK;
1899 }
1900}
1901
1902API_CALLABLE(LandJumpPart) {
1903 Bytecode* args = script->ptrReadPos;
1904 Actor* actor;
1905 ActorPart* part;
1906 ActorPartMovement* movement;
1907
1908 if (isInitialCall) {
1909 script->functionTemp[0] = 0;
1910 }
1911
1912 if (script->functionTemp[0] == 0) {
1913 s32 actorID = evt_get_variable(script, *args++);
1914 s32 partID = evt_get_variable(script, *args++);
1915
1916 if (actorID == ACTOR_SELF) {
1917 actorID = script->owner1.actorID;
1918 }
1919
1920 actor = get_actor(actorID);
1921 part = get_actor_part(actor, partID);
1922 script->functionTempPtr[1] = actor;
1923 script->functionTempPtr[2] = part;
1924 movement = part->movement;
1925 movement->absolutePos.x = part->absolutePos.x;
1926 movement->absolutePos.y = part->absolutePos.y;
1927 movement->absolutePos.z = part->absolutePos.z;
1928 script->functionTemp[0] = 1;
1929 }
1930
1931 part = script->functionTempPtr[2];
1932 movement = part->movement;
1933 movement->absolutePos.y += movement->unk_2C;
1934 movement->unk_2C -= movement->jumpScale;
1935 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1936 part->absolutePos.x = movement->absolutePos.x;
1937 part->absolutePos.y = movement->absolutePos.y;
1938 part->absolutePos.z = movement->absolutePos.z;
1939
1940 if (part->absolutePos.y < 0.0f) {
1941 part->absolutePos.y = 0.0f;
1942 play_movement_dust_effects(2, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z, part->yaw);
1943 return ApiStatus_DONE1;
1944 }
1945
1946 return ApiStatus_BLOCK;
1947}
1948
1949API_CALLABLE(RunPartTo) {
1950 Bytecode* args = script->ptrReadPos;
1951 Actor* actor;
1952 ActorPart* part;
1953 ActorPartMovement* movement;
1954 s32 actorID, partID;
1955 f32 posX, posY, posZ;
1956 f32 goalX, goalY, goalZ;
1957
1958 if (isInitialCall) {
1959 script->functionTemp[0] = 0;
1960 }
1961
1962 if (script->functionTemp[0] == 0) {
1963 actorID = evt_get_variable(script, *args++);
1964 if (actorID == ACTOR_SELF) {
1965 actorID = script->owner1.actorID;
1966 }
1967 partID = evt_get_variable(script, *args++);
1968
1969 actor = get_actor(actorID);
1970 part = get_actor_part(actor, partID);
1971 script->functionTempPtr[1] = actor;
1972 script->functionTempPtr[2] = part;
1973 movement = part->movement;
1974
1975 posX = evt_get_variable(script, *args++);
1976 posY = evt_get_variable(script, *args++);
1977 posZ = evt_get_variable(script, *args++);
1978 movement->goalPos.x = posX;
1979 movement->goalPos.y = posY;
1980 movement->goalPos.z = posZ;
1981 movement->moveTime = evt_get_variable(script, *args++);
1982
1983 goalX = movement->goalPos.x;
1984 goalY = movement->goalPos.y;
1985 goalZ = movement->goalPos.z;
1986
1987 movement->absolutePos.x = part->absolutePos.x;
1988 movement->absolutePos.y = part->absolutePos.y;
1989 movement->absolutePos.z = part->absolutePos.z;
1990
1991 posX = movement->absolutePos.x;
1992 posY = movement->absolutePos.y;
1993 posZ = movement->absolutePos.z;
1994
1995 movement->angle = atan2(posX, posZ, goalX, goalZ);
1996 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1997
1998 if (movement->moveTime == 0) {
1999 movement->moveTime = movement->dist / movement->moveSpeed;
2000 } else {
2001 movement->moveSpeed = movement->dist / movement->moveTime;
2002 }
2003 if (part->actorTypeData2b[0] >= 0) {
2004 movement->dist = part->actorTypeData2b[0] + 1;
2005 } else {
2006 movement->dist = -(part->actorTypeData2b[0] + 1);
2007 }
2008 if (part->partTypeData[0] != 0 && part->partTypeData[1] == 0) {
2009 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2010 }
2011 script->functionTemp[0] = 1;
2012 }
2013
2014 part = script->functionTempPtr[2];
2015 movement = part->movement;
2016 actor = script->functionTempPtr[1];
2017
2018 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
2019 if (movement->moveSpeed < 4.0f) {
2020 play_movement_dust_effects(0, movement->absolutePos.x, movement->absolutePos.y, movement->absolutePos.z, movement->angle);
2021 } else {
2022 play_movement_dust_effects(1, movement->absolutePos.x, movement->absolutePos.y, movement->absolutePos.z, movement->angle);
2023 }
2024 part->absolutePos.x = movement->absolutePos.x;
2025 part->absolutePos.y = movement->absolutePos.y;
2026 part->absolutePos.z = movement->absolutePos.z;
2027
2028 if (part->partTypeData[0] != 0 && part->partTypeData[1] != 0) {
2029 if (part->actorTypeData2b[0] >= 0) {
2030 movement->dist += movement->moveSpeed;
2031 if (part->actorTypeData2b[0] < movement->dist) {
2032 actor->footStepCounter++;
2033 movement->dist = 0;
2034 if (actor->footStepCounter % 2 != 0) {
2035 if (part->partTypeData[0] != 0) {
2036 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2037 }
2038 } else {
2039 if (part->partTypeData[1] != 0) {
2040 sfx_play_sound_at_position(part->partTypeData[1], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2041 }
2042 }
2043 }
2044 } else {
2045 movement->dist += 1.0f;
2046 if (-part->actorTypeData2b[0] <= movement->dist) {
2047 actor->footStepCounter++;
2048 movement->dist = 0;
2049 if (actor->footStepCounter % 2 != 0) {
2050 if (part->partTypeData[0] != 0) {
2051 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2052 }
2053 } else {
2054 if (part->partTypeData[1] != 0) {
2055 sfx_play_sound_at_position(part->partTypeData[1], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2056 }
2057 }
2058 }
2059 }
2060 }
2061
2062 movement->moveTime--;
2063 if (movement->moveTime > 0) {
2064 return ApiStatus_BLOCK;
2065 } else {
2066 part->absolutePos.x = movement->goalPos.x;
2067 part->absolutePos.z = movement->goalPos.z;
2068 if (part->partTypeData[0] != 0 && part->partTypeData[1] == 0) {
2069 snd_stop_sound(part->partTypeData[0]);
2070 }
2071 return ApiStatus_DONE1;
2072 }
2073}
2074
2076 s32 timeLeft;
2077 f32 absMag;
2078 f64 start1;
2079 f64 start2;
2080 f32 len1;
2081 f32 len2;
2082 f32 len3;
2083 f32 len4;
2084 f64 len5;
2085 f32 len6;
2086 f64 len7;
2087
2088 switch (easing) {
2089 case EASING_LINEAR:
2090 return start + (end - start) * elapsed / duration;
2092 return start + SQ(elapsed) * (end - start) / SQ(duration);
2093 case EASING_CUBIC_IN:
2094 return start + CUBE(elapsed) * (end - start) / CUBE(duration);
2095 case EASING_QUARTIC_IN:
2096 return start + QUART(elapsed) * (end - start) / QUART(duration);
2098 len1 = end - start;
2099 return end - (len1 * cos_rad(((f32)elapsed / duration) * PI_D * 4.0) * (duration - elapsed) *
2100 (duration - elapsed)) / SQ((f32)duration);
2102 len2 = end - start;
2103 return end - (len2 * cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 15.0) * (duration - elapsed) *
2104 (duration - elapsed)) / SQ((f32)duration);
2106 timeLeft = duration - elapsed;
2107 return start + (end - start) - ((SQ(timeLeft) * (end - start))) / SQ(duration);
2108 case EASING_CUBIC_OUT:
2109 len3 = end - start;
2110 timeLeft = duration - elapsed;
2111 return start + len3 - ((CUBE(timeLeft) * len3)) / CUBE(duration);
2112 case EASING_QUARTIC_OUT:
2113 len4 = end - start;
2114 timeLeft = duration - elapsed;
2115 return start + len4 - ((QUART(timeLeft) * len4)) / QUART(duration);
2116 case EASING_COS_BOUNCE:
2117 absMag = cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 40.0) * (duration - elapsed) *
2118 (duration - elapsed) / SQ((f32)duration);
2119 if (absMag < 0.0f) {
2120 absMag = -absMag;
2121 }
2122 return end - (end - start) * absMag;
2123 case EASING_COS_IN_OUT:
2124 len5 = end - start;
2125 start1 = start;
2126 return start1 + (len5 * (1.0 - cos_rad(((f32)elapsed * PI_D) / (f32)duration)) / 2);
2127 case EASING_SIN_OUT:
2128 len6 = end - start;
2129 return start + (len6 * sin_rad((((f32) elapsed) * (PI_D / 2)) / ((f32) duration)));
2130 case EASING_COS_IN:
2131 len7 = end - start;
2132 start2 = start;
2133 return start2 + (len7 * (1.0 - cos_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration)));
2134 }
2135
2136 return 0.0f;
2137}
2138
2139API_CALLABLE(FlyToGoal) {
2140 Bytecode* args = script->ptrReadPos;
2141 Actor* actor;
2143 s32 actorID;
2144 f32 posX, posY, posZ;
2145 f32 goalX, goalY, goalZ;
2147 f32 dist3D;
2148 f32 offsetY;
2149
2150 if (isInitialCall) {
2151 actorID = evt_get_variable(script, *args++);
2152 if (actorID == ACTOR_SELF) {
2153 actorID = script->owner1.enemyID;
2154 }
2155 script->functionTempPtr[1] = actor = get_actor(actorID);
2156 actorState = &actor->state;
2157
2159 actorState->moveArcAmplitude = evt_get_variable(script, *args++);
2160 script->functionTemp[3] = evt_get_variable(script, *args++);
2161 actorState->functionTemp[0] = false;
2162
2163 if (script->functionTemp[3] >= 100) {
2164 script->functionTemp[3] -= 100;
2165 actorState->functionTemp[0] = true;
2166 }
2167
2168 goalX = actorState->goalPos.x;
2169 goalY = actorState->goalPos.y;
2170 goalZ = actorState->goalPos.z;
2171
2172 posX = actor->curPos.x;
2173 posY = actor->curPos.y;
2174 posZ = actor->curPos.z;
2175
2176 deltaX = posX - goalX;
2177 deltaY = posY - goalY;
2178 deltaZ = posZ - goalZ;
2179
2180 actorState->curPos.x = posX;
2181 actorState->unk_18.x = posX;
2182 actorState->curPos.y = posY;
2183 actorState->unk_18.y = posY;
2184 actorState->curPos.z = posZ;
2185 actorState->unk_18.z = posZ;
2186
2187 actorState->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2188
2189 if (actorState->moveTime == 0) {
2190 actorState->moveTime = actorState->dist / actorState->speed;
2191 } else {
2192 actorState->speed = actorState->dist / actorState->moveTime;
2193 }
2194 if (actorState->moveTime == 0) {
2195 return ApiStatus_DONE2;
2196 }
2197
2198 actorState->bounceDivisor = 0.0f;
2199 actorState->angle = 0.0f;
2200 if (actor->actorTypeData1b[1] >= 0) {
2201 actorState->vel = actor->actorTypeData1b[1] + 1;
2202 } else {
2203 actorState->vel = -(actor->actorTypeData1b[1] + 1);
2204 }
2205 if ((actor->actorTypeData1[2] != 0) && (actor->actorTypeData1[3] == 0)) {
2207 }
2208 }
2209
2210 actor = script->functionTempPtr[1];
2211 actorState = &actor->state;
2212
2213 actorState->curPos.x = update_lerp_battle(script->functionTemp[3], actorState->unk_18.x, actorState->goalPos.x, actorState->bounceDivisor, actorState->moveTime);
2214 actorState->curPos.y = update_lerp_battle(script->functionTemp[3], actorState->unk_18.y, actorState->goalPos.y, actorState->bounceDivisor, actorState->moveTime);
2215 actorState->curPos.z = update_lerp_battle(script->functionTemp[3], actorState->unk_18.z, actorState->goalPos.z, actorState->bounceDivisor, actorState->moveTime);
2216 if ((actorState->functionTemp[0]) && (actorState->curPos.y < 0.0f)) {
2217 actorState->bounceDivisor = actorState->moveTime;
2218 actorState->goalPos.x = actorState->curPos.x;
2219 actorState->goalPos.y = 0.0f;
2220 actorState->goalPos.z = actorState->curPos.z;
2221 }
2222 actorState->bounceDivisor += 1.0f;
2223 if (actorState->moveTime < actorState->bounceDivisor) {
2224 actor->curPos.x = actorState->goalPos.x;
2225 actor->curPos.y = actorState->goalPos.y;
2226 actor->curPos.z = actorState->goalPos.z;
2227 if (actor->actorTypeData1[2] != 0) {
2228 if (actor->actorTypeData1[3] == 0) {
2229 snd_stop_sound(actor->actorTypeData1[2]);
2230 }
2231 }
2232 return ApiStatus_DONE2;
2233 }
2234 if ((actor->actorTypeData1[2] != 0) && (actor->actorTypeData1[3] != 0)) {
2235 if (actor->actorTypeData1b[1] >= 0) {
2236 actorState->vel += actorState->speed;
2237 if (actor->actorTypeData1b[1] < actorState->vel) {
2238 actor->footStepCounter++;
2239 actorState->vel = 0.0f;
2240 if (actor->footStepCounter & 1) {
2241 if (actor->actorTypeData1[2] != 0) {
2243 }
2244 } else {
2245 if (actor->actorTypeData1[3] != 0) {
2247 }
2248 }
2249 }
2250 } else {
2251 actorState->vel += 1.0f;
2252 if (-actor->actorTypeData1b[1] <= actorState->vel) {
2253 actor->footStepCounter++;
2254 actorState->vel = 0.0f;
2255 if (actor->footStepCounter & 1) {
2256 if (actor->actorTypeData1[2] != 0) {
2258 }
2259 } else {
2260 if (actor->actorTypeData1[3] != 0) {
2262 }
2263 }
2264 }
2265 }
2266 }
2267
2268 deltaX = actorState->goalPos.x - actorState->curPos.x;
2269 deltaY = actorState->goalPos.y - actorState->curPos.y;
2270 deltaZ = actorState->goalPos.z - actorState->curPos.z;
2271 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2272 if (dist3D == 0.0f) {
2273 dist3D = 1.0f;
2274 }
2275 if (actorState->dist == 0.0f) {
2276 actorState->dist = 1.0f;
2277 }
2278 offsetY = sin_deg((1.0 - (dist3D / actorState->dist)) * 180.0);
2279 if (actorState->moveArcAmplitude == 0) {
2280 offsetY = 0.0f;
2281 }
2282 if (actorState->moveArcAmplitude < 0) {
2283 offsetY = -offsetY * -actorState->moveArcAmplitude;
2284 }
2285 if (actorState->moveArcAmplitude > 0) {
2286 offsetY = offsetY * actorState->moveArcAmplitude;
2287 }
2288 actor->curPos.x = actorState->curPos.x;
2289 actor->curPos.y = actorState->curPos.y + offsetY;
2290 actor->curPos.z = actorState->curPos.z;
2291 return ApiStatus_BLOCK;
2292}
2293
2294API_CALLABLE(IdleFlyToGoal) {
2295 Bytecode* args = script->ptrReadPos;
2296 Actor* actor;
2297 ActorMovement* movement;
2298 s32 actorID;
2299 f32 posX, posY, posZ;
2300 f32 goalX, goalY, goalZ;
2302 f32 dist3D;
2303 f32 offsetY;
2304
2305 if (isInitialCall) {
2306 actorID = evt_get_variable(script, *args++);
2307 if (actorID == ACTOR_SELF) {
2308 actorID = script->owner1.enemyID;
2309 }
2310 script->functionTempPtr[1] = actor = get_actor(actorID);
2311 movement = &actor->fly;
2312
2313 movement->flyTime = evt_get_variable(script, *args++);
2314 movement->flyArcAmplitude = evt_get_variable(script, *args++);
2315 script->functionTemp[3] = evt_get_variable(script, *args++);
2316
2317 goalX = movement->goalPos.x;
2318 goalY = movement->goalPos.y;
2319 goalZ = movement->goalPos.z;
2320
2321 posX = actor->curPos.x;
2322 posY = actor->curPos.y;
2323 posZ = actor->curPos.z;
2324
2325 deltaX = posX - goalX;
2326 deltaY = posY - goalY;
2327 deltaZ = posZ - goalZ;
2328
2329 movement->curPos.x = posX;
2330 movement->unk_18.x = posX;
2331 movement->curPos.y = posY;
2332 movement->unk_18.y = posY;
2333 movement->curPos.z = posZ;
2334 movement->unk_18.z = posZ;
2335
2336 movement->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2337
2338 if (movement->flyTime == 0) {
2339 movement->flyTime = movement->dist / movement->speed;
2340 } else {
2341 movement->speed = movement->dist / movement->flyTime;
2342 }
2343 if (movement->flyTime == 0) {
2344 return ApiStatus_DONE2;
2345 }
2346
2347 movement->flyElapsed = 0.0f;
2348 movement->angle = 0.0f;
2349 movement->vel = 0.0f;
2350 }
2351
2352 actor = script->functionTempPtr[1];
2353 movement = &actor->fly;
2354
2355 movement->curPos.x = update_lerp_battle(script->functionTemp[3], movement->unk_18.x, movement->goalPos.x, movement->flyElapsed, movement->flyTime);
2356 movement->curPos.y = update_lerp_battle(script->functionTemp[3], movement->unk_18.y, movement->goalPos.y, movement->flyElapsed, movement->flyTime);
2357 movement->curPos.z = update_lerp_battle(script->functionTemp[3], movement->unk_18.z, movement->goalPos.z, movement->flyElapsed, movement->flyTime);
2358
2359 movement->flyElapsed += 1.0f;
2360 if (movement->flyTime < movement->flyElapsed) {
2361 actor->curPos.x = movement->goalPos.x;
2362 actor->curPos.y = movement->goalPos.y;
2363 actor->curPos.z = movement->goalPos.z;
2364 return ApiStatus_DONE2;
2365 }
2366
2367 deltaX = movement->goalPos.x - movement->curPos.x;
2368 deltaY = movement->goalPos.y - movement->curPos.y;
2369 deltaZ = movement->goalPos.z - movement->curPos.z;
2370 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2371 if (dist3D == 0.0f) {
2372 dist3D = 1.0f;
2373 }
2374 if (movement->dist == 0.0f) {
2375 movement->dist = 1.0f;
2376 }
2377
2378 offsetY = sin_deg((1.0 - (dist3D / movement->dist)) * 180.0);
2379 if (movement->flyArcAmplitude == 0) {
2380 offsetY = 0.0f;
2381 }
2382 if (movement->flyArcAmplitude < 0) {
2383 offsetY = -offsetY * -movement->flyArcAmplitude;
2384 }
2385 if (movement->flyArcAmplitude > 0) {
2386 offsetY = offsetY * movement->flyArcAmplitude;
2387 }
2388
2389 actor->curPos.x = movement->curPos.x;
2390 actor->curPos.y = movement->curPos.y + offsetY;
2391 actor->curPos.z = movement->curPos.z;
2392 return ApiStatus_BLOCK;
2393}
2394
2395API_CALLABLE(FlyPartTo) {
2396 Bytecode* args = script->ptrReadPos;
2397 Actor* actor;
2398 ActorPart* part;
2400 s32 actorID;
2401 s32 partID;
2402
2403 f32 posX, posY, posZ;
2404 f32 goalX, goalY, goalZ;
2406 f32 dist3D;
2407 f32 offsetY;
2408
2409 if (isInitialCall) {
2410 actorID = evt_get_variable(script, *args++);
2411 if (actorID == ACTOR_SELF) {
2412 actorID = script->owner1.actorID;
2413 }
2414 partID = evt_get_variable(script, *args++);
2415
2416 actor = get_actor(actorID);
2417 part = get_actor_part(actor, partID);
2418 script->functionTempPtr[1] = actor;
2419 script->functionTempPtr[2] = part;
2420 partMovement = part->movement;
2421
2422 partMovement->goalPos.x = evt_get_variable(script, *args++);
2423 partMovement->goalPos.y = evt_get_variable(script, *args++);
2424 partMovement->goalPos.z = evt_get_variable(script, *args++);
2425 partMovement->moveTime = evt_get_variable(script, *args++);
2426 partMovement->unk_3A = evt_get_variable(script, *args++);
2427 script->functionTemp[3] = evt_get_variable(script, *args++);
2428
2429 goalX = partMovement->goalPos.x;
2430 posX = part->absolutePos.x;
2431 deltaX = posX - goalX;
2432 partMovement->absolutePos.x = posX;
2433 partMovement->unk_18.x = posX;
2434
2435 goalY = partMovement->goalPos.y;
2436 posY = part->absolutePos.y;
2437 deltaY = posY - goalY;
2438 partMovement->absolutePos.y = posY;
2439 partMovement->unk_18.y = posY;
2440
2441 goalZ = partMovement->goalPos.z;
2442 posZ = part->absolutePos.z;
2443 deltaZ = posZ - goalZ;
2444 partMovement->absolutePos.z = posZ;
2445 partMovement->unk_18.z = posZ;
2446
2447 partMovement->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2448
2449 if (partMovement->moveTime == 0) {
2450 partMovement->moveTime = partMovement->dist / partMovement->moveSpeed;
2451 } else {
2452 partMovement->moveSpeed = partMovement->dist / partMovement->moveTime;
2453 }
2454
2455 if (partMovement->moveTime == 0) {
2456 return ApiStatus_DONE2;
2457 }
2458
2459 if (part->partTypeData[2] != 0 && part->partTypeData[3] == 0) {
2460 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2461 }
2462 partMovement->unk_3C = 0;
2463 partMovement->angle = 0.0f;
2464
2465 if (part->actorTypeData2b[1] >= 0) {
2466 partMovement->unk_2C = actor->actorTypeData1b[1] + 1;
2467 } else {
2468 partMovement->unk_2C = -(actor->actorTypeData1b[1] + 1);
2469 }
2470 }
2471
2472 part = script->functionTempPtr[2];
2473 actor = script->functionTempPtr[1];
2474 partMovement = part->movement;
2475 partMovement->absolutePos.x = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.x, partMovement->goalPos.x, partMovement->unk_3C, partMovement->moveTime);
2476 partMovement->absolutePos.y = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.y, partMovement->goalPos.y, partMovement->unk_3C, partMovement->moveTime);
2477 partMovement->absolutePos.z = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.z, partMovement->goalPos.z, partMovement->unk_3C, partMovement->moveTime);
2478 partMovement->unk_3C++;
2479
2480 if (partMovement->moveTime < partMovement->unk_3C) {
2481 part->absolutePos.x = partMovement->goalPos.x;
2482 part->absolutePos.y = partMovement->goalPos.y;
2483 part->absolutePos.z = partMovement->goalPos.z;
2484 if (part->partTypeData[2] != 0 && part->partTypeData[3] == 0) {
2485 snd_stop_sound(part->partTypeData[2]);
2486 }
2487 return ApiStatus_DONE2;
2488 }
2489
2490 if (part->partTypeData[2] != 0 && part->partTypeData[3] != 0) {
2491 if (part->actorTypeData2b[1] >= 0) {
2492 partMovement->unk_2C += partMovement->moveSpeed;
2493 if (part->actorTypeData2b[1] < partMovement->unk_2C) {
2494 actor->footStepCounter++;
2495 partMovement->unk_2C = 0;
2496 if (actor->footStepCounter % 2 != 0) {
2497 if (part->partTypeData[2] != 0) {
2498 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2499 }
2500 } else {
2501 if (part->partTypeData[3] != 0) {
2502 sfx_play_sound_at_position(part->partTypeData[3], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2503 }
2504 }
2505 }
2506 } else {
2507 partMovement->unk_2C += 1.0f;
2508 if (-part->actorTypeData2b[1] <= partMovement->unk_2C) {
2509 actor->footStepCounter++;
2510 partMovement->unk_2C = 0;
2511 if (actor->footStepCounter % 2 != 0) {
2512 if (part->partTypeData[2] != 0) {
2513 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2514 }
2515 } else {
2516 if (part->partTypeData[3] != 0) {
2517 sfx_play_sound_at_position(part->partTypeData[3], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2518 }
2519 }
2520 }
2521 }
2522 }
2523
2524 deltaX = partMovement->goalPos.x - partMovement->absolutePos.x;
2525 deltaY = partMovement->goalPos.y - partMovement->absolutePos.y;
2526 deltaZ = partMovement->goalPos.z - partMovement->absolutePos.z;
2527 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2528 if (dist3D == 0.0f) {
2529 dist3D = 1.0f;
2530 }
2531 if (partMovement->dist == 0.0f) {
2532 partMovement->dist = 1.0f;
2533 }
2534
2535 offsetY = sin_deg((1.0 - dist3D / partMovement->dist) * 180.0);
2536 if (partMovement->unk_3A == 0) {
2537 offsetY = 0.0f;
2538 }
2539 if (partMovement->unk_3A < 0) {
2540 offsetY = -offsetY * (-partMovement->unk_3A);
2541 }
2542 if (partMovement->unk_3A > 0) {
2543 offsetY = offsetY * partMovement->unk_3A;
2544 }
2545
2546 part->absolutePos.x = partMovement->absolutePos.x;
2547 part->absolutePos.y = partMovement->absolutePos.y + offsetY;
2548 part->absolutePos.z = partMovement->absolutePos.z;
2549 return ApiStatus_BLOCK;
2550}
2551
2552API_CALLABLE(GetLastEvent) {
2553 Bytecode* args = script->ptrReadPos;
2554 s32 actorID = evt_get_variable(script, *args++);
2555 s32 outVar;
2556
2557 if (actorID == ACTOR_SELF) {
2558 actorID = script->owner1.actorID;
2559 }
2560
2561 outVar = *args++;
2562 evt_set_variable(script, outVar, get_actor(actorID)->lastEventType);
2563 return ApiStatus_DONE2;
2564}
2565
2566API_CALLABLE(SetTargetActor) {
2567 Bytecode* args = script->ptrReadPos;
2568 s32 actorID = evt_get_variable(script, *args++);
2569 s32 targetActorID;
2570 Actor* actor;
2571
2572 if (actorID == ACTOR_SELF) {
2573 actorID = script->owner1.actorID;
2574 }
2575
2576 targetActorID = evt_get_variable(script, *args++);
2577 actor = get_actor(actorID);
2578 actor->targetActorID = targetActorID;
2579 actor->targetPartID = 1;
2580 return ApiStatus_DONE2;
2581}
2582
2583API_CALLABLE(SetEnemyHP) {
2584 Bytecode* args = script->ptrReadPos;
2585 s32 actorID = evt_get_variable(script, *args++);
2586 s8 newHP;
2587 Actor* actor;
2588
2589 if (actorID == ACTOR_SELF) {
2590 actorID = script->owner1.actorID;
2591 }
2592
2593 newHP = evt_get_variable(script, *args++);
2594 actor = get_actor(actorID);
2595
2596 actor->curHP = newHP;
2597 if (newHP > actor->maxHP) {
2598 actor->curHP = actor->maxHP;
2599 }
2600
2601 actor->healthFraction = (actor->curHP * 25) / actor->maxHP;
2602
2603 return ApiStatus_DONE2;
2604}
2605
2606API_CALLABLE(GetActorHP) {
2608 Bytecode* args = script->ptrReadPos;
2609 s32 actorID = evt_get_variable(script, *args++);
2610 Actor* actor;
2611 s32 outVar;
2612 s32 outVal;
2613
2614 if (actorID == ACTOR_SELF) {
2615 actorID = script->owner1.actorID;
2616 }
2617 outVar = *args++;
2618
2619 actor = get_actor(actorID);
2620
2621 switch (actorID & ACTOR_CLASS_MASK) {
2622 case ACTOR_CLASS_PLAYER:
2623 outVal = playerData->curHP;
2624 break;
2626 outVal = 99;
2627 break;
2628 default:
2629 outVal = actor->curHP;
2630 break;
2631 }
2632
2634 return ApiStatus_DONE2;
2635}
2636
2637API_CALLABLE(GetEnemyMaxHP) {
2638 Bytecode* args = script->ptrReadPos;
2639 s32 actorID = evt_get_variable(script, *args++);
2640 s32 outVar;
2641
2642 if (actorID == ACTOR_SELF) {
2643 actorID = script->owner1.actorID;
2644 }
2645
2646 outVar = *args++;
2647 evt_set_variable(script, outVar, get_actor(actorID)->maxHP);
2648 return ApiStatus_DONE2;
2649}
2650
2651API_CALLABLE(RemoveActor) {
2654 Bytecode* args = script->ptrReadPos;
2655 s32 actorID = evt_get_variable(script, *args++);
2656 Actor* actor;
2657 s32 i;
2659 s16* enemyIDs;
2660
2661 if (actorID == ACTOR_SELF) {
2662 actorID = script->owner1.actorID;
2663 }
2664
2665 actor = get_actor(actorID);
2666 numEnemies = battleStatus->numEnemyActors;
2667 enemyIDs = battleStatus->enemyIDs;
2668
2669 for (i = 0; i < numEnemies; i++) {
2670 if (actor == battleStatus->enemyActors[enemyIDs[i] & 0xFF]) {
2671 enemyIDs[i] = -1;
2672 }
2673 }
2674
2675 currentEncounter->coinsEarned += actor->extraCoinBonus;
2676 currentEncounter->coinsEarned += actor->actorBlueprint->coinReward;
2677 btl_delete_actor(actor);
2678 battleStatus->enemyActors[actorID & 0xFF] = nullptr;
2679
2680 return ApiStatus_DONE2;
2681}
2682
2687 100, 100, 100,
2688 110,
2689 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
2690};
2691
2692API_CALLABLE(DropStarPoints) {
2695 Bytecode* args = script->ptrReadPos;
2696 Actor* dropper;
2699 s32 actorID;
2700 f32 ntd;
2701 s32 numToDrop;
2702
2703 actorID = evt_get_variable(script, *args++);
2704 if (actorID == ACTOR_SELF) {
2705 actorID = script->owner1.enemyID;
2706 }
2707 dropper = get_actor(actorID);
2708
2709 enemyLevel = dropper->actorBlueprint->level;
2710 if (dropper->actorBlueprint->level == 0.0f) {
2711 enemyLevel = 1.0f;
2712 }
2713
2714 playerLevel = playerData->level;
2715 if (playerLevel == 0.0f) {
2716 playerLevel = 1.0f;
2717 }
2718
2719 ntd = 0.0f;
2720 if (!(enemyLevel < playerLevel)) {
2721 ntd = ((enemyLevel - playerLevel) * 0.5f) * StarPointMultiplier[battleStatus->initialEnemyCount];
2722 ntd = (ntd + 50.0f) / 100.0f;
2723 }
2724 numToDrop = ntd;
2725
2726 if (playerData->level < 27) {
2727 s32 spawnMode;
2728 s32 i;
2729
2730 if (dropper->flags & ACTOR_FLAG_UPSIDE_DOWN) {
2731 spawnMode = ITEM_SPAWN_MODE_TOSS_FADE3;
2732 } else {
2733 spawnMode = ITEM_SPAWN_MODE_TOSS_FADE1;
2734 }
2735
2736 for (i = 0; i < numToDrop; i++) {
2738 dropper->curPos.x, dropper->curPos.y, dropper->curPos.z, spawnMode, i, 0);
2739 }
2740
2741 battleStatus->incrementStarPointDelay = 40;
2742 battleStatus->pendingStarPoints += numToDrop;
2743 }
2744
2746 return ApiStatus_DONE2;
2747}
2748
2749API_CALLABLE(SetDefenseTable) {
2750 Bytecode* args = script->ptrReadPos;
2751 s32 actorID = evt_get_variable(script, *args++);
2752 s32 partID;
2753 u32* table;
2754
2755 if (actorID == ACTOR_SELF) {
2756 actorID = script->owner1.actorID;
2757 }
2758
2759 partID = evt_get_variable(script, *args++);
2760 table = (u32*) evt_get_variable(script, *args++);
2761 get_actor_part(get_actor(actorID), partID)->defenseTable = table;
2762 return ApiStatus_DONE2;
2763}
2764
2765API_CALLABLE(SetStatusTable) {
2766 Bytecode* args = script->ptrReadPos;
2767 s32 actorID = evt_get_variable(script, *args++);
2768 u32* table;
2769
2770 if (actorID == ACTOR_SELF) {
2771 actorID = script->owner1.actorID;
2772 }
2773
2774 table = (u32*) evt_get_variable(script, *args++);
2775 get_actor(actorID)->statusTable = table;
2776 return ApiStatus_DONE2;
2777}
2778
2779API_CALLABLE(SetIdleAnimations) {
2780 Bytecode* args = script->ptrReadPos;
2781 s32 actorID = evt_get_variable(script, *args++);
2782 s32 partID;
2784
2785 if (actorID == ACTOR_SELF) {
2786 actorID = script->owner1.actorID;
2787 }
2788
2789 partID = evt_get_variable(script, *args++);
2790 idleAnims = (u32*) evt_get_variable(script, *args++);
2791 get_actor_part(get_actor(actorID), partID)->idleAnimations = idleAnims;
2792 return ApiStatus_DONE2;
2793}
2794
2795API_CALLABLE(func_8027CC10) {
2796 Bytecode* args = script->ptrReadPos;
2797 s32 actorID = evt_get_variable(script, *args++);
2798 s32 partID;
2799
2800 if (actorID == ACTOR_SELF) {
2801 actorID = script->owner1.actorID;
2802 }
2803
2804 partID = evt_get_variable(script, *args++);
2805
2806 // weirdly unused
2807 evt_get_variable(script, *args++);
2808 evt_get_variable(script, *args++);
2809
2810 get_actor_part(get_actor(actorID), partID);
2811 return ApiStatus_DONE2;
2812}
2813
2814API_CALLABLE(EnemyDamageTarget) {
2815 Bytecode* args = script->ptrReadPos;
2817 s32 actorID = evt_get_variable(script, *args++);
2818 Actor* actor;
2819 s32 outVar;
2820 s32 hitResult;
2822
2823 if (actorID == ACTOR_SELF) {
2824 actorID = script->owner1.enemyID;
2825 }
2826
2827 actor = get_actor(actorID);
2828 outVar = *args++;
2829 battleStatus->curAttackElement = *args++;
2830 battleStatus->curAttackEventSuppression = *args++;
2831 battleStatus->curAttackStatus = *args++;
2832 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
2833 battleFlagsModifier = *args++;
2834
2835 #if DX_DEBUG_MENU
2837 battleStatus->curAttackDamage = 0;
2838 battleStatus->curAttackStatus = 0;
2839 }
2840 #endif
2841
2842 // BS_FLAGS1_INCLUDE_POWER_UPS and BS_FLAGS1_TRIGGER_EVENTS are mutually exclusive
2849 } else {
2852 }
2853
2856 } else {
2858 }
2859
2862 } else {
2864 }
2865
2868 } else {
2870 }
2871
2872 battleStatus->curTargetID = actor->targetActorID;
2873 battleStatus->curTargetPart = actor->targetPartID;
2874
2875 battleStatus->statusChance = battleStatus->curAttackStatus & 0xFF;
2876 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
2877 battleStatus->statusChance = 0;
2878 }
2879 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
2880
2882 if (hitResult < 0) {
2883 return ApiStatus_FINISH;
2884 }
2885
2888 return ApiStatus_FINISH;
2889 }
2890
2891 return ApiStatus_DONE2;
2892}
2893
2894API_CALLABLE(EnemyFollowupAfflictTarget) {
2897 Bytecode* args = script->ptrReadPos;
2898 Actor* actor;
2899 s32 actorID = evt_get_variable(script, *args++);
2901 s32 outVar;
2902
2903 if (actorID == ACTOR_SELF) {
2904 actorID = script->owner1.actorID;
2905 }
2906
2907 actor = get_actor(actorID);
2908 outVar = *args++;
2909
2910 battleStatus->curTargetID = actor->targetActorID;
2911 battleStatus->curTargetPart = actor->targetPartID;
2912 battleStatus->statusChance = battleStatus->curAttackStatus;
2913
2914 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
2915 battleStatus->statusChance = 0;
2916 }
2917
2918 anotherBattleStatus->statusDuration = (anotherBattleStatus->curAttackStatus & 0xF00) >> 8;
2920
2921 if (hitResults < 0) {
2922 return ApiStatus_FINISH;
2923 }
2924
2926 if (does_script_exist_by_ref(script) == nullptr) {
2927 return ApiStatus_FINISH;
2928 }
2929 return ApiStatus_DONE2;
2930}
2931
2932API_CALLABLE(EnemyTestTarget) {
2933 Bytecode* args = script->ptrReadPos;
2935 s32 actorID = evt_get_variable(script, *args++);
2936 Actor *actor;
2937 s32 outVar;
2938 s32 hitResult;
2941
2942 if (actorID == ACTOR_SELF) {
2943 actorID = script->owner1.enemyID;
2944 }
2945
2946 actor = get_actor(actorID);
2947 outVar = *args++;
2948 battleStatus->curAttackElement = *args++;
2949 battleStatus->curAttackEventSuppression = 0;
2950 battleStatus->curAttackStatus = *args++;
2951 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
2952 battleFlagsModifier = *args++;
2953
2960 } else {
2963 }
2964
2967 } else {
2969 }
2972 } else {
2974 }
2977 } else {
2979 }
2980
2981 attackStatus = battleStatus->curAttackStatus;
2982 battleStatus->curTargetID = actor->targetActorID;
2983
2984 battleStatus->curTargetPart = actor->targetPartID;
2985 battleStatus->statusChance = attackStatus;
2986
2987 if ((attackStatus & 0xFF) == 0xFF) {
2988 battleStatus->statusChance = 0;
2989 }
2990
2991 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
2993
2994 if (hitResult < 0) {
2995 return ApiStatus_FINISH;
2996 }
2997
2999
3000 return ApiStatus_DONE2;
3001}
3002
3003API_CALLABLE(DispatchDamageEvent) {
3004 Bytecode* args = script->ptrReadPos;
3005 s32 actorID = evt_get_variable(script, *args++);
3006 Actor* actor;
3008 s32 eventID;
3009
3010 if (actorID == ACTOR_SELF) {
3011 actorID = script->owner1.actorID;
3012 }
3013
3014 actor = get_actor(actorID);
3016 eventID = evt_get_variable(script, *args++);
3017
3019 return ApiStatus_BLOCK;
3020 }
3021
3023 return ApiStatus_DONE2;
3024 } else {
3025 return ApiStatus_BLOCK;
3026 }
3027}
3028
3029API_CALLABLE(DispatchEvent) {
3030 Bytecode* args = script->ptrReadPos;
3031 s32 actorID = evt_get_variable(script, *args++);
3032
3033 if (actorID == ACTOR_SELF) {
3034 actorID = script->owner1.actorID;
3035 }
3036
3038 return ApiStatus_DONE2;
3039}
3040
3041API_CALLABLE(ShowHealthBar) {
3042 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3043
3044 if (actorID == ACTOR_SELF) {
3045 actorID = script->owner1.actorID;
3046 }
3047
3049 return ApiStatus_DONE2;
3050}
3051
3052API_CALLABLE(HideHealthBar) {
3053 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3054
3055 if (actorID == ACTOR_SELF) {
3056 actorID = script->owner1.actorID;
3057 }
3058
3060 return ApiStatus_DONE2;
3061}
3062
3063API_CALLABLE(SetTargetOffset) {
3064 Bytecode* args = script->ptrReadPos;
3065 s32 actorID = evt_get_variable(script, *args++);
3066 s32 partID;
3067 ActorPart* part;
3068 s32 x;
3069 s32 y;
3070
3071 if (actorID == ACTOR_SELF) {
3072 actorID = script->owner1.actorID;
3073 }
3074
3075 partID = evt_get_variable(script, *args++);
3076 part = get_actor_part(get_actor(actorID), partID);
3077
3078 x = evt_get_variable(script, *args++);
3079 y = evt_get_variable(script, *args++);
3080
3081 part->targetOffset.x = x;
3082 part->targetOffset.y = y;
3083
3084 return ApiStatus_DONE2;
3085}
3086
3087API_CALLABLE(func_8027D434) {
3088 Bytecode* args = script->ptrReadPos;
3089 s32 actorID = evt_get_variable(script, *args++);
3090 s32 partID;
3091 ActorPart* part;
3092
3093 if (actorID == ACTOR_SELF) {
3094 actorID = script->owner1.actorID;
3095 }
3096
3097 partID = evt_get_variable(script, *args++);
3098 part = get_actor_part(get_actor(actorID), partID);
3099 part->targetPriorityOffset = evt_get_variable(script, *args++);
3100 return ApiStatus_DONE2;
3101}
3102
3103API_CALLABLE(SetProjectileTargetOffset) {
3104 Bytecode* args = script->ptrReadPos;
3105 s32 actorID = evt_get_variable(script, *args++);
3106 s32 partID;
3107 ActorPart* part;
3108 s32 dx;
3109 s32 dy;
3110
3111 if (actorID == ACTOR_SELF) {
3112 actorID = script->owner1.actorID;
3113 }
3114
3115 partID = evt_get_variable(script, *args++);
3116 part = get_actor_part(get_actor(actorID), partID);
3117
3118 dx = evt_get_variable(script, *args++);
3119 dy = evt_get_variable(script, *args++);
3120
3121 part->projectileTargetOffset.x = dx;
3122 part->projectileTargetOffset.y = dy;
3123
3124 return ApiStatus_DONE2;
3125}
3126
3127API_CALLABLE(EnableActorBlur) {
3128 Bytecode* args = script->ptrReadPos;
3129 s32 actorID = evt_get_variable(script, *args++);
3130 s32 enable = evt_get_variable(script, *args++);
3131 Actor* actor;
3132
3133 if (actorID == ACTOR_SELF) {
3134 actorID = script->owner1.actorID;
3135 }
3136
3137 actor = get_actor(actorID);
3138
3139 if (enable == ACTOR_BLUR_DISABLE) {
3140 disable_actor_blur(actor);
3141 } else if (enable == ACTOR_BLUR_ENABLE) {
3142 enable_actor_blur(actor);
3143 } else {
3144 reset_actor_blur(actor);
3145 }
3146 return ApiStatus_DONE2;
3147}
3148
3149API_CALLABLE(ForceDisableActorBlur) {
3150 Bytecode* args = script->ptrReadPos;
3151 s32 actorID = evt_get_variable(script, *args++);
3152 Actor* actor;
3153
3154 if (actorID == ACTOR_SELF) {
3155 actorID = script->owner1.actorID;
3156 }
3157
3158 actor = get_actor(actorID);
3160 return ApiStatus_DONE2;
3161}
3162
3163API_CALLABLE(AfflictActor) {
3164 Bytecode* args = script->ptrReadPos;
3165 s32 actorID = evt_get_variable(script, *args++);
3166 Actor* actor;
3168 s32 duration;
3170
3172 duration = evt_get_variable(script, *args++);
3173
3174 if (actorID == ACTOR_SELF) {
3175 actorID = script->owner1.actorID;
3176 }
3177 actor = get_actor(actorID);
3178
3179 switch (statusTypeKey) {
3180 case STATUS_KEY_FROZEN:
3182 break;
3183 case STATUS_KEY_SLEEP:
3185 break;
3188 break;
3189 case STATUS_KEY_DIZZY:
3191 break;
3192 default:
3194 break;
3195 }
3196
3198
3199 return ApiStatus_DONE2;
3200}
3201
3202API_CALLABLE(GetInstigatorValue) {
3203 Bytecode* args = script->ptrReadPos;
3204 s32 actorID = evt_get_variable(script, *args++);
3205 s32 outVar = *args++;
3206
3207 if (actorID == ACTOR_SELF) {
3208 actorID = script->owner1.actorID;
3209 }
3210
3211 evt_set_variable(script, outVar, get_actor(actorID)->instigatorValue);
3212 return ApiStatus_DONE2;
3213}
3214
3215API_CALLABLE(GetEncounterTrigger) {
3217 return ApiStatus_DONE2;
3218}
3219
3220API_CALLABLE(YieldTurn) {
3222 return ApiStatus_DONE2;
3223}
3224
3225API_CALLABLE(SetActorSize) {
3226 Bytecode* args = script->ptrReadPos;
3227 s32 actorID = evt_get_variable(script, *args++);
3228 s32 y = evt_get_variable(script, *args++);
3229 s32 x = evt_get_variable(script, *args++);
3230 Actor* actor;
3231
3232 if (actorID == ACTOR_SELF) {
3233 actorID = script->owner1.actorID;
3234 }
3235
3236 actor = get_actor(actorID);
3237
3238 if (y != EVT_IGNORE_ARG) {
3239 actor->size.y = y;
3240 }
3241 if (x != EVT_IGNORE_ARG) {
3242 actor->size.x = x;
3243 }
3244 actor->shadowScale = actor->size.x / 24.0;
3245
3246 return ApiStatus_DONE2;
3247}
3248
3249API_CALLABLE(GetActorSize) {
3250 Bytecode* args = script->ptrReadPos;
3251 s32 actorID = evt_get_variable(script, *args++);
3252 s32 outY = *args++;
3253 s32 outX = *args++;
3254 Actor* actor;
3255
3256 if (actorID == ACTOR_SELF) {
3257 actorID = script->owner1.actorID;
3258 }
3259
3260 actor = get_actor(actorID);
3261 evt_set_variable(script, outY, actor->size.y);
3262 evt_set_variable(script, outX, actor->size.x);
3263 return ApiStatus_DONE2;
3264}
3265
3266API_CALLABLE(SetPartSize) {
3267 Bytecode* args = script->ptrReadPos;
3268 s32 actorID = evt_get_variable(script, *args++);
3269 s32 partID = evt_get_variable(script, *args++);
3270 s32 sizeY = evt_get_variable(script, *args++);
3271 s32 sizeX = evt_get_variable(script, *args++);
3272 ActorPart* part;
3273
3274 if (actorID == ACTOR_SELF) {
3275 actorID = script->owner1.actorID;
3276 }
3277
3278 part = get_actor_part(get_actor(actorID), partID);
3279
3280 if (sizeY != EVT_IGNORE_ARG) {
3281 part->size.y = sizeY;
3282 }
3283
3284 if (sizeX != EVT_IGNORE_ARG) {
3285 part->size.x = sizeX;
3286 }
3287
3288 part->shadowScale = part->size.x / 24.0;
3289
3290 return ApiStatus_DONE2;
3291}
3292
3293API_CALLABLE(GetOriginalActorType) {
3294 Bytecode* args = script->ptrReadPos;
3295 s32 actorID = evt_get_variable(script, *args++);
3296 s32 outVar = *args++;
3297
3298 if (actorID == ACTOR_SELF) {
3299 actorID = script->owner1.actorID;
3300 }
3301
3302 evt_set_variable(script, outVar, get_actor(actorID)->actorBlueprint->type);
3303 return ApiStatus_DONE2;
3304}
3305
3306API_CALLABLE(GetCurrentActorType) {
3307 Bytecode* args = script->ptrReadPos;
3308 s32 actorID = evt_get_variable(script, *args++);
3309 s32 outVar = *args++;
3310
3311 if (actorID == ACTOR_SELF) {
3312 actorID = script->owner1.actorID;
3313 }
3314
3315 evt_set_variable(script, outVar, get_actor(actorID)->actorType);
3316 return ApiStatus_DONE2;
3317}
3318
3319API_CALLABLE(GetLastDamage) {
3320 Bytecode* args = script->ptrReadPos;
3321 s32 actorID = evt_get_variable(script, *args++);
3322 s32 outVar;
3323
3324 if (actorID == ACTOR_SELF) {
3325 actorID = script->owner1.actorID;
3326 }
3327 outVar = *args++;
3328
3329 evt_set_variable(script, outVar, get_actor(actorID)->lastDamageTaken);
3330 return ApiStatus_DONE2;
3331}
3332
3333API_CALLABLE(EnableActorGlow) {
3334 Bytecode* args = script->ptrReadPos;
3335 s32 actorID = evt_get_variable(script, *args++);
3336 s32 flag;
3337 Actor* actor;
3338
3339 if (actorID == ACTOR_SELF) {
3340 actorID = script->owner1.actorID;
3341 }
3342
3343 flag = evt_get_variable(script, *args++);
3344 actor = get_actor(actorID);
3345 actor->isGlowing = flag;
3346
3347 if (!flag) {
3348 ActorPart* it = actor->partsTable;
3349
3350 while (it != nullptr) {
3351 if (it->idleAnimations != nullptr) {
3352 set_npc_imgfx_all(it->spriteInstanceID, IMGFX_CLEAR, 0, 0, 0, 0, 0);
3353 }
3354 it = it->nextPart;
3355 }
3357 }
3358
3359 return ApiStatus_DONE2;
3360}
3361
3362API_CALLABLE(WasStatusInflicted) {
3363 Bytecode* args = script->ptrReadPos;
3365 s32 outVal;
3366
3367 evt_get_variable(script, *args++);
3368
3369 if (script) { // can be args or script but not 1 or do while 0, nor does else work after
3370 outVal = battleStatus->wasStatusInflicted;
3371 }
3372 outVal = battleStatus->wasStatusInflicted;
3373
3374 evt_set_variable(script, *args++, outVal);
3375
3376 return ApiStatus_DONE2;
3377}
3378
3379API_CALLABLE(CopyStatusEffects) {
3380 Bytecode* args = script->ptrReadPos;
3381 s32 actorIDTo;
3383 Actor* actorTo;
3385
3387 if (actorIDFrom == ACTOR_SELF) {
3388 actorIDFrom = script->owner1.actorID;
3389 }
3391
3392 actorIDTo = evt_get_variable(script, *args++);
3393 if (actorIDTo == ACTOR_SELF) {
3394 actorIDTo = script->owner1.actorID;
3395 }
3397
3398 inflict_status(actorTo, actorFrom->debuff, actorFrom->debuffDuration);
3399 inflict_status(actorTo, actorFrom->staticStatus, actorFrom->staticDuration);
3400 inflict_status(actorTo, actorFrom->stoneStatus, actorFrom->stoneDuration);
3401 inflict_status(actorTo, actorFrom->koStatus, actorFrom->koDuration);
3402 inflict_status(actorTo, actorFrom->transparentStatus, actorFrom->transparentDuration);
3403
3404 actorFrom->statusAfflicted = 0;
3405 actorTo->statusAfflicted = 0;
3406
3407 return ApiStatus_DONE2;
3408}
3409
3410API_CALLABLE(ClearStatusEffects) {
3411 Bytecode* args = script->ptrReadPos;
3412 s32 actorID = evt_get_variable(script, *args++);
3413 Actor* actor;
3414
3415 if (actorID == ACTOR_SELF) {
3416 actorID = script->owner1.actorID;
3417 }
3418
3419 actor = get_actor(actorID);
3420
3421 if (actor->debuff != 0) {
3422 actor->debuffDuration = 0;
3423 actor->debuff = 0;
3425 }
3426
3427 if (actor->staticStatus != 0) {
3428 actor->staticDuration = 0;
3429 actor->staticStatus = 0;
3431 }
3432
3433 if (actor->transparentStatus != 0) {
3434 actor->transparentDuration = 0;
3435 actor->transparentStatus = 0;
3437 }
3438
3439 if (actor->stoneStatus != 0) {
3440 actor->stoneDuration = 0;
3441 actor->stoneStatus = 0;
3442 }
3443
3444 actor->koStatus = 0;
3445 actor->koDuration = 0;
3447 actor->attackBoost = 0;
3448 actor->defenseBoost = 0;
3449 actor->isGlowing = false;
3450
3451 return ApiStatus_DONE2;
3452}
s32 dispatch_damage_event_actor_1(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:876
void dispatch_event_actor(Actor *actor, s32 event)
Definition 1A5830.c:102
HitResult calc_enemy_test_target(Actor *actor)
Definition 1A5830.c:127
void dispatch_event_general(Actor *actor, s32 event)
Definition 1A5830.c:23
f32 update_lerp_battle(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 1A5830.c:2075
s32 dispatch_damage_event_actor(Actor *actor, s32 damageAmount, s32 originalEvent, s32 stopMotion)
Definition 1A5830.c:807
void play_hit_sound(Actor *actor, f32 x, f32 y, f32 z, u32 hitSound)
Definition 1A5830.c:37
s32 StarPointMultiplier[]
Star Point multiplier, indexed by actor count.
Definition 1A5830.c:2686
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:872
s32 has_enchanted_part(Actor *actor)
Definition 1A5830.c:7
HitResult calc_enemy_damage_target(Actor *attacker)
Definition 1A5830.c:231
BSS s32 PopupMenu_SelectedIndex
s32 check_block_input(s32 buttonMask)
Definition action_cmd.c:537
struct EffectInstance * disableEffect
struct Evt * takeTurnScript
s32 idleScriptID
u32 * idleAnimations
s8 transparentStatus
EvtScript * handleEventSource
EvtScript * idleSource
f32 shadowScale
s16 lastDamageTaken
struct ActorBlueprint * actorBlueprint
s32 actorTypeData1[6]
s8 healthFraction
u8 footStepCounter
struct Evt * idleScript
s8 extraCoinBonus
ActorState state
s16 damageCounter
struct Evt * handleEventScript
struct ActorPart * partsTable
s32 takeTurnScriptID
s16 actorTypeData1b[2]
struct SelectableTarget targetData[24]
EvtScript * handlePhaseSource
s16 targetActorID
s32 b32
Vec2bu size
s32 handleEventScriptID
s16 hudElementDataIndex
ActorMovement fly
EvtScript * takeTurnSource
Vec3f curPos
s16 hpChangeCounter
Bytecode EvtScript[]
struct ActorPart * nextPart
s8 staticDuration
s32 * statusTable
s8 debuffDuration
u32 AnimID
s8 transparentDuration
union Evt::@10 owner1
Initially -1.
#define sfx_play_sound_at_position
#define sqrtf
#define sin_deg
#define rand_int
#define atan2
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
#define ASSERT(condition)
@ ACTION_RATING_NICE
sets nice hits = 1
Definition enums.h:2005
@ ACTOR_CLASS_ENEMY
Definition enums.h:2112
@ ACTOR_CLASS_PLAYER
Definition enums.h:2110
@ ACTOR_CLASS_PARTNER
Definition enums.h:2111
@ ACTOR_CLASS_MASK
Definition enums.h:2113
@ BUTTON_A
Definition enums.h:2776
@ IMGFX_CLEAR
Definition enums.h:4702
@ GLOW_PAL_OFF
Definition enums.h:2244
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3627
@ BS_FLAGS1_NO_RATING
Definition enums.h:3610
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3626
@ BS_FLAGS1_SUPER_HIT
Definition enums.h:3612
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3623
@ BS_FLAGS1_PLAYER_DEFENDING
Definition enums.h:3624
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3609
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3608
@ BS_FLAGS1_ATK_BLOCKED
Definition enums.h:3633
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3604
@ HIT_SOUND_NORMAL
Definition enums.h:2220
@ HIT_SOUND_FIRE
Definition enums.h:2221
@ HIT_SOUND_SHOCK
Definition enums.h:2223
@ HIT_SOUND_BONES
Definition enums.h:2219
@ HIT_SOUND_ICE
Definition enums.h:2222
@ HIT_SOUND_MISS
Definition enums.h:2218
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
Definition enums.h:3420
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
Definition enums.h:3409
@ ACTOR_EVENT_FLAG_BURIED
Actor can only by hit by quake-element attacks.
Definition enums.h:3413
@ ACTOR_EVENT_FLAG_FLIPABLE
Actor can be flipped; triggered by jump and quake attacks.
Definition enums.h:3414
@ ACTOR_EVENT_FLAG_EXPLODE_ON_IGNITION
Blast and fire attacks trigger an explosion.
Definition enums.h:3411
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
Definition enums.h:3408
@ ACTOR_EVENT_FLAG_ENCHANTED
Actor glows and listens for the Star Beam event.
Definition enums.h:3419
@ ITEM_SPAWN_MODE_TOSS_FADE3
Definition enums.h:2302
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2300
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3651
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_TURN_MOD_PARALYZE
Definition enums.h:2839
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_TURN_MOD_SLEEP
Definition enums.h:2833
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2837
@ STATUS_TURN_MOD_UNUSED
Definition enums.h:2836
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2815
@ STATUS_KEY_STATIC
Definition enums.h:2812
@ STATUS_KEY_KO
Definition enums.h:2814
@ STATUS_TURN_MOD_POISON
Definition enums.h:2838
@ STATUS_TURN_MOD_STOP
Definition enums.h:2842
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_UNUSED
Definition enums.h:2804
@ STATUS_KEY_STONE
Definition enums.h:2813
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_TURN_MOD_STONE
Definition enums.h:2841
@ STATUS_TURN_MOD_FROZEN
Definition enums.h:2835
@ STATUS_KEY_SHRINK
Definition enums.h:2811
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ STATUS_KEY_POISON
Definition enums.h:2810
@ STATUS_TURN_MOD_STATIC
Definition enums.h:2834
@ STATUS_TURN_MOD_SHRINK
Definition enums.h:2840
HitResult
Definition enums.h:1974
@ HIT_RESULT_HIT_STATIC
Definition enums.h:1983
@ HIT_RESULT_BACKFIRE
Definition enums.h:1975
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1978
@ HIT_RESULT_HIT
Definition enums.h:1976
@ HIT_RESULT_LUCKY
Definition enums.h:1981
@ HIT_RESULT_IMMUNE
Definition enums.h:1984
@ HIT_RESULT_MISS
Definition enums.h:1982
@ SUPPRESS_EVENT_SHOCK_CONTACT
Definition enums.h:2937
@ EASING_SIN_OUT
Definition enums.h:521
@ EASING_COS_IN
Definition enums.h:522
@ EASING_CUBIC_IN
Definition enums.h:512
@ EASING_CUBIC_OUT
Definition enums.h:515
@ EASING_QUARTIC_IN
Definition enums.h:513
@ EASING_COS_BOUNCE
Definition enums.h:519
@ EASING_COS_SLOW_OVERSHOOT
Definition enums.h:517
@ EASING_QUADRATIC_IN
Definition enums.h:511
@ EASING_COS_IN_OUT
Definition enums.h:520
@ EASING_QUARTIC_OUT
Definition enums.h:516
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ EASING_LINEAR
Definition enums.h:510
@ EASING_COS_FAST_OVERSHOOT
Definition enums.h:518
@ IDLE_SCRIPT_RESTART
Definition enums.h:6000
@ IDLE_SCRIPT_ENABLE
Definition enums.h:5999
@ IDLE_SCRIPT_DISABLE
Definition enums.h:5998
@ STATUS_FLAG_STOP
Definition enums.h:2855
@ STATUS_FLAG_FROZEN
Definition enums.h:2848
@ STATUS_FLAG_STATIC
Definition enums.h:2847
@ STATUS_FLAG_SHRINK
Definition enums.h:2853
@ STATUS_FLAG_PARALYZE
Definition enums.h:2850
@ STATUS_FLAG_STONE
Definition enums.h:2854
@ STATUS_FLAG_DIZZY
Definition enums.h:2852
@ STATUS_FLAG_SLEEP
Definition enums.h:2846
@ STATUS_FLAG_POISON
Definition enums.h:2851
@ STATUS_FLAG_UNUSED
Definition enums.h:2849
@ DMG_SRC_DEFAULT
Definition enums.h:2014
@ ABILITY_BERSERKER
Definition enums.h:457
@ ABILITY_P_DOWN_D_UP
Definition enums.h:473
@ ABILITY_CLOSE_CALL
Definition enums.h:469
@ ABILITY_HEALTHY_HEALTHY
Definition enums.h:491
@ ABILITY_DEFEND_PLUS
Definition enums.h:463
@ ABILITY_DAMAGE_DODGE
Definition enums.h:487
@ ABILITY_LAST_STAND
Definition enums.h:468
@ ABILITY_P_UP_D_DOWN
Definition enums.h:470
@ ABILITY_FIRE_SHIELD
Definition enums.h:443
@ ABILITY_LUCKY_DAY
Definition enums.h:471
@ ABILITY_PRETTY_LUCKY
Definition enums.h:444
@ SOUND_IMMUNE
Definition enums.h:748
@ SOUND_DAMAGE_STARS
Definition enums.h:953
@ SOUND_INFLICT_STATUS
Definition enums.h:1358
@ SOUND_HIT_PLAYER_ICE
Definition enums.h:724
@ SOUND_HIT_PLAYER_SHOCK
Definition enums.h:1197
@ SOUND_NONE
Definition enums.h:550
@ SOUND_HIT_PLAYER_FIRE
Definition enums.h:723
@ SOUND_HIT_NORMAL
Definition enums.h:727
@ SOUND_SMACK_TREE
Definition enums.h:790
@ SOUND_HIT_SHOCK
Definition enums.h:1198
@ SOUND_HIT_ICE
Definition enums.h:729
@ SOUND_HIT_FIRE
Definition enums.h:728
@ SOUND_HIT_BONES
Definition enums.h:749
@ SOUND_HIT_PLAYER_NORMAL
Definition enums.h:722
@ SOUND_INFLICT_SLEEP
Definition enums.h:1357
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_SELF
Definition enums.h:2117
@ ACTOR_FLAG_FLYING
Quake Hammer can't hit.
Definition enums.h:3363
@ ACTOR_FLAG_NO_DMG_POPUP
Hide damage popup.
Definition enums.h:3375
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3372
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3365
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3374
@ SOUND_SPACE_DEFAULT
Definition enums.h:1740
@ ACTOR_BLUR_ENABLE
Definition enums.h:6005
@ ACTOR_BLUR_DISABLE
Definition enums.h:6004
@ EVENT_LUCKY
Definition enums.h:2205
@ EVENT_HIT
Definition enums.h:2165
@ EVENT_SPIN_SMASH_LAUNCH_HIT
Definition enums.h:2171
@ EVENT_BURN_HIT
Definition enums.h:2169
@ EVENT_FIRE_DEATH
Definition enums.h:2195
@ EVENT_IMMUNE
Definition enums.h:2179
@ EVENT_ZERO_DAMAGE
Definition enums.h:2177
@ EVENT_SHOCK_DEATH
Definition enums.h:2192
@ EVENT_EXPLODE_TRIGGER
Definition enums.h:2188
@ EVENT_BLOCK
Definition enums.h:2180
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2187
@ EVENT_18
Definition enums.h:2178
@ EVENT_HIT_COMBO
Definition enums.h:2164
@ EVENT_DEATH
Definition enums.h:2186
@ EVENT_SPIN_SMASH_LAUNCH_DEATH
Definition enums.h:2191
@ EVENT_FLIP_TRIGGER
Definition enums.h:2168
@ EVENT_SHOCK_HIT
Definition enums.h:2198
@ ACTOR_PART_FLAG_DAMAGE_IMMUNE
electrified Plays extra hurt SFX?
Definition enums.h:3392
@ DAMAGE_TYPE_POW
Definition enums.h:2895
@ DAMAGE_TYPE_4000
Definition enums.h:2899
@ DAMAGE_TYPE_ICE
Definition enums.h:2888
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2914
@ DAMAGE_TYPE_SMASH
Definition enums.h:2891
@ DAMAGE_TYPE_UNBLOCKABLE
Definition enums.h:2909
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2911
@ DAMAGE_TYPE_MAGIC
Definition enums.h:2889
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2890
@ DAMAGE_TYPE_BLAST
Definition enums.h:2894
@ DAMAGE_TYPE_FIRE
Definition enums.h:2886
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2915
@ DAMAGE_TYPE_QUAKE
Definition enums.h:2896
@ DAMAGE_TYPE_JUMP
Definition enums.h:2892
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2912
@ DAMAGE_TYPE_MULTIPLE_POPUPS
Definition enums.h:2913
@ DAMAGE_TYPE_WATER
Definition enums.h:2887
@ EVT_PRIORITY_A
Definition evt.h:154
#define ApiStatus_DONE2
Definition evt.h:119
s32 Bytecode
Definition evt.h:7
#define ApiStatus_FINISH
Definition evt.h:121
#define ApiStatus_DONE1
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:117
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:162
void show_primary_damage_popup(f32 x, f32 y, f32 z, s32 attack, s32 a)
Definition 190B20.c:1999
void enable_actor_blur(Actor *)
s32 does_script_exist_by_ref(Evt *script)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2495
void show_immune_bonk(f32 x, f32 y, f32 z, s32, s32, s32)
void remove_status_debuff(s32)
void resume_all_script(s32 id)
void disable_actor_blur(Actor *)
void add_xz_vec3f_copy1(Vec3f *vector, f32 speed, f32 angleDeg)
Definition 190B20.c:880
void hide_actor_health_bar(Actor *)
Definition 190B20.c:2240
void show_actor_health_bar(Actor *)
Definition 190B20.c:2235
void remove_status_static(s32)
void clear_part_pal_adjustment(ActorPart *)
Definition 190B20.c:2348
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz)
Definition 43F0.c:677
Evt * get_script_by_index(s32 index)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1887
f32 cos_rad(f32 x)
Definition 43F0.c:717
void remove_status_transparent(s32)
void dispatch_event_player(s32)
Definition dmg_player.c:131
void set_actor_flash_mode(Actor *actor, s32 arg1)
Definition 190B20.c:2426
void show_damage_fx(Actor *actor, f32 x, f32 y, f32 z, s32 damage)
Definition 190B20.c:2064
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void cancel_action_rating_combo(Actor *)
Definition 190B20.c:2169
void add_xz_vec3f(Vec3f *vector, f32 speed, f32 angleDeg)
Definition 190B20.c:871
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:1814
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:923
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558
void set_actor_glow_pal(Actor *actor, s32 arg1)
Definition 190B20.c:2384
void show_next_damage_popup(f32 x, f32 y, f32 z, s32 damageAmount, s32 angle)
Definition 190B20.c:2025
s32 get_defense(Actor *actor, s32 *defenseTable, s32 elementFlags)
Definition 190B20.c:1949
void add_xz_vec3f_copy2(Vec3f *vector, f32 speed, f32 angleDeg)
Definition 190B20.c:889
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:737
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void kill_script_by_ID(s32 id)
void reset_actor_blur(Actor *)
void play_movement_dust_effects(s32 var0, f32 xPos, f32 yPos, f32 zPos, f32 angleDeg)
Definition 190B20.c:898
void force_disable_actor_blur(Actor *)
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2311
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1970
void btl_delete_actor(Actor *actor)
Definition 16C8E0.c:1040
f32 sin_rad(f32 x)
Definition 43F0.c:713
void suspend_all_script(s32 id)
void apply_shock_effect(Actor *)
s32 make_item_entity_delayed(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 pickupVar)
void show_action_rating(s32, Actor *, f32, f32, f32)
Definition 190B20.c:2090
s32 try_inflict_status(Actor *, s32, s32)
Definition 190B20.c:2262
s32 inflict_partner_ko(Actor *target, s32 statusTypeKey, s32 duration)
Definition 190B20.c:1933
Evt * restart_script(Evt *script)
void dispatch_event_partner(s32)
Definition dmg_partner.c:7
EvtScript EVS_PlayStopHitFX
Definition dmg_player.c:109
EvtScript EVS_PlayFreezeHitFX
Definition dmg_player.c:115
EvtScript EVS_PlayShrinkHitFX
Definition dmg_player.c:125
EvtScript EVS_PlayParalyzeHitFX
Definition dmg_player.c:97
EvtScript EVS_PlayPoisonHitFX
Definition dmg_player.c:103
EvtScript EVS_PlaySleepHitFX
Definition dmg_player.c:85
EvtScript EVS_PlayDizzyHitFX
Definition dmg_player.c:91
EncounterStatus gCurrentEncounter
Definition encounter.c:175
void snd_stop_sound(s32 soundID)
#define PI_D
Definition macros.h:138
#define QUART(x)
Definition macros.h:179
#define EVT_IGNORE_ARG
Definition macros.h:47
#define STATUS_KEY_NEVER
Definition macros.h:234
#define CUBE(x)
Definition macros.h:178
#define SQ(x)
Definition macros.h:177
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1238
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14