Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
dmg_player.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "battle/battle.h"
4#include "script_api/battle.h"
5#include "sprite/player.h"
6
7b32 dispatch_damage_event_player(s32 damageAmount, s32 event, b32 noHitSound);
8b32 dispatch_hazard_event_player(s32 damageAmount, s32 event);
9
10API_CALLABLE(PlaySleepHitFX) {
11 fx_debuff(0, script->varTable[0], script->varTable[1], script->varTable[2]);
12 return ApiStatus_DONE2;
13}
14
15API_CALLABLE(PlayDizzyHitFX) {
16 fx_debuff(1, script->varTable[0], script->varTable[1], script->varTable[2]);
17 return ApiStatus_DONE2;
18}
19
20API_CALLABLE(PlayParalyzeHitFX) {
21 EffectInstance* debuffEffect = fx_debuff(2, script->varTable[0], script->varTable[1], script->varTable[2]);
22
23 debuffEffect->data.debuff->primCol.r = 200;
24 debuffEffect->data.debuff->primCol.g = 120;
25 debuffEffect->data.debuff->primCol.b = 0;
26 debuffEffect->data.debuff->envCol.r = 234;
27 debuffEffect->data.debuff->envCol.g = 193;
28 debuffEffect->data.debuff->envCol.b = 0;
29 return ApiStatus_DONE2;
30}
31
32API_CALLABLE(PlayPoisonHitFX) {
33 EffectInstance* debuffEffect = fx_debuff(2, script->varTable[0], script->varTable[1], script->varTable[2]);
34
35 debuffEffect->data.debuff->primCol.r = 60;
36 debuffEffect->data.debuff->primCol.g = 160;
37 debuffEffect->data.debuff->primCol.b = 0;
38 debuffEffect->data.debuff->envCol.r = 90;
39 debuffEffect->data.debuff->envCol.g = 240;
40 debuffEffect->data.debuff->envCol.b = 0;
41 return ApiStatus_DONE2;
42}
43
44API_CALLABLE(PlayStopHitFX) {
45 EffectInstance* debuffEffect = fx_debuff(2, script->varTable[0], script->varTable[1], script->varTable[2]);
46
47 debuffEffect->data.debuff->primCol.r = 205;
48 debuffEffect->data.debuff->primCol.g = 0;
49 debuffEffect->data.debuff->primCol.b = 40;
50 debuffEffect->data.debuff->envCol.r = 205;
51 debuffEffect->data.debuff->envCol.g = 32;
52 debuffEffect->data.debuff->envCol.b = 242;
53 return ApiStatus_DONE2;
54}
55
56API_CALLABLE(PlayFreezeHitSnowflakeFX) {
57 fx_big_snowflakes(0, script->varTable[0], script->varTable[1], script->varTable[2]);
58 return ApiStatus_DONE2;
59}
60
61API_CALLABLE(PlayFreezeHitParticleFX) {
62 Actor* actor = (Actor*)script->varTable[3];
63 f32 temp1 = actor->size.y;
64 f32 temp2 = actor->size.x / 2;
65
66 fx_misc_particles(0, script->varTable[0], script->varTable[1], script->varTable[2], temp1, temp2, 1.0f, 10, 30);
67 fx_misc_particles(1, script->varTable[0], script->varTable[1], script->varTable[2], temp1, temp2, 1.0f, 10, 30);
68 return ApiStatus_DONE2;
69}
70
71API_CALLABLE(PlayShrinkHitFX) {
72 s32 i;
73
74 for (i = 0; i < 20; i++) {
75 fx_floating_cloud_puff(0,
76 script->varTable[0] + rand_int(30) - 15,
77 script->varTable[1] + rand_int(20) - 15,
78 script->varTable[2] + 5,
79 1.0f,
80 25);
81 }
82 return ApiStatus_DONE2;
83}
84
86 Call(PlaySleepHitFX)
87 Return
88 End
89};
90
92 Call(PlayDizzyHitFX)
93 Return
94 End
95};
96
98 Call(PlayParalyzeHitFX)
99 Return
100 End
101};
102
104 Call(PlayPoisonHitFX)
105 Return
106 End
107};
108
110 Call(PlayStopHitFX)
111 Return
112 End
113};
114
116 Call(PlayFreezeHitSnowflakeFX)
117 Wait(8)
118 Call(PlayFreezeHitSnowflakeFX)
119 Wait(15)
120 Call(PlayFreezeHitParticleFX)
121 Return
122 End
123};
124
126 Call(PlayShrinkHitFX)
127 Return
128 End
129};
130
131void dispatch_event_player(s32 eventType) {
133 Evt* oldOnHitScript;
134 s32 oldOnHitID;
135 Evt* eventScript;
136
137 player->lastEventType = eventType;
138
139 oldOnHitScript = player->handleEventScript;
140 oldOnHitID = player->handleEventScriptID;
141
143 player->handleEventScript = eventScript;
144 player->handleEventScriptID = eventScript->id;
145 eventScript->owner1.actor = NULL;
146
147 if (player->takeTurnScript != NULL) {
149 player->takeTurnScript = NULL;
150 }
151
152 if (oldOnHitScript != NULL) {
153 kill_script_by_ID(oldOnHitID);
154 }
155}
156
159 Evt* oldOnHitScript;
160 s32 oldOnHitID;
161 Evt* eventScript;
162
163 player->lastEventType = eventType;
164
165 oldOnHitScript = player->handleEventScript;
166 oldOnHitID = player->handleEventScriptID;
167
169 player->handleEventScript = eventScript;
170 player->handleEventScriptID = eventScript->id;
171 eventScript->owner1.actor = NULL;
172
173 if (oldOnHitScript != NULL) {
174 kill_script_by_ID(oldOnHitID);
175 }
176}
177
178// Determines whether an attack from the player will hit an enemy or
180 BattleStatus* battleStatus = &gBattleStatus;
181 Actor* player = battleStatus->playerActor;
182 ActorState* state = &player->state;
183 s32 targetActorID = battleStatus->curTargetID;
184 s32 targetPartIdx = battleStatus->curTargetPart;
185 Actor* target;
186 ActorPart* targetPart;
187
188 battleStatus->curTargetID2 = battleStatus->curTargetID;
189 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
190
191 target = get_actor(targetActorID);
192 if (target == NULL) {
193 return HIT_RESULT_HIT;
194 }
195
196 targetPart = get_actor_part(target, targetPartIdx);
197 ASSERT(targetPart != NULL);
198
199 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY) {
200 return HIT_RESULT_MISS;
201 }
202
204 || (targetPart->eventFlags & ACTOR_EVENT_FLAG_BURIED && !(battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE))
205 ) {
206 return HIT_RESULT_MISS;
207 }
208
209 if (target->stoneStatus == STATUS_KEY_STONE) {
211 return HIT_RESULT_IMMUNE;
212 }
213
214 if ((battleStatus->curAttackElement & DAMAGE_TYPE_JUMP)
215 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_SPIKY_TOP)
217 {
220 }
221
226 {
230 return HIT_RESULT_BACKFIRE;
231 }
232
233 if (player->staticStatus != STATUS_KEY_STATIC && target->staticStatus == STATUS_KEY_STATIC) {
235 }
236
237 return HIT_RESULT_HIT;
238}
239
241 BattleStatus* battleStatus = &gBattleStatus;
242 Actor* player = battleStatus->playerActor;
243 s32 currentTargetID = battleStatus->curTargetID;
244 s32 currentTargetPartID = battleStatus->curTargetPart;
245 ActorState* state;
246 Evt* evt;
247 Actor* target;
248 ActorPart* targetPart;
249 s32 hitResult;
250 s32 currentAttackDamage;
251 s32 targetDefense;
252 s32 dispatchEvent;
253 s32 partImmuneToElement;
254 s32 canBeShocked;
255 s32 missedAllOrNothing;
256 s32 isFireDamage;
257 s32 isShockDamage;
258 s32 isWaterDamage;
259 s32 isIceDamage;
260 s32 wasSpecialHit;
261 s32 wasStatusInflicted;
262 s32 attackFxType;
263
264 canBeShocked = FALSE;
265 isFireDamage = FALSE;
266 isWaterDamage = FALSE;
267 isShockDamage = FALSE;
268 isIceDamage = FALSE;
269 wasSpecialHit = FALSE;
270 partImmuneToElement = FALSE;
271 wasStatusInflicted = FALSE;
272 missedAllOrNothing = FALSE;
273
274 battleStatus->wasStatusInflicted = FALSE;
275 battleStatus->lastAttackDamage = 0;
276 battleStatus->attackerActorID = player->actorID;
277 battleStatus->curTargetID2 = battleStatus->curTargetID;
278 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
279 target = get_actor(currentTargetID);
280 state = &player->state;
281
282 if (target == NULL) {
283 return HIT_RESULT_HIT;
284 }
285
286 targetPart = get_actor_part(target, currentTargetPartID);
287
288 ASSERT(targetPart != NULL);
289
290 target->lastDamageTaken = 0;
291
293 hitResult = HIT_RESULT_NO_DAMAGE;
294 dispatchEvent = EVENT_ZERO_DAMAGE;
295 } else {
297 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)) {
298 battleStatus->curAttackElement |= DAMAGE_TYPE_ICE;
299 }
300 }
301
302 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY
304 || (targetPart->eventFlags & ACTOR_EVENT_FLAG_BURIED && !(battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE))
305 ) {
306 return HIT_RESULT_MISS;
307 }
308
309 if (target->stoneStatus == STATUS_KEY_STONE) {
311 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 1);
312 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 0);
314 return HIT_RESULT_NICE;
315 } else {
316 return HIT_RESULT_HIT;
317 }
318 }
319
320 if (targetPart->elementalImmunities & battleStatus->curAttackElement) {
321 partImmuneToElement = TRUE;
322 }
323
324 // check jumping on spiky enemy
325 if ((battleStatus->curAttackElement & DAMAGE_TYPE_JUMP)
326 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_SPIKY_TOP)
328 {
332 return HIT_RESULT_BACKFIRE;
333 }
334
335 // check touching fiery enemy and explode on contact
336 if (!(battleStatus->curAttackElement & (DAMAGE_TYPE_NO_CONTACT | DAMAGE_TYPE_SMASH))) {
341 return HIT_RESULT_BACKFIRE;
342 }
343
344 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_FIREY
348 ) {
352 return HIT_RESULT_BACKFIRE;
353 }
354 }
355
356 // check explode on ignition
358 && battleStatus->curAttackElement & DAMAGE_TYPE_FIRE
360 ) {
364 return HIT_RESULT_NICE;
365 } else {
366 return HIT_RESULT_HIT;
367 }
368 }
369
370 // unknown alternate spiky #1
375 ) {
379 return HIT_RESULT_BACKFIRE;
380 }
381
382 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
383 fx_ring_blast(0, state->goalPos.x, state->goalPos.y, state->goalPos.z * 5.0f, 1.0f, 24);
384 isFireDamage = TRUE;
385 }
386
387 if (battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK) {
388 apply_shock_effect(target);
389 isShockDamage = TRUE;
390 }
391
392 if (battleStatus->curAttackElement & DAMAGE_TYPE_WATER) {
393 fx_water_splash(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
394 isWaterDamage = TRUE;
395 }
396
397 if (battleStatus->curAttackElement & DAMAGE_TYPE_ICE) {
398 fx_big_snowflakes(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f);
399 isIceDamage = TRUE;
400 }
401
402 attackFxType = player_team_is_ability_active(player, ABILITY_ATTACK_FX);
403
404 if (attackFxType) {
405 fx_breaking_junk(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 30);
406
407 switch (attackFxType) {
408 case 1:
410 break;
411 case 2:
413 break;
414 case 3:
416 break;
417 case 4:
419 break;
420 case 5:
422 break;
423 case 6:
425 break;
426 }
427 }
428
430 && player->staticStatus != STATUS_KEY_STATIC
434 ) {
436 canBeShocked = TRUE;
437 }
438
440 battleStatus->curAttackElement &= ~DAMAGE_TYPE_IGNORE_DEFENSE;
441 }
442
443 targetDefense = get_defense(target, targetPart->defenseTable, battleStatus->curAttackElement);
444
445 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_IGNORE_DEFENSE)) {
446 targetDefense += target->defenseBoost;
447 }
448
450 targetDefense += 127;
451 }
452
453 currentAttackDamage = battleStatus->curAttackDamage;
454 currentAttackDamage += count_power_plus(battleStatus->curAttackElement);
455
456 if (battleStatus->merleeAttackBoost > 0
458 ) {
459 currentAttackDamage += battleStatus->merleeAttackBoost;
460 }
461
462 if (battleStatus->jumpCharge && battleStatus->curAttackElement & DAMAGE_TYPE_JUMP) {
463 currentAttackDamage += battleStatus->jumpCharge;
464 gBattleStatus.flags1 &= ~BS_FLAGS1_JUMP_CHARGED;
465 }
466
468 currentAttackDamage += battleStatus->hammerCharge;
469 gBattleStatus.flags1 &= ~BS_FLAGS1_HAMMER_CHARGED;
470 }
471
472 if (battleStatus->unk_98 != 0) {
473 currentAttackDamage += 2;
474 }
475
477 currentAttackDamage += 2;
478 }
479
481 currentAttackDamage++;
482 }
483
485 currentAttackDamage--;
486 }
487
488 if (battleStatus->turboChargeTurnsLeft != 0) {
489 currentAttackDamage++;
490 }
491
492 currentAttackDamage += player->attackBoost;
493
495 battleStatus->hpDrainCount++;
496 currentAttackDamage--;
497
498 if (currentAttackDamage < 0) {
499 battleStatus->hpDrainCount += currentAttackDamage;
500 }
501
503
504 if (battleStatus->hpDrainCount > 5) {
505 battleStatus->hpDrainCount = 5;
506 }
507 }
508
510 battleStatus->hpDrainCount += 2;
511 currentAttackDamage -= 2;
512
513 if (currentAttackDamage < 0) {
514 battleStatus->hpDrainCount += currentAttackDamage;
515 }
516
518
519 if (battleStatus->hpDrainCount > 5) {
520 battleStatus->hpDrainCount = 5;
521 }
522 }
523
526 ) {
527 if (battleStatus->rushFlags & RUSH_FLAG_POWER) {
528 currentAttackDamage += 2;
529 }
530
531 if (battleStatus->rushFlags & RUSH_FLAG_MEGA) {
532 currentAttackDamage += 4;
533 }
534 fx_radial_shimmer(9, state->goalPos.x, state->goalPos.y, state->goalPos.z, 0.5f, 20);
535 }
536
539 ) {
540 currentAttackDamage++;
541
543 missedAllOrNothing = TRUE;
544 currentAttackDamage = 0;
545#if !VERSION_JP
546 targetDefense = 0;
547#endif
548 gBattleStatus.flags1 &= ~BS_FLAGS1_NICE_HIT;
549 gBattleStatus.flags1 &= ~BS_FLAGS1_SUPER_HIT;
550 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
552 }
553 }
554
555 if (player->debuff == STATUS_KEY_SHRINK) {
556 if (currentAttackDamage > 0) {
557 currentAttackDamage /= 2;
558
559 if (currentAttackDamage == 0) {
560 currentAttackDamage = 1;
561 }
562 }
563 }
564
566 && battleStatus->curAttackElement & DAMAGE_TYPE_BLAST
568 ) {
569 targetDefense = 0;
570 currentAttackDamage = target->curHP;
571 }
572
574 targetDefense = 0;
575 currentAttackDamage = 0;
576 }
577
578 if (currentAttackDamage > 99) {
579 currentAttackDamage = 99;
580 }
581
582 if (currentAttackDamage < 0) {
583 targetDefense = 0;
584 }
585
586 target->hpChangeCounter = 0;
587 currentAttackDamage -= targetDefense;
588
589 if (currentAttackDamage < 0) {
590 currentAttackDamage = 0;
591 }
592
593 if (battleStatus->curAttackElement & DAMAGE_TYPE_POWER_BOUNCE && currentAttackDamage > 0) {
594 currentAttackDamage += battleStatus->powerBounceCounter;
595
596 if (currentAttackDamage < 1) {
597 currentAttackDamage = 1;
598 }
599 }
600
601 battleStatus->lastAttackDamage = 0;
602
603 if (currentAttackDamage < 1) {
604 target->hpChangeCounter = 0;
605 hitResult = HIT_RESULT_NO_DAMAGE;
606
607 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS)) {
608 dispatchEvent = EVENT_ZERO_DAMAGE;
610 } else {
611 if (target->curHP < 1) {
612 dispatchEvent = EVENT_DEATH;
613 } else {
614 dispatchEvent = EVENT_ZERO_DAMAGE;
615 }
616 }
617
618 battleStatus->lastAttackDamage = 0;
619 } else {
620 target->damageCounter += currentAttackDamage;
621 dispatchEvent = EVENT_HIT_COMBO;
622 hitResult = HIT_RESULT_HIT;
623 target->hpChangeCounter -= currentAttackDamage;
624
625 if (!(targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE)
627 && !partImmuneToElement
628 && !(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)
629 ) {
630 target->curHP -= currentAttackDamage;
631
632 if (target->curHP < 1) {
633 target->curHP = 0;
634 dispatchEvent = EVENT_DEATH;
635 }
636 }
637
638 battleStatus->lastAttackDamage += currentAttackDamage;
639 target->lastDamageTaken = battleStatus->lastAttackDamage;
640 target->hpChangeCounter = 0;
641 }
642
643 if (targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE) {
645 && player->staticStatus != STATUS_KEY_STATIC
647 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
649 && !(battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK)
650 ) {
652 apply_shock_effect(player);
654 return HIT_RESULT_BACKFIRE;
655 } else {
657 dispatchEvent = EVENT_ZERO_DAMAGE;
658 } else {
659 dispatchEvent = EVENT_IMMUNE;
660 }
662 dispatch_event_actor(target, dispatchEvent);
663 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
665 return HIT_RESULT_NICE;
666 } else {
667 return HIT_RESULT_HIT;
668 }
669 }
670 }
671
673 if (battleStatus->curAttackElement & DAMAGE_TYPE_FEAR
674 && rand_int(99) < (target->actorBlueprint->escapeChance * battleStatus->statusChance) / 100
675 && (target->debuff != STATUS_KEY_FEAR
676 && target->debuff != STATUS_KEY_DIZZY
677 && target->debuff != STATUS_KEY_PARALYZE
678 && target->debuff != STATUS_KEY_SLEEP
679 && target->debuff != STATUS_KEY_FROZEN
680 && target->debuff != STATUS_KEY_STOP)
681 && !(target->flags & ACTOR_FLAG_FLIPPED)
682 ) {
685 return HIT_RESULT_NICE;
686 } else {
687 return HIT_RESULT_HIT;
688 }
689 }
690 }
691 }
692
694 if (dispatchEvent == EVENT_HIT_COMBO) {
695 dispatchEvent = EVENT_HIT;
696 }
697
698 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
699 dispatchEvent = EVENT_IMMUNE;
700 }
701
702 if (target->curHP < 1) {
703 if (dispatchEvent == EVENT_IMMUNE) {
704 dispatchEvent = EVENT_DEATH;
705 }
706 }
707 } else if (dispatchEvent == EVENT_DEATH) {
708 dispatchEvent = EVENT_HIT_COMBO;
709 }
710
712 clear_part_pal_adjustment(targetPart);
713 }
714
715 // check for special case damage events
717 // if damage is from Spin Smash, convert generic events to Spin Smash specific events
718 if (battleStatus->curAttackElement & DAMAGE_TYPE_SPIN_SMASH) {
719 PlayerData* playerData = &gPlayerData;
720
721 if (target->actorBlueprint->spinSmashReq != 255
722 && playerData->hammerLevel + 1 >= target->actorBlueprint->spinSmashReq
723 && battleStatus->lastAttackDamage > 0
725 ) {
726 if (dispatchEvent == EVENT_HIT_COMBO) {
727 dispatchEvent = EVENT_SPIN_SMASH_HIT;
728 }
729
730 if (dispatchEvent == EVENT_HIT) {
731 dispatchEvent = EVENT_SPIN_SMASH_HIT;
732 }
733
734 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
735 dispatchEvent = EVENT_SPIN_SMASH_HIT;
736 }
737
738 if (dispatchEvent == EVENT_IMMUNE) {
739 dispatchEvent = EVENT_SPIN_SMASH_HIT;
740 }
741
742 if (dispatchEvent == EVENT_DEATH) {
743 dispatchEvent = EVENT_SPIN_SMASH_DEATH;
744 }
745 }
746 }
747
748 // if damage is from Power Bounce, convert generic events to Power Bounce specific events
750 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
752 ) {
753 if (dispatchEvent == EVENT_HIT_COMBO) {
754 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
755 }
756
757 if (dispatchEvent == EVENT_HIT) {
758 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
759 }
760
761 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
762 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
763 }
764
765 if (dispatchEvent == EVENT_IMMUNE) {
766 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
767 }
768
769 if (dispatchEvent == EVENT_DEATH) {
770 dispatchEvent = EVENT_POWER_BOUNCE_DEATH;
771 }
772 }
773
774 // try generating fall trigger events
776 && (battleStatus->curAttackElement & (DAMAGE_TYPE_POW | DAMAGE_TYPE_JUMP))
778 ) {
779 if (dispatchEvent == EVENT_HIT) {
780 dispatchEvent = EVENT_FALL_TRIGGER;
781 }
782
783 if (dispatchEvent == EVENT_IMMUNE) {
784 dispatchEvent = EVENT_FALL_TRIGGER;
785 }
786
787 wasSpecialHit = TRUE;
788 }
789
790 // try generating flip trigger events
794 ) {
795 if (dispatchEvent == EVENT_HIT) {
796 dispatchEvent = EVENT_FLIP_TRIGGER;
797 }
798
799 if (dispatchEvent == EVENT_IMMUNE) {
800 dispatchEvent = EVENT_FLIP_TRIGGER;
801 }
802
803 if (!(target->flags & ACTOR_FLAG_FLIPPED)) {
804 wasSpecialHit = TRUE;
805 }
806 }
807 }
808
809 // try generating flip trigger events
813 ) {
814 if (dispatchEvent == EVENT_HIT_COMBO) {
815 dispatchEvent = EVENT_FLIP_TRIGGER;
816 }
817
818 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
819 dispatchEvent = EVENT_FLIP_TRIGGER;
820 }
821
822 if (!(target->flags & ACTOR_FLAG_FLIPPED)) {
823 wasSpecialHit = TRUE;
824 }
825 }
826
827 // try generating shell crack events
831 ) {
832 if (dispatchEvent == EVENT_HIT) {
833 dispatchEvent = EVENT_SHELL_CRACK_HIT;
834 }
835
836 if (dispatchEvent == EVENT_IMMUNE) {
837 dispatchEvent = EVENT_SHELL_CRACK_HIT;
838 }
839 wasSpecialHit = TRUE;
840 }
841
842 // try generating burn events
845 ) {
846 if (dispatchEvent == EVENT_HIT) {
847 dispatchEvent = EVENT_BURN_HIT;
848 }
849
850 if (dispatchEvent == EVENT_DEATH) {
851 dispatchEvent = EVENT_BURN_DEATH;
852 }
853
854 isFireDamage = TRUE;
855 }
856
857 // try inflicting status effects
859 && battleStatus->lastAttackDamage >= 0
860 && dispatchEvent != EVENT_DEATH
861 && dispatchEvent != EVENT_SPIN_SMASH_DEATH
862 && dispatchEvent != EVENT_EXPLODE_TRIGGER
863 && !(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)
864 ) {
865 #define INFLICT_STATUS(STATUS_TYPE) \
866 if ((battleStatus->curAttackStatus & STATUS_FLAG_##STATUS_TYPE) && \
867 try_inflict_status(target, STATUS_KEY_##STATUS_TYPE, STATUS_TURN_MOD_##STATUS_TYPE)) { \
868 wasSpecialHit = TRUE; \
869 wasStatusInflicted = TRUE; \
870 } \
871
872 INFLICT_STATUS(SHRINK);
873 INFLICT_STATUS(POISON);
874 INFLICT_STATUS(STONE);
875 INFLICT_STATUS(SLEEP);
876 INFLICT_STATUS(STOP);
877 INFLICT_STATUS(STATIC);
878 INFLICT_STATUS(FEAR);
879 INFLICT_STATUS(PARALYZE);
880 INFLICT_STATUS(DIZZY);
881
882 #undef INFLICT_STATUS
883
884 if (wasStatusInflicted) {
885 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
886 dispatchEvent = EVENT_HIT_COMBO;
887 }
888
889 if (dispatchEvent == EVENT_IMMUNE) {
890 dispatchEvent = EVENT_HIT;
891 }
892 }
893 }
894
895 battleStatus->wasStatusInflicted = wasStatusInflicted;
896 dispatch_event_actor(target, dispatchEvent);
897
898 if (!(target->flags & ACTOR_FLAG_NO_DMG_POPUP)) {
899 if (battleStatus->lastAttackDamage == 0) {
900 if (!wasSpecialHit && !wasStatusInflicted) {
901 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
902 }
903 } else if (!partImmuneToElement) {
905 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
906 } else {
907 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
908 }
909
910 if (!(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)) {
911 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
912 }
913 }
914 }
915
918 if (player->actorTypeData1[5]) {
920 }
921
922 if (battleStatus->lastAttackDamage > 0) {
924 }
925
926 if (battleStatus->lastAttackDamage > 0 || ((battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS) && wasSpecialHit)) {
927 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_MULTI_BOUNCE)) {
928 show_action_rating(ACTION_RATING_NICE, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
929 } else {
931 }
932 }
933 }
934 }
935
936 if (missedAllOrNothing) {
937 show_action_rating(ACTION_RATING_MISS, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
938 }
939
941 func_80266970(target);
942 }
943
944 if ((battleStatus->lastAttackDamage > 0 || wasSpecialHit) && !partImmuneToElement) {
945 set_actor_flash_mode(target, 1);
946
947 if (isFireDamage) {
949 } else if (isShockDamage) {
951 } else if (isIceDamage) {
953 } else {
955 }
956 }
957
958 if (battleStatus->lastAttackDamage < 1 && !wasSpecialHit && !canBeShocked || targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE) {
960 }
961
962 if (battleStatus->curAttackStatus & STATUS_FLAG_SLEEP && wasStatusInflicted) {
964 evt->varTable[0] = state->goalPos.x;
965 evt->varTable[1] = state->goalPos.y;
966 evt->varTable[2] = state->goalPos.z;
968 }
969
970 if (battleStatus->curAttackStatus & STATUS_FLAG_DIZZY && wasStatusInflicted) {
972 evt->varTable[0] = state->goalPos.x;
973 evt->varTable[1] = state->goalPos.y;
974 evt->varTable[2] = state->goalPos.z;
976 }
977
978 if (battleStatus->curAttackStatus & STATUS_FLAG_PARALYZE && wasStatusInflicted) {
980 evt->varTable[0] = state->goalPos.x;
981 evt->varTable[1] = state->goalPos.y;
982 evt->varTable[2] = state->goalPos.z;
984 }
985
986 if (battleStatus->curAttackStatus & STATUS_FLAG_POISON && wasStatusInflicted) {
988 evt->varTable[0] = state->goalPos.x;
989 evt->varTable[1] = state->goalPos.y;
990 evt->varTable[2] = state->goalPos.z;
992 }
993
994 if (battleStatus->curAttackStatus & STATUS_FLAG_STOP && wasStatusInflicted) {
996 evt->varTable[0] = state->goalPos.x;
997 evt->varTable[1] = state->goalPos.y;
998 evt->varTable[2] = state->goalPos.z;
1000 }
1001
1002 if (battleStatus->curAttackStatus & STATUS_FLAG_FROZEN && wasStatusInflicted) {
1004 evt->varTable[0] = state->goalPos.x;
1005 evt->varTable[1] = state->goalPos.y;
1006 evt->varTable[2] = state->goalPos.z;
1007 evt->varTablePtr[3] = target;
1009 }
1010
1011 if (battleStatus->curAttackStatus & STATUS_FLAG_SHRINK && wasStatusInflicted) {
1013 evt->varTable[0] = state->goalPos.x;
1014 evt->varTable[1] = state->goalPos.y;
1015 evt->varTable[2] = state->goalPos.z;
1016 evt->varTablePtr[3] = target;
1018 }
1019
1020 if (battleStatus->curAttackElement & DAMAGE_TYPE_SMASH && target->actorType == ACTOR_TYPE_GOOMNUT_TREE) {
1022 }
1023
1024 show_actor_health_bar(target);
1025
1027 if (hitResult == HIT_RESULT_HIT) {
1028 hitResult = HIT_RESULT_NICE;
1029 }
1030 if (hitResult == HIT_RESULT_NO_DAMAGE) {
1031 hitResult = HIT_RESULT_NICE_NO_DAMAGE;
1032 }
1033 }
1034
1036 && (player->staticStatus != STATUS_KEY_STATIC)
1040 ) {
1042 apply_shock_effect(player);
1044 return HIT_RESULT_BACKFIRE;
1045 }
1046
1047 return hitResult;
1048}
1049
1050b32 dispatch_damage_event_player(s32 damageAmount, s32 event, b32 noHitSound) {
1051 BattleStatus* battleStatus = &gBattleStatus;
1052 PlayerData* playerData = &gPlayerData;
1053 Actor* player = battleStatus->playerActor;
1054 ActorState* state = &player->state;
1055 s32 oldHPChangeCounter;
1056 s32 flags;
1057 s32 dispatchEvent;
1058 s32 oldPlayerHP;
1059 s32 temp;
1060
1061 battleStatus->curAttackDamage = damageAmount;
1062
1063 temp = (s16)damageAmount; //TODO usage of temp here required to match
1064 player->hpChangeCounter += temp;
1065
1066 temp = player->hpChangeCounter;
1067 player->curHP = playerData->curHP;
1068 player->damageCounter += temp;
1069 player->hpChangeCounter -= temp;
1070 battleStatus->lastAttackDamage = 0;
1071 player->curHP -= temp;
1072 battleStatus->damageTaken += temp;
1073
1074 oldPlayerHP = player->curHP;
1075
1076 dispatchEvent = event;
1077 if (player->curHP < 1) {
1078 battleStatus->lastAttackDamage += oldPlayerHP;
1079 player->curHP = 0;
1080 dispatchEvent = EVENT_DEATH;
1081 }
1082 battleStatus->lastAttackDamage += temp;
1083 playerData->curHP = player->curHP;
1084
1085 if (dispatchEvent == EVENT_HIT_COMBO) {
1086 dispatchEvent = EVENT_HIT;
1087 }
1088 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
1089 dispatchEvent = EVENT_IMMUNE;
1090 }
1091
1092 if (dispatchEvent == EVENT_DEATH) {
1093 if (event == EVENT_SPIKE_CONTACT) {
1094 dispatchEvent = EVENT_SPIKE_DEATH;
1095 }
1096 if (event == EVENT_BURN_CONTACT) {
1097 dispatchEvent = EVENT_BURN_DEATH;
1098 }
1099 if (event == EVENT_SHOCK_HIT) {
1100 dispatchEvent = EVENT_SHOCK_DEATH;
1101 }
1102 }
1103
1104 if (!noHitSound) {
1107 }
1108
1109 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 1);
1110 show_damage_fx(player, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
1111
1112 if (battleStatus->lastAttackDamage > 0) {
1113 set_actor_flash_mode(player, 1);
1114 }
1115
1117 dispatch_event_player(dispatchEvent);
1118 return flags;
1119}
1120
1121// damage received from "damage over time" effects (only used for poison)
1122b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event) {
1123 BattleStatus* battleStatus = &gBattleStatus;
1124
1125 battleStatus->curAttackElement = ELEMENT_END;
1126 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
1127 return dispatch_damage_event_player(damageAmount, event, FALSE);
1128}
1129
1130// damage received from contact hazards
1131b32 dispatch_hazard_event_player(s32 damageAmount, s32 event) {
1132 return dispatch_damage_event_player(damageAmount, event, TRUE);
1133}
1134
1135API_CALLABLE(GetMenuSelection) {
1136 BattleStatus* battleStatus = &gBattleStatus;
1137 Bytecode* args = script->ptrReadPos;
1138 s32 outVar1 = *args++;
1139 s32 outVar2 = *args++;
1140 s32 outVar3 = *args++;
1141
1142 evt_set_variable(script, outVar1, battleStatus->moveCategory);
1143 evt_set_variable(script, outVar2, battleStatus->moveArgument);
1144 evt_set_variable(script, outVar3, battleStatus->selectedMoveID);
1145
1146 return ApiStatus_DONE2;
1147}
1148
1149API_CALLABLE(PlayerHopToGoal) {
1150 BattleStatus* battleStatus = &gBattleStatus;
1151 Bytecode* args = script->ptrReadPos;
1152 Actor* player = battleStatus->playerActor;
1153 ActorState* playerState = &player->state;
1154 f32 playerVel;
1155 f32 x, y, z;
1156 f32 goalX, goalY, goalZ;
1157
1158 if (isInitialCall) {
1159 script->functionTemp[0] = FALSE;
1160 }
1161
1162 if (script->functionTemp[0] == 0) {
1163 playerState->moveTime = evt_get_variable(script, *args++);
1164 playerState->moveArcAmplitude = evt_get_variable(script, *args++);
1165 script->functionTemp[1] = evt_get_variable(script, *args++);
1166
1167 playerState->curPos.x = player->curPos.x;
1168 playerState->curPos.y = player->curPos.y;
1169 playerState->curPos.z = player->curPos.z;
1170
1171 x = playerState->curPos.x;
1172 y = playerState->curPos.y;
1173 z = playerState->curPos.z;
1174 goalX = playerState->goalPos.x;
1175 goalY = playerState->goalPos.y;
1176 goalZ = playerState->goalPos.z;
1177
1178 playerState->angle = atan2(x, z, goalX, goalZ);
1179 playerState->dist = dist2D(x, z, goalX, goalZ);
1180
1181 if (playerState->moveTime == 0) {
1182 playerState->moveTime = playerState->dist / playerState->speed;
1183 } else {
1184 playerState->speed = playerState->dist / playerState->moveTime;
1185 }
1186
1187 playerState->speed = playerState->dist / playerState->moveTime;
1188 playerState->vel = (playerState->acceleration * playerState->moveTime * 0.5f) + ((goalY - y) / playerState->moveTime);
1189 set_actor_anim(0, 0, playerState->animJumpRise);
1190 playerState->unk_24 = 90.0f;
1191 playerState->unk_28 = 180 / playerState->moveTime;
1192 playerState->unk_2C = playerState->goalPos.y;
1193 if (script->functionTemp[1] != 2) {
1195 }
1196 script->functionTemp[0] = TRUE;
1197 }
1198
1199 if (playerState->vel < 0.0f) {
1200 set_actor_anim(0, 0, playerState->animJumpFall);
1201 }
1202
1203 playerVel = playerState->vel;
1204 switch (playerState->moveArcAmplitude) {
1205 case 0:
1206 break;
1207 case 1:
1208 if (playerState->curPos.y - playerState->unk_2C > 45.0f) {
1209 playerVel *= 0.25f;
1210 }
1211 break;
1212 case 2:
1213 if (playerState->curPos.y - playerState->unk_2C > 54.9) {
1214 playerVel *= 0.25f;
1215 }
1216 break;
1217 }
1218
1219 playerState->curPos.y += playerVel;
1220 playerState->vel -= playerState->acceleration;
1221 add_xz_vec3f(&playerState->curPos, playerState->speed + sin_rad(DEG_TO_RAD(playerState->unk_24)), playerState->angle);
1222 playerState->unk_24 += playerState->unk_28;
1223 playerState->unk_24 = clamp_angle(playerState->unk_24);
1224 player->curPos.x = playerState->curPos.x;
1225 player->curPos.y = playerState->curPos.y;
1226 player->curPos.z = playerState->curPos.z;
1227 playerState->moveTime--;
1228
1229 if (playerState->moveTime >= 0) {
1230 return ApiStatus_BLOCK;
1231 }
1232
1233 player->curPos.y = playerState->goalPos.y;
1234 if (script->functionTemp[1] != 1) {
1235 play_movement_dust_effects(2, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1236 }
1237 if (script->functionTemp[1] != 2) {
1239 }
1240
1241 return ApiStatus_DONE1;
1242}
1243
1244API_CALLABLE(PlayerFallToGoal) {
1245 Bytecode* args = script->ptrReadPos;
1247 ActorState* state = &player->state;
1248 f32 x, y, z;
1249 f32 goalX, goalY, goalZ;
1250
1251 if (isInitialCall) {
1252 script->functionTemp[0] = FALSE;
1253 }
1254
1255 if (!script->functionTemp[0]) {
1256 s32 moveTime = evt_get_variable(script, *args++);
1257
1258 player->state.curPos.x = player->curPos.x;
1259 player->state.curPos.y = player->curPos.y;
1260 player->state.curPos.z = player->curPos.z;
1261
1262 x = player->state.curPos.x;
1263 y = player->state.curPos.y;
1264 z = player->state.curPos.z;
1265 goalX = player->state.goalPos.x;
1266 goalY = player->state.goalPos.y;
1267 goalZ = player->state.goalPos.z;
1268
1269 state->moveTime = moveTime;
1270
1271 player->state.angle = atan2(x, z, goalX, goalZ);
1272 player->state.dist = dist2D(x, z, goalX, goalZ);
1273
1274 y = goalY - y;
1275
1276 if (state->moveTime == 0) {
1277 state->moveTime = state->dist / state->speed;
1278 } else {
1279 state->speed = state->dist / state->moveTime;
1280 }
1281
1282 state->vel = 0.0f;
1283 state->acceleration = ((y / state->moveTime) - state->vel) / (-state->moveTime * 0.5);
1285 script->functionTemp[0] = TRUE;
1286 }
1287
1288 if (state->vel < 0.0f) {
1290 }
1291
1292 state->curPos.y += state->vel;
1293 state->vel -= state->acceleration;
1294 add_xz_vec3f(&state->curPos, state->speed, state->angle);
1295
1296 player->curPos.x = state->curPos.x;
1297 player->curPos.y = state->curPos.y;
1298 player->curPos.z = state->curPos.z;
1299 state->moveTime--;
1300
1301 if (state->moveTime < 0) {
1302 player->curPos.x = state->goalPos.x;
1303 player->curPos.y = state->goalPos.y;
1304 player->curPos.z = state->goalPos.z;
1305 play_movement_dust_effects(2, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1307 return ApiStatus_DONE1;
1308 }
1309 return ApiStatus_BLOCK;
1310}
1311
1312API_CALLABLE(PlayerLandJump) {
1314 ActorState* walkMovement = &player->state;
1315
1316 if (isInitialCall) {
1317 script->functionTemp[0] = 0;
1318 }
1319
1320 if (script->functionTemp[0] == 0) {
1321 walkMovement->curPos.x = player->curPos.x;
1322 walkMovement->curPos.y = player->curPos.y;
1323 walkMovement->curPos.z = player->curPos.z;
1324 script->functionTemp[0] = 1;
1325 }
1326
1327 if (walkMovement->vel > 0.0f) {
1328 if (walkMovement->animJumpRise != 0) {
1329 set_actor_anim(0, 0, walkMovement->animJumpRise);
1330 }
1331 }
1332
1333 if (walkMovement->vel < 0.0f) {
1334 if (walkMovement->animJumpFall != 0) {
1335 set_actor_anim(0, 0, walkMovement->animJumpFall);
1336 }
1337 }
1338
1339 walkMovement->curPos.y += walkMovement->vel;
1340 walkMovement->vel -= walkMovement->acceleration;
1341
1342 add_xz_vec3f(&walkMovement->curPos, walkMovement->speed, walkMovement->angle);
1343
1344 player->curPos.x = walkMovement->curPos.x;
1345 player->curPos.y = walkMovement->curPos.y;
1346 player->curPos.z = walkMovement->curPos.z;
1347
1348 if (player->curPos.y < 0.0f) {
1349 player->curPos.y = 0.0f;
1350
1351 play_movement_dust_effects(2, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1353
1354 return ApiStatus_DONE1;
1355 }
1356
1357 return ApiStatus_BLOCK;
1358}
1359
1360API_CALLABLE(PlayerRunToGoal) {
1361 BattleStatus* battleStatus = &gBattleStatus;
1362 Bytecode* args = script->ptrReadPos;
1363 Actor* player = battleStatus->playerActor;
1364 ActorState* playerState = &player->state;
1365 f32 currentX, currentZ, goalX, goalZ;
1366
1367 if (isInitialCall) {
1368 script->functionTemp[0] = FALSE;
1369 }
1370
1371 if (!script->functionTemp[0]) {
1372 player->state.moveTime = evt_get_variable(script, *args++);
1373 player->state.curPos.x = player->curPos.x;
1374 player->state.curPos.y = player->curPos.y;
1375 player->state.curPos.z = player->curPos.z;
1376
1377 goalX = player->state.goalPos.x;
1378 goalZ = player->state.goalPos.z;
1379 currentX = player->state.curPos.x;
1380 currentZ = player->state.curPos.z;
1381
1382 player->state.angle = atan2(currentX, currentZ, goalX, goalZ);
1383 player->state.dist = dist2D(currentX, currentZ, goalX, goalZ);
1384 if (player->state.moveTime == 0) {
1385 player->state.moveTime = player->state.dist / player->state.speed;
1386 if (player->state.moveTime == 0) {
1387 player->state.moveTime = 1;
1388 }
1389 player->state.speed += (player->state.dist - (player->state.moveTime * player->state.speed)) / player->state.moveTime;
1390 } else {
1391 player->state.speed = player->state.dist / player->state.moveTime;
1392 }
1393 playerState->dist = player->actorTypeData1b[0] + 1;
1394 script->functionTemp[0] = TRUE;
1395 }
1396
1397 add_xz_vec3f(&playerState->curPos, playerState->speed, playerState->angle);
1398
1399 player->curPos.x = playerState->curPos.x;
1400 player->curPos.y = playerState->curPos.y;
1401 player->curPos.z = playerState->curPos.z;
1402
1403 if (playerState->speed < 4.0f) {
1404 play_movement_dust_effects(0, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1405 } else {
1406 play_movement_dust_effects(1, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1407 }
1408
1409 playerState->dist += playerState->speed;
1410 if (playerState->dist > player->actorTypeData1b[0]) {
1411 player->footStepCounter++;
1412 playerState->dist = 0.0f;
1413 if ((player->footStepCounter % 2) != 0) {
1415 } else {
1417 }
1418 }
1419
1420 playerState->moveTime--;
1421
1422 if (playerState->moveTime <= 0) {
1423 player->curPos.x = playerState->goalPos.x;
1424 player->curPos.z = playerState->goalPos.z;
1425 return ApiStatus_DONE2;
1426 }
1427 return ApiStatus_BLOCK;
1428}
1429
1430API_CALLABLE(CancelablePlayerRunToGoal) {
1431 BattleStatus* battleStatus = &gBattleStatus;
1432 Bytecode* args = script->ptrReadPos;
1433 Actor* player = battleStatus->playerActor;
1434 ActorState* playerState = &player->state;
1435 f32 currentX, currentZ, goalX, goalZ;
1436
1437 if (isInitialCall) {
1438 script->functionTemp[0] = FALSE;
1439 }
1440
1441 if (!script->functionTemp[0]) {
1442 player->state.moveTime = evt_get_variable(script, *args++);
1443 script->functionTemp[1] = *args++;
1444 player->state.curPos.x = player->curPos.x;
1445 player->state.curPos.y = player->curPos.y;
1446 player->state.curPos.z = player->curPos.z;
1447
1448 goalX = player->state.goalPos.x;
1449 goalZ = player->state.goalPos.z;
1450 currentX = player->state.curPos.x;
1451 currentZ = player->state.curPos.z;
1452
1453 player->state.angle = atan2(currentX, currentZ, goalX, goalZ);
1454 player->state.dist = dist2D(currentX, currentZ, goalX, goalZ);
1455 if (player->state.moveTime == 0) {
1456 player->state.moveTime = player->state.dist / player->state.speed;
1457 player->state.speed += (player->state.dist - (player->state.moveTime * player->state.speed)) / player->state.moveTime;
1458 } else {
1459 player->state.speed = player->state.dist / player->state.moveTime;
1460 }
1461 playerState->dist = player->actorTypeData1b[0] + 1;
1462
1463 if (playerState->moveTime == 0) {
1464 return ApiStatus_DONE2;
1465 }
1466
1467 script->functionTemp[2] = FALSE;
1468 script->functionTemp[3] = 0;
1469 script->functionTemp[0] = TRUE;
1470 }
1471
1472 add_xz_vec3f(&playerState->curPos, playerState->speed, playerState->angle);
1473
1474 player->curPos.x = playerState->curPos.x;
1475 player->curPos.y = playerState->curPos.y;
1476 player->curPos.z = playerState->curPos.z;
1477
1478 if (playerState->speed < 4.0f) {
1479 play_movement_dust_effects(0, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1480 } else {
1481 play_movement_dust_effects(1, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
1482 }
1483
1484 playerState->dist += playerState->speed;
1485 if (playerState->dist > player->actorTypeData1b[0]) {
1486 player->footStepCounter++;
1487 playerState->dist = 0.0f;
1488 if ((player->footStepCounter % 2) != 0) {
1490 } else {
1492 }
1493 }
1494
1495 if (script->functionTemp[3] > 12) {
1496 if (!script->functionTemp[2]) {
1497 if (!(battleStatus->curButtonsDown & BUTTON_A)) {
1498 script->functionTemp[2] = TRUE;
1499 }
1500 }
1501
1502 if (script->functionTemp[2]) {
1503 if (battleStatus->curButtonsPressed & BUTTON_A) {
1504 evt_set_variable(script, script->functionTemp[1], 1);
1505 return ApiStatus_DONE2;
1506 }
1507 }
1508 }
1509
1510 script->functionTemp[3]++;
1511
1512 playerState->moveTime--;
1513 if (playerState->moveTime > 0) {
1514 return ApiStatus_BLOCK;
1515 }
1516
1517 player->curPos.x = playerState->goalPos.x;
1518 player->curPos.z = playerState->goalPos.z;
1519 evt_set_variable(script, script->functionTemp[1], 0);
1520 return ApiStatus_DONE2;
1521}
1522
1523API_CALLABLE(GetPlayerHP) {
1524 evt_set_variable(script, *script->ptrReadPos, gPlayerData.curHP);
1525 return ApiStatus_DONE2;
1526}
1527
1528API_CALLABLE(PlayerDamageEnemy) {
1529 BattleStatus* battleStatus = &gBattleStatus;
1530 Bytecode* args = script->ptrReadPos;
1531 s32 hitResultOutVar = *args++;
1532 s32 flags;
1533 Actor* target;
1534 HitResult hitResult;
1535
1536 battleStatus->curAttackElement = *args++;
1537 battleStatus->curAttackEventSuppression = *args++;
1538 battleStatus->curAttackStatus = *args++;
1539 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
1540 battleStatus->powerBounceCounter = 0;
1541 flags = *args++;
1542
1543 #if DX_DEBUG_MENU
1544 if (dx_debug_is_cheat_enabled(DEBUG_CHEAT_GOD_MODE)) {
1545 battleStatus->curAttackDamage = 99;
1546 }
1547 #endif
1548
1552 } else if (flags & BS_FLAGS1_INCLUDE_POWER_UPS) {
1554 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1555 } else if (flags & BS_FLAGS1_TRIGGER_EVENTS) {
1556 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1558 } else {
1559 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1560 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1561 }
1562
1563 if (flags & BS_FLAGS1_NICE_HIT) {
1565 } else {
1566 gBattleStatus.flags1 &= ~BS_FLAGS1_NICE_HIT;
1567 }
1568 if (flags & BS_FLAGS1_SUPER_HIT) {
1570 } else {
1571 gBattleStatus.flags1 &= ~BS_FLAGS1_SUPER_HIT;
1572 }
1573 if (flags & BS_FLAGS1_NO_RATING) {
1575 } else {
1576 gBattleStatus.flags1 &= ~BS_FLAGS1_NO_RATING;
1577 }
1580 } else {
1581 gBattleStatus.flags1 &= ~BS_FLAGS1_FORCE_IMMUNE_HIT;
1582 }
1583
1584 target = get_actor(script->owner1.actorID);
1585 battleStatus->curTargetID = target->targetActorID;
1586 battleStatus->curTargetPart = target->targetPartID;
1587 battleStatus->statusChance = battleStatus->curAttackStatus;
1588 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
1589 battleStatus->statusChance = 0;
1590 }
1591 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
1592
1593 hitResult = calc_player_damage_enemy();
1594 if (hitResult < 0) {
1595 return ApiStatus_FINISH;
1596 }
1597 evt_set_variable(script, hitResultOutVar, hitResult);
1598
1599 if (!does_script_exist_by_ref(script)) {
1600 return ApiStatus_FINISH;
1601 }
1602
1603 return ApiStatus_DONE2;
1604}
1605
1606API_CALLABLE(PlayerPowerBounceEnemy) {
1607 BattleStatus* battleStatus = &gBattleStatus;
1608 Bytecode* args = script->ptrReadPos;
1609 s32 hitResultOutVar = *args++;
1610 s32 flags;
1611 Actor* target;
1612 HitResult hitResult;
1613
1614 battleStatus->curAttackElement = *args++;
1615 battleStatus->curAttackEventSuppression = *args++;
1616 battleStatus->curAttackStatus = *args++;
1617 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
1618 battleStatus->powerBounceCounter = evt_get_variable(script, *args++);
1619 flags = *args++;
1620
1623 } else if (flags & BS_FLAGS1_INCLUDE_POWER_UPS) {
1625 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1626 } else if (flags & BS_FLAGS1_TRIGGER_EVENTS) {
1627 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1629 } else {
1630 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1631 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1632 }
1633
1634 if (flags & BS_FLAGS1_NICE_HIT) {
1636 } else {
1637 gBattleStatus.flags1 &= ~BS_FLAGS1_NICE_HIT;
1638 }
1639 if (flags & BS_FLAGS1_SUPER_HIT) {
1641 } else {
1642 gBattleStatus.flags1 &= ~BS_FLAGS1_SUPER_HIT;
1643 }
1644 if (flags & BS_FLAGS1_NO_RATING) {
1646 } else {
1647 gBattleStatus.flags1 &= ~BS_FLAGS1_NO_RATING;
1648 }
1651 } else {
1652 gBattleStatus.flags1 &= ~BS_FLAGS1_FORCE_IMMUNE_HIT;
1653 }
1654
1655 target = get_actor(script->owner1.actorID);
1656 battleStatus->curTargetID = target->targetActorID;
1657 battleStatus->curTargetPart = target->targetPartID;
1658 battleStatus->statusChance = battleStatus->curAttackStatus;
1659 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
1660 battleStatus->statusChance = 0;
1661 }
1662 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
1663
1664 hitResult = calc_player_damage_enemy();
1665 if (hitResult < 0) {
1666 return ApiStatus_FINISH;
1667 }
1668 evt_set_variable(script, hitResultOutVar, hitResult);
1669
1670 if (!does_script_exist_by_ref(script)) {
1671 return ApiStatus_FINISH;
1672 }
1673
1674 return ApiStatus_DONE2;
1675}
1676
1677API_CALLABLE(PlayerTestEnemy) {
1678 BattleStatus* battleStatus = &gBattleStatus;
1679 Bytecode* args = script->ptrReadPos;
1680 s32 hitResultOutVar = *args++;
1681 s32 flags;
1682 Actor* target;
1683 HitResult hitResult;
1684
1685 battleStatus->curAttackElement = *args++;
1686 battleStatus->curAttackEventSuppression = *args++;
1687 battleStatus->curAttackStatus = *args++;
1688 battleStatus->curAttackDamage = evt_get_variable(script, *args++);
1689 battleStatus->powerBounceCounter = 0;
1690 flags = *args++;
1691
1694 } else if (flags & BS_FLAGS1_INCLUDE_POWER_UPS) {
1696 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1697 } else if (flags & BS_FLAGS1_TRIGGER_EVENTS) {
1698 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1700 } else {
1701 gBattleStatus.flags1 &= ~BS_FLAGS1_INCLUDE_POWER_UPS;
1702 gBattleStatus.flags1 &= ~BS_FLAGS1_TRIGGER_EVENTS;
1703 }
1704
1705 if (flags & BS_FLAGS1_NICE_HIT) {
1707 } else {
1708 gBattleStatus.flags1 &= ~BS_FLAGS1_NICE_HIT;
1709 }
1710 if (flags & BS_FLAGS1_SUPER_HIT) {
1712 } else {
1713 gBattleStatus.flags1 &= ~BS_FLAGS1_SUPER_HIT;
1714 }
1715 if (flags & BS_FLAGS1_NO_RATING) {
1717 } else {
1718 gBattleStatus.flags1 &= ~BS_FLAGS1_NO_RATING;
1719 }
1722 } else {
1723 gBattleStatus.flags1 &= ~BS_FLAGS1_FORCE_IMMUNE_HIT;
1724 }
1725
1726 target = get_actor(script->owner1.actorID);
1727 battleStatus->curTargetID = target->targetActorID;
1728 battleStatus->curTargetPart = target->targetPartID;
1729 battleStatus->statusChance = battleStatus->curAttackStatus;
1730 if (battleStatus->statusChance == STATUS_KEY_NEVER) {
1731 battleStatus->statusChance = 0;
1732 }
1733 battleStatus->statusDuration = (battleStatus->curAttackStatus & 0xF00) >> 8;
1734
1735 hitResult = calc_player_test_enemy();
1736 if (hitResult < 0) {
1737 return ApiStatus_FINISH;
1738 }
1739 evt_set_variable(script, hitResultOutVar, hitResult);
1740 return ApiStatus_DONE2;
1741}
1742
1743API_CALLABLE(DispatchDamagePlayerEvent) {
1744 Bytecode* args = script->ptrReadPos;
1745 s32 damageAmount = evt_get_variable(script, *args++);
1746
1747 if (dispatch_damage_tick_event_player(damageAmount, *args++) < 0) {
1748 return ApiStatus_BLOCK;
1749 }
1750
1751 if (does_script_exist_by_ref(script)) {
1752 return ApiStatus_DONE2;
1753 }
1754
1755 return ApiStatus_BLOCK;
1756}
1757
1758API_CALLABLE(EnablePlayerBlur) {
1759 s32 setting = evt_get_variable(script, *script->ptrReadPos);
1760
1761 if (setting == ACTOR_BLUR_DISABLE) {
1763 } else if (setting == ACTOR_BLUR_ENABLE) {
1765 } else {
1767 }
1768
1769 return ApiStatus_DONE2;
1770}
1771
1772API_CALLABLE(ForceDisablePlayerBlur) {
1774 return ApiStatus_DONE2;
1775}
1776
1777API_CALLABLE(ForceDisablePlayerBlurImmediately) {
1779 return ApiStatus_DONE2;
1780}
1781
1782API_CALLABLE(PlayerBasicJumpToGoal) {
1783 BattleStatus* battleStatus = &gBattleStatus;
1784 Bytecode* args = script->ptrReadPos;
1785 Actor* player = battleStatus->playerActor;
1786 ActorState* playerState = &player->state;
1787 f32 posX, posY, posZ;
1788 f32 goalX, goalZ;
1789 f64 accel;
1790
1791 enum {
1792 BASIC_STATE_00 = 0,
1793 BASIC_STATE_01 = 1,
1794 BASIC_STATE_02 = 2,
1795 BASIC_STATE_03 = 3,
1796 };
1797
1798 if (isInitialCall) {
1799 player->state.moveTime = evt_get_variable(script, *args++);
1800 player->state.moveArcAmplitude = evt_get_variable(script, *args++);
1801
1802 switch(player->state.moveArcAmplitude) {
1803 default:
1804 script->functionTemp[0] = BASIC_STATE_00;
1805 break;
1807 script->functionTemp[0] = BASIC_STATE_02;
1808 break;
1809 }
1810
1811 script->functionTemp[1] = 0;
1812 }
1813
1814 if (script->functionTemp[0] == BASIC_STATE_00) {
1815 playerState->curPos.x = player->curPos.x;
1816 playerState->curPos.y = player->curPos.y;
1817 playerState->curPos.z = player->curPos.z;
1818 goalX = playerState->goalPos.x;
1819 goalZ = playerState->goalPos.z;
1820 posX = playerState->curPos.x;
1821 posY = playerState->curPos.y;
1822 posZ = playerState->curPos.z;
1823 playerState->angle = atan2(posX, posZ, goalX, goalZ);
1824 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
1825 if (playerState->moveTime == 0) {
1826 playerState->moveTime = playerState->dist / playerState->speed;
1827 } else {
1828 playerState->speed = playerState->dist / playerState->moveTime;
1829 }
1830
1831 if (playerState->moveTime == 0) {
1832 return ApiStatus_DONE2;
1833 }
1834
1835 playerState->speed = playerState->dist / playerState->moveTime;
1836 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
1837 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
1838 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
1839 playerState->acceleration = PI_S / playerState->moveTime;
1840 playerState->vel = 0.0f;
1841
1842 if (playerState->moveArcAmplitude < PLAYER_BASIC_JUMP_3) {
1843 playerState->bounceDivisor = 47.0 + (playerState->dist - 20.0) / 6.0;
1844 if (playerState->moveArcAmplitude == PLAYER_BASIC_JUMP_2) {
1845 playerState->bounceDivisor *= 1.12;
1846 }
1847 playerState->unk_24 = 90.0f;
1848 playerState->unk_28 = 360 / playerState->moveTime;
1849 playerState->unk_18.x = 0.0f;
1850 playerState->unk_18.y = 0.0f;
1851 accel = playerState->acceleration;
1852 playerState->vel += accel + (sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * accel);
1853 } else {
1854 playerState->bounceDivisor = 47.0 + (playerState->dist - 20.0) / 6.0;
1855 if (playerState->moveArcAmplitude == PLAYER_BASIC_JUMP_4) {
1856 playerState->bounceDivisor *= 1.25;
1857 }
1858 playerState->unk_24 = 90.0f;
1859 playerState->unk_28 = 360 / playerState->moveTime;
1860 playerState->unk_18.x = 0.0f;
1861 playerState->unk_18.y = 0.0f;
1862 accel = playerState->acceleration;
1863 playerState->vel += accel + (sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.8 * accel);
1864 }
1865 set_actor_anim(0, 0, playerState->animJumpRise);
1867 script->functionTemp[0] = BASIC_STATE_01;
1868 }
1869
1870 switch (script->functionTemp[0]) {
1871 case BASIC_STATE_01:
1872 if (playerState->vel > PI_S / 2) {
1873 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpFall);
1874 }
1875 playerState->curPos.x += playerState->velStep.x;
1876 playerState->curPos.y += playerState->velStep.y;
1877 playerState->curPos.z += playerState->velStep.z;
1878 playerState->unk_18.x = player->curPos.y;
1879 player->curPos.x = playerState->curPos.x;
1880 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(playerState->vel));
1881 player->curPos.z = playerState->curPos.z;
1882 if (playerState->goalPos.y > player->curPos.y && playerState->moveTime < 3) {
1883 player->curPos.y = playerState->goalPos.y;
1884 }
1885 playerState->unk_18.y = player->curPos.y;
1886 if (playerState->moveArcAmplitude < PLAYER_BASIC_JUMP_3) {
1887 accel = playerState->acceleration;
1888 playerState->vel += accel + (sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * accel);
1889 } else {
1890 accel = playerState->acceleration;
1891 playerState->vel += accel + (sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.8 * accel);
1892 }
1893 playerState->unk_24 += playerState->unk_28;
1894 playerState->unk_24 = clamp_angle(playerState->unk_24);
1895 playerState->moveTime--;
1896 if (playerState->moveTime == 0) {
1897 player->curPos.y = playerState->goalPos.y;
1898 playerState->acceleration = 1.8f;
1899 playerState->vel = -(playerState->unk_18.x - playerState->unk_18.y);
1900 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpLand);
1901 return ApiStatus_DONE1;
1902 }
1903 break;
1904 case BASIC_STATE_02:
1906 return ApiStatus_DONE2;
1907 }
1908 playerState->moveTime = 1;
1909 playerState->acceleration = 1.8f;
1910 playerState->unk_24 = 90.0f;
1911 playerState->vel = -(playerState->unk_18.x - playerState->unk_18.y);
1912 playerState->bounceDivisor = fabsf(playerState->unk_18.x - playerState->unk_18.y) / 16.5;
1913 playerState->unk_28 = 360 / playerState->moveTime;
1914 playerState->curPos.x = player->curPos.x;
1915 playerState->curPos.y = player->curPos.y;
1916 playerState->curPos.z = player->curPos.z;
1917 script->functionTemp[0] = BASIC_STATE_03;
1918 // fallthrough
1919 case BASIC_STATE_03:
1920 playerState->curPos.x += (playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24))) / 33.0;
1921 playerState->curPos.y -= (playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24)));
1922 playerState->unk_24 += playerState->unk_28;
1923 playerState->unk_24 = clamp_angle(playerState->unk_24);
1924 player->curPos.x = playerState->curPos.x;
1925 player->curPos.y = playerState->curPos.y;
1926 player->curPos.z = playerState->curPos.z;
1928 return ApiStatus_DONE2;
1929 }
1930 playerState->moveTime--;
1931 if (playerState->moveTime == 0) {
1932 return ApiStatus_DONE1;
1933 }
1934 break;
1935 }
1936
1937 return ApiStatus_BLOCK;
1938}
1939
1940API_CALLABLE(PlayerSuperJumpToGoal) {
1941 Bytecode* args = script->ptrReadPos;
1943 ActorState* playerState = &player->state;
1944 f32 posX, posY, posZ;
1945 f32 goalX, goalZ;
1946 f32 temp;
1947 f64 temp_f20;
1948 f64 vel1, vel2;
1949 f64 vel3, vel4;
1950 f64 vel5, vel6;
1951 f64 vel7, vel8;
1952 f64 acc1, acc2;
1953 f64 acc3, acc4;
1954 f64 acc5, acc6;
1955 f64 acc7, acc8;
1956
1957 enum {
1958 SUPER_STATE_00 = 0,
1959 SUPER_STATE_01 = 1,
1960 SUPER_STATE_02 = 2,
1961 SUPER_STATE_10 = 10,
1962 SUPER_STATE_11 = 11,
1963 SUPER_STATE_20 = 20,
1964 SUPER_STATE_21 = 21,
1965 };
1966
1967 if (isInitialCall) {
1968 player->state.moveTime = evt_get_variable(script, *args++);
1969 player->state.moveArcAmplitude = evt_get_variable(script, *args++);
1970
1971 switch(player->state.moveArcAmplitude) {
1972 default:
1973 script->functionTemp[0] = SUPER_STATE_00;
1974 break;
1978 script->functionTemp[0] = SUPER_STATE_10;
1979 break;
1981 script->functionTemp[0] = SUPER_STATE_20;
1982 break;
1983 }
1984 }
1985
1986 switch (script->functionTemp[0]) {
1987 case SUPER_STATE_00:
1988 playerState->curPos.x = player->curPos.x;
1989 playerState->curPos.y = player->curPos.y;
1990 playerState->curPos.z = player->curPos.z;
1991 goalX = playerState->goalPos.x;
1992 goalZ = playerState->goalPos.z;
1993 posX = playerState->curPos.x;
1994 posY = playerState->curPos.y;
1995 posZ = playerState->curPos.z;
1996 playerState->angle = atan2(posX, posZ, goalX, goalZ);
1997 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
1998
1999 if (playerState->moveTime == 0) {
2000 playerState->moveTime = playerState->dist / playerState->speed;
2001 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2002 } else {
2003 playerState->speed = playerState->dist / playerState->moveTime;
2004 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2005 }
2006
2007 if (playerState->moveTime == 0) {
2008 return ApiStatus_DONE2;
2009 }
2010
2011 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
2012 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
2013 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
2014 playerState->acceleration = (PI_S / 2) / playerState->moveTime;
2015 playerState->vel = 0.0f;
2016 playerState->speed += temp / playerState->moveTime;
2017 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpRise);
2019 playerState->unk_24 = 90.0f;
2020 playerState->bounceDivisor = 45.0f;
2021 playerState->unk_28 = 360 / playerState->moveTime;
2022 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_4) {
2023 playerState->bounceDivisor = 56.25f;
2024 }
2025 playerState->unk_18.x = 0.0f;
2026 playerState->unk_18.y = 0.0f;
2027 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_0) {
2028 vel1 = playerState->vel;
2029 acc1 = playerState->acceleration;
2030 playerState->vel = (vel1 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * acc1) + acc1));
2031 } else {
2032 vel2 = playerState->vel;
2033 acc2 = playerState->acceleration;
2034 playerState->vel = (vel2 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.01 * acc2) + acc2));
2035 }
2036 script->functionTemp[0] = SUPER_STATE_01;
2037 break;
2038 case SUPER_STATE_10:
2039 playerState->curPos.x = player->curPos.x;
2040 playerState->curPos.y = player->curPos.y;
2041 playerState->curPos.z = player->curPos.z;
2042 goalX = playerState->goalPos.x;
2043 goalZ = playerState->goalPos.z;
2044 posX = playerState->curPos.x;
2045 posY = playerState->curPos.y;
2046 posZ = playerState->curPos.z;
2047 playerState->angle = atan2(posX, posZ, goalX, goalZ);
2048 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
2049 if (playerState->moveTime == 0) {
2050 playerState->moveTime = playerState->dist / playerState->speed;
2051 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2052 } else {
2053 playerState->speed = playerState->dist / playerState->moveTime;
2054 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2055 }
2056
2057 if (playerState->moveTime == 0) {
2058 return ApiStatus_DONE2;
2059 }
2060 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
2061 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
2062 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
2063 playerState->vel = (PI_S / 2);
2064 playerState->acceleration = (PI_S / 4) / (playerState->moveTime + 1);
2065 playerState->speed += temp / playerState->moveTime;
2066 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpLand);
2067 playerState->unk_24 = 90.0f;
2068 playerState->bounceDivisor = 45.0f;
2069 playerState->unk_28 = (360 / playerState->moveTime);
2070 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_5) {
2071 playerState->bounceDivisor = 56.25f;
2072 }
2073 playerState->unk_18.x = 0.0f;
2074 playerState->unk_18.y = 0.0f;
2075 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_1) {
2076 vel3 = playerState->vel;
2077 acc3 = playerState->acceleration;
2078 playerState->vel = (vel3 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * acc3) + acc3));
2079 } else {
2080 vel4 = playerState->vel;
2081 acc4 = playerState->acceleration;
2082 playerState->vel = (vel4 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.01 * acc4) + acc4));
2083 }
2084 playerState->curPos.y = player->curPos.y - playerState->bounceDivisor;
2085 script->functionTemp[0] = SUPER_STATE_11;
2086 break;
2087 case SUPER_STATE_20:
2088 playerState->moveTime = 1;
2089 playerState->unk_24 = 90.0f;
2090 playerState->bounceDivisor = (fabsf(playerState->unk_18.x - playerState->unk_18.y) / 16.5);
2091 playerState->unk_28 = (360 / playerState->moveTime);
2092 playerState->curPos.x = player->curPos.x;
2093 playerState->curPos.y = player->curPos.y;
2094 playerState->curPos.z = player->curPos.z;
2095 script->functionTemp[0] = SUPER_STATE_21;
2096 break;
2097 }
2098
2099 switch (script->functionTemp[0]) {
2100 case SUPER_STATE_01:
2101 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_0) {
2102 vel5 = playerState->vel;
2103 acc5 = playerState->acceleration;
2104 playerState->vel = (vel5 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * acc5) + acc5));
2105 } else {
2106 vel6 = playerState->vel;
2107 acc6 = playerState->acceleration;
2108 playerState->vel = (vel6 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.01 * acc6) + acc6));
2109 }
2110 playerState->curPos.x += playerState->velStep.x;
2111 playerState->curPos.y += playerState->velStep.y;
2112 playerState->curPos.z += playerState->velStep.z;
2113 playerState->unk_18.x = player->curPos.y;
2114 player->curPos.x = playerState->curPos.x;
2115 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(sin_rad(sin_rad(playerState->vel) * (PI_S / 2)) * (PI_S / 2)));
2116 player->curPos.z = playerState->curPos.z;
2117 playerState->unk_18.y = player->curPos.y;
2118 playerState->unk_24 += playerState->unk_28;
2119 playerState->unk_24 = clamp_angle(playerState->unk_24);
2120 playerState->moveTime--;
2121 if (playerState->moveTime == 0) {
2123 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpFall);
2124 player->rotPivotOffset.y = 14;
2125 player->rot.z -= 66.0f;
2126 playerState->moveTime = 7;
2127 script->functionTemp[0] = SUPER_STATE_02;
2128 }
2129 break;
2130 case SUPER_STATE_02:
2131 player->rotPivotOffset.y = 14;
2132 player->rot.z -= 66.0f;
2133 playerState->moveTime--;
2134 if (playerState->moveTime == 0) {
2135 player->rot.z = 0.0f;
2136 player->rotPivotOffset.y = 0;
2137 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpLand);
2138 return ApiStatus_DONE1;
2139 }
2140 break;
2141 case SUPER_STATE_11:
2142 playerState->curPos.x += playerState->velStep.x;
2143 playerState->curPos.y += playerState->velStep.y;
2144 playerState->curPos.z += playerState->velStep.z;
2145 playerState->unk_18.x = player->curPos.y;
2146 player->curPos.x = playerState->curPos.x;
2147 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(playerState->vel));
2148 player->curPos.z = playerState->curPos.z;
2149 if (playerState->goalPos.y > player->curPos.y) {
2150 player->curPos.y = playerState->goalPos.y;
2151 }
2152 playerState->unk_18.y = player->curPos.y;
2153
2154 if (playerState->moveArcAmplitude == PLAYER_SUPER_JUMP_1) {
2155 vel7 = playerState->vel;
2156 acc7 = playerState->acceleration;
2157 playerState->vel = (vel7 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * acc7) + acc7));
2158 } else {
2159 vel8 = playerState->vel;
2160 acc8 = playerState->acceleration;
2161 playerState->vel = (vel8 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.01 * acc8) + acc8));
2162 }
2163
2164 playerState->unk_24 += playerState->unk_28;
2165 playerState->unk_24 = clamp_angle(playerState->unk_24);
2166 playerState->moveTime--;
2167 if (playerState->moveTime == 0) {
2168 player->curPos.y = playerState->goalPos.y;
2169 set_actor_anim(ACTOR_PLAYER, 0, ANIM_Mario1_SpinFall);
2170 return ApiStatus_DONE1;
2171 }
2172 break;
2173 case SUPER_STATE_21:
2174 temp_f20 = playerState->curPos.x;
2175 temp_f20 += (playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24))) / 33.0;
2176 playerState->curPos.x = temp_f20;
2177 playerState->curPos.y -= playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24));
2178 playerState->unk_24 += playerState->unk_28;
2179 playerState->unk_24 = clamp_angle(playerState->unk_24);
2180 player->curPos.x = playerState->curPos.x;
2181 player->curPos.y = playerState->curPos.y;
2182 player->curPos.z = playerState->curPos.z;
2184 return ApiStatus_DONE2;
2185 }
2186 playerState->moveTime--;
2187 if (playerState->moveTime == 0) {
2188 return ApiStatus_DONE1;
2189 }
2190 break;
2191 }
2192
2193 return ApiStatus_BLOCK;
2194}
2195
2196API_CALLABLE(PlayerUltraJumpToGoal) {
2197 Bytecode* args = script->ptrReadPos;
2199 ActorState* playerState = &player->state;
2200 f32 posX, posY, posZ;
2201 f32 goalX, goalZ;
2202 f32 speed;
2203 f32 temp;
2204
2205 f64 temp_f20;
2206 f64 temp_f20_2;
2207 f64 temp_f20_4;
2208 f64 temp_f20_5;
2209 f64 temp_f20_6;
2210 f64 temp_f20_7;
2211
2212 f64 temp_f22;
2213 f64 temp_f22_2;
2214 f64 temp_f22_3;
2215 f64 temp_f22_4;
2216 f64 temp_f22_5;
2217 f64 temp_f22_6;
2218
2219 enum {
2220 ULTRA_STATE_00 = 0,
2221 ULTRA_STATE_01 = 1,
2222 ULTRA_STATE_10 = 10,
2223 ULTRA_STATE_11 = 11,
2224 ULTRA_STATE_20 = 20,
2225 ULTRA_STATE_21 = 21,
2226 ULTRA_STATE_30 = 30,
2227 ULTRA_STATE_31 = 31,
2228 };
2229
2230 if (isInitialCall) {
2231 player->state.moveTime = evt_get_variable(script, *args++);
2232 player->state.moveArcAmplitude = evt_get_variable(script, *args++);
2233
2234 switch(player->state.moveArcAmplitude) {
2235 default:
2237 script->functionTemp[0] = ULTRA_STATE_00;
2238 break;
2240 script->functionTemp[0] = ULTRA_STATE_11;
2241 break;
2243 script->functionTemp[0] = ULTRA_STATE_30;
2244 break;
2246 script->functionTemp[0] = ULTRA_STATE_20;
2247 break;
2249 script->functionTemp[0] = ULTRA_STATE_30;
2250 break;
2251 }
2252
2253 script->functionTemp[1] = 0;
2254 }
2255
2256 switch (script->functionTemp[0]) {
2257 case ULTRA_STATE_00:
2258 playerState->curPos.x = player->curPos.x;
2259 playerState->curPos.y = player->curPos.y;
2260 playerState->curPos.z = player->curPos.z;
2261 goalX = playerState->goalPos.x;
2262 goalZ = playerState->goalPos.z;
2263 posX = playerState->curPos.x;
2264 posY = playerState->curPos.y;
2265 posZ = playerState->curPos.z;
2266 playerState->angle = atan2(posX, posZ, goalX, goalZ);
2267 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
2268 if (playerState->moveTime == 0) {
2269 playerState->moveTime = playerState->dist / playerState->speed;
2270 } else {
2271 playerState->speed = playerState->dist / playerState->moveTime;
2272 }
2273 playerState->acceleration = PI_S / playerState->moveTime;
2274 playerState->vel = 0.0f;
2275 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
2276 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
2277 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
2278 playerState->speed = playerState->dist / playerState->moveTime;
2279 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpFall);
2282 playerState->unk_18.x = 0.0f;
2283 playerState->unk_18.y = 0.0f;
2284 playerState->unk_24 = 90.0f;
2285
2286 temp = playerState->dist;
2287 temp -= 20.0;
2288 temp /= 6.0;
2289 temp += 47.0;
2290 playerState->bounceDivisor = temp;
2291
2292 temp_f20 = playerState->vel;
2293 temp_f22 = playerState->acceleration;
2294 playerState->unk_28 = 360 / playerState->moveTime;
2295 playerState->vel = temp_f20 + (((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53) * temp_f22) + temp_f22);
2296 script->functionTemp[0] = ULTRA_STATE_01;
2297 break;
2298 case ULTRA_STATE_10:
2299 playerState->curPos.x = player->curPos.x;
2300 playerState->curPos.y = player->curPos.y;
2301 playerState->curPos.z = player->curPos.z;
2302 goalX = playerState->goalPos.x;
2303 goalZ = playerState->goalPos.z;
2304 posX = playerState->curPos.x;
2305 posY = playerState->curPos.y;
2306 posZ = playerState->curPos.z;
2307 playerState->angle = atan2(posX, posZ, goalX, goalZ);
2308 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
2309 if (playerState->moveTime == 0) {
2310 playerState->moveTime = playerState->dist / playerState->speed;
2311 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2312 } else {
2313 speed = playerState->dist / playerState->moveTime;
2314 playerState->speed = speed;
2315 temp = playerState->dist - (playerState->moveTime * speed);
2316 }
2317 playerState->acceleration = PI_S / playerState->moveTime;
2318 playerState->vel = 0.0f;
2319 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
2320 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
2321 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
2322 playerState->speed += temp / playerState->moveTime;
2323 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpRise);
2326 playerState->unk_18.x = 0.0f;
2327 playerState->unk_18.y = 0.0f;
2328 playerState->unk_24 = 90.0f;
2329 temp_f20_2 = playerState->vel;
2330 temp_f22_2 = playerState->acceleration;
2331
2332 temp = playerState->dist;
2333 temp -= 20.0;
2334 temp /= 6.0;
2335 temp += 47.0;
2336 playerState->bounceDivisor = temp;
2337
2338 playerState->unk_28 = 360 / playerState->moveTime;
2339 playerState->vel = temp_f20_2 + (((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53) * temp_f22_2) + temp_f22_2);
2340 script->functionTemp[0] = ULTRA_STATE_11;
2341 break;
2342 case ULTRA_STATE_20:
2343 playerState->moveTime = 1;
2344 set_actor_anim(ACTOR_PLAYER, 1, ANIM_Mario1_SpinFall);
2345 player->rot.y = 0.0f;
2346 playerState->unk_24 = 90.0f;
2347 playerState->bounceDivisor = fabsf(playerState->unk_18.x - playerState->unk_18.y) / 16.5;
2348 playerState->unk_28 = 360 / playerState->moveTime;
2349 playerState->curPos.x = player->curPos.x;
2350 playerState->curPos.y = player->curPos.y;
2351 playerState->curPos.z = player->curPos.z;
2352 script->functionTemp[0] = ULTRA_STATE_21;
2353 break;
2354 case ULTRA_STATE_30:
2355 playerState->curPos.x = player->curPos.x;
2356 playerState->curPos.y = player->curPos.y;
2357 playerState->curPos.z = player->curPos.z;
2358 goalX = playerState->goalPos.x;
2359 goalZ = playerState->goalPos.z;
2360 posX = playerState->curPos.x;
2361 posY = playerState->curPos.y;
2362 posZ = playerState->curPos.z;
2363 playerState->angle = atan2(posX, posZ, goalX, goalZ);
2364 playerState->dist = dist2D(posX, posZ, goalX, goalZ);
2365 if (playerState->moveTime == 0) {
2366 playerState->moveTime = playerState->dist / playerState->speed;
2367 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2368 } else {
2369 playerState->speed = playerState->dist / playerState->moveTime;
2370 temp = playerState->dist - (playerState->moveTime * playerState->speed);
2371 }
2372 playerState->acceleration = PI_S / (playerState->moveTime + 1);
2373 playerState->vel = 0.0f;
2374 playerState->velStep.x = (playerState->goalPos.x - playerState->curPos.x) / playerState->moveTime;
2375 playerState->velStep.y = (playerState->goalPos.y - playerState->curPos.y) / playerState->moveTime;
2376 playerState->velStep.z = (playerState->goalPos.z - playerState->curPos.z) / playerState->moveTime;
2377 playerState->speed += temp / playerState->moveTime;
2378 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpRise);
2380 playerState->unk_24 = 90.0f;
2381 playerState->unk_28 = 360 / playerState->moveTime;
2382 if (playerState->moveArcAmplitude == PLAYER_ULTRA_JUMP_4) {
2383 playerState->bounceDivisor = 56.25f;
2384 } else {
2385 playerState->bounceDivisor = 45.0f;
2386 }
2387 playerState->unk_18.x = 0.0f;
2388 playerState->unk_18.y = 0.0f;
2389 temp_f22_3 = playerState->acceleration;
2390 playerState->vel += ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * temp_f22_3) + temp_f22_3);
2391 script->functionTemp[0] = ULTRA_STATE_31;
2392 break;
2393 }
2394
2395 switch (script->functionTemp[0]) {
2396 case ULTRA_STATE_01:
2397 temp_f22_4 = playerState->vel;
2398 temp_f20_4 = playerState->acceleration;
2399 playerState->vel = temp_f22_4 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * temp_f20_4) + temp_f20_4);
2400 playerState->curPos.x += playerState->velStep.x;
2401 playerState->curPos.y += playerState->velStep.y;
2402 playerState->curPos.z += playerState->velStep.z;
2403 playerState->unk_18.x = player->curPos.y;
2404 player->curPos.x = playerState->curPos.x;
2405 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(playerState->vel));
2406 player->curPos.z = playerState->curPos.z;
2407 playerState->unk_18.y = player->curPos.y;
2408 playerState->unk_24 += playerState->unk_28;
2409 playerState->unk_24 = clamp_angle(playerState->unk_24);
2410 player->rot.y += 133.0f;
2411 player->rot.y = clamp_angle(player->rot.y);
2413 return ApiStatus_DONE2;
2414 }
2415 playerState->moveTime--;
2416 if (playerState->moveTime == 4) {
2417 return ApiStatus_DONE1;
2418 }
2419 break;
2420 case ULTRA_STATE_11:
2421 temp_f22_6 = playerState->vel;
2422 temp_f20_7 = playerState->acceleration;
2423 playerState->vel = temp_f22_6 + ((sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * temp_f20_7) + temp_f20_7);
2424 playerState->curPos.x += playerState->velStep.x;
2425 playerState->curPos.y += playerState->velStep.y;
2426 playerState->curPos.z += playerState->velStep.z;
2427 playerState->unk_18.x = player->curPos.y;
2428 player->curPos.x = playerState->curPos.x;
2429 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(playerState->vel));
2430 player->curPos.z = playerState->curPos.z;
2431 if (playerState->goalPos.y > player->curPos.y && playerState->moveTime < 3) {
2432 player->curPos.y = playerState->goalPos.y;
2433 }
2434 playerState->unk_18.y = player->curPos.y;
2435 playerState->unk_24 += playerState->unk_28;
2436 playerState->unk_24 = clamp_angle(playerState->unk_24);
2437 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpFall);
2438 player->rot.y += 133.0f;
2439 player->rot.y = clamp_angle(player->rot.y);
2440 playerState->moveTime--;
2441 if (playerState->moveTime == 0) {
2442 playerState->acceleration = 1.8f;
2443 playerState->vel = -(playerState->unk_18.x - playerState->unk_18.y);
2444 player->curPos.y = playerState->goalPos.y;
2445 player->rot.y = 0.0f;
2446 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpLand);
2447 play_movement_dust_effects(2, player->curPos.x, player->curPos.y, player->curPos.z, player->yaw);
2448 return ApiStatus_DONE1;
2449 }
2450 break;
2451 case ULTRA_STATE_21:
2452 playerState->curPos.x += (playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24))) / 33.0;
2453 playerState->curPos.y -= playerState->bounceDivisor * sin_rad(DEG_TO_RAD(playerState->unk_24));
2454 playerState->unk_24 += playerState->unk_28;
2455 playerState->unk_24 = clamp_angle(playerState->unk_24);
2456 player->curPos.x = playerState->curPos.x;
2457 player->curPos.y = playerState->curPos.y;
2458 player->curPos.z = playerState->curPos.z;
2460 return ApiStatus_DONE2;
2461 }
2462 playerState->moveTime--;
2463 if (playerState->moveTime == 0) {
2464 return ApiStatus_DONE1;
2465 }
2466 break;
2467 case ULTRA_STATE_31:
2468 temp_f20_6 = playerState->acceleration;
2469 playerState->vel += (sin_rad(DEG_TO_RAD(playerState->unk_24)) * 0.53 * temp_f20_6) + temp_f20_6;
2470 playerState->curPos.x += playerState->velStep.x;
2471 playerState->curPos.y += playerState->velStep.y;
2472 playerState->curPos.z += playerState->velStep.z;
2473 playerState->unk_18.x = player->curPos.y;
2474 player->curPos.x = playerState->curPos.x;
2475 player->curPos.y = playerState->curPos.y + (playerState->bounceDivisor * sin_rad(playerState->vel));
2476 player->curPos.z = playerState->curPos.z;
2477 if (playerState->goalPos.y > player->curPos.y && playerState->moveTime < 3) {
2478 player->curPos.y = playerState->goalPos.y;
2479 }
2480 playerState->unk_18.y = player->curPos.y;
2481 playerState->unk_24 += playerState->unk_28;
2482 playerState->unk_24 = clamp_angle(playerState->unk_24);
2483 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpFall);
2484 player->rot.y += 133.0f;
2485 player->rot.y = clamp_angle(player->rot.y);
2486 playerState->moveTime--;
2487 if (playerState->moveTime == 0) {
2488 player->curPos.y = playerState->goalPos.y;
2489 player->rot.y = 0.0f;
2490 set_actor_anim(ACTOR_PLAYER, 0, playerState->animJumpLand);
2491 playerState->acceleration = 1.8f;
2492 playerState->vel = -(playerState->unk_18.x - playerState->unk_18.y);
2493 return ApiStatus_DONE1;
2494 }
2495 break;
2496 }
2497
2498 return ApiStatus_BLOCK;
2499}
2500
2501API_CALLABLE(GetPlayerActionSuccess) {
2502 Bytecode* args = script->ptrReadPos;
2503 s32 outVar = *args++;
2504 s32 actionSuccess = gBattleStatus.actionSuccess;
2505 s32 actionSucceeded = 0;
2506
2507 if (actionSuccess < 0) {
2508 actionSuccess = 0;
2509 }
2510
2511 if (actionSucceeded < actionSuccess) {
2512 actionSucceeded = actionSuccess;
2513 }
2514
2515 evt_set_variable(script, outVar, actionSucceeded);
2516 return ApiStatus_DONE2;
2517}
2518
2519API_CALLABLE(PlayerYieldTurn) {
2521 return ApiStatus_DONE2;
2522}
2523
2524API_CALLABLE(DispatchEventPlayer) {
2525 dispatch_event_player(evt_get_variable(script, *script->ptrReadPos));
2526 return ApiStatus_DONE2;
2527}
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
struct Evt * takeTurnScript
s8 transparentStatus
s16 lastDamageTaken
struct ActorBlueprint * actorBlueprint
s32 elementalImmunities
s32 actorTypeData1[6]
u8 footStepCounter
ActorState state
s16 damageCounter
struct Evt * handleEventScript
s32 takeTurnScriptID
s16 actorTypeData1b[2]
Vec3s rotPivotOffset
s16 targetActorID
s32 b32
s32 handleEventScriptID
union Evt::@8 owner1
Initially -1.
Vec3f curPos
s16 hpChangeCounter
Bytecode EvtScript[]
s8 flags
Definition demo_api.c:15
HitResult calc_player_test_enemy(void)
Definition dmg_player.c:179
EvtScript EVS_PlayStopHitFX
Definition dmg_player.c:109
#define INFLICT_STATUS(STATUS_TYPE)
b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event)
void dispatch_event_player(s32 eventType)
Definition dmg_player.c:131
void dispatch_event_player_continue_turn(s32 eventType)
Definition dmg_player.c:157
EvtScript EVS_PlayFreezeHitFX
Definition dmg_player.c:115
b32 dispatch_damage_event_player(s32 damageAmount, s32 event, b32 noHitSound)
EvtScript EVS_PlayShrinkHitFX
Definition dmg_player.c:125
b32 dispatch_hazard_event_player(s32 damageAmount, s32 event)
EvtScript EVS_PlayParalyzeHitFX
Definition dmg_player.c:97
HitResult calc_player_damage_enemy(void)
Definition dmg_player.c:240
EvtScript EVS_PlayPoisonHitFX
Definition dmg_player.c:103
EvtScript EVS_PlaySleepHitFX
Definition dmg_player.c:85
EvtScript EVS_PlayDizzyHitFX
Definition dmg_player.c:91
#define sfx_play_sound_at_position
#define rand_int
#define clamp_angle
#define atan2
Color_RGB8 envCol
Definition effects.h:735
struct DebuffFXData * debuff
Definition effects.h:2513
Color_RGB8 primCol
Definition effects.h:734
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ ACTION_RATING_NICE_SUPER_COMBO
'Nice' but becomes 'Super' if nice hits > 2
Definition enums.h:1984
@ ACTION_RATING_MISS
clears nice hits
Definition enums.h:1980
@ ACTION_RATING_NICE
sets nice hits = 1
Definition enums.h:1979
@ BUTTON_A
Definition enums.h:2790
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3594
@ BS_FLAGS1_NO_RATING
Definition enums.h:3577
@ BS_FLAGS1_FORCE_IMMUNE_HIT
Definition enums.h:3580
@ BS_FLAGS1_SUPER_HIT
Definition enums.h:3579
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3590
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3576
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_2000
Definition enums.h:3582
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3571
@ ELEMENT_END
Definition enums.h:2114
@ PLAYER_ULTRA_JUMP_2
Definition enums.h:4315
@ PLAYER_ULTRA_JUMP_0
Definition enums.h:4313
@ PLAYER_ULTRA_JUMP_3
Definition enums.h:4316
@ PLAYER_ULTRA_JUMP_4
Definition enums.h:4317
@ PLAYER_ULTRA_JUMP_1
Definition enums.h:4314
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
Definition enums.h:3386
@ ACTOR_EVENT_FLAG_GROUNDABLE
Actor can be knocked down from flight; triggered by jump attacks.
Definition enums.h:3382
@ ACTOR_EVENT_FLAG_FIRE_EXPLODE
Fire attacks trigger an explosion, used only by bullet/bombshell bills.
Definition enums.h:3378
@ ACTOR_EVENT_FLAG_POWER_BOUNCE
Actor listens for Power Bounce events.
Definition enums.h:3387
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
Definition enums.h:3375
@ ACTOR_EVENT_FLAG_SPIKY_FRONT
Player takes spike damage from hammer attacks.
Definition enums.h:3384
@ ACTOR_EVENT_FLAG_EXTREME_DEFENSE
Actor has 127 extra defense during damage calculation, unaffected by IGNORE_DEFENSE.
Definition enums.h:3381
@ ACTOR_EVENT_FLAG_EXPLODE_ON_CONTACT
Attacks that contact will trigger an explosion.
Definition enums.h:3383
@ ACTOR_EVENT_FLAG_FIREY
Player takes burn damage upon contact.
Definition enums.h:3371
@ ACTOR_EVENT_FLAG_BURIED
Actor can only by hit by quake-element attacks.
Definition enums.h:3379
@ ACTOR_EVENT_FLAG_ALT_SPIKY
Additional spiky quality associated with Pokeys and Spinies.
Definition enums.h:3388
@ 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_SPIKY_TOP
Player takes spike damage from jump attacks.
Definition enums.h:3373
@ ACTOR_EVENT_FLAG_ENCHANTED
Actor glows and listens for the Star Beam event.
Definition enums.h:3385
@ ACTOR_PART_TARGET_NO_DAMAGE
Definition enums.h:1877
@ PLAYER_SUPER_JUMP_0
Definition enums.h:4303
@ PLAYER_SUPER_JUMP_4
Definition enums.h:4307
@ PLAYER_SUPER_JUMP_1
Definition enums.h:4304
@ PLAYER_SUPER_JUMP_5
Definition enums.h:4308
@ PLAYER_SUPER_JUMP_6
Definition enums.h:4309
@ PLAYER_SUPER_JUMP_2
Definition enums.h:4305
@ RUSH_FLAG_MEGA
Definition enums.h:5331
@ RUSH_FLAG_POWER
Definition enums.h:5332
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3618
@ BS_FLAGS2_HAS_DRAINED_HP
Definition enums.h:3620
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3621
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
HitResult
Definition enums.h:1948
@ HIT_RESULT_LANDED_ON_SPIKE
Definition enums.h:1954
@ 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_IMMUNE
Definition enums.h:1958
@ HIT_RESULT_NICE_NO_DAMAGE
Definition enums.h:1953
@ HIT_RESULT_NICE
Definition enums.h:1951
@ HIT_RESULT_MISS
Definition enums.h:1956
@ PLAYER_BASIC_JUMP_3
Definition enums.h:4298
@ PLAYER_BASIC_JUMP_1
Definition enums.h:4296
@ PLAYER_BASIC_JUMP_4
Definition enums.h:4299
@ PLAYER_BASIC_JUMP_2
Definition enums.h:4297
@ SUPPRESS_EVENT_ALT_SPIKY
Definition enums.h:2905
@ SUPPRESS_EVENT_SHOCK_CONTACT
Definition enums.h:2903
@ SUPPRESS_EVENT_SPIKY_FRONT
Definition enums.h:2902
@ SUPPRESS_EVENT_BURN_CONTACT
Definition enums.h:2904
@ STATUS_FLAG_STOP
Definition enums.h:2821
@ STATUS_FLAG_FROZEN
Definition enums.h:2814
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ STATUS_FLAG_PARALYZE
Definition enums.h:2816
@ 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_ATTACK_FX
Definition enums.h:451
@ ABILITY_P_DOWN_D_UP
Definition enums.h:473
@ ABILITY_MEGA_HP_DRAIN
Definition enums.h:472
@ ABILITY_SPIKE_SHIELD
Definition enums.h:438
@ ABILITY_ZAP_TAP
Definition enums.h:455
@ ABILITY_P_UP_D_DOWN
Definition enums.h:470
@ ABILITY_FIRE_SHIELD
Definition enums.h:443
@ ABILITY_ICE_POWER
Definition enums.h:449
@ ABILITY_ALL_OR_NOTHING
Definition enums.h:446
@ ABILITY_HP_DRAIN
Definition enums.h:445
@ SOUND_STEP_NORMAL1
Definition enums.h:759
@ SOUND_IMMUNE
Definition enums.h:745
@ SOUND_LAND_SOFTLY
Definition enums.h:765
@ SOUND_DAMAGE_STARS
Definition enums.h:950
@ SOUND_INFLICT_STATUS
Definition enums.h:1355
@ SOUND_HIT_PLAYER_ICE
Definition enums.h:721
@ SOUND_FLOWERS_LAUGH
Definition enums.h:1389
@ SOUND_HIT_SPIKE
Definition enums.h:743
@ SOUND_HIT_PLAYER_SHOCK
Definition enums.h:1194
@ SOUND_SLIDE_WHISTLE_OUT
Definition enums.h:715
@ SOUND_HIT_PLAYER_FIRE
Definition enums.h:720
@ SOUND_TORNADO_JUMP
Definition enums.h:764
@ SOUND_HIT_NORMAL
Definition enums.h:724
@ SOUND_HIT_WHACKA
Definition enums.h:1412
@ SOUND_SMACK_TREE
Definition enums.h:787
@ SOUND_HIT_SHOCK
Definition enums.h:1195
@ SOUND_PLANTS_BELL
Definition enums.h:727
@ SOUND_HIT_ICE
Definition enums.h:726
@ SOUND_HIT_FIRE
Definition enums.h:725
@ SOUND_LIFE_SHROOM_CHIME
Definition enums.h:1186
@ SOUND_LONG_PLAYER_JUMP
Definition enums.h:782
@ SOUND_YOSHI
Definition enums.h:1411
@ SOUND_INFLICT_SLEEP
Definition enums.h:1354
@ SOUND_STEP_NORMAL2
Definition enums.h:760
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_FLAG_NO_DMG_POPUP
Hide damage popup.
Definition enums.h:3341
@ ACTOR_FLAG_FLIPPED
Actor has been flipped over.
Definition enums.h:3330
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ ACTOR_BLUR_ENABLE
Definition enums.h:6414
@ ACTOR_BLUR_DISABLE
Definition enums.h:6413
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_SPIKE_DEATH
Definition enums.h:2160
@ EVENT_SCARE_AWAY
Definition enums.h:2174
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_SPIKE_CONTACT
Definition enums.h:2163
@ EVENT_POWER_BOUNCE_DEATH
Definition enums.h:2161
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_FALL_TRIGGER
Definition enums.h:2134
@ EVENT_BURN_DEATH
Definition enums.h:2157
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_SHOCK_DEATH
Definition enums.h:2159
@ EVENT_SPIN_SMASH_HIT
Definition enums.h:2133
@ EVENT_EXPLODE_TRIGGER
Definition enums.h:2155
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_SHELL_CRACK_HIT
Definition enums.h:2139
@ EVENT_SPIKE_TAUNT
Definition enums.h:2148
@ EVENT_POWER_BOUNCE_HIT
Definition enums.h:2142
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_FLIP_TRIGGER
Definition enums.h:2135
@ EVENT_SHOCK_HIT
Definition enums.h:2165
@ EVENT_BURN_CONTACT
Definition enums.h:2164
@ EVENT_BURN_TAUNT
Definition enums.h:2149
@ ACTOR_PART_FLAG_DAMAGE_IMMUNE
electrified Plays extra hurt SFX?
Definition enums.h:3358
@ DAMAGE_TYPE_SPIN_SMASH
Definition enums.h:2876
@ DAMAGE_TYPE_POW
Definition enums.h:2861
@ DAMAGE_TYPE_MULTI_BOUNCE
Definition enums.h:2874
@ DAMAGE_TYPE_ICE
Definition enums.h:2854
@ DAMAGE_TYPE_SHELL_CRACK
Definition enums.h:2868
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2880
@ DAMAGE_TYPE_THROW
Definition enums.h:2869
@ DAMAGE_TYPE_SMASH
Definition enums.h:2857
@ DAMAGE_TYPE_POWER_BOUNCE
Definition enums.h:2870
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2856
@ DAMAGE_TYPE_BLAST
Definition enums.h:2860
@ DAMAGE_TYPE_FIRE
Definition enums.h:2852
@ DAMAGE_TYPE_QUAKE_HAMMER
Definition enums.h:2871
@ DAMAGE_TYPE_QUAKE
Definition enums.h:2862
@ DAMAGE_TYPE_JUMP
Definition enums.h:2858
@ DAMAGE_TYPE_FEAR
Definition enums.h:2863
@ 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
s32 does_script_exist_by_ref(Evt *script)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
f32 fabsf(f32 f)
void show_immune_bonk(f32 x, f32 y, f32 z, s32, s32, s32)
s32 count_power_plus(s32)
Definition 190B20.c:939
void disable_player_blur(void)
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
void show_actor_health_bar(Actor *)
Definition 190B20.c:2505
void clear_part_pal_adjustment(ActorPart *)
Definition 190B20.c:2618
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
void enable_player_blur(void)
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
void force_disable_player_blur_immediately(void)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void add_xz_vec3f(Vec3f *vector, f32 speed, f32 angleDeg)
Definition 190B20.c:1139
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
s32 get_defense(Actor *actor, s32 *defenseTable, s32 elementFlags)
Definition 190B20.c:2219
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 set_goal_pos_to_part(ActorState *state, s32 actorID, s32 partID)
Definition actor_api.c:44
void play_movement_dust_effects(s32 var0, f32 xPos, f32 yPos, f32 zPos, f32 angleDeg)
Definition 190B20.c:1166
void force_disable_player_blur(void)
f32 sin_rad(f32 x)
Definition 43F0.c:713
void show_next_damage_popup(f32 x, f32 y, f32 z, s32 damageAmount, s32)
Definition 190B20.c:2295
void apply_shock_effect(Actor *)
void show_action_rating(s32, Actor *, f32, f32, f32)
Definition 190B20.c:2360
void reset_player_blur(void)
EvtScript EVS_Player_HandleEvent
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define PI_S
Definition macros.h:129
#define STATUS_KEY_NEVER
Definition macros.h:223
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Return
Kills the current EVT thread.
Definition macros.h:217
s8 moveCategory
0 = jump, 1 = hammer, 5 = partner, ...
s32 curAttackEventSuppression
struct Actor * playerActor
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11