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