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 != NULL) {
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 != NULL) {
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 != NULL) {
119 actor->takeTurnScript = NULL;
120 }
121
122 if (handleEventScript != NULL) {
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 == NULL) {
143 return HIT_RESULT_HIT;
144 }
145
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;
242 b32 isFire = FALSE;
243 b32 isWater = FALSE;
244 b32 isIce = 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 == NULL) {
262 return HIT_RESULT_HIT;
263 }
264
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) {
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 {
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 {
604 }
608 }
612 }
616 }
620 }
624 }
628 }
632 }
636 }
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 hpChangeCounter;
815 s32 new_var;
816
817 battleStatus->curAttackDamage = damageAmount;
819 actor->hpChangeCounter += hpChange;
820 new_var = actor->hpChangeCounter;
822 actor->damageCounter += hpChange;
823 actor->hpChangeCounter -= hpChange;
824 battleStatus->lastAttackDamage = 0;
825 actor->curHP -= hpChange;
826
827 if (actor->curHP <= 0) {
829 battleStatus->lastAttackDamage += actor->curHP;
830 actor->curHP = 0;
831 }
832
833 battleStatus->lastAttackDamage += hpChange;
834 actor->lastDamageTaken = battleStatus->lastAttackDamage;
835 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
839 }
842 }
843 }
844 if (dispatchEvent == EVENT_DEATH) {
847 }
850 }
851 }
852
853 if (!stopMotion) {
855
856 if (func_80263230(actor, actor) != 0) {
857 show_next_damage_popup(actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage, 0);
858 show_damage_fx(actor, actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage);
859 }
861
862 } else {
863 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
864 show_damage_fx(actor, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
865 }
866
867 if (battleStatus->lastAttackDamage > 0) {
868 set_actor_flash_mode(actor, 1);
869 }
872 return 0;
873}
874
878
882
883API_CALLABLE(BindTakeTurn) {
884 Bytecode* args = script->ptrReadPos;
885 s32 actorID = evt_get_variable(script, *args++);
886 EvtScript* takeTurnScript;
887
888 if (actorID == ACTOR_SELF) {
889 actorID = script->owner1.actorID;
890 }
891
892 takeTurnScript = (EvtScript*) evt_get_variable(script, *args++);
893 get_actor(actorID)->takeTurnSource = takeTurnScript;
894 return ApiStatus_DONE2;
895}
896
897API_CALLABLE(PauseTakeTurn) {
898 Bytecode* args = script->ptrReadPos;
899 s32 actorID = evt_get_variable(script, *args++);
900
901 if (actorID == ACTOR_SELF) {
902 actorID = script->owner1.actorID;
903 }
904
905 evt_get_variable(script, *args++);
906 suspend_all_script(get_actor(actorID)->takeTurnScriptID);
907 return ApiStatus_DONE2;
908}
909
910API_CALLABLE(ResumeTakeTurn) {
911 Bytecode* args = script->ptrReadPos;
912 s32 actorID = evt_get_variable(script, *args++);
913
914 if (actorID == ACTOR_SELF) {
915 actorID = script->owner1.actorID;
916 }
917
918 evt_get_variable(script, *args++);
919 resume_all_script(get_actor(actorID)->takeTurnScriptID);
920 return ApiStatus_DONE2;
921}
922
923API_CALLABLE(BindIdle) {
924 Bytecode* args = script->ptrReadPos;
925 s32 actorID = evt_get_variable(script, *args++);
927 Actor* actor;
929
930 if (actorID == ACTOR_SELF) {
931 actorID = script->owner1.actorID;
932 }
933
935 actor = get_actor(actorID);
936
937 if (actor->idleScript != 0) {
939 actor->idleScript = 0;
940 }
941
942 actor->idleSource = idleCode;
945 actor->idleScriptID = newScriptContext->id;
946 newScriptContext->owner1.actorID = actorID;
947 return ApiStatus_DONE2;
948}
949
950API_CALLABLE(EnableIdleScript) {
951 Bytecode* args = script->ptrReadPos;
952 s32 actorID = evt_get_variable(script, *args++);
953 s32 var1;
954 Actor* actor;
955
956 if (actorID == ACTOR_SELF) {
957 actorID = script->owner1.actorID;
958 }
959
960 var1 = evt_get_variable(script, *args++);
961 actor = get_actor(actorID);
962
963 if (actor->idleScript != NULL) {
964 switch (var1) {
968 break;
971 break;
974 break;
975 }
976 }
977
978 return ApiStatus_DONE2;
979}
980
981API_CALLABLE(BindHandleEvent) {
982 Bytecode* args = script->ptrReadPos;
983 s32 actorID = evt_get_variable(script, *args++);
984 EvtScript* src;
985
986 if (actorID == ACTOR_SELF) {
987 actorID = script->owner1.actorID;
988 }
989
990 src = (EvtScript*) evt_get_variable(script, *args++);
991 get_actor(actorID)->handleEventSource = src;
992 return ApiStatus_DONE2;
993}
994
995API_CALLABLE(BindHandlePhase) {
996 Bytecode* args = script->ptrReadPos;
997 s32 actorID = evt_get_variable(script, *args++);
998 EvtScript* src;
999
1000 if (actorID == ACTOR_SELF) {
1001 actorID = script->owner1.actorID;
1002 }
1003
1004 src = (EvtScript*) evt_get_variable(script, *args++);
1005 get_actor(actorID)->handlePhaseSource = src;
1006 return ApiStatus_DONE2;
1007}
1008
1009API_CALLABLE(JumpToGoal) {
1010 Bytecode* args = script->ptrReadPos;
1011 Actor* actor;
1013 s32 actorID;
1014 f32 posX, posY, posZ;
1015 f32 goalX, goalY, goalZ;
1016 f32 moveDist;
1017
1018 if (isInitialCall) {
1019 script->functionTemp[0] = 0;
1020 }
1021
1022 if (script->functionTemp[0] == 0) {
1023 actorID = evt_get_variable(script, *args++);
1024 if (actorID == ACTOR_SELF) {
1025 actorID = script->owner1.enemyID;
1026 }
1027 script->functionTempPtr[1] = actor = get_actor(actorID);
1028 actorState = &actor->state;
1030 script->functionTemp[2] = evt_get_variable(script, *args++);
1031 script->functionTemp[3] = 0;
1032 if (evt_get_variable(script, *args++) != 0) {
1033 script->functionTemp[3] |= 1;
1034 }
1035 if (evt_get_variable(script, *args++) != 0) {
1036 script->functionTemp[3] |= 2;
1037 }
1038
1039 actorState->curPos.x = actor->curPos.x;
1040 actorState->curPos.y = actor->curPos.y;
1041 actorState->curPos.z = actor->curPos.z;
1042
1043 posX = actorState->curPos.x;
1044 posY = actorState->curPos.y;
1045 posZ = actorState->curPos.z;
1046 goalX = actorState->goalPos.x;
1047 goalY = actorState->goalPos.y;
1048 goalZ = actorState->goalPos.z;
1049 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1050 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1051
1052 // make relative
1053 posX = (goalX - posX);
1054 posY = (goalY - posY);
1055 posZ = (goalZ - posZ);
1056
1057 if (actorState->moveTime == 0) {
1058 actorState->moveTime = actorState->dist / actorState->speed;
1059 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1060 } else {
1061 actorState->speed = actorState->dist / actorState->moveTime;
1062 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1063 }
1064
1065 if (actorState->moveTime == 0) {
1066 return ApiStatus_DONE2;
1067 }
1068
1069 actorState->vel = (actorState->acceleration * actorState->moveTime * 0.5f) + (posY / actorState->moveTime);
1070 actorState->speed += (moveDist / actorState->moveTime);
1071
1072 if (script->functionTemp[2] != 0) {
1073 set_actor_anim(actor->actorID, (s8) actor->state.jumpPartIndex, actor->state.animJumpRise);
1074 }
1075 if (!(script->functionTemp[3] & 2) && (actor->actorTypeData1[4] != 0)) {
1077 }
1078 script->functionTemp[0] = 1;
1079 }
1080
1081 actor = script->functionTempPtr[1];
1082 actorState = &actor->state;
1083
1084 actorState->curPos.y += actorState->vel;
1085 actorState->vel -= actorState->acceleration;
1086
1087 if ((script->functionTemp[2] != 0) && (actorState->vel < 0.0f)) {
1088 set_actor_anim(actor->actorID, (s8) actorState->jumpPartIndex, actorState->animJumpFall);
1089 }
1090 if (actorState->vel < 0.0f) {
1091 if (actorState->curPos.y < actorState->goalPos.y) {
1092 actorState->curPos.y = actorState->goalPos.y;
1093 }
1094 }
1095
1096 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1097 actor->curPos.x = actorState->curPos.x;
1098 actor->curPos.y = actorState->curPos.y;
1099 actor->curPos.z = actorState->curPos.z;
1100
1101 actorState->moveTime--;
1102 if (actorState->moveTime > 0) {
1103 return ApiStatus_BLOCK;
1104 }
1105
1106 if (script->functionTemp[3] & 1) {
1107 play_movement_dust_effects(2, actorState->goalPos.x, actorState->goalPos.y, actorState->goalPos.z, actorState->angle);
1108 }
1109 actor->curPos.x = actorState->goalPos.x;
1110 actor->curPos.y = actorState->goalPos.y;
1111 actor->curPos.z = actorState->goalPos.z;
1112 if (script->functionTemp[2] != 0) {
1113 set_actor_anim(actor->actorID, (s8) actorState->jumpPartIndex, actorState->animJumpLand);
1114 }
1115 return ApiStatus_DONE1;
1116}
1117
1118API_CALLABLE(IdleJumpToGoal) {
1119 Bytecode* args = script->ptrReadPos;
1120 Actor* actor;
1121 ActorMovement* movement;
1122 f32 posX, posY, posZ;
1123 f32 goalX, goalY, goalZ;
1124 f32 moveDist;
1125
1126 if (isInitialCall) {
1127 script->functionTemp[0] = FALSE;
1128 }
1129
1130 if (!script->functionTemp[0]) {
1131 s32 actorID = evt_get_variable(script, *args++);
1132
1133 if (actorID == ACTOR_SELF) {
1134 actorID = script->owner1.actorID;
1135 }
1136
1137 script->functionTempPtr[1] = actor = get_actor(actorID);
1138 movement = &actor->fly;
1139
1140 actor->fly.flyTime = evt_get_variable(script, *args++);
1141 script->functionTemp[2] = evt_get_variable(script, *args++);
1142 script->functionTemp[3] = evt_get_variable(script, *args++);
1143
1144 movement->curPos.x = actor->curPos.x;
1145 movement->curPos.y = actor->curPos.y;
1146 movement->curPos.z = actor->curPos.z;
1147
1148 posX = movement->curPos.x;
1149 posY = movement->curPos.y;
1150 posZ = movement->curPos.z;
1151 goalX = movement->goalPos.x;
1152 goalY = movement->goalPos.y;
1153 goalZ = movement->goalPos.z;
1154 movement->angle = atan2(posX, posZ, goalX, goalZ);
1155 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1156
1157 // make relative
1158 posX = (goalX - posX);
1159 posY = (goalY - posY);
1160 posZ = (goalZ - posZ);
1161
1162 if (movement->flyTime == 0) {
1163 movement->flyTime = movement->dist / movement->speed;
1164 moveDist = movement->dist - (movement->flyTime * movement->speed);
1165 } else {
1166 movement->speed = movement->dist / movement->flyTime;
1167 moveDist = movement->dist - (movement->flyTime * movement->speed);
1168 }
1169
1170 if (movement->flyTime == 0) {
1171 return ApiStatus_DONE2;
1172 }
1173
1174 movement->vel = (movement->acceleration * movement->flyTime * 0.5f) + (posY / movement->flyTime);
1175 movement->speed += moveDist / movement->flyTime;
1176 script->functionTemp[0] = TRUE;
1177 }
1178
1179 actor = script->functionTempPtr[1];
1180 movement = &actor->fly;
1181
1182 movement->curPos.y += movement->vel;
1183 movement->vel -= movement->acceleration;
1184 if (movement->vel < 0.0f && movement->goalPos.y > movement->curPos.y) {
1185 movement->curPos.y = movement->goalPos.y;
1186 }
1187 add_xz_vec3f_copy2(&movement->curPos, movement->speed, movement->angle);
1188 actor->curPos.x = movement->curPos.x;
1189 actor->curPos.y = movement->curPos.y;
1190 actor->curPos.z = movement->curPos.z;
1191
1192 movement->flyTime--;
1193 if (movement->flyTime <= 0) {
1194 if (script->functionTemp[3] != 0) {
1195 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1196 }
1197 actor->curPos.x = movement->goalPos.x;
1198 actor->curPos.y = movement->goalPos.y;
1199 actor->curPos.z = movement->goalPos.z;
1200 return ApiStatus_DONE1;
1201 }
1202
1203 return ApiStatus_BLOCK;
1204}
1205
1206API_CALLABLE(JumpToGoalSimple2) {
1207 Bytecode* args = script->ptrReadPos;
1208 ActorState* state;
1209 f32 posX, posY, posZ;
1210 f32 goalX, goalY, goalZ;
1211 f32 moveDist;
1212 Actor* actor;
1213
1214 if (isInitialCall) {
1215 script->functionTemp[0] = FALSE;
1216 }
1217
1218 if (!script->functionTemp[0]) {
1219 s32 actorID = evt_get_variable(script, *args++);
1220
1221 if (actorID == ACTOR_SELF) {
1222 actorID = script->owner1.actorID;
1223 }
1224
1225 script->functionTempPtr[1] = actor = get_actor(actorID);
1226 state = &actor->state;
1227
1228 state->moveTime = evt_get_variable(script, *args++);
1229 state->curPos.x = actor->curPos.x;
1230 state->curPos.y = actor->curPos.y;
1231 state->curPos.z = actor->curPos.z;
1232
1233 posX = state->curPos.x;
1234 posY = state->curPos.y;
1235 posZ = state->curPos.z;
1236 goalX = state->goalPos.x;
1237 goalY = state->goalPos.y;
1238 goalZ = state->goalPos.z;
1239 state->angle = atan2(posX, posZ, goalX, goalZ);
1240 state->dist = dist2D(posX, posZ, goalX, goalZ);
1241
1242 // make relative (note: negated)
1243 posX = (posX - goalX);
1244 posY = (posY - goalY);
1245 posZ = (posZ - goalZ);
1246
1247 if (state->moveTime == 0) {
1248 state->moveTime = state->dist / state->speed;
1249 moveDist = state->dist - (state->moveTime * state->speed);
1250 } else {
1251 state->speed = state->dist / state->moveTime;
1252 moveDist = state->dist - (state->moveTime * state->speed);
1253 }
1254
1255 if (state->moveTime == 0) {
1256 return ApiStatus_DONE2;
1257 }
1258
1259 state->vel = ((state->acceleration * state->moveTime) * 0.5f) + (posY / state->moveTime);
1260 state->speed += moveDist / state->moveTime;
1261 if (actor->actorTypeData1[4] != 0) {
1263 }
1264 script->functionTemp[0] = TRUE;
1265 }
1266
1267 actor = script->functionTempPtr[1];
1268 state = &actor->state;
1269
1270 state->curPos.y -= state->vel;
1271 state->vel -= state->acceleration;
1272 if (state->vel > 0.0f && state->goalPos.y < state->curPos.y) {
1273 state->curPos.y = state->goalPos.y;
1274 }
1275 add_xz_vec3f(&state->curPos, state->speed, state->angle);
1276 actor->curPos.x = state->curPos.x;
1277 actor->curPos.y = state->curPos.y;
1278 actor->curPos.z = state->curPos.z;
1279
1280 state->moveTime--;
1281 if (state->moveTime <= 0) {
1282 play_movement_dust_effects(2, state->goalPos.x, state->goalPos.y, state->goalPos.z, state->angle);
1283 actor->curPos.x = state->goalPos.x;
1284 actor->curPos.y = state->goalPos.y;
1285 actor->curPos.z = state->goalPos.z;
1286 return ApiStatus_DONE1;
1287 }
1288
1289 return ApiStatus_BLOCK;
1290}
1291
1292API_CALLABLE(JumpWithBounce) {
1293 Bytecode* args = script->ptrReadPos;
1294 Actor* actor;
1296 s32 actorID;
1297 f32 posX, posY, posZ;
1298 f32 goalX, goalY, goalZ;
1299 f32 moveDist;
1300
1301 if (isInitialCall) {
1302 script->functionTemp[0] = FALSE;
1303 }
1304
1305 if (!script->functionTemp[0]) {
1306 actorID = evt_get_variable(script, *args++);
1307 if (actorID == ACTOR_SELF) {
1308 actorID = script->owner1.enemyID;
1309 }
1310 script->functionTempPtr[1] = actor = get_actor(actorID);
1311 actorState = &actor->state;
1312
1314 actorState->bounceDivisor = evt_get_float_variable(script, *args++);
1315
1316 actorState->curPos.x = actor->curPos.x;
1317 actorState->curPos.y = actor->curPos.y;
1318 actorState->curPos.z = actor->curPos.z;
1319
1320 posX = actorState->curPos.x;
1321 posY = actorState->curPos.y;
1322 posZ = actorState->curPos.z;
1323 goalX = actorState->goalPos.x;
1324 goalZ = actorState->goalPos.z;
1325 goalY = actorState->goalPos.y;
1326 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1327 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1328
1329 // make relative
1330 posX = (goalX - posX);
1331 posY = (goalY - posY);
1332 posZ = (goalZ - posZ);
1333
1334 if (actorState->moveTime == 0) {
1335 actorState->moveTime = (s32) (actorState->dist / actorState->speed);
1336 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1337 } else {
1338 actorState->speed = actorState->dist / actorState->moveTime;
1339 moveDist = actorState->dist - (actorState->moveTime * actorState->speed);
1340 }
1341
1342 if (actorState->moveTime == 0) {
1343 return ApiStatus_DONE2;
1344 }
1345
1346 actorState->vel = (actorState->acceleration * actorState->moveTime * 0.5f) + (posY / actorState->moveTime);
1347 actorState->speed += moveDist / actorState->moveTime;
1348
1349 if (actor->actorTypeData1[4] != 0) {
1351 }
1352 script->functionTemp[0] = TRUE;
1353 }
1354
1355 actor = script->functionTempPtr[1];
1356 actorState = &actor->state;
1357
1358 switch (script->functionTemp[0]) {
1359 case 1:
1360 actorState->curPos.y += actorState->vel;
1361 actorState->vel -= actorState->acceleration;
1362 if ((actorState->vel < 0.0f) && (actorState->curPos.y < actorState->goalPos.y)) {
1363 actorState->acceleration = -actorState->acceleration;
1364 actorState->vel /= actorState->bounceDivisor;
1365 script->functionTemp[0] = 2;
1366 }
1367 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1368 break;
1369 case 2:
1370 actorState->curPos.y += actorState->vel;
1371 actorState->vel -= actorState->acceleration;
1372 if (actorState->vel > 0.0f) {
1373 if (actorState->goalPos.y < actorState->curPos.y) {
1374 actorState->curPos.y = actorState->goalPos.y;
1375 script->functionTemp[0] = 3;
1376 }
1377 }
1378 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1379 actor->curPos.x = actorState->curPos.x;
1380 actor->curPos.y = actorState->curPos.y;
1381 actor->curPos.z = actorState->curPos.z;
1382 break;
1383
1384 case 3:
1385 return ApiStatus_DONE2;
1386 }
1387
1388 actor->curPos.x = actorState->curPos.x;
1389 actor->curPos.y = actorState->curPos.y;
1390 actor->curPos.z = actorState->curPos.z;
1391 return ApiStatus_BLOCK;
1392}
1393
1394API_CALLABLE(LandJump) {
1395 Bytecode* args = script->ptrReadPos;
1396 Actor* actor;
1397
1398 if (isInitialCall) {
1399 script->functionTemp[0] = FALSE;
1400 }
1401
1402 if (!script->functionTemp[0]) {
1403 s32 actorID = evt_get_variable(script, *args++);
1404
1405 if (actorID == ACTOR_SELF) {
1406 actorID = script->owner1.actorID;
1407 }
1408
1409 actor = get_actor(actorID);
1410 script->functionTempPtr[1] = actor;
1411 actor->state.curPos.x = actor->curPos.x;
1412 actor->state.curPos.y = actor->curPos.y;
1413 actor->state.curPos.z = actor->curPos.z;
1414 script->functionTemp[0] = TRUE;
1415 }
1416
1417 actor = script->functionTempPtr[1];
1418 actor->state.curPos.y += actor->state.vel;
1419 actor->state.vel -= actor->state.acceleration;
1420
1421 add_xz_vec3f(&actor->state.curPos, actor->state.speed, actor->state.angle);
1422 actor->curPos.x = actor->state.curPos.x;
1423 actor->curPos.y = actor->state.curPos.y;
1424 actor->curPos.z = actor->state.curPos.z;
1425
1426 if (actor->curPos.y < 0.0f) {
1427 actor->curPos.y = 0.0f;
1428 play_movement_dust_effects(2, actor->curPos.x, actor->curPos.y, actor->curPos.z, actor->yaw);
1429 return ApiStatus_DONE1;
1430 }
1431
1432 return ApiStatus_BLOCK;
1433}
1434
1435API_CALLABLE(FallToGoal) {
1436 Bytecode* args = script->ptrReadPos;
1437 Actor* actor;
1438 ActorState* state;
1439 f32 posX, posY, posZ;
1440 f32 goalX, goalY, goalZ;
1441
1442 if (isInitialCall) {
1443 script->functionTemp[0] = 0;
1444 }
1445
1446 if (script->functionTemp[0] == 0) {
1447 s32 actorID = evt_get_variable(script, *args++);
1448
1449 if (actorID == ACTOR_SELF) {
1450 actorID = script->owner1.enemyID;
1451 }
1452 actor = get_actor(actorID);
1453 state = &actor->state;
1454 script->functionTempPtr[1] = actor;
1455
1456 actor->state.moveTime = evt_get_variable(script, *args++);
1457
1458 actor->state.curPos.x = actor->curPos.x;
1459 actor->state.curPos.y = actor->curPos.y;
1460 actor->state.curPos.z = actor->curPos.z;
1461
1462 posX = actor->state.curPos.x;
1463 posY = actor->state.curPos.y;
1464 posZ = actor->state.curPos.z;
1465 goalX = actor->state.goalPos.x;
1466 goalY = actor->state.goalPos.y;
1467 goalZ = actor->state.goalPos.z;
1468
1469 actor->state.angle = atan2(posX, posZ, goalX, goalZ);
1470 actor->state.dist = dist2D(posX, posZ, goalX, goalZ);
1471
1472 // make relative
1473 posX = (goalX - posX);
1474 posY = (goalY - posY);
1475 posZ = (goalZ - posZ);
1476
1477 if (actor->state.moveTime == 0) {
1478 actor->state.moveTime = actor->state.dist / actor->state.speed;
1479 } else {
1480 actor->state.speed = actor->state.dist / actor->state.moveTime;
1481 }
1482
1483 state->vel = 0.0f;
1484 state->acceleration = (posY / state->moveTime - state->vel) / (-state->moveTime * 0.5);
1485
1486 if (actor->actorTypeData1[4] != 0) {
1488 }
1489 script->functionTemp[0] = 1;
1490 }
1491
1492 actor = script->functionTempPtr[1];
1493 actor->state.curPos.y += actor->state.vel;
1494 actor->state.vel -= actor->state.acceleration;
1495 add_xz_vec3f(&actor->state.curPos, actor->state.speed, actor->state.angle);
1496 actor->curPos.x = actor->state.curPos.x;
1497 actor->curPos.y = actor->state.curPos.y;
1498 actor->curPos.z = actor->state.curPos.z;
1499 actor->state.moveTime--;
1500
1501 if (actor->state.moveTime <= 0) {
1502 play_movement_dust_effects(2, actor->state.goalPos.x, actor->state.goalPos.y, actor->state.goalPos.z, actor->state.angle);
1503 actor->curPos.x = actor->state.goalPos.x;
1504 actor->curPos.y = actor->state.goalPos.y;
1505 actor->curPos.z = actor->state.goalPos.z;
1506 return ApiStatus_DONE1;
1507 } else {
1508 return ApiStatus_BLOCK;
1509 }
1510}
1511
1512API_CALLABLE(RunToGoal) {
1513 Bytecode* args = script->ptrReadPos;
1514 Actor* actor;
1516 s32 actorID;
1517 f32 posX, posY, posZ;
1518 f32 goalX, goalY, goalZ;
1519
1520 if (isInitialCall) {
1521 script->functionTemp[0] = FALSE;
1522 }
1523
1524 if (!script->functionTemp[0]) {
1525 actorID = evt_get_variable(script, *args++);
1526 if (actorID == ACTOR_SELF) {
1527 actorID = script->owner1.enemyID;
1528 }
1529 script->functionTempPtr[1] = actor = get_actor(actorID);
1530 actorState = &actor->state;
1531
1533 script->functionTemp[2] = evt_get_variable(script, *args++);
1534
1535 actorState->curPos.x = actor->curPos.x;
1536 actorState->curPos.y = actor->curPos.y;
1537 actorState->curPos.z = actor->curPos.z;
1538
1539 goalX = actorState->goalPos.x;
1540 goalY = actorState->goalPos.y;
1541 goalZ = actorState->goalPos.z;
1542 posX = actorState->curPos.x;
1543 posY = actorState->curPos.y;
1544 posZ = actorState->curPos.z;
1545
1546 actorState->unk_18.x = goalX;
1547 actorState->unk_18.y = goalY;
1548 actorState->unk_18.z = goalZ;
1549
1550 actorState->angle = atan2(posX, posZ, goalX, goalZ);
1551 actorState->dist = dist2D(posX, posZ, goalX, goalZ);
1552
1553 if (actorState->moveTime == 0) {
1554 actorState->moveTime = actorState->dist / actorState->speed;
1555 if (actorState->moveTime == 0) {
1556 actorState->moveTime = 1;
1557 }
1558 actorState->speed += (actorState->dist - (actorState->moveTime * actorState->speed)) / actorState->moveTime;
1559 } else {
1560 actorState->speed = actorState->dist / actorState->moveTime;
1561 }
1562
1563 if (actor->actorTypeData1b[0] >= 0) {
1564 actorState->dist = actor->actorTypeData1b[0] + 1;
1565 } else {
1566 actorState->dist = -(actor->actorTypeData1b[0] + 1);
1567 }
1568 if ((actor->actorTypeData1[0] != 0) && (actor->actorTypeData1[1] == 0)) {
1570 }
1571 script->functionTemp[0] = TRUE;
1572 }
1573
1574 actor = script->functionTempPtr[1];
1575 actorState = &actor->state;
1576
1577 add_xz_vec3f(&actorState->curPos, actorState->speed, actorState->angle);
1578 if (script->functionTemp[2] == 0) {
1579 if (actorState->speed < 4.0f) {
1580 play_movement_dust_effects(0, actorState->curPos.x, actorState->curPos.y, actorState->curPos.z, actorState->angle);
1581 } else {
1582 play_movement_dust_effects(1, actorState->curPos.x, actorState->curPos.y, actorState->curPos.z, actorState->angle);
1583 }
1584 }
1585 actor->curPos.x = actorState->curPos.x;
1586 actor->curPos.z = actorState->curPos.z;
1587
1588 if ((actor->actorTypeData1[0] != 0) && (actor->actorTypeData1[1] != 0)) {
1589 if (actor->actorTypeData1b[0] >= 0) {
1590 actorState->dist += actorState->speed;
1591 if (actor->actorTypeData1b[0] < actorState->dist) {
1592 actor->footStepCounter++;
1593 actorState->dist = 0.0f;
1594 if (actor->footStepCounter & 1) {
1595 if (actor->actorTypeData1[0] != 0) {
1597 }
1598 } else {
1599 if (actor->actorTypeData1[1] != 0) {
1601 }
1602 }
1603 }
1604 } else {
1605 actorState->dist += 1.0f;
1606 if (-actor->actorTypeData1b[0] <= actorState->dist) {
1607 actor->footStepCounter++;
1608 actorState->dist = 0.0f;
1609 if (actor->footStepCounter & 1) {
1610 if (actor->actorTypeData1[0] != 0) {
1612 }
1613 } else {
1614 if (actor->actorTypeData1[1] != 0) {
1616 }
1617 }
1618 }
1619 }
1620 }
1621
1622 actorState->moveTime--;
1623 if (actorState->moveTime > 0) {
1624 return ApiStatus_BLOCK;
1625 }
1626
1627 actor->curPos.x = actorState->unk_18.x;
1628 actor->curPos.z = actorState->unk_18.z;
1629 if (actor->actorTypeData1[0] != 0) {
1630 if (actor->actorTypeData1[1] == 0) {
1631 snd_stop_sound(actor->actorTypeData1[0]);
1632 }
1633 }
1634 return ApiStatus_DONE1;
1635}
1636
1637API_CALLABLE(IdleRunToGoal) {
1638 Bytecode* args = script->ptrReadPos;
1639 Actor* actor;
1640 ActorMovement* movement;
1641 f32 posX, posY, posZ;
1642 f32 goalX, goalY, goalZ;
1643 s32 actorID;
1644
1645 if (isInitialCall) {
1646 script->functionTemp[0] = FALSE;
1647 }
1648
1649 if (!script->functionTemp[0]) {
1650 actorID = evt_get_variable(script, *args++);
1651 if (actorID == ACTOR_SELF) {
1652 actorID = script->owner1.actorID;
1653 }
1654 script->functionTempPtr[1] = actor = get_actor(actorID);
1655 movement = &actor->fly;
1656
1657 movement->flyTime = evt_get_variable(script, *args++);
1658
1659 movement->curPos.x = actor->curPos.x;
1660 movement->curPos.y = actor->curPos.y;
1661 movement->curPos.z = actor->curPos.z;
1662
1663 goalX = movement->goalPos.x;
1664 goalY = movement->goalPos.y;
1665 goalZ = movement->goalPos.z;
1666
1667 posX = movement->curPos.x;
1668 posY = movement->curPos.y;
1669 posZ = movement->curPos.z;
1670
1671 movement->unk_18.x = goalX;
1672 movement->unk_18.y = goalY;
1673 movement->unk_18.z = goalZ;
1674
1675 movement->angle = atan2(posX, posZ, goalX, goalZ);
1676 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1677
1678 if (movement->flyTime == 0) {
1679 movement->flyTime = movement->dist / movement->speed;
1680 if (movement->flyTime == 0) {
1681 movement->flyTime = 1;
1682 }
1683 // this simplifies to: flyMotion->speed = flyMotion->distance / flyMotion->flyTime
1684 movement->speed += (movement->dist - movement->flyTime * movement->speed) / movement->flyTime;
1685 } else {
1686 movement->speed = movement->dist / movement->flyTime;
1687 }
1688
1689 if (actor->actorTypeData1b[0] >= 0) {
1690 movement->dist = actor->actorTypeData1b[0] + 1;
1691 } else {
1692 movement->dist = -(actor->actorTypeData1b[0] + 1);
1693 }
1694 script->functionTemp[0] = TRUE;
1695 }
1696
1697 actor = script->functionTempPtr[1];
1698 movement = &actor->fly;
1699
1700 add_xz_vec3f_copy2(&movement->curPos, movement->speed, movement->angle);
1701 if (movement->speed < 4.0f) {
1702 play_movement_dust_effects(0, movement->curPos.x, movement->curPos.y, movement->curPos.z, movement->angle);
1703 } else {
1704 play_movement_dust_effects(1, movement->curPos.x, movement->curPos.y, movement->curPos.z, movement->angle);
1705 }
1706 actor->curPos.x = movement->curPos.x;
1707 actor->curPos.z = movement->curPos.z;
1708
1709 movement->flyTime--;
1710 if (movement->flyTime > 0) {
1711 return ApiStatus_BLOCK;
1712 }
1713
1714 actor->curPos.x = movement->unk_18.x;
1715 actor->curPos.z = movement->unk_18.z;
1716 if (actor->actorTypeData1[0] != 0 && actor->actorTypeData1[1] == 0) {
1717 snd_stop_sound(actor->actorTypeData1[0]);
1718 }
1719 return ApiStatus_DONE1;
1720}
1721
1722API_CALLABLE(JumpPartTo) {
1723 Bytecode* args = script->ptrReadPos;
1724 Actor* actor;
1725 ActorPart* part;
1726 ActorPartMovement* movement;
1727 s32 actorID, partID;
1728 f32 posX, posY, posZ;
1729 f32 goalX, goalY, goalZ;
1730 f32 deltaDist;
1731
1732 if (isInitialCall) {
1733 script->functionTemp[0] = 0;
1734 }
1735
1736 if (script->functionTemp[0] == 0) {
1737 actorID = evt_get_variable(script, *args++);
1738 if (actorID == ACTOR_SELF) {
1739 actorID = script->owner1.actorID;
1740 }
1741 partID = evt_get_variable(script, *args++);
1742
1743 actor = get_actor(actorID);
1744 part = get_actor_part(actor, partID);
1745 script->functionTempPtr[1] = actor;
1746 script->functionTempPtr[2] = part;
1747 movement = part->movement;
1748
1749 posX = evt_get_variable(script, *args++);
1750 posY = evt_get_variable(script, *args++);
1751 posZ = evt_get_variable(script, *args++);
1752 movement->goalPos.x = posX;
1753 movement->goalPos.y = posY;
1754 movement->goalPos.z = posZ;
1755 movement->moveTime = evt_get_variable(script, *args++);
1756 script->functionTemp[3] = evt_get_variable(script, *args++);
1757
1758 goalX = movement->goalPos.x;
1759 goalY = movement->goalPos.y;
1760 goalZ = movement->goalPos.z;
1761
1762 movement->absolutePos.x = part->absolutePos.x;
1763 movement->absolutePos.y = part->absolutePos.y;
1764 movement->absolutePos.z = part->absolutePos.z;
1765
1766 posX = movement->absolutePos.x;
1767 posY = movement->absolutePos.y;
1768 posZ = movement->absolutePos.z;
1769
1770 movement->angle = atan2(posX, posZ, goalX, goalZ);
1771 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1772
1773 // make relative
1774 posX = (goalX - posX);
1775 posY = (goalY - posY);
1776 posZ = (goalZ - posZ);
1777
1778 if (movement->moveTime == 0) {
1779 movement->moveTime = movement->dist / movement->moveSpeed;
1780 deltaDist = movement->dist - movement->moveTime * movement->moveSpeed;
1781 } else {
1782 movement->moveSpeed = movement->dist / movement->moveTime;
1783 deltaDist = movement->dist - movement->moveTime * movement->moveSpeed;
1784 }
1785 movement->moveSpeed += deltaDist / movement->moveTime;
1786 movement->unk_2C = movement->jumpScale * movement->moveTime * 0.5f + posY / movement->moveTime;
1787 if (part->partTypeData[4] != 0) {
1788 sfx_play_sound_at_position(part->partTypeData[4], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
1789 }
1790 script->functionTemp[0] = 1;
1791 }
1792
1793 part = script->functionTempPtr[2];
1794 movement = part->movement;
1795 movement->absolutePos.y += movement->unk_2C;
1796 movement->unk_2C -= movement->jumpScale;
1797 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1798 part->absolutePos.x = movement->absolutePos.x;
1799 part->absolutePos.y = movement->absolutePos.y;
1800 part->absolutePos.z = movement->absolutePos.z;
1801 movement->moveTime--;
1802
1803 if (movement->moveTime <= 0) {
1804 if (script->functionTemp[3] != 0) {
1805 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1806 }
1807 part->absolutePos.x = movement->goalPos.x;
1808 part->absolutePos.y = movement->goalPos.y;
1809 part->absolutePos.z = movement->goalPos.z;
1810 return ApiStatus_DONE1;
1811 } else {
1812 return ApiStatus_BLOCK;
1813 }
1814}
1815
1816API_CALLABLE(FallPartTo) {
1817 Bytecode* args = script->ptrReadPos;
1818 Actor* actor;
1819 ActorPart* part;
1820 ActorPartMovement* movement;
1821 s32 actorID, partID;
1822 f32 posX, posY, posZ;
1823 f32 goalX, goalY, goalZ;
1824
1825 if (isInitialCall) {
1826 script->functionTemp[0] = 0;
1827 }
1828
1829 if (script->functionTemp[0] == 0) {
1830 actorID = evt_get_variable(script, *args++);
1831 if (actorID == ACTOR_SELF) {
1832 actorID = script->owner1.actorID;
1833 }
1834 partID = evt_get_variable(script, *args++);
1835
1836 actor = get_actor(actorID);
1837 part = get_actor_part(actor, partID);
1838 script->functionTempPtr[1] = actor;
1839 script->functionTempPtr[2] = part;
1840 movement = part->movement;
1841
1842 posX = evt_get_variable(script, *args++);
1843 posY = evt_get_variable(script, *args++);
1844 posZ = evt_get_variable(script, *args++);
1845 movement->goalPos.x = posX;
1846 movement->goalPos.y = posY;
1847 movement->goalPos.z = posZ;
1848 movement->moveTime = evt_get_variable(script, *args++);
1849
1850 goalX = movement->goalPos.x;
1851 goalY = movement->goalPos.y;
1852 goalZ = movement->goalPos.z;
1853
1854 movement->absolutePos.x = part->absolutePos.x;
1855 movement->absolutePos.y = part->absolutePos.y;
1856 movement->absolutePos.z = part->absolutePos.z;
1857
1858 posX = movement->absolutePos.x;
1859 posY = movement->absolutePos.y;
1860 posZ = movement->absolutePos.z;
1861
1862 movement->angle = atan2(posX, posZ, goalX, goalZ);
1863 movement->dist = dist2D(posX, posZ, goalX, goalZ);
1864
1865 // make relative
1866 posX = (goalX - posX);
1867 posY = (goalY - posY);
1868 posZ = (goalZ - posZ);
1869
1870 if (movement->moveTime == 0) {
1871 movement->moveTime = movement->dist / movement->moveSpeed;
1872 } else {
1873 movement->moveSpeed = movement->dist / movement->moveTime;
1874 }
1875
1876 movement->unk_2C = 0.0f;
1877 movement->jumpScale = (posY / movement->moveTime - movement->unk_2C) / (-movement->moveTime * 0.5);
1878 if (part->partTypeData[4] != 0) {
1879 sfx_play_sound_at_position(part->partTypeData[4], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
1880 }
1881 script->functionTemp[0] = 1;
1882 }
1883
1884 part = script->functionTempPtr[2];
1885 movement = part->movement;
1886 movement->absolutePos.y += movement->unk_2C;
1887 movement->unk_2C -= movement->jumpScale;
1888 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1889 part->absolutePos.x = movement->absolutePos.x;
1890 part->absolutePos.y = movement->absolutePos.y;
1891 part->absolutePos.z = movement->absolutePos.z;
1892 movement->moveTime--;
1893
1894 if (movement->moveTime <= 0) {
1895 play_movement_dust_effects(2, movement->goalPos.x, movement->goalPos.y, movement->goalPos.z, movement->angle);
1896 part->absolutePos.x = movement->goalPos.x;
1897 part->absolutePos.y = movement->goalPos.y;
1898 part->absolutePos.z = movement->goalPos.z;
1899 return ApiStatus_DONE1;
1900 } else {
1901 return ApiStatus_BLOCK;
1902 }
1903}
1904
1905API_CALLABLE(LandJumpPart) {
1906 Bytecode* args = script->ptrReadPos;
1907 Actor* actor;
1908 ActorPart* part;
1909 ActorPartMovement* movement;
1910
1911 if (isInitialCall) {
1912 script->functionTemp[0] = 0;
1913 }
1914
1915 if (script->functionTemp[0] == 0) {
1916 s32 actorID = evt_get_variable(script, *args++);
1917 s32 partID = evt_get_variable(script, *args++);
1918
1919 if (actorID == ACTOR_SELF) {
1920 actorID = script->owner1.actorID;
1921 }
1922
1923 actor = get_actor(actorID);
1924 part = get_actor_part(actor, partID);
1925 script->functionTempPtr[1] = actor;
1926 script->functionTempPtr[2] = part;
1927 movement = part->movement;
1928 movement->absolutePos.x = part->absolutePos.x;
1929 movement->absolutePos.y = part->absolutePos.y;
1930 movement->absolutePos.z = part->absolutePos.z;
1931 script->functionTemp[0] = 1;
1932 }
1933
1934 part = script->functionTempPtr[2];
1935 movement = part->movement;
1936 movement->absolutePos.y += movement->unk_2C;
1937 movement->unk_2C -= movement->jumpScale;
1938 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
1939 part->absolutePos.x = movement->absolutePos.x;
1940 part->absolutePos.y = movement->absolutePos.y;
1941 part->absolutePos.z = movement->absolutePos.z;
1942
1943 if (part->absolutePos.y < 0.0f) {
1944 part->absolutePos.y = 0.0f;
1945 play_movement_dust_effects(2, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z, part->yaw);
1946 return ApiStatus_DONE1;
1947 }
1948
1949 return ApiStatus_BLOCK;
1950}
1951
1952API_CALLABLE(RunPartTo) {
1953 Bytecode* args = script->ptrReadPos;
1954 Actor* actor;
1955 ActorPart* part;
1956 ActorPartMovement* movement;
1957 s32 actorID, partID;
1958 f32 posX, posY, posZ;
1959 f32 goalX, goalY, goalZ;
1960 f32 deltaDist;
1961
1962 if (isInitialCall) {
1963 script->functionTemp[0] = 0;
1964 }
1965
1966 if (script->functionTemp[0] == 0) {
1967 actorID = evt_get_variable(script, *args++);
1968 if (actorID == ACTOR_SELF) {
1969 actorID = script->owner1.actorID;
1970 }
1971 partID = evt_get_variable(script, *args++);
1972
1973 actor = get_actor(actorID);
1974 part = get_actor_part(actor, partID);
1975 script->functionTempPtr[1] = actor;
1976 script->functionTempPtr[2] = part;
1977 movement = part->movement;
1978
1979 posX = evt_get_variable(script, *args++);
1980 posY = evt_get_variable(script, *args++);
1981 posZ = evt_get_variable(script, *args++);
1982 movement->goalPos.x = posX;
1983 movement->goalPos.y = posY;
1984 movement->goalPos.z = posZ;
1985 movement->moveTime = evt_get_variable(script, *args++);
1986
1987 goalX = movement->goalPos.x;
1988 goalY = movement->goalPos.y;
1989 goalZ = movement->goalPos.z;
1990
1991 movement->absolutePos.x = part->absolutePos.x;
1992 movement->absolutePos.y = part->absolutePos.y;
1993 movement->absolutePos.z = part->absolutePos.z;
1994
1995 posX = movement->absolutePos.x;
1996 posY = movement->absolutePos.y;
1997 posZ = movement->absolutePos.z;
1998
1999 movement->angle = atan2(posX, posZ, goalX, goalZ);
2000 movement->dist = dist2D(posX, posZ, goalX, goalZ);
2001
2002 if (movement->moveTime == 0) {
2003 movement->moveTime = movement->dist / movement->moveSpeed;
2004 } else {
2005 movement->moveSpeed = movement->dist / movement->moveTime;
2006 }
2007 if (part->actorTypeData2b[0] >= 0) {
2008 movement->dist = part->actorTypeData2b[0] + 1;
2009 } else {
2010 movement->dist = -(part->actorTypeData2b[0] + 1);
2011 }
2012 if (part->partTypeData[0] != 0 && part->partTypeData[1] == 0) {
2013 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2014 }
2015 script->functionTemp[0] = 1;
2016 }
2017
2018 part = script->functionTempPtr[2];
2019 movement = part->movement;
2020 actor = script->functionTempPtr[1];
2021
2022 add_xz_vec3f_copy1(&movement->absolutePos, movement->moveSpeed, movement->angle);
2023 if (movement->moveSpeed < 4.0f) {
2024 play_movement_dust_effects(0, movement->absolutePos.x, movement->absolutePos.y, movement->absolutePos.z, movement->angle);
2025 } else {
2026 play_movement_dust_effects(1, movement->absolutePos.x, movement->absolutePos.y, movement->absolutePos.z, movement->angle);
2027 }
2028 part->absolutePos.x = movement->absolutePos.x;
2029 part->absolutePos.y = movement->absolutePos.y;
2030 part->absolutePos.z = movement->absolutePos.z;
2031
2032 if (part->partTypeData[0] != 0 && part->partTypeData[1] != 0) {
2033 if (part->actorTypeData2b[0] >= 0) {
2034 movement->dist += movement->moveSpeed;
2035 if (part->actorTypeData2b[0] < movement->dist) {
2036 actor->footStepCounter++;
2037 movement->dist = 0;
2038 if (actor->footStepCounter % 2 != 0) {
2039 if (part->partTypeData[0] != 0) {
2040 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2041 }
2042 } else {
2043 if (part->partTypeData[1] != 0) {
2044 sfx_play_sound_at_position(part->partTypeData[1], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2045 }
2046 }
2047 }
2048 } else {
2049 movement->dist += 1.0f;
2050 if (-part->actorTypeData2b[0] <= movement->dist) {
2051 actor->footStepCounter++;
2052 movement->dist = 0;
2053 if (actor->footStepCounter % 2 != 0) {
2054 if (part->partTypeData[0] != 0) {
2055 sfx_play_sound_at_position(part->partTypeData[0], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2056 }
2057 } else {
2058 if (part->partTypeData[1] != 0) {
2059 sfx_play_sound_at_position(part->partTypeData[1], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2060 }
2061 }
2062 }
2063 }
2064 }
2065
2066 movement->moveTime--;
2067 if (movement->moveTime > 0) {
2068 return ApiStatus_BLOCK;
2069 } else {
2070 part->absolutePos.x = movement->goalPos.x;
2071 part->absolutePos.z = movement->goalPos.z;
2072 if (part->partTypeData[0] != 0 && part->partTypeData[1] == 0) {
2073 snd_stop_sound(part->partTypeData[0]);
2074 }
2075 return ApiStatus_DONE1;
2076 }
2077}
2078
2080 s32 timeLeft;
2081 f32 absMag;
2082 f64 start1;
2083 f64 start2;
2084 f32 len1;
2085 f32 len2;
2086 f32 len3;
2087 f32 len4;
2088 f64 len5;
2089 f32 len6;
2090 f64 len7;
2091
2092 switch (easing) {
2093 case EASING_LINEAR:
2094 return start + (end - start) * elapsed / duration;
2096 return start + SQ(elapsed) * (end - start) / SQ(duration);
2097 case EASING_CUBIC_IN:
2098 return start + CUBE(elapsed) * (end - start) / CUBE(duration);
2099 case EASING_QUARTIC_IN:
2100 return start + QUART(elapsed) * (end - start) / QUART(duration);
2102 len1 = end - start;
2103 return end - (len1 * cos_rad(((f32)elapsed / duration) * PI_D * 4.0) * (duration - elapsed) *
2104 (duration - elapsed)) / SQ((f32)duration);
2106 len2 = end - start;
2107 return end - (len2 * cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 15.0) * (duration - elapsed) *
2108 (duration - elapsed)) / SQ((f32)duration);
2110 timeLeft = duration - elapsed;
2111 return start + (end - start) - ((SQ(timeLeft) * (end - start))) / SQ(duration);
2112 case EASING_CUBIC_OUT:
2113 len3 = end - start;
2114 timeLeft = duration - elapsed;
2115 return start + len3 - ((CUBE(timeLeft) * len3)) / CUBE(duration);
2116 case EASING_QUARTIC_OUT:
2117 len4 = end - start;
2118 timeLeft = duration - elapsed;
2119 return start + len4 - ((QUART(timeLeft) * len4)) / QUART(duration);
2120 case EASING_COS_BOUNCE:
2121 absMag = cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 40.0) * (duration - elapsed) *
2122 (duration - elapsed) / SQ((f32)duration);
2123 if (absMag < 0.0f) {
2124 absMag = -absMag;
2125 }
2126 return end - (end - start) * absMag;
2127 case EASING_COS_IN_OUT:
2128 len5 = end - start;
2129 start1 = start;
2130 return start1 + (len5 * (1.0 - cos_rad(((f32)elapsed * PI_D) / (f32)duration)) / 2);
2131 case EASING_SIN_OUT:
2132 len6 = end - start;
2133 return start + (len6 * sin_rad((((f32) elapsed) * (PI_D / 2)) / ((f32) duration)));
2134 case EASING_COS_IN:
2135 len7 = end - start;
2136 start2 = start;
2137 return start2 + (len7 * (1.0 - cos_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration)));
2138 }
2139
2140 return 0.0f;
2141}
2142
2143API_CALLABLE(FlyToGoal) {
2144 Bytecode* args = script->ptrReadPos;
2145 Actor* actor;
2147 s32 actorID;
2148 f32 posX, posY, posZ;
2149 f32 goalX, goalY, goalZ;
2151 f32 dist3D;
2152 f32 offsetY;
2153
2154 if (isInitialCall) {
2155 actorID = evt_get_variable(script, *args++);
2156 if (actorID == ACTOR_SELF) {
2157 actorID = script->owner1.enemyID;
2158 }
2159 script->functionTempPtr[1] = actor = get_actor(actorID);
2160 actorState = &actor->state;
2161
2163 actorState->moveArcAmplitude = evt_get_variable(script, *args++);
2164 script->functionTemp[3] = evt_get_variable(script, *args++);
2165 actorState->functionTemp[0] = FALSE;
2166
2167 if (script->functionTemp[3] >= 100) {
2168 script->functionTemp[3] -= 100;
2169 actorState->functionTemp[0] = TRUE;
2170 }
2171
2172 goalX = actorState->goalPos.x;
2173 goalY = actorState->goalPos.y;
2174 goalZ = actorState->goalPos.z;
2175
2176 posX = actor->curPos.x;
2177 posY = actor->curPos.y;
2178 posZ = actor->curPos.z;
2179
2180 deltaX = posX - goalX;
2181 deltaY = posY - goalY;
2182 deltaZ = posZ - goalZ;
2183
2184 actorState->curPos.x = posX;
2185 actorState->unk_18.x = posX;
2186 actorState->curPos.y = posY;
2187 actorState->unk_18.y = posY;
2188 actorState->curPos.z = posZ;
2189 actorState->unk_18.z = posZ;
2190
2191 actorState->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2192
2193 if (actorState->moveTime == 0) {
2194 actorState->moveTime = actorState->dist / actorState->speed;
2195 } else {
2196 actorState->speed = actorState->dist / actorState->moveTime;
2197 }
2198 if (actorState->moveTime == 0) {
2199 return ApiStatus_DONE2;
2200 }
2201
2202 actorState->bounceDivisor = 0.0f;
2203 actorState->angle = 0.0f;
2204 if (actor->actorTypeData1b[1] >= 0) {
2205 actorState->vel = actor->actorTypeData1b[1] + 1;
2206 } else {
2207 actorState->vel = -(actor->actorTypeData1b[1] + 1);
2208 }
2209 if ((actor->actorTypeData1[2] != 0) && (actor->actorTypeData1[3] == 0)) {
2211 }
2212 }
2213
2214 actor = script->functionTempPtr[1];
2215 actorState = &actor->state;
2216
2217 actorState->curPos.x = update_lerp_battle(script->functionTemp[3], actorState->unk_18.x, actorState->goalPos.x, actorState->bounceDivisor, actorState->moveTime);
2218 actorState->curPos.y = update_lerp_battle(script->functionTemp[3], actorState->unk_18.y, actorState->goalPos.y, actorState->bounceDivisor, actorState->moveTime);
2219 actorState->curPos.z = update_lerp_battle(script->functionTemp[3], actorState->unk_18.z, actorState->goalPos.z, actorState->bounceDivisor, actorState->moveTime);
2220 if ((actorState->functionTemp[0]) && (actorState->curPos.y < 0.0f)) {
2221 actorState->bounceDivisor = actorState->moveTime;
2222 actorState->goalPos.x = actorState->curPos.x;
2223 actorState->goalPos.y = 0.0f;
2224 actorState->goalPos.z = actorState->curPos.z;
2225 }
2226 actorState->bounceDivisor += 1.0f;
2227 if (actorState->moveTime < actorState->bounceDivisor) {
2228 actor->curPos.x = actorState->goalPos.x;
2229 actor->curPos.y = actorState->goalPos.y;
2230 actor->curPos.z = actorState->goalPos.z;
2231 if (actor->actorTypeData1[2] != 0) {
2232 if (actor->actorTypeData1[3] == 0) {
2233 snd_stop_sound(actor->actorTypeData1[2]);
2234 }
2235 }
2236 return ApiStatus_DONE2;
2237 }
2238 if ((actor->actorTypeData1[2] != 0) && (actor->actorTypeData1[3] != 0)) {
2239 if (actor->actorTypeData1b[1] >= 0) {
2240 actorState->vel += actorState->speed;
2241 if (actor->actorTypeData1b[1] < actorState->vel) {
2242 actor->footStepCounter++;
2243 actorState->vel = 0.0f;
2244 if (actor->footStepCounter & 1) {
2245 if (actor->actorTypeData1[2] != 0) {
2247 }
2248 } else {
2249 if (actor->actorTypeData1[3] != 0) {
2251 }
2252 }
2253 }
2254 } else {
2255 actorState->vel += 1.0f;
2256 if (-actor->actorTypeData1b[1] <= actorState->vel) {
2257 actor->footStepCounter++;
2258 actorState->vel = 0.0f;
2259 if (actor->footStepCounter & 1) {
2260 if (actor->actorTypeData1[2] != 0) {
2262 }
2263 } else {
2264 if (actor->actorTypeData1[3] != 0) {
2266 }
2267 }
2268 }
2269 }
2270 }
2271
2272 deltaX = actorState->goalPos.x - actorState->curPos.x;
2273 deltaY = actorState->goalPos.y - actorState->curPos.y;
2274 deltaZ = actorState->goalPos.z - actorState->curPos.z;
2275 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2276 if (dist3D == 0.0f) {
2277 dist3D = 1.0f;
2278 }
2279 if (actorState->dist == 0.0f) {
2280 actorState->dist = 1.0f;
2281 }
2282 offsetY = sin_deg((1.0 - (dist3D / actorState->dist)) * 180.0);
2283 if (actorState->moveArcAmplitude == 0) {
2284 offsetY = 0.0f;
2285 }
2286 if (actorState->moveArcAmplitude < 0) {
2287 offsetY = -offsetY * -actorState->moveArcAmplitude;
2288 }
2289 if (actorState->moveArcAmplitude > 0) {
2290 offsetY = offsetY * actorState->moveArcAmplitude;
2291 }
2292 actor->curPos.x = actorState->curPos.x;
2293 actor->curPos.y = actorState->curPos.y + offsetY;
2294 actor->curPos.z = actorState->curPos.z;
2295 return ApiStatus_BLOCK;
2296}
2297
2298API_CALLABLE(IdleFlyToGoal) {
2299 Bytecode* args = script->ptrReadPos;
2300 Actor* actor;
2301 ActorMovement* movement;
2302 s32 actorID;
2303 f32 posX, posY, posZ;
2304 f32 goalX, goalY, goalZ;
2306 f32 dist3D;
2307 f32 offsetY;
2308
2309 if (isInitialCall) {
2310 actorID = evt_get_variable(script, *args++);
2311 if (actorID == ACTOR_SELF) {
2312 actorID = script->owner1.enemyID;
2313 }
2314 script->functionTempPtr[1] = actor = get_actor(actorID);
2315 movement = &actor->fly;
2316
2317 movement->flyTime = evt_get_variable(script, *args++);
2318 movement->flyArcAmplitude = evt_get_variable(script, *args++);
2319 script->functionTemp[3] = evt_get_variable(script, *args++);
2320
2321 goalX = movement->goalPos.x;
2322 goalY = movement->goalPos.y;
2323 goalZ = movement->goalPos.z;
2324
2325 posX = actor->curPos.x;
2326 posY = actor->curPos.y;
2327 posZ = actor->curPos.z;
2328
2329 deltaX = posX - goalX;
2330 deltaY = posY - goalY;
2331 deltaZ = posZ - goalZ;
2332
2333 movement->curPos.x = posX;
2334 movement->unk_18.x = posX;
2335 movement->curPos.y = posY;
2336 movement->unk_18.y = posY;
2337 movement->curPos.z = posZ;
2338 movement->unk_18.z = posZ;
2339
2340 movement->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2341
2342 if (movement->flyTime == 0) {
2343 movement->flyTime = movement->dist / movement->speed;
2344 } else {
2345 movement->speed = movement->dist / movement->flyTime;
2346 }
2347 if (movement->flyTime == 0) {
2348 return ApiStatus_DONE2;
2349 }
2350
2351 movement->flyElapsed = 0.0f;
2352 movement->angle = 0.0f;
2353 movement->vel = 0.0f;
2354 }
2355
2356 actor = script->functionTempPtr[1];
2357 movement = &actor->fly;
2358
2359 movement->curPos.x = update_lerp_battle(script->functionTemp[3], movement->unk_18.x, movement->goalPos.x, movement->flyElapsed, movement->flyTime);
2360 movement->curPos.y = update_lerp_battle(script->functionTemp[3], movement->unk_18.y, movement->goalPos.y, movement->flyElapsed, movement->flyTime);
2361 movement->curPos.z = update_lerp_battle(script->functionTemp[3], movement->unk_18.z, movement->goalPos.z, movement->flyElapsed, movement->flyTime);
2362
2363 movement->flyElapsed += 1.0f;
2364 if (movement->flyTime < movement->flyElapsed) {
2365 actor->curPos.x = movement->goalPos.x;
2366 actor->curPos.y = movement->goalPos.y;
2367 actor->curPos.z = movement->goalPos.z;
2368 return ApiStatus_DONE2;
2369 }
2370
2371 deltaX = movement->goalPos.x - movement->curPos.x;
2372 deltaY = movement->goalPos.y - movement->curPos.y;
2373 deltaZ = movement->goalPos.z - movement->curPos.z;
2374 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2375 if (dist3D == 0.0f) {
2376 dist3D = 1.0f;
2377 }
2378 if (movement->dist == 0.0f) {
2379 movement->dist = 1.0f;
2380 }
2381
2382 offsetY = sin_deg((1.0 - (dist3D / movement->dist)) * 180.0);
2383 if (movement->flyArcAmplitude == 0) {
2384 offsetY = 0.0f;
2385 }
2386 if (movement->flyArcAmplitude < 0) {
2387 offsetY = -offsetY * -movement->flyArcAmplitude;
2388 }
2389 if (movement->flyArcAmplitude > 0) {
2390 offsetY = offsetY * movement->flyArcAmplitude;
2391 }
2392
2393 actor->curPos.x = movement->curPos.x;
2394 actor->curPos.y = movement->curPos.y + offsetY;
2395 actor->curPos.z = movement->curPos.z;
2396 return ApiStatus_BLOCK;
2397}
2398
2399API_CALLABLE(FlyPartTo) {
2400 Bytecode* args = script->ptrReadPos;
2401 Actor* actor;
2402 ActorPart* part;
2404 s32 actorID;
2405 s32 partID;
2406
2407 f32 posX, posY, posZ;
2408 f32 goalX, goalY, goalZ;
2410 f32 dist3D;
2411 f32 offsetY;
2412
2413 if (isInitialCall) {
2414 actorID = evt_get_variable(script, *args++);
2415 if (actorID == ACTOR_SELF) {
2416 actorID = script->owner1.actorID;
2417 }
2418 partID = evt_get_variable(script, *args++);
2419
2420 actor = get_actor(actorID);
2421 part = get_actor_part(actor, partID);
2422 script->functionTempPtr[1] = actor;
2423 script->functionTempPtr[2] = part;
2424 partMovement = part->movement;
2425
2426 partMovement->goalPos.x = evt_get_variable(script, *args++);
2427 partMovement->goalPos.y = evt_get_variable(script, *args++);
2428 partMovement->goalPos.z = evt_get_variable(script, *args++);
2429 partMovement->moveTime = evt_get_variable(script, *args++);
2430 partMovement->unk_3A = evt_get_variable(script, *args++);
2431 script->functionTemp[3] = evt_get_variable(script, *args++);
2432
2433 goalX = partMovement->goalPos.x;
2434 posX = part->absolutePos.x;
2435 deltaX = posX - goalX;
2436 partMovement->absolutePos.x = posX;
2437 partMovement->unk_18.x = posX;
2438
2439 goalY = partMovement->goalPos.y;
2440 posY = part->absolutePos.y;
2441 deltaY = posY - goalY;
2442 partMovement->absolutePos.y = posY;
2443 partMovement->unk_18.y = posY;
2444
2445 goalZ = partMovement->goalPos.z;
2446 posZ = part->absolutePos.z;
2447 deltaZ = posZ - goalZ;
2448 partMovement->absolutePos.z = posZ;
2449 partMovement->unk_18.z = posZ;
2450
2451 partMovement->dist = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2452
2453 if (partMovement->moveTime == 0) {
2454 partMovement->moveTime = partMovement->dist / partMovement->moveSpeed;
2455 } else {
2456 partMovement->moveSpeed = partMovement->dist / partMovement->moveTime;
2457 }
2458
2459 if (partMovement->moveTime == 0) {
2460 return ApiStatus_DONE2;
2461 }
2462
2463 if (part->partTypeData[2] != 0 && part->partTypeData[3] == 0) {
2464 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2465 }
2466 partMovement->unk_3C = 0;
2467 partMovement->angle = 0.0f;
2468
2469 if (part->actorTypeData2b[1] >= 0) {
2470 partMovement->unk_2C = actor->actorTypeData1b[1] + 1;
2471 } else {
2472 partMovement->unk_2C = -(actor->actorTypeData1b[1] + 1);
2473 }
2474 }
2475
2476 part = script->functionTempPtr[2];
2477 actor = script->functionTempPtr[1];
2478 partMovement = part->movement;
2479 partMovement->absolutePos.x = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.x, partMovement->goalPos.x, partMovement->unk_3C, partMovement->moveTime);
2480 partMovement->absolutePos.y = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.y, partMovement->goalPos.y, partMovement->unk_3C, partMovement->moveTime);
2481 partMovement->absolutePos.z = update_lerp_battle(script->functionTemp[3], partMovement->unk_18.z, partMovement->goalPos.z, partMovement->unk_3C, partMovement->moveTime);
2482 partMovement->unk_3C++;
2483
2484 if (partMovement->moveTime < partMovement->unk_3C) {
2485 part->absolutePos.x = partMovement->goalPos.x;
2486 part->absolutePos.y = partMovement->goalPos.y;
2487 part->absolutePos.z = partMovement->goalPos.z;
2488 if (part->partTypeData[2] != 0 && part->partTypeData[3] == 0) {
2489 snd_stop_sound(part->partTypeData[2]);
2490 }
2491 return ApiStatus_DONE2;
2492 }
2493
2494 if (part->partTypeData[2] != 0 && part->partTypeData[3] != 0) {
2495 if (part->actorTypeData2b[1] >= 0) {
2496 partMovement->unk_2C += partMovement->moveSpeed;
2497 if (part->actorTypeData2b[1] < partMovement->unk_2C) {
2498 actor->footStepCounter++;
2499 partMovement->unk_2C = 0;
2500 if (actor->footStepCounter % 2 != 0) {
2501 if (part->partTypeData[2] != 0) {
2502 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2503 }
2504 } else {
2505 if (part->partTypeData[3] != 0) {
2506 sfx_play_sound_at_position(part->partTypeData[3], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2507 }
2508 }
2509 }
2510 } else {
2511 partMovement->unk_2C += 1.0f;
2512 if (-part->actorTypeData2b[1] <= partMovement->unk_2C) {
2513 actor->footStepCounter++;
2514 partMovement->unk_2C = 0;
2515 if (actor->footStepCounter % 2 != 0) {
2516 if (part->partTypeData[2] != 0) {
2517 sfx_play_sound_at_position(part->partTypeData[2], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2518 }
2519 } else {
2520 if (part->partTypeData[3] != 0) {
2521 sfx_play_sound_at_position(part->partTypeData[3], SOUND_SPACE_DEFAULT, part->absolutePos.x, part->absolutePos.y, part->absolutePos.z);
2522 }
2523 }
2524 }
2525 }
2526 }
2527
2528 deltaX = partMovement->goalPos.x - partMovement->absolutePos.x;
2529 deltaY = partMovement->goalPos.y - partMovement->absolutePos.y;
2530 deltaZ = partMovement->goalPos.z - partMovement->absolutePos.z;
2531 dist3D = sqrtf(SQ(deltaX) + SQ(deltaY) + SQ(deltaZ));
2532 if (dist3D == 0.0f) {
2533 dist3D = 1.0f;
2534 }
2535 if (partMovement->dist == 0.0f) {
2536 partMovement->dist = 1.0f;
2537 }
2538
2539 offsetY = sin_deg((1.0 - dist3D / partMovement->dist) * 180.0);
2540 if (partMovement->unk_3A == 0) {
2541 offsetY = 0.0f;
2542 }
2543 if (partMovement->unk_3A < 0) {
2544 offsetY = -offsetY * (-partMovement->unk_3A);
2545 }
2546 if (partMovement->unk_3A > 0) {
2547 offsetY = offsetY * partMovement->unk_3A;
2548 }
2549
2550 part->absolutePos.x = partMovement->absolutePos.x;
2551 part->absolutePos.y = partMovement->absolutePos.y + offsetY;
2552 part->absolutePos.z = partMovement->absolutePos.z;
2553 return ApiStatus_BLOCK;
2554}
2555
2556API_CALLABLE(GetLastEvent) {
2557 Bytecode* args = script->ptrReadPos;
2558 s32 actorID = evt_get_variable(script, *args++);
2559 s32 outVar;
2560
2561 if (actorID == ACTOR_SELF) {
2562 actorID = script->owner1.actorID;
2563 }
2564
2565 outVar = *args++;
2566 evt_set_variable(script, outVar, get_actor(actorID)->lastEventType);
2567 return ApiStatus_DONE2;
2568}
2569
2570API_CALLABLE(SetTargetActor) {
2571 Bytecode* args = script->ptrReadPos;
2572 s32 actorID = evt_get_variable(script, *args++);
2573 s32 targetActorID;
2574 Actor* actor;
2575
2576 if (actorID == ACTOR_SELF) {
2577 actorID = script->owner1.actorID;
2578 }
2579
2580 targetActorID = evt_get_variable(script, *args++);
2581 actor = get_actor(actorID);
2582 actor->targetActorID = targetActorID;
2583 actor->targetPartID = 1;
2584 return ApiStatus_DONE2;
2585}
2586
2587API_CALLABLE(SetEnemyHP) {
2588 Bytecode* args = script->ptrReadPos;
2589 s32 actorID = evt_get_variable(script, *args++);
2590 s8 newHP;
2591 Actor* actor;
2592
2593 if (actorID == ACTOR_SELF) {
2594 actorID = script->owner1.actorID;
2595 }
2596
2597 newHP = evt_get_variable(script, *args++);
2598 actor = get_actor(actorID);
2599
2600 actor->curHP = newHP;
2601 if (newHP > actor->maxHP) {
2602 actor->curHP = actor->maxHP;
2603 }
2604
2605 actor->healthFraction = (actor->curHP * 25) / actor->maxHP;
2606
2607 return ApiStatus_DONE2;
2608}
2609
2610API_CALLABLE(GetActorHP) {
2612 Bytecode* args = script->ptrReadPos;
2613 s32 actorID = evt_get_variable(script, *args++);
2614 Actor* actor;
2615 s32 outVar;
2616 s32 outVal;
2617
2618 if (actorID == ACTOR_SELF) {
2619 actorID = script->owner1.actorID;
2620 }
2621 outVar = *args++;
2622
2623 actor = get_actor(actorID);
2624
2625 switch (actorID & ACTOR_CLASS_MASK) {
2626 case ACTOR_CLASS_PLAYER:
2627 outVal = playerData->curHP;
2628 break;
2630 outVal = 99;
2631 break;
2632 default:
2633 outVal = actor->curHP;
2634 break;
2635 }
2636
2638 return ApiStatus_DONE2;
2639}
2640
2641API_CALLABLE(GetEnemyMaxHP) {
2642 Bytecode* args = script->ptrReadPos;
2643 s32 actorID = evt_get_variable(script, *args++);
2644 s32 outVar;
2645
2646 if (actorID == ACTOR_SELF) {
2647 actorID = script->owner1.actorID;
2648 }
2649
2650 outVar = *args++;
2651 evt_set_variable(script, outVar, get_actor(actorID)->maxHP);
2652 return ApiStatus_DONE2;
2653}
2654
2655API_CALLABLE(RemoveActor) {
2658 Bytecode* args = script->ptrReadPos;
2659 s32 actorID = evt_get_variable(script, *args++);
2660 Actor* actor;
2661 s32 i;
2663 s16* enemyIDs;
2664
2665 if (actorID == ACTOR_SELF) {
2666 actorID = script->owner1.actorID;
2667 }
2668
2669 actor = get_actor(actorID);
2670 numEnemies = battleStatus->numEnemyActors;
2671 enemyIDs = battleStatus->enemyIDs;
2672
2673 for (i = 0; i < numEnemies; i++) {
2674 if (actor == battleStatus->enemyActors[enemyIDs[i] & 0xFF]) {
2675 enemyIDs[i] = -1;
2676 }
2677 }
2678
2679 currentEncounter->coinsEarned += actor->extraCoinBonus;
2680 currentEncounter->coinsEarned += actor->actorBlueprint->coinReward;
2681 btl_delete_actor(actor);
2682 battleStatus->enemyActors[actorID & 0xFF] = NULL;
2683
2684 return ApiStatus_DONE2;
2685}
2686
2691 100, 100, 100,
2692 110,
2693 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
2694};
2695
2696API_CALLABLE(DropStarPoints) {
2699 Bytecode* args = script->ptrReadPos;
2700 Actor* dropper;
2703 s32 actorID;
2704 f32 ntd;
2705 s32 numToDrop;
2706
2707 actorID = evt_get_variable(script, *args++);
2708 if (actorID == ACTOR_SELF) {
2709 actorID = script->owner1.enemyID;
2710 }
2711 dropper = get_actor(actorID);
2712
2713 enemyLevel = dropper->actorBlueprint->level;
2714 if (dropper->actorBlueprint->level == 0.0f) {
2715 enemyLevel = 1.0f;
2716 }
2717
2718 playerLevel = playerData->level;
2719 if (playerLevel == 0.0f) {
2720 playerLevel = 1.0f;
2721 }
2722
2723 ntd = 0.0f;
2724 if (!(enemyLevel < playerLevel)) {
2725 ntd = ((enemyLevel - playerLevel) * 0.5f) * StarPointMultiplier[battleStatus->initialEnemyCount];
2726 ntd = (ntd + 50.0f) / 100.0f;
2727 }
2728 numToDrop = ntd;
2729
2730 if (playerData->level < 27) {
2731 s32 spawnMode;
2732 s32 i;
2733
2734 if (dropper->flags & ACTOR_FLAG_UPSIDE_DOWN) {
2735 spawnMode = ITEM_SPAWN_MODE_TOSS_FADE3;
2736 } else {
2737 spawnMode = ITEM_SPAWN_MODE_TOSS_FADE1;
2738 }
2739
2740 for (i = 0; i < numToDrop; i++) {
2742 dropper->curPos.x, dropper->curPos.y, dropper->curPos.z, spawnMode, i, 0);
2743 }
2744
2745 battleStatus->incrementStarPointDelay = 40;
2746 battleStatus->pendingStarPoints += numToDrop;
2747 }
2748
2750 return ApiStatus_DONE2;
2751}
2752
2753API_CALLABLE(SetDefenseTable) {
2754 Bytecode* args = script->ptrReadPos;
2755 s32 actorID = evt_get_variable(script, *args++);
2756 s32 partID;
2757 u32* table;
2758
2759 if (actorID == ACTOR_SELF) {
2760 actorID = script->owner1.actorID;
2761 }
2762
2763 partID = evt_get_variable(script, *args++);
2764 table = (u32*) evt_get_variable(script, *args++);
2765 get_actor_part(get_actor(actorID), partID)->defenseTable = table;
2766 return ApiStatus_DONE2;
2767}
2768
2769API_CALLABLE(SetStatusTable) {
2770 Bytecode* args = script->ptrReadPos;
2771 s32 actorID = evt_get_variable(script, *args++);
2772 u32* table;
2773
2774 if (actorID == ACTOR_SELF) {
2775 actorID = script->owner1.actorID;
2776 }
2777
2778 table = (u32*) evt_get_variable(script, *args++);
2779 get_actor(actorID)->statusTable = table;
2780 return ApiStatus_DONE2;
2781}
2782
2783API_CALLABLE(SetIdleAnimations) {
2784 Bytecode* args = script->ptrReadPos;
2785 s32 actorID = evt_get_variable(script, *args++);
2786 s32 partID;
2788
2789 if (actorID == ACTOR_SELF) {
2790 actorID = script->owner1.actorID;
2791 }
2792
2793 partID = evt_get_variable(script, *args++);
2794 idleAnims = (u32*) evt_get_variable(script, *args++);
2795 get_actor_part(get_actor(actorID), partID)->idleAnimations = idleAnims;
2796 return ApiStatus_DONE2;
2797}
2798
2799API_CALLABLE(func_8027CC10) {
2800 Bytecode* args = script->ptrReadPos;
2801 s32 actorID = evt_get_variable(script, *args++);
2802 s32 partID;
2803
2804 if (actorID == ACTOR_SELF) {
2805 actorID = script->owner1.actorID;
2806 }
2807
2808 partID = evt_get_variable(script, *args++);
2809
2810 // weirdly unused
2811 evt_get_variable(script, *args++);
2812 evt_get_variable(script, *args++);
2813
2814 get_actor_part(get_actor(actorID), partID);
2815 return ApiStatus_DONE2;
2816}
2817
2818API_CALLABLE(EnemyDamageTarget) {
2819 Bytecode* args = script->ptrReadPos;
2821 s32 actorID = evt_get_variable(script, *args++);
2822 Actor* actor;
2823 s32 outVar;
2824 s32 hitResult;
2827
2828 if (actorID == ACTOR_SELF) {
2829 actorID = script->owner1.enemyID;
2830 }
2831
2832 actor = get_actor(actorID);
2833 outVar = *args++;
2834 battleStatus->curAttackElement = *args++;
2835 battleStatus->curAttackEventSuppression = *args++;
2836 battleStatus->curAttackStatus = *args++;
2837 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
2838 battleFlagsModifier = *args++;
2839
2840 #if DX_DEBUG_MENU
2842 battleStatus->curAttackDamage = 0;
2843 battleStatus->curAttackStatus = 0;
2844 }
2845 #endif
2846
2847 // BS_FLAGS1_INCLUDE_POWER_UPS and BS_FLAGS1_TRIGGER_EVENTS are mutually exclusive
2854 } else {
2857 }
2858
2861 } else {
2863 }
2864
2867 } else {
2869 }
2870
2873 } else {
2875 }
2876
2877 battleStatus->curTargetID = actor->targetActorID;
2878 battleStatus->curTargetPart = actor->targetPartID;
2879
2880 battleStatus->statusChance = battleStatus->curAttackStatus & 0xFF;
2881 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
2882 battleStatus->statusChance = 0;
2883 }
2884 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
2885
2887 if (hitResult < 0) {
2888 return ApiStatus_FINISH;
2889 }
2890
2893 return ApiStatus_FINISH;
2894 }
2895
2896 return ApiStatus_DONE2;
2897}
2898
2899API_CALLABLE(EnemyFollowupAfflictTarget) {
2902 Bytecode* args = script->ptrReadPos;
2903 Actor* actor;
2904 s32 actorID = evt_get_variable(script, *args++);
2906 s32 outVar;
2907
2908 if (actorID == ACTOR_SELF) {
2909 actorID = script->owner1.actorID;
2910 }
2911
2912 actor = get_actor(actorID);
2913 outVar = *args++;
2914
2915 battleStatus->curTargetID = actor->targetActorID;
2916 battleStatus->curTargetPart = actor->targetPartID;
2917 battleStatus->statusChance = battleStatus->curAttackStatus;
2918
2919 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
2920 battleStatus->statusChance = 0;
2921 }
2922
2923 anotherBattleStatus->statusDuration = (anotherBattleStatus->curAttackStatus & 0xF00) >> 8;
2925
2926 if (hitResults < 0) {
2927 return ApiStatus_FINISH;
2928 }
2929
2932 return ApiStatus_FINISH;
2933 }
2934 return ApiStatus_DONE2;
2935}
2936
2937API_CALLABLE(EnemyTestTarget) {
2938 Bytecode* args = script->ptrReadPos;
2940 s32 actorID = evt_get_variable(script, *args++);
2941 Actor *actor;
2942 s32 outVar;
2943 s32 hitResult;
2947
2948 if (actorID == ACTOR_SELF) {
2949 actorID = script->owner1.enemyID;
2950 }
2951
2952 actor = get_actor(actorID);
2953 outVar = *args++;
2954 battleStatus->curAttackElement = *args++;
2955 battleStatus->curAttackEventSuppression = 0;
2956 battleStatus->curAttackStatus = *args++;
2957 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
2958 battleFlagsModifier = *args++;
2959
2966 } else {
2969 }
2970
2973 } else {
2975 }
2978 } else {
2980 }
2983 } else {
2985 }
2986
2987 attackStatus = battleStatus->curAttackStatus;
2988 battleStatus->curTargetID = actor->targetActorID;
2989
2990 battleStatus->curTargetPart = actor->targetPartID;
2991 battleStatus->statusChance = attackStatus;
2992
2993 if ((attackStatus & 0xFF) == 0xFF) {
2994 battleStatus->statusChance = 0;
2995 }
2996
2997 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
2999
3000 if (hitResult < 0) {
3001 return ApiStatus_FINISH;
3002 }
3003
3005
3006 return ApiStatus_DONE2;
3007}
3008
3009API_CALLABLE(DispatchDamageEvent) {
3010 Bytecode* args = script->ptrReadPos;
3011 s32 actorID = evt_get_variable(script, *args++);
3012 Actor* actor;
3014 s32 eventID;
3015
3016 if (actorID == ACTOR_SELF) {
3017 actorID = script->owner1.actorID;
3018 }
3019
3020 actor = get_actor(actorID);
3022 eventID = evt_get_variable(script, *args++);
3023
3025 return ApiStatus_BLOCK;
3026 }
3027
3029 return ApiStatus_DONE2;
3030 } else {
3031 return ApiStatus_BLOCK;
3032 }
3033}
3034
3035API_CALLABLE(DispatchEvent) {
3036 Bytecode* args = script->ptrReadPos;
3037 s32 actorID = evt_get_variable(script, *args++);
3038
3039 if (actorID == ACTOR_SELF) {
3040 actorID = script->owner1.actorID;
3041 }
3042
3044 return ApiStatus_DONE2;
3045}
3046
3047API_CALLABLE(ShowHealthBar) {
3048 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3049
3050 if (actorID == ACTOR_SELF) {
3051 actorID = script->owner1.actorID;
3052 }
3053
3055 return ApiStatus_DONE2;
3056}
3057
3058API_CALLABLE(HideHealthBar) {
3059 s32 actorID = evt_get_variable(script, *script->ptrReadPos);
3060
3061 if (actorID == ACTOR_SELF) {
3062 actorID = script->owner1.actorID;
3063 }
3064
3066 return ApiStatus_DONE2;
3067}
3068
3069API_CALLABLE(SetTargetOffset) {
3070 Bytecode* args = script->ptrReadPos;
3071 s32 actorID = evt_get_variable(script, *args++);
3072 s32 partID;
3073 ActorPart* part;
3074 s32 x;
3075 s32 y;
3076
3077 if (actorID == ACTOR_SELF) {
3078 actorID = script->owner1.actorID;
3079 }
3080
3081 partID = evt_get_variable(script, *args++);
3082 part = get_actor_part(get_actor(actorID), partID);
3083
3084 x = evt_get_variable(script, *args++);
3085 y = evt_get_variable(script, *args++);
3086
3087 part->targetOffset.x = x;
3088 part->targetOffset.y = y;
3089
3090 return ApiStatus_DONE2;
3091}
3092
3093API_CALLABLE(func_8027D434) {
3094 Bytecode* args = script->ptrReadPos;
3095 s32 actorID = evt_get_variable(script, *args++);
3096 s32 partID;
3097 ActorPart* part;
3098
3099 if (actorID == ACTOR_SELF) {
3100 actorID = script->owner1.actorID;
3101 }
3102
3103 partID = evt_get_variable(script, *args++);
3104 part = get_actor_part(get_actor(actorID), partID);
3105 part->targetPriorityOffset = evt_get_variable(script, *args++);
3106 return ApiStatus_DONE2;
3107}
3108
3109API_CALLABLE(SetProjectileTargetOffset) {
3110 Bytecode* args = script->ptrReadPos;
3111 s32 actorID = evt_get_variable(script, *args++);
3112 s32 partID;
3113 ActorPart* part;
3114 s32 dx;
3115 s32 dy;
3116
3117 if (actorID == ACTOR_SELF) {
3118 actorID = script->owner1.actorID;
3119 }
3120
3121 partID = evt_get_variable(script, *args++);
3122 part = get_actor_part(get_actor(actorID), partID);
3123
3124 dx = evt_get_variable(script, *args++);
3125 dy = evt_get_variable(script, *args++);
3126
3127 part->projectileTargetOffset.x = dx;
3128 part->projectileTargetOffset.y = dy;
3129
3130 return ApiStatus_DONE2;
3131}
3132
3133API_CALLABLE(EnableActorBlur) {
3134 Bytecode* args = script->ptrReadPos;
3135 s32 actorID = evt_get_variable(script, *args++);
3136 s32 enable = evt_get_variable(script, *args++);
3137 Actor* actor;
3138
3139 if (actorID == ACTOR_SELF) {
3140 actorID = script->owner1.actorID;
3141 }
3142
3143 actor = get_actor(actorID);
3144
3145 if (enable == ACTOR_BLUR_DISABLE) {
3146 disable_actor_blur(actor);
3147 } else if (enable == ACTOR_BLUR_ENABLE) {
3148 enable_actor_blur(actor);
3149 } else {
3150 reset_actor_blur(actor);
3151 }
3152 return ApiStatus_DONE2;
3153}
3154
3155API_CALLABLE(ForceDisableActorBlur) {
3156 Bytecode* args = script->ptrReadPos;
3157 s32 actorID = evt_get_variable(script, *args++);
3158 Actor* actor;
3159
3160 if (actorID == ACTOR_SELF) {
3161 actorID = script->owner1.actorID;
3162 }
3163
3164 actor = get_actor(actorID);
3166 return ApiStatus_DONE2;
3167}
3168
3169API_CALLABLE(AfflictActor) {
3170 Bytecode* args = script->ptrReadPos;
3171 s32 actorID = evt_get_variable(script, *args++);
3172 Actor* actor;
3174 s32 duration;
3176
3178 duration = evt_get_variable(script, *args++);
3179
3180 if (actorID == ACTOR_SELF) {
3181 actorID = script->owner1.actorID;
3182 }
3183 actor = get_actor(actorID);
3184
3185 switch (statusTypeKey) {
3186 case STATUS_KEY_FROZEN:
3188 break;
3189 case STATUS_KEY_SLEEP:
3191 break;
3194 break;
3195 case STATUS_KEY_DIZZY:
3197 break;
3198 default:
3200 break;
3201 }
3202
3204
3205 return ApiStatus_DONE2;
3206}
3207
3208API_CALLABLE(GetInstigatorValue) {
3209 Bytecode* args = script->ptrReadPos;
3210 s32 actorID = evt_get_variable(script, *args++);
3211 s32 outVar = *args++;
3212
3213 if (actorID == ACTOR_SELF) {
3214 actorID = script->owner1.actorID;
3215 }
3216
3217 evt_set_variable(script, outVar, get_actor(actorID)->instigatorValue);
3218 return ApiStatus_DONE2;
3219}
3220
3221API_CALLABLE(GetEncounterTrigger) {
3223 return ApiStatus_DONE2;
3224}
3225
3226API_CALLABLE(YieldTurn) {
3228 return ApiStatus_DONE2;
3229}
3230
3231API_CALLABLE(SetActorSize) {
3232 Bytecode* args = script->ptrReadPos;
3233 s32 actorID = evt_get_variable(script, *args++);
3234 s32 y = evt_get_variable(script, *args++);
3235 s32 x = evt_get_variable(script, *args++);
3236 Actor* actor;
3237
3238 if (actorID == ACTOR_SELF) {
3239 actorID = script->owner1.actorID;
3240 }
3241
3242 actor = get_actor(actorID);
3243
3244 if (y != EVT_IGNORE_ARG) {
3245 actor->size.y = y;
3246 }
3247 if (x != EVT_IGNORE_ARG) {
3248 actor->size.x = x;
3249 }
3250 actor->shadowScale = actor->size.x / 24.0;
3251
3252 return ApiStatus_DONE2;
3253}
3254
3255API_CALLABLE(GetActorSize) {
3256 Bytecode* args = script->ptrReadPos;
3257 s32 actorID = evt_get_variable(script, *args++);
3258 s32 outY = *args++;
3259 s32 outX = *args++;
3260 Actor* actor;
3261
3262 if (actorID == ACTOR_SELF) {
3263 actorID = script->owner1.actorID;
3264 }
3265
3266 actor = get_actor(actorID);
3267 evt_set_variable(script, outY, actor->size.y);
3268 evt_set_variable(script, outX, actor->size.x);
3269 return ApiStatus_DONE2;
3270}
3271
3272API_CALLABLE(SetPartSize) {
3273 Bytecode* args = script->ptrReadPos;
3274 s32 actorID = evt_get_variable(script, *args++);
3275 s32 partID = evt_get_variable(script, *args++);
3276 s32 sizeY = evt_get_variable(script, *args++);
3277 s32 sizeX = evt_get_variable(script, *args++);
3278 ActorPart* part;
3279
3280 if (actorID == ACTOR_SELF) {
3281 actorID = script->owner1.actorID;
3282 }
3283
3284 part = get_actor_part(get_actor(actorID), partID);
3285
3286 if (sizeY != EVT_IGNORE_ARG) {
3287 part->size.y = sizeY;
3288 }
3289
3290 if (sizeX != EVT_IGNORE_ARG) {
3291 part->size.x = sizeX;
3292 }
3293
3294 part->shadowScale = part->size.x / 24.0;
3295
3296 return ApiStatus_DONE2;
3297}
3298
3299API_CALLABLE(GetOriginalActorType) {
3300 Bytecode* args = script->ptrReadPos;
3301 s32 actorID = evt_get_variable(script, *args++);
3302 s32 outVar = *args++;
3303
3304 if (actorID == ACTOR_SELF) {
3305 actorID = script->owner1.actorID;
3306 }
3307
3308 evt_set_variable(script, outVar, get_actor(actorID)->actorBlueprint->type);
3309 return ApiStatus_DONE2;
3310}
3311
3312API_CALLABLE(GetCurrentActorType) {
3313 Bytecode* args = script->ptrReadPos;
3314 s32 actorID = evt_get_variable(script, *args++);
3315 s32 outVar = *args++;
3316
3317 if (actorID == ACTOR_SELF) {
3318 actorID = script->owner1.actorID;
3319 }
3320
3321 evt_set_variable(script, outVar, get_actor(actorID)->actorType);
3322 return ApiStatus_DONE2;
3323}
3324
3325API_CALLABLE(GetLastDamage) {
3326 Bytecode* args = script->ptrReadPos;
3327 s32 actorID = evt_get_variable(script, *args++);
3328 s32 outVar;
3329
3330 if (actorID == ACTOR_SELF) {
3331 actorID = script->owner1.actorID;
3332 }
3333 outVar = *args++;
3334
3335 evt_set_variable(script, outVar, get_actor(actorID)->lastDamageTaken);
3336 return ApiStatus_DONE2;
3337}
3338
3339API_CALLABLE(EnableActorGlow) {
3340 Bytecode* args = script->ptrReadPos;
3341 s32 actorID = evt_get_variable(script, *args++);
3342 s32 flag;
3343 Actor* actor;
3344
3345 if (actorID == ACTOR_SELF) {
3346 actorID = script->owner1.actorID;
3347 }
3348
3349 flag = evt_get_variable(script, *args++);
3350 actor = get_actor(actorID);
3351 actor->isGlowing = flag;
3352
3353 if (!flag) {
3354 ActorPart* it = actor->partsTable;
3355
3356 while (it != NULL) {
3357 if (it->idleAnimations != NULL) {
3358 set_npc_imgfx_all(it->spriteInstanceID, IMGFX_CLEAR, 0, 0, 0, 0, 0);
3359 }
3360 it = it->nextPart;
3361 }
3363 }
3364
3365 return ApiStatus_DONE2;
3366}
3367
3368API_CALLABLE(WasStatusInflicted) {
3369 Bytecode* args = script->ptrReadPos;
3371 s32 outVal;
3372
3373 evt_get_variable(script, *args++);
3374
3375 if (script) { // can be args or script but not 1 or do while 0, nor does else work after
3376 outVal = battleStatus->wasStatusInflicted;
3377 }
3378 outVal = battleStatus->wasStatusInflicted;
3379
3380 evt_set_variable(script, *args++, outVal);
3381
3382 return ApiStatus_DONE2;
3383}
3384
3385API_CALLABLE(CopyStatusEffects) {
3386 Bytecode* args = script->ptrReadPos;
3387 s32 actorIDTo;
3389 Actor* actorTo;
3391
3393 if (actorIDFrom == ACTOR_SELF) {
3394 actorIDFrom = script->owner1.actorID;
3395 }
3397
3398 actorIDTo = evt_get_variable(script, *args++);
3399 if (actorIDTo == ACTOR_SELF) {
3400 actorIDTo = script->owner1.actorID;
3401 }
3403
3404 inflict_status(actorTo, actorFrom->debuff, actorFrom->debuffDuration);
3405 inflict_status(actorTo, actorFrom->staticStatus, actorFrom->staticDuration);
3406 inflict_status(actorTo, actorFrom->stoneStatus, actorFrom->stoneDuration);
3407 inflict_status(actorTo, actorFrom->koStatus, actorFrom->koDuration);
3408 inflict_status(actorTo, actorFrom->transparentStatus, actorFrom->transparentDuration);
3409
3410 actorFrom->statusAfflicted = 0;
3411 actorTo->statusAfflicted = 0;
3412
3413 return ApiStatus_DONE2;
3414}
3415
3416API_CALLABLE(ClearStatusEffects) {
3417 Bytecode* args = script->ptrReadPos;
3418 s32 actorID = evt_get_variable(script, *args++);
3419 s32 flag;
3420 Actor* actor;
3421
3422 if (actorID == ACTOR_SELF) {
3423 actorID = script->owner1.actorID;
3424 }
3425
3426 actor = get_actor(actorID);
3427
3428 if (actor->debuff != 0) {
3429 actor->debuffDuration = 0;
3430 actor->debuff = 0;
3432 }
3433
3434 if (actor->staticStatus != 0) {
3435 actor->staticDuration = 0;
3436 actor->staticStatus = 0;
3438 }
3439
3440 if (actor->transparentStatus != 0) {
3441 actor->transparentDuration = 0;
3442 actor->transparentStatus = 0;
3444 }
3445
3446 if (actor->stoneStatus != 0) {
3447 actor->stoneDuration = 0;
3448 actor->stoneStatus = 0;
3449 }
3450
3451 actor->koStatus = 0;
3452 actor->koDuration = 0;
3454 actor->attackBoost = 0;
3455 actor->defenseBoost = 0;
3456 actor->isGlowing = FALSE;
3457
3458 return ApiStatus_DONE2;
3459}
s32 dispatch_damage_event_actor_1(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:879
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:2079
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:2690
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:875
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:2001
void enable_actor_blur(Actor *)
s32 does_script_exist_by_ref(Evt *script)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1725
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2497
void show_immune_bonk(f32 x, f32 y, f32 z, s32, s32, s32)
void remove_status_debuff(s32)
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:2242
void show_actor_health_bar(Actor *)
Definition 190B20.c:2237
void remove_status_static(s32)
void clear_part_pal_adjustment(ActorPart *)
Definition 190B20.c:2350
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz)
Definition 43F0.c:675
Evt * get_script_by_index(s32 index)
s32 suspend_all_script(s32 id)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1882
f32 cos_rad(f32 x)
Definition 43F0.c:715
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:2428
void show_damage_fx(Actor *actor, f32 x, f32 y, f32 z, s32 damage)
Definition 190B20.c:2066
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:668
void cancel_action_rating_combo(Actor *)
Definition 190B20.c:2171
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:1816
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:2386
void show_next_damage_popup(f32 x, f32 y, f32 z, s32 damageAmount, s32 angle)
Definition 190B20.c:2027
s32 get_defense(Actor *actor, s32 *defenseTable, s32 elementFlags)
Definition 190B20.c:1951
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:2313
s32 resume_all_script(s32 id)
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1965
void btl_delete_actor(Actor *actor)
Definition 16C8E0.c:1041
f32 sin_rad(f32 x)
Definition 43F0.c:711
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:2092
s32 try_inflict_status(Actor *, s32, s32)
Definition 190B20.c:2264
s32 inflict_partner_ko(Actor *target, s32 statusTypeKey, s32 duration)
Definition 190B20.c:1935
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:139
#define QUART(x)
Definition macros.h:180
#define EVT_IGNORE_ARG
Definition macros.h:47
#define STATUS_KEY_NEVER
Definition macros.h:235
#define CUBE(x)
Definition macros.h:179
#define SQ(x)
Definition macros.h:178
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