2#include "../src/world/partners.h"
3#include "sprite/npc/WorldParakarry.h"
4#include "sprite/player.h"
6#define NAMESPACE world_parakarry
9BSS b32 N(LockingPlayerInput);
10BSS b32 N(PlayerCollisionDisabled);
11BSS b32 N(PlayerWasFacingLeft);
12BSS s32 N(AbilityState);
13BSS s32 N(AbilityStateTime);
32 parakarry->collisionHeight = 37;
33 parakarry->collisionDiameter = 40;
34 N(UsingAbility) = FALSE;
36 N(LockingPlayerInput) = FALSE;
37 N(PlayerCollisionDisabled) = FALSE;
38 N(PlayerWasFacingLeft) = FALSE;
39 N(AbilityStateTime) = 0;
42API_CALLABLE(N(TakeOut)) {
43 Npc* parakarry = script->owner2.npc;
64API_CALLABLE(N(Update)) {
66 Npc* parakarry = script->owner2.npc;
67 f32 sinAngle, cosAngle, liftoffVelocity;
85 switch (N(TweesterPhysicsPtr)->state) {
87 N(TweesterPhysicsPtr)->state++;
88 N(TweesterPhysicsPtr)->prevFlags = parakarry->
flags;
91 N(TweesterPhysicsPtr)->angle =
atan2(entity->
pos.
x, entity->
pos.
z,
93 N(TweesterPhysicsPtr)->angularVel = 6.0f;
94 N(TweesterPhysicsPtr)->liftoffVelPhase = 50.0f;
95 N(TweesterPhysicsPtr)->countdown = 120;
97 parakarry->
flags &= ~NPC_FLAG_GRAVITY;
100 parakarry->
pos.
x = entity->
pos.
x + (sinAngle * N(TweesterPhysicsPtr)->radius);
101 parakarry->
pos.
z = entity->
pos.
z - (cosAngle * N(TweesterPhysicsPtr)->radius);
102 N(TweesterPhysicsPtr)->angle =
clamp_angle(N(TweesterPhysicsPtr)->angle - N(TweesterPhysicsPtr)->angularVel);
104 if (N(TweesterPhysicsPtr)->radius > 20.0f) {
105 N(TweesterPhysicsPtr)->radius--;
106 }
else if (N(TweesterPhysicsPtr)->radius < 19.0f) {
107 N(TweesterPhysicsPtr)->radius++;
110 liftoffVelocity =
sin_rad(
DEG_TO_RAD(N(TweesterPhysicsPtr)->liftoffVelPhase)) * 3.0f;
111 N(TweesterPhysicsPtr)->liftoffVelPhase += 3.0f;
113 if (N(TweesterPhysicsPtr)->liftoffVelPhase > 150.0f) {
114 N(TweesterPhysicsPtr)->liftoffVelPhase = 150.0f;
117 parakarry->
pos.
y += liftoffVelocity;
119 N(TweesterPhysicsPtr)->angularVel += 0.8;
121 if (N(TweesterPhysicsPtr)->angularVel > 40.0f) {
122 N(TweesterPhysicsPtr)->angularVel = 40.0f;
125 if (--N(TweesterPhysicsPtr)->countdown == 0) {
126 N(TweesterPhysicsPtr)->state++;
130 parakarry->
flags = N(TweesterPhysicsPtr)->prevFlags;
131 N(TweesterPhysicsPtr)->countdown = 30;
132 N(TweesterPhysicsPtr)->state++;
138 if (--N(TweesterPhysicsPtr)->countdown == 0) {
156 parakarry->
flags = N(TweesterPhysicsPtr)->prevFlags;
163 f32 x, y, z, length, hitRx, hitRz, hitDirX, hitDirZ;
171 length = colliderBaseHeight / 2.0f;
174 &hitRz, &hitDirX, &hitDirZ);
186API_CALLABLE(N(UseAbility)) {
189 Npc* parakarry = script->owner2.npc;
191 f32 x, y, z, yaw, length;
192 f32 playerDeltaX, playerDeltaZ;
193 f32 parakarryDeltaX, parakarryDeltaZ;
194 f32 halfCollisionHeight;
213 parakarry->
flags &= ~NPC_FLAG_COLLDING_FORWARD_WITH_WORLD;
219 N(UsingAbility) = TRUE;
221 parakarry->
curAnim = ANIM_WorldParakarry_CarryLight;
224 parakarry->
flags &= ~NPC_FLAG_COLLDING_FORWARD_WITH_WORLD;
229 switch (N(AbilityState)) {
234 N(AbilityStateTime) = 3;
239 if (N(AbilityStateTime) == 0) {
245 N(AbilityStateTime)--;
250 switch (N(AbilityState)) {
256 N(LockingPlayerInput) = TRUE;
257 N(PlayerCollisionDisabled) = TRUE;
258 N(UsingAbility) = TRUE;
284 parakarry->
curAnim = ANIM_WorldParakarry_Run;
288 yaw += !N(PlayerWasFacingLeft) ? 90.0f : -90.0f;
305 parakarry->
curAnim = ANIM_WorldParakarry_CarryHeavy;
312 N(AbilityStateTime) = 20;
337 playerStatus->
pos.
y += length;
338 parakarry->
pos.
y += length;
339 x = parakarry->
pos.
x;
341 z = parakarry->
pos.
z;
343 halfCollisionHeight = length;
346 if (length < halfCollisionHeight) {
347 N(AbilityStateTime) = 0;
352 x = playerStatus->
pos.
x;
354 z = playerStatus->
pos.
z;
362 x = playerStatus->
pos.
x;
363 y = playerStatus->
pos.
y;
364 z = playerStatus->
pos.
z;
367 playerStatus->
pos.
x += (x - playerStatus->
pos.
x) / 8.0f;
368 playerStatus->
pos.
z += (z - playerStatus->
pos.
z) / 8.0f;
369 parakarry->
pos.
x += (x - parakarry->
pos.
x) / 8.0f;
370 parakarry->
pos.
z += (z - parakarry->
pos.
z) / 8.0f;
373 x = parakarry->
pos.
x;
374 y = parakarry->
pos.
y;
375 z = parakarry->
pos.
z;
378 playerDeltaX = (x - playerStatus->
pos.
x) / 8.0f;
379 playerDeltaZ = (z - playerStatus->
pos.
z) / 8.0f;
380 parakarryDeltaX = (x - parakarry->
pos.
x) / 8.0f;
381 parakarryDeltaZ = (z - parakarry->
pos.
z) / 8.0f;
383 x = parakarry->
pos.
x + parakarryDeltaX;
384 z = parakarry->
pos.
z + parakarryDeltaZ;
386 x = parakarry->
pos.
x;
387 y = parakarry->
pos.
y;
388 z = parakarry->
pos.
z;
391 playerStatus->
pos.
x += playerDeltaX;
392 playerStatus->
pos.
z += playerDeltaZ;
393 parakarry->
pos.
x += parakarryDeltaX;
394 parakarry->
pos.
z += parakarryDeltaZ;
404 x = playerStatus->
pos.
x;
406 z = playerStatus->
pos.
z;
416 playerStatus->
pos.
y += (y - playerStatus->
pos.
y) / 4.0f;
417 parakarry->
pos.
y = playerStatus->
pos.
y + 32.0f;
429 if (N(AbilityStateTime) != 0) {
430 N(AbilityStateTime)--;
436 parakarry->
curAnim = ANIM_WorldParakarry_CarryHeavy;
461 if (!parakarry->
pos.
x) {
474 if (parakarry->
jumpVel > 0.0) {
497 x = playerStatus->
pos.
x;
498 y = playerStatus->
pos.
y;
499 z = playerStatus->
pos.
z;
509 x = parakarry->
pos.
x;
510 y = parakarry->
pos.
y;
511 z = parakarry->
pos.
z;
517 x = parakarry->
pos.
x;
519 z = parakarry->
pos.
z;
522 halfCollisionHeight = length;
525 playerStatus->
pos.
y = parakarry->
pos.
y - 32.0f;
528 x = playerStatus->
pos.
x;
530 z = playerStatus->
pos.
z;
534 playerStatus->
pos.
y += (y - playerStatus->
pos.
y) / 4.0f;
535 parakarry->
pos.
y = playerStatus->
pos.
y + 32.0f;
536 y = parakarry->
pos.
y;
537 parakarry->
pos.
y = playerStatus->
pos.
y;
539 parakarry->
pos.
y = y;
556 N(AbilityStateTime) = 5;
568 if (N(AbilityStateTime) != 0) {
569 N(AbilityStateTime)--;
580 parakarry->
curAnim = ANIM_WorldParakarry_Idle;
581 N(UsingAbility) = FALSE;
583 parakarry->
flags &= ~NPC_FLAG_JUMPING;
590 if (N(LockingPlayerInput)) {
593 if (N(PlayerCollisionDisabled)) {
619API_CALLABLE(N(PutAway)) {
620 Npc* parakarry = script->owner2.npc;
642 if (N(UsingAbility)) {
643 if (N(PlayerCollisionDisabled)) {
647 if (N(LockingPlayerInput)) {
652 partnerStatus->
npc = *parakarry;
664 if (N(PlayerCollisionDisabled)) {
667 if (N(LockingPlayerInput)) {
672 *parakarry = partnerStatus->
npc;
s32 partner_use_ability(void)
@ TWEESTER_PARTNER_ATTRACT
@ TWEESTER_PARTNER_RELEASE
@ PARTNER_ACTION_PARAKARRY_HOVER
@ LANDING_CAM_NEVER_ADJUST
@ COLLIDER_FLAG_IGNORE_PLAYER
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
@ ACTION_STATE_HOP
Released A before apex of jump.
@ ACTION_STATE_HIT_FIRE
Causes Mario to fly up and take damage. Used for fire bars.
@ CAMERA_MOVE_IGNORE_PLAYER_Y
@ NPC_FLAG_IGNORE_WORLD_COLLISION
@ NPC_FLAG_IGNORE_PLAYER_COLLISION
@ NPC_FLAG_COLLDING_FORWARD_WITH_WORLD
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
@ NPC_FLAG_COLLDING_WITH_WORLD
b32 npc_raycast_down_around(s32, f32 *, f32 *, f32 *, f32 *, f32, f32)
void disable_npc_blur(Npc *npc)
HitID player_raycast_below_cam_relative(PlayerStatus *playerStatus, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
s32 npc_test_move_complex_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
void suggest_player_anim_always_forward(AnimID anim)
void partner_clear_player_tracking(Npc *partner)
void partner_flying_update_player_tracking(Npc *partner)
s32 disable_player_input(void)
s32 get_collider_flags(s32 colliderID)
void enable_npc_blur(Npc *npc)
s32 disable_player_static_collisions(void)
s32 enable_player_input(void)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
s32 phys_adjust_cam_on_landing(void)
void gravity_use_fall_parms(void)
void start_bounce_b(void)
void set_action_state(s32 actionState)
void enable_partner_ai(void)
b32 npc_raycast_up(s32, f32 *, f32 *, f32 *, f32 *)
HitID player_raycast_up_corners(PlayerStatus *, f32 *, f32 *, f32 *, f32 *, f32)
void suggest_player_anim_allow_backward(AnimID anim)
void partner_flying_update_motion(Npc *partner)
void partner_flying_enable(Npc *partner, s32 val)
s32 enable_player_static_collisions(void)
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
EncounterStatus gCurrentEncounter
s32 func_800EA52C(s32 partnerID)
s32 partner_init_get_out(Npc *npc)
s32 partner_init_put_away(Npc *partner)
s32 partner_put_away(Npc *partner)
s32 partner_force_player_flip_done(void)
s32 partner_get_out(Npc *partner)
void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID)
void sfx_stop_sound(s32 soundID)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
#define Return
Kills the current EVT thread.
Entity * TweesterTouchingPartner
CollisionStatus gCollisionStatus
PartnerStatus gPartnerStatus
GameStatus * gGameStatusPtr
s32 NpcHitQueryColliderID
PlayerStatus gPlayerStatus
EvtScript EVS_WorldParakarry_UseAbility
void N pre_battle(Npc *parakarry)
void N post_battle(Npc *parakarry)
EvtScript EVS_WorldParakarry_PutAway
HitID N update_current_floor(void)
EvtScript EVS_WorldParakarry_Update
void N init(Npc *parakarry)
EvtScript EVS_WorldParakarry_TakeOut
void N try_cancel_tweester(Npc *parakarry)