Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
player_api.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3#include "sprite.h"
4#include "world/partners.h"
5#include "world/surfaces.h"
6#include "sprite/player.h"
7
8extern Npc playerNpcData;
9extern u16 PlayerImgFXFlags;
10extern s32 D_802DB5B4[3]; // unused
11
13
14API_CALLABLE(HidePlayerShadow) {
15 Bytecode* args = script->ptrReadPos;
16 s32 hideShadow = evt_get_variable(script, *args++);
17
18 if (hideShadow) {
20 } else {
22 }
23 return ApiStatus_DONE2;
24}
25
26API_CALLABLE(DisablePlayerPhysics) {
27 Bytecode* args = script->ptrReadPos;
28 s32 disable = evt_get_variable(script, *args++);
29
30 if (disable) {
32 } else {
34 }
35 return ApiStatus_DONE2;
36}
37
38API_CALLABLE(DisablePlayerInput) {
39 PlayerStatus* playerStatus = &gPlayerStatus;
40 Bytecode* args = script->ptrReadPos;
41 s32 enable = evt_get_variable(script, *args++);
42
43 if (enable) {
48 if (playerStatus->actionState == ACTION_STATE_SPIN) {
49 playerStatus->animFlags |= PA_FLAG_INTERRUPT_SPIN;
50 }
52 } else {
56 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
58 }
59 return ApiStatus_DONE2;
60}
61
62API_CALLABLE(SetPlayerPos) {
63 PlayerStatus* playerStatus = &gPlayerStatus;
64 Bytecode* args = script->ptrReadPos;
65 f32 x = evt_get_variable(script, *args++);
66 f32 y = evt_get_variable(script, *args++);
67 f32 z = evt_get_variable(script, *args++);
68
69 playerNpc->pos.x = x;
70 playerNpc->pos.y = y;
71 playerNpc->pos.z = z;
72
73 playerStatus->pos.x = playerNpc->pos.x;
74 playerStatus->pos.y = playerNpc->pos.y;
75 playerStatus->pos.z = playerNpc->pos.z;
76
77 return ApiStatus_DONE2;
78}
79
80API_CALLABLE(SetPlayerCollisionSize) {
81 PlayerStatus* playerStatus = &gPlayerStatus;
82 Bytecode* args = script->ptrReadPos;
83 s32 height = evt_get_variable(script, *args++);
84 s32 radius = evt_get_variable(script, *args++);
85
86 playerNpc->collisionHeight = height;
88
91
92 return ApiStatus_DONE2;
93}
94
95API_CALLABLE(SetPlayerSpeed) {
96 Bytecode* args = script->ptrReadPos;
97
98 playerNpc->moveSpeed = evt_get_float_variable(script, *args++);
99 return ApiStatus_DONE2;
100}
101
102API_CALLABLE(SetPlayerJumpscale) {
103 Bytecode* args = script->ptrReadPos;
104
105 playerNpc->jumpScale = evt_get_float_variable(script, *args++);
106 return ApiStatus_DONE2;
107}
108
109API_CALLABLE(SetPlayerAnimation) {
110 Bytecode* args = script->ptrReadPos;
111 AnimID anim = evt_get_variable(script, *args++);
112
114
115 if (gPlayerStatus.anim == ANIM_MarioW2_Collapse) {
116 exec_ShakeCam1(0, 0, 2);
117 }
118
119 return ApiStatus_DONE2;
120}
121
122API_CALLABLE(SetPlayerActionState) {
123 Bytecode* args = script->ptrReadPos;
124
125 set_action_state(evt_get_variable(script, *args++));
126 return ApiStatus_DONE2;
127}
128
129API_CALLABLE(SetPlayerAnimationSpeed) {
130 Bytecode* args = script->ptrReadPos;
131
133 return ApiStatus_DONE2;
134}
135
136API_CALLABLE(PlayerMoveTo) {
137 Bytecode* args = script->ptrReadPos;
138 PlayerStatus* playerStatus = &gPlayerStatus;
139
140 if (isInitialCall) {
141 f32 targetX = evt_get_variable(script, *args++);
142 f32 targetZ = evt_get_variable(script, *args++);
143 f32 moveSpeed;
144
145 script->functionTemp[0] = evt_get_variable(script, *args++);
146 playerStatus->targetYaw = atan2(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ);
147
148 if (script->functionTemp[0] == 0) {
149 script->functionTemp[0] = dist2D(playerStatus->pos.x, playerStatus->pos.z, targetX,
150 targetZ) / playerNpc->moveSpeed;
151 moveSpeed = playerNpc->moveSpeed;
152 } else {
153 moveSpeed = dist2D(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ) / script->functionTemp[0];
154 }
155 move_player(script->functionTemp[0], playerStatus->targetYaw, moveSpeed);
156 }
157
158 // functionTemp 0 is the time left
159 script->functionTemp[0]--;
160 return script->functionTemp[0] < 0;
161}
162
163API_CALLABLE(func_802D1270) {
164 Bytecode* args = script->ptrReadPos;
165 PlayerStatus* playerStatus = &gPlayerStatus;
166
167 if (isInitialCall) {
168 f32 targetX = evt_get_variable(script, *args++);
169 f32 targetZ = evt_get_variable(script, *args++);
170 f32 var3 = evt_get_float_variable(script, *args++);
171 f32 dist;
172 f32 moveSpeed;
173
174 playerStatus->targetYaw = atan2(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ);
175 dist = dist2D(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ);
176 script->functionTemp[0] = dist / var3;
177 moveSpeed = dist / script->functionTemp[0];
178
179 move_player(script->functionTemp[0], playerStatus->targetYaw, moveSpeed);
180 }
181
182 // functionTemp 0 is the time left
183 script->functionTemp[0]--;
184 return (script->functionTemp[0] < 0) * ApiStatus_DONE2;
185}
186
187API_CALLABLE(func_802D1380) {
188 Bytecode* args = script->ptrReadPos;
189 PlayerStatus* playerStatus = &gPlayerStatus;
190
191 if (isInitialCall) {
192 f32 targetX = evt_get_variable(script, *args++);
193 f32 targetZ = evt_get_variable(script, *args++);
194
195 playerNpc->duration = evt_get_variable(script, *args++);
196 playerStatus->targetYaw = atan2(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ);
197
198 if (playerNpc->duration != 0) {
199 playerNpc->moveSpeed = dist2D(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ) / (f32) playerNpc->duration;
200 } else {
201 playerNpc->duration = dist2D(playerStatus->pos.x, playerStatus->pos.z, targetX, targetZ) / playerNpc->moveSpeed;
202 if (playerNpc->duration == 0) {
203 playerNpc->duration = 1;
204 }
205 }
206
208 }
209
210 return ApiStatus_DONE1;
211}
212
214ApiStatus player_jump(Evt* script, s32 isInitialCall, s32 mode) {
215 Bytecode* args = script->ptrReadPos;
216 PlayerStatus* playerStatus = &gPlayerStatus;
217 f32 xTemp;
218 f32 yTemp;
219 f32 zTemp;
220 f32 jumpVel;
221 s32 duration;
222 AnimID anim;
223 f32 dist;
224
225 if (isInitialCall) {
226 script->functionTemp[0] = 0;
227 }
228
229 if (script->functionTemp[0] == 0) {
230 xTemp = evt_get_variable(script, *args++);
231 yTemp = evt_get_variable(script, *args++);
232 zTemp = evt_get_variable(script, *args++);
233 duration = evt_get_variable(script, *args++);
234
235 playerNpc->pos.x = playerStatus->pos.x;
236 playerNpc->pos.y = playerStatus->pos.y;
237 playerNpc->pos.z = playerStatus->pos.z;
238 playerNpc->moveToPos.x = xTemp;
239 playerNpc->moveToPos.y = yTemp;
240 playerNpc->moveToPos.z = zTemp;
241 playerNpc->duration = duration;
242 playerNpc->yaw = playerStatus->targetYaw;
243
245 if (dist > 1.0) {
247 }
248
249 yTemp = playerNpc->moveToPos.y - playerNpc->pos.y;
250
251 if (playerNpc->duration == 0) {
253 } else {
255 }
256
258 playerStatus->flags |= PS_FLAG_FLYING;
259 playerStatus->animFlags |= PA_FLAG_NO_OOB_RESPAWN;
260
261 if (mode == 0) {
262 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
263 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
264 anim = ANIM_Mario1_Jump;
265 } else {
266 anim = ANIM_MarioW1_JumpWatt;
267 }
268 } else {
269 anim = ANIM_MarioW3_8bit_Jump;
270 }
273 }
274 script->functionTemp[0] = 1;
275 }
276
279 jumpVel = playerNpc->jumpVel; // TODO: temp needed and used specifically only once below for this to match
281
282 if (mode == 0 && jumpVel > 0.0f && playerNpc->jumpVel <= 0.0f) {
283 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
284 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
285 anim = ANIM_Mario1_Fall;
286 } else {
287 anim = ANIM_MarioW1_FallWatt;
288 }
289 } else {
290 anim = ANIM_MarioW3_8bit_Jump;
291 }
293 }
294
295 playerStatus->pos.x = playerNpc->pos.x;
296 playerStatus->pos.y = playerNpc->pos.y;
297 playerStatus->pos.z = playerNpc->pos.z;
298
299 if (mode == 0) {
300 playerStatus->targetYaw = playerNpc->yaw;
301 }
302
304 if (playerNpc->duration == 0) {
305 playerStatus->flags &= ~PS_FLAG_FLYING;
306 playerStatus->animFlags &= ~PA_FLAG_NO_OOB_RESPAWN;
307
308 if (mode == 0) {
309 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO)) {
310 if (!(playerStatus->animFlags & PA_FLAG_USING_WATT)) {
311 anim = ANIM_Mario1_Land;
312 } else {
313 anim = ANIM_MarioW1_LandWatt;
314 }
315 } else {
316 anim = ANIM_Mario1_TiredIdle;
317 }
320 }
321
322 if (mode == 0 || mode == 2) {
323 s32 colliderID;
324
325 yTemp = player_check_collision_below(playerNpc->jumpVel, &colliderID);
326
327 if (colliderID > NO_COLLIDER) {
328 playerStatus->pos.y = yTemp;
331 }
332 }
333 return ApiStatus_DONE1;
334 }
335 return ApiStatus_BLOCK;
336}
337
338API_CALLABLE(PlayerJump) {
339 return player_jump(script, isInitialCall, 0);
340}
341
342API_CALLABLE(PlayerJump1) {
343 return player_jump(script, isInitialCall, 1);
344}
345
346API_CALLABLE(PlayerJump2) {
347 return player_jump(script, isInitialCall, 2);
348}
349
350API_CALLABLE(InterpPlayerYaw) {
351 Bytecode* args = script->ptrReadPos;
352 PlayerStatus* playerStatus = &gPlayerStatus;
353 f32* initialYaw = &script->functionTempF[1];
354 f32* deltaYaw = &script->functionTempF[2];
355 s32* time = &script->functionTemp[3];
356
357 if (isInitialCall) {
358 playerNpc->yaw = playerStatus->targetYaw;
359 *initialYaw = playerNpc->yaw;
360 *deltaYaw = evt_get_float_variable(script, *args++) - *initialYaw;
361 *time = evt_get_variable(script, *args++);
362 playerNpc->duration = 0;
363
364 if (*deltaYaw < -180.0f) {
365 *deltaYaw += 360.0f;
366 }
367 if (*deltaYaw > 180.0f) {
368 *deltaYaw -= 360.0f;
369 }
370 }
371
372 if (*time > 0) {
374 playerNpc->yaw = *initialYaw + ((*deltaYaw * playerNpc->duration) / *time);
376 playerStatus->targetYaw = playerNpc->yaw;
377
378 return !(playerNpc->duration < *time);
379 } else {
380 playerNpc->yaw += *deltaYaw;
382 playerStatus->targetYaw = playerNpc->yaw;
383
384 return ApiStatus_DONE2;
385 }
386}
387
388API_CALLABLE(PlayerFaceNpc) {
389 PlayerStatus* playerStatus = &gPlayerStatus;
390 s32* args = script->ptrReadPos;
391 f32* playerTargetYaw = &script->functionTempF[1];
392 f32* angle = &script->functionTempF[2];
393 s32* ft3 = &script->functionTemp[3];
394
395 if (isInitialCall) {
396 s32 npcID = evt_get_variable(script, *args++);
397 Npc* npc;
398
399 if (npcID == NPC_SELF) {
400 npc = get_npc_safe(script->owner2.npcID);
401 } else if (npcID < EVT_LIMIT) {
402 npc = (Npc*)npcID;
403 } else {
404 npc = get_npc_safe(npcID);
405 if (npc == NULL) {
406 return ApiStatus_DONE2;
407 }
408 }
409
410 *playerTargetYaw = playerNpc->yaw = playerStatus->targetYaw;
411 *angle = atan2(playerStatus->pos.x, playerStatus->pos.z, npc->pos.x, npc->pos.z) - *playerTargetYaw;
412 *ft3 = evt_get_variable(script, *args++);
413
414 playerNpc->duration = 0;
415
416 if (*angle < -180.0f) {
417 *angle += 360.0f;
418 }
419 if (*angle > 180.0f) {
420 *angle -= 360.0f;
421 }
422 }
423
424 if (*ft3 > 0) {
426 playerNpc->yaw = *playerTargetYaw + ((*angle * playerNpc->duration) / *ft3);
427 playerStatus->targetYaw = playerNpc->yaw = clamp_angle(playerNpc->yaw);
428 return (playerNpc->duration >= *ft3) * ApiStatus_DONE1;
429 }
430
431 playerNpc->yaw += *angle;
432 playerStatus->targetYaw = playerNpc->yaw = clamp_angle(playerNpc->yaw);
433
434 return ApiStatus_DONE2;
435}
436
437API_CALLABLE(GetPlayerTargetYaw) {
438 evt_set_variable(script, *script->ptrReadPos, gPlayerStatus.targetYaw);
439 return ApiStatus_DONE2;
440}
441
442API_CALLABLE(SetPlayerFlagBits) {
443 Bytecode* args = script->ptrReadPos;
444 PlayerStatus* playerStatus = &gPlayerStatus;
445 Bytecode bits = *args++;
446 Bytecode mode = evt_get_variable(script, *args++);
447
448 if (mode) {
449 playerStatus->flags |= bits;
450 } else {
451 playerStatus->flags &= ~bits;
452 }
453
454 return ApiStatus_DONE2;
455}
456
457API_CALLABLE(GetPlayerActionState) {
458 Bytecode outVar = *script->ptrReadPos;
460 return ApiStatus_DONE2;
461}
462
463API_CALLABLE(GetPlayerPos) {
464 PlayerStatus* playerStatus = &gPlayerStatus;
465 Bytecode* args = script->ptrReadPos;
466 Bytecode outVar1 = *args++;
467 Bytecode outVar2 = *args++;
468 Bytecode outVar3 = *args++;
469
470 evt_set_variable(script, outVar1, playerStatus->pos.x);
471 evt_set_variable(script, outVar2, playerStatus->pos.y);
472 evt_set_variable(script, outVar3, playerStatus->pos.z);
473 return ApiStatus_DONE2;
474}
475
476API_CALLABLE(GetPlayerAnimation) {
477 Bytecode outVar = *script->ptrReadPos;
478
479 evt_set_variable(script, outVar, gPlayerStatus.anim);
480 return ApiStatus_DONE2;
481}
482
483API_CALLABLE(FullyRestoreHPandFP) {
484 PlayerData* playerData = &gPlayerData;
485
486 playerData->curHP = playerData->curMaxHP;
487 playerData->curFP = playerData->curMaxFP;
488 return ApiStatus_DONE2;
489}
490
491API_CALLABLE(FullyRestoreSP) {
492 PlayerData* playerData = &gPlayerData;
493
494 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
495 return ApiStatus_DONE2;
496}
497
498API_CALLABLE(EnablePartner) {
499 s32 partnerIdx = evt_get_variable(script, *script->ptrReadPos) - 1;
500 PartnerData* partner = &gPlayerData.partners[partnerIdx];
501
502 partner->enabled = TRUE;
503 return ApiStatus_DONE2;
504}
505
506API_CALLABLE(DisablePartner) {
507 s32 partnerIdx = evt_get_variable(script, *script->ptrReadPos) - 1;
508 PartnerData* partner = &gPlayerData.partners[partnerIdx];
509
510 partner->enabled = FALSE;
511 return ApiStatus_DONE2;
512}
513
514API_CALLABLE(UseEntryHeading) {
515 Bytecode* args = script->ptrReadPos;
516 MapSettings* mapSettings = get_current_map_settings();
517 s32 var1 = evt_get_variable(script, *args++);
518 s32 var2 = evt_get_variable(script, *args++);
519 f32 entryX = script->varTable[1] = (*mapSettings->entryList)[gGameStatusPtr->entryID].x;
520 f32 entryY = script->varTable[2] = (*mapSettings->entryList)[gGameStatusPtr->entryID].y;
521 f32 entryZ = script->varTable[3] = (*mapSettings->entryList)[gGameStatusPtr->entryID].z;
522 f32 cosTheta;
523 f32 sinTheta;
524 f32 exitTangentFrac;
525
526 sin_cos_deg(clamp_angle((*mapSettings->entryList)[gGameStatusPtr->entryID].yaw + 180.0f), &sinTheta, &cosTheta);
527
528 exitTangentFrac = gGameStatusPtr->exitTangent * 0.3f;
529 gPlayerStatus.pos.x = (entryX + (var1 * sinTheta)) - (exitTangentFrac * cosTheta);
530 gPlayerStatus.pos.z = (entryZ - (var1 * cosTheta)) - (exitTangentFrac * sinTheta);
531
532 script->varTableF[5] = dist2D(gPlayerStatus.pos.x, gPlayerStatus.pos.z, entryX, entryZ) / var2;
534
535 return ApiStatus_DONE2;
536}
537
538API_CALLABLE(func_802D2148) {
539 gPlayerStatus.flags &= ~PS_FLAG_CAMERA_DOESNT_FOLLOW;
540 return ApiStatus_DONE2;
541}
542
543API_CALLABLE(UseExitHeading) {
544 Bytecode* args = script->ptrReadPos;
545 PlayerStatus* playerStatus = &gPlayerStatus;
546 MapSettings* mapSettings = get_current_map_settings();
547 f32* varTableVar5 = &script->varTableF[5];
548
550 s32 var1 = evt_get_variable(script, *args++);
551 s32 entryID = evt_get_variable(script, *args++);
552 f32 entryX = (*mapSettings->entryList)[entryID].x;
553 f32 entryZ = (*mapSettings->entryList)[entryID].z;
554 f32 temp = (var1 + 10.0f) / 2;
555 f32 temp_f2 = dist2D(entryX, entryZ, playerStatus->pos.x, playerStatus->pos.z) - temp;
556 f32 sinTheta;
557 f32 cosTheta;
558 f32 exitTangentFrac;
559
560 if (temp_f2 > 0.0f) {
561 if (temp_f2 > var1 + 10.0f) {
562 temp_f2 = var1 + 10.0f;
563 }
564 var1 -= temp_f2 / 2;
565 }
566
567 sin_cos_deg(clamp_angle((*mapSettings->entryList)[entryID].yaw + 180.0f), &sinTheta, &cosTheta);
568 gGameStatusPtr->exitTangent = (cosTheta * (playerStatus->pos.x - entryX)) - (sinTheta * (entryZ - playerStatus->pos.z));
569 exitTangentFrac = gGameStatusPtr->exitTangent * 0.3f;
570 script->varTable[1] = (playerStatus->pos.x + (var1 * sinTheta)) - (exitTangentFrac * cosTheta);
571 script->varTable[3] = (playerStatus->pos.z - (var1 * cosTheta)) - (exitTangentFrac * sinTheta);
572 script->varTable[2] = (*mapSettings->entryList)[entryID].y;
573 *varTableVar5 = var1 / 15;
574 playerStatus->animFlags |= PA_FLAG_CHANGING_MAP;
575 playerStatus->flags |= PS_FLAG_CAMERA_DOESNT_FOLLOW;
576 return ApiStatus_DONE2;
577 }
578
579 return ApiStatus_BLOCK;
580}
581
591
592API_CALLABLE(WaitForPlayerTouchingFloor) {
593 if ((gCollisionStatus.curFloor >= 0) && func_802D23F8()) {
594 return ApiStatus_DONE2;
595 } else {
596 return ApiStatus_BLOCK;
597 }
598}
599
600API_CALLABLE(func_802D2484) {
601 if (gCollisionStatus.curFloor >= 0) {
602 return ApiStatus_DONE2;
603 } else {
604 return ApiStatus_BLOCK;
605 }
606}
607
608API_CALLABLE(IsPlayerOnValidFloor) {
609 Bytecode* args = script->ptrReadPos;
610 s32 result = FALSE;
611
612 if (gCollisionStatus.curFloor >= 0) {
613 result = (func_802D23F8() != 0);
614 }
615 evt_set_variable(script, *args++, result);
616
617 return ApiStatus_DONE2;
618}
619
620API_CALLABLE(WaitForPlayerMoveToComplete) {
621 if (gPlayerStatus.moveFrames == 0) {
622 return ApiStatus_DONE2;
623 } else {
624 return ApiStatus_BLOCK;
625 }
626}
627
628API_CALLABLE(WaitForPlayerInputEnabled) {
630 return ApiStatus_BLOCK;
631 } else {
632 return ApiStatus_DONE2;
633 }
634}
635
636API_CALLABLE(UpdatePlayerImgFX) {
637 Bytecode* args = script->ptrReadPos;
638 PlayerStatus* playerStatus = &gPlayerStatus;
639 s32 a0 = *args++;
640 s32 imgfxType = evt_get_variable(script, *args++);
641 s32 a2, a3, a4, a5;
642
643 set_player_imgfx_all(a0, IMGFX_CLEAR, 0, 0, 0, 0, 0);
644
645 switch (imgfxType) {
646 case IMGFX_CLEAR:
647 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
649 break;
650 case IMGFX_UNK_2:
651 case IMGFX_RESET:
652 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
653 case IMGFX_UNK_1:
654 set_player_imgfx_all(a0, imgfxType, 0, 0, 0, 0, PlayerImgFXFlags);
655 break;
656 case IMGFX_SET_WAVY:
657 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
658 a2 = evt_get_variable(script, *args++);
659 a3 = evt_get_variable(script, *args++);
660 a4 = evt_get_variable(script, *args++);
662 break;
663 case IMGFX_SET_COLOR:
664 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
665 a2 = evt_get_variable(script, *args++);
666 a3 = evt_get_variable(script, *args++);
667 a4 = evt_get_variable(script, *args++);
669 break;
670 case IMGFX_SET_ALPHA:
672 a5 = evt_get_variable(script, *args++);
674 break;
675 case IMGFX_SET_TINT:
677 a2 = evt_get_variable(script, *args++);
678 a3 = evt_get_variable(script, *args++);
679 a4 = evt_get_variable(script, *args++);
680 a5 = evt_get_variable(script, *args++);
682 break;
683 case IMGFX_SET_ANIM:
684 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
685 a2 = evt_get_variable(script, *args++);
686 a3 = evt_get_variable(script, *args++);
687 a4 = evt_get_variable(script, *args++);
689 break;
690 case IMGFX_HOLOGRAM:
692 a2 = evt_get_variable(script, *args++);
693 a3 = evt_get_variable(script, *args++);
694 a4 = evt_get_variable(script, *args++);
695 a5 = evt_get_variable(script, *args++);
697 break;
698 }
699
701 return ApiStatus_DONE2;
702}
703
704API_CALLABLE(SetPlayerImgFXFlags) {
705 s32 imgfxFlags = *script->ptrReadPos;
706
707 PlayerImgFXFlags = imgfxFlags;
708 return ApiStatus_DONE2;
709}
710
711API_CALLABLE(FacePlayerTowardPoint) {
712 Bytecode* args = script->ptrReadPos;
713 PlayerStatus* playerStatus = &gPlayerStatus;
714 f32* initialYaw = &script->functionTempF[1];
715 f32* deltaYaw = &script->functionTempF[2];
716 s32* duration = &script->functionTemp[3];
717
718 if (isInitialCall) {
719 f32 targetX = evt_get_float_variable(script, *args++);
720 f32 targetY = evt_get_float_variable(script, *args++);
721 f32 targetYaw;
722
723 *initialYaw = playerNpc->yaw = playerStatus->targetYaw;
724
725 if (playerStatus->pos.x != targetX || playerStatus->pos.z != targetY) {
726 targetYaw = atan2(playerStatus->pos.x, playerStatus->pos.z, targetX, targetY);
727 } else {
728 targetYaw = playerStatus->targetYaw;
729 }
730
731 *deltaYaw = targetYaw - *initialYaw;
732 *duration = evt_get_variable(script, *args++);
733 playerNpc->duration = 0;
734
735 if (*deltaYaw < -180.0f) {
736 *deltaYaw += 360.0f;
737 }
738 if (*deltaYaw > 180.0f) {
739 *deltaYaw -= 360.0f;
740 }
741 }
742
743 if (*duration > 0) {
745 playerNpc->yaw = *initialYaw + ((*deltaYaw * playerNpc->duration) / *duration);
746 playerStatus->targetYaw = playerNpc->yaw = clamp_angle(playerNpc->yaw);
747 if (playerNpc->duration < *duration) {
748 return ApiStatus_BLOCK;
749 } else {
750 return ApiStatus_DONE1;
751 }
752 }
753
754 playerNpc->yaw += *deltaYaw;
755 playerStatus->targetYaw = playerNpc->yaw = clamp_angle(playerNpc->yaw);
756 return ApiStatus_DONE2;
757}
758
759API_CALLABLE(DisablePulseStone) {
760 PlayerStatus* playerStatus = &gPlayerStatus;
761
762 if (evt_get_variable(script, *script->ptrReadPos)) {
763 playerStatus->animFlags &= ~PA_FLAG_USING_PULSE_STONE;
764 } else {
765 playerStatus->animFlags |= PA_FLAG_USING_PULSE_STONE;
766 }
767
768 return ApiStatus_DONE2;
769}
770
771// returns partnerID of current partner if using their ability, otherwise PARTNER_NONE
772API_CALLABLE(GetPartnerInUse) {
773 Bytecode* args = script->ptrReadPos;
774 Bytecode outVar = *args++;
775 PlayerData* playerData = &gPlayerData;
776 s32 currentPartner = PARTNER_NONE;
777
779 currentPartner = playerData->curPartner;
780 }
781
782 evt_set_variable(script, outVar, currentPartner);
783 return ApiStatus_DONE2;
784}
785
786API_CALLABLE(ForceUsePartner) {
787 PlayerStatus* playerStatus = &gPlayerStatus;
788
789 playerStatus->animFlags |= PA_FLAG_FORCE_USE_PARTNER;
790 return ApiStatus_DONE2;
791}
792
793API_CALLABLE(InterruptUsePartner) {
794 PlayerStatus* playerStatus = &gPlayerStatus;
795
797 return ApiStatus_DONE2;
798}
799
800API_CALLABLE(Disable8bitMario) {
801 Bytecode* args = script->ptrReadPos;
802 PlayerStatus* playerStatus = &gPlayerStatus;
803
804 if (evt_get_variable(script, *args)) {
805 playerStatus->colliderHeight = 37;
806 playerStatus->colliderDiameter = 26;
807 playerStatus->animFlags &= ~PA_FLAG_8BIT_MARIO;
808 } else {
809 playerStatus->colliderHeight = 19;
810 playerStatus->colliderDiameter = 26;
811 playerStatus->animFlags |= PA_FLAG_8BIT_MARIO
814 }
815
816 return ApiStatus_DONE2;
817}
818
819API_CALLABLE(func_802D2C14) {
820 Bytecode* args = script->ptrReadPos;
821
822 func_800EF3D4(evt_get_variable(script, *args++));
823 return ApiStatus_DONE2;
824}
825
826API_CALLABLE(SetPlayerPushVelocity) {
827 Bytecode* args = script->ptrReadPos;
828 f32 x = evt_get_variable(script, *args++);
829 f32 y;
830 f32 z;
831
833 gPlayerStatus.pushVel.y = evt_get_variable(script, *args++);
834 gPlayerStatus.pushVel.z = evt_get_variable(script, *args++);
835
836 return ApiStatus_DONE2;
837}
838
839API_CALLABLE(PlaySoundAtPlayer) {
840 Bytecode* args = script->ptrReadPos;
841 s32 soundID = evt_get_variable(script, *args++);
842 s32 flags = evt_get_variable(script, *args++);
843
845 return ApiStatus_DONE2;
846}
PartnerData partners[12]
Bytecode * ptrReadPos
u32 AnimID
s8 flags
Definition demo_api.c:15
#define clamp_angle
#define atan2
@ IMGFX_SET_ALPHA
Definition enums.h:5124
@ IMGFX_RESET
Definition enums.h:5120
@ IMGFX_HOLOGRAM
Definition enums.h:5130
@ IMGFX_SET_COLOR
Definition enums.h:5123
@ IMGFX_CLEAR
Definition enums.h:5117
@ IMGFX_SET_WAVY
Definition enums.h:5121
@ IMGFX_SET_TINT
Definition enums.h:5125
@ IMGFX_SET_ANIM
Definition enums.h:5122
@ IMGFX_UNK_2
Definition enums.h:5119
@ IMGFX_UNK_1
Definition enums.h:5118
@ PS_FLAG_CAMERA_DOESNT_FOLLOW
Definition enums.h:3075
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PS_FLAG_INPUT_DISABLED
Definition enums.h:3052
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ NPC_SELF
Definition enums.h:2526
@ PA_FLAG_INTERRUPT_SPIN
Definition enums.h:3110
@ PA_FLAG_INTERRUPT_USE_PARTNER
forces actions with bow, parakarry, watt, and lakilester to end (sushie not tested)
Definition enums.h:3093
@ PA_FLAG_NO_OOB_RESPAWN
Definition enums.h:3121
@ PA_FLAG_FORCE_USE_PARTNER
triggers partner use when set
Definition enums.h:3094
@ PA_FLAG_8BIT_MARIO
Definition enums.h:3105
@ PA_FLAG_USING_PULSE_STONE
Definition enums.h:3098
@ PA_FLAG_USING_WATT
Definition enums.h:3090
@ PA_FLAG_CHANGING_MAP
Definition enums.h:3112
@ SOUND_QUICK_PLAYER_JUMP
Definition enums.h:1424
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3287
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ PARTNER_NONE
Definition enums.h:2885
@ ACTION_STATE_STEP_DOWN_LAND
Definition enums.h:2438
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_LAND
Definition enums.h:2437
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_SPIN
Definition enums.h:2454
@ ACTION_STATE_RUN
Definition enums.h:2428
@ SURFACE_INTERACT_LAND
Definition enums.h:4686
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
s32 ApiStatus
Definition evt.h:115
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void enable_status_bar_input(void)
Definition inventory.c:1472
void partner_disable_input(void)
Definition partners.c:2489
void func_800EF3D4(s32)
Definition partners.c:2414
s32 disable_player_input(void)
Definition 77480.c:990
f32 player_check_collision_below(f32, s32 *colliderID)
Definition 7BB60.c:470
s32 disable_player_static_collisions(void)
Definition 77480.c:972
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
void close_status_bar(void)
Definition inventory.c:1440
s32 enable_player_input(void)
Definition 77480.c:998
void move_player(s32 duration, f32 heading, f32 speed)
Definition 7BB60.c:57
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void func_800E01DC(void)
Definition 77480.c:1008
void enable_player_shadow(void)
Definition 77480.c:964
void player_handle_floor_collider_type(s32 colliderID)
Definition 7BB60.c:326
void sin_cos_deg(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:720
void disable_status_bar_input(void)
Definition inventory.c:1476
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void exec_ShakeCam1(s32 arg0, s32 arg1, s32 arg2)
Definition cam_api.c:365
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
void player_surface_spawn_fx(void)
Definition surfaces.c:42
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
s32 enable_player_static_collisions(void)
Definition 77480.c:980
void disable_player_shadow(void)
Definition 77480.c:968
b32 can_trigger_loading_zone(void)
Definition 7BB60.c:22
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
Npc * get_npc_safe(s32 npcID)
Definition npc.c:1010
void partner_enable_input(void)
Definition partners.c:2480
Npc playerNpcData
Definition script_list.c:43
ApiStatus player_jump(Evt *script, s32 isInitialCall, s32 mode)
Internal function for PlayerJump(), PlayerJump1(), and PlayerJump2().
Definition player_api.c:214
s32 func_802D23F8(void)
Definition player_api.c:582
u16 PlayerImgFXFlags
Definition script_list.c:44
Npc * playerNpc
Definition player_api.c:12
s32 D_802DB5B4[3]
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
ApiStatus GetPartnerInUse(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerImgFXFlags(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerPos(Evt *script, b32 isInitialCall)
Sets the player position.
ApiStatus func_802D2484(Evt *script, b32 isInitialCall)
ApiStatus ForceUsePartner(Evt *script, b32 isInitialCall)
ApiStatus IsPlayerOnValidFloor(Evt *script, b32 isInitialCall)
ApiStatus PlayerJump1(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerAnimation(Evt *script, b32 isInitialCall)
ApiStatus func_802D2148(Evt *script, b32 isInitialCall)
ApiStatus UseEntryHeading(Evt *script, b32 isInitialCall)
ApiStatus PlayerJump2(Evt *script, b32 isInitialCall)
ApiStatus UpdatePlayerImgFX(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerAnimationSpeed(Evt *script, b32 isInitialCall)
ApiStatus DisablePlayerInput(Evt *script, b32 isInitialCall)
Disables player and partner input, and disables the status menu.
ApiStatus HidePlayerShadow(Evt *script, b32 isInitialCall)
Hides the player's shadow if hide is TRUE, shows it if FALSE.
ApiStatus GetPlayerTargetYaw(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerJumpscale(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerCollisionSize(Evt *script, b32 isInitialCall)
Overrides the player collision size.
ApiStatus GetPlayerActionState(Evt *script, b32 isInitialCall)
ApiStatus Disable8bitMario(Evt *script, b32 isInitialCall)
Enables and disables the 8-bit Mario easter egg.
ApiStatus FacePlayerTowardPoint(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerAnimation(Evt *script, b32 isInitialCall)
ApiStatus PlaySoundAtPlayer(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerPushVelocity(Evt *script, b32 isInitialCall)
ApiStatus func_802D2C14(Evt *script, b32 isInitialCall)
ApiStatus PlayerFaceNpc(Evt *script, b32 isInitialCall)
ApiStatus UseExitHeading(Evt *script, b32 isInitialCall)
ApiStatus WaitForPlayerMoveToComplete(Evt *script, b32 isInitialCall)
ApiStatus WaitForPlayerTouchingFloor(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerSpeed(Evt *script, b32 isInitialCall)
Sets the move speed of the player for subequent PlayerMoveTo calls.
ApiStatus SetPlayerActionState(Evt *script, b32 isInitialCall)
ApiStatus FullyRestoreSP(Evt *script, b32 isInitialCall)
ApiStatus DisablePulseStone(Evt *script, b32 isInitialCall)
ApiStatus DisablePartner(Evt *script, b32 isInitialCall)
Disables switching to the given partner.
ApiStatus FullyRestoreHPandFP(Evt *script, b32 isInitialCall)
ApiStatus PlayerMoveTo(Evt *script, b32 isInitialCall)
ApiStatus WaitForPlayerInputEnabled(Evt *script, b32 isInitialCall)
ApiStatus EnablePartner(Evt *script, b32 isInitialCall)
Enables switching to the given partner.
ApiStatus DisablePlayerPhysics(Evt *script, b32 isInitialCall)
Disables player physics if disable is TRUE, enables it if FALSE.
ApiStatus InterpPlayerYaw(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerFlagBits(Evt *script, b32 isInitialCall)
ApiStatus InterruptUsePartner(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerPos(Evt *script, b32 isInitialCall)
ApiStatus func_802D1380(Evt *script, b32 isInitialCall)
ApiStatus PlayerJump(Evt *script, b32 isInitialCall)
ApiStatus func_802D1270(Evt *script, b32 isInitialCall)
#define SP_PER_BAR
Definition macros.h:102
#define NO_COLLIDER
Definition macros.h:156
#define EVT_LIMIT
Definition macros.h:47
MapSettings * get_current_map_settings(void)
Definition world.c:224
EntryList * entryList
Definition map.h:32
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:26
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:995
s16 collisionDiameter
f32 jumpScale
f32 jumpVel
f32 animationSpeed
AnimID curAnim
Vec3f moveToPos
s16 collisionHeight
Vec3f pos
f32 moveSpeed
s16 duration
s32 gOverrideFlags
Definition main_loop.c:11
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
PartnerStatus gPartnerStatus
Definition partners.c:42
GameStatus * gGameStatusPtr
Definition main_loop.c:32
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39