Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
lakilester.c
Go to the documentation of this file.
1#include "common.h"
2#include "../partners.h"
3#include "effects.h"
4#include "sprite/npc/WorldLakilester.h"
5#include "sprite/player.h"
6
7#define NAMESPACE world_lakilester
8
9BSS s32 N(PutAwayState);
10BSS b32 N(LockingPlayerInput);
11BSS b32 N(PlayerCollisionDisabled);
12BSS s32 N(MountState);
13BSS b32 N(UpdatePushingWall);
14BSS s32 N(AbilityState);
15BSS s32 N(PlayerBounceOffset);
16BSS s32 N(MoveSoundsTime);
17BSS s32 N(MovePitchAdjustment);
18BSS s32 N(MountingDeltaY);
19BSS f32 N(CurrentGroundPitch);
20BSS s32 N(D_802BFF2C); // unused (padding?)
21
22enum {
29 RIDE_STATE_START_RIDING = 104, // cannot dismount until this state is done
36};
37
38// states for putting lakilester away, paralleling ride states
39enum {
46};
47
48enum {
52};
53
54void N(offset_player_from_camera)(f32 arg0);
55
56void N(sync_player_position)(void) {
57 PlayerStatus* playerStatus = &gPlayerStatus;
58 Npc* lakilester = get_npc_unsafe(NPC_PARTNER);
59 f32 speed;
60
61 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
62 speed = playerStatus->curSpeed;
63 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
64 speed *= 0.5f;
65 }
66
67 add_vec2D_polar(&lakilester->pos.x, &lakilester->pos.z, speed, playerStatus->heading);
68 lakilester->yaw = playerStatus->targetYaw;
69 }
70
71 playerStatus->pos.x = lakilester->pos.x;
72 playerStatus->pos.y = lakilester->pos.y + 10.0f + abs(N(PlayerBounceOffset)) * 0.34f;
73 playerStatus->pos.z = lakilester->pos.z;
74 add_vec2D_polar(&playerStatus->pos.x, &playerStatus->pos.z, 2.0f, gCameras[gCurrentCameraID].curYaw);
75}
76
77void N(init)(Npc* lakilester) {
78 lakilester->collisionHeight = 38;
79 lakilester->collisionDiameter = 36;
80 lakilester->collisionChannel = COLLIDER_FLAG_IGNORE_PLAYER;
81 N(PlayerBounceOffset) = 0;
82 N(LockingPlayerInput) = FALSE;
83 N(PlayerCollisionDisabled) = FALSE;
84 N(MountState) = MOUNT_STATE_NONE;
85 N(UpdatePushingWall) = TRUE;
86 N(MoveSoundsTime) = 0;
87 N(MovePitchAdjustment) = 0;
88 N(MountingDeltaY) = 0;
89 N(CurrentGroundPitch) = 0;
90 lakilester->moveToPos.x = lakilester->pos.x;
91 lakilester->moveToPos.y = lakilester->pos.y;
92 lakilester->moveToPos.z = lakilester->pos.z;
93}
94
95API_CALLABLE(N(TakeOut)) {
96 Npc* lakilester = script->owner2.npc;
97
98 if (isInitialCall) {
99 partner_init_get_out(lakilester);
100 }
101
102 if (partner_get_out(lakilester)) {
103 return ApiStatus_DONE1;
104 } else {
105 return ApiStatus_BLOCK;
106 }
107}
108
110 Call(N(TakeOut))
111 Return
112 End
113};
114
115BSS TweesterPhysics N(TweesterPhysicsData);
116TweesterPhysics* N(TweesterPhysicsPtr) = &N(TweesterPhysicsData);
117
118API_CALLABLE(N(Update)) {
119 PlayerData* playerData = &gPlayerData;
120 Npc* lakilester = script->owner2.npc;
121 f32 sinAngle, cosAngle, liftoffVelocity;
122 Entity* entity;
123
124 if (isInitialCall) {
125 partner_flying_enable(lakilester, 1);
126 mem_clear(N(TweesterPhysicsPtr), sizeof(TweesterPhysics));
128 }
129
130 playerData->partnerUsedTime[PARTNER_LAKILESTER]++;
131 lakilester->flags |= NPC_FLAG_DIRTY_SHADOW;
133
134 if (entity == NULL) {
137 return ApiStatus_BLOCK;
138 }
139
140 switch (N(TweesterPhysicsPtr)->state) {
142 N(TweesterPhysicsPtr)->state++;
143 N(TweesterPhysicsPtr)->prevFlags = lakilester->flags;
144 N(TweesterPhysicsPtr)->radius = fabsf(dist2D(lakilester->pos.x, lakilester->pos.z, entity->pos.x, entity->pos.z));
145 N(TweesterPhysicsPtr)->angle = atan2(entity->pos.x, entity->pos.z, lakilester->pos.x, lakilester->pos.z);
146 N(TweesterPhysicsPtr)->angularVel = 6.0f;
147 N(TweesterPhysicsPtr)->liftoffVelPhase = 50.0f;
148 N(TweesterPhysicsPtr)->countdown = 120;
150 lakilester->flags &= ~NPC_FLAG_GRAVITY;
152 sin_cos_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->angle), &sinAngle, &cosAngle);
153 lakilester->pos.x = entity->pos.x + (sinAngle * N(TweesterPhysicsPtr)->radius);
154 lakilester->pos.z = entity->pos.z - (cosAngle * N(TweesterPhysicsPtr)->radius);
155 N(TweesterPhysicsPtr)->angle = clamp_angle(N(TweesterPhysicsPtr)->angle - N(TweesterPhysicsPtr)->angularVel);
156
157 if (N(TweesterPhysicsPtr)->radius > 20.0f) {
158 N(TweesterPhysicsPtr)->radius--;
159 } else if (N(TweesterPhysicsPtr)->radius < 19.0f) {
160 N(TweesterPhysicsPtr)->radius++;
161 }
162
163 liftoffVelocity = sin_rad(DEG_TO_RAD(N(TweesterPhysicsPtr)->liftoffVelPhase)) * 3.0f;
164 N(TweesterPhysicsPtr)->liftoffVelPhase += 3.0f;
165
166 if (N(TweesterPhysicsPtr)->liftoffVelPhase > 150.0f) {
167 N(TweesterPhysicsPtr)->liftoffVelPhase = 150.0f;
168 }
169
170 lakilester->pos.y += liftoffVelocity;
171 lakilester->renderYaw = clamp_angle(360.0f - N(TweesterPhysicsPtr)->angle);
172 N(TweesterPhysicsPtr)->angularVel += 0.8;
173
174 if (N(TweesterPhysicsPtr)->angularVel > 40.0f) {
175 N(TweesterPhysicsPtr)->angularVel = 40.0f;
176 }
177
178 if (--N(TweesterPhysicsPtr)->countdown == 0) {
179 N(TweesterPhysicsPtr)->state++;
180 }
181 break;
183 lakilester->flags = N(TweesterPhysicsPtr)->prevFlags;
184 N(TweesterPhysicsPtr)->countdown = 30;
185 N(TweesterPhysicsPtr)->state++;
186 break;
190
191 if (--N(TweesterPhysicsPtr)->countdown == 0) {
192 N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT;
194 }
195 break;
196 }
197 return ApiStatus_BLOCK;
198}
199
201 Call(N(Update))
202 Return
203 End
204};
205
206void N(try_cancel_tweester)(Npc* lakilester) {
207 if (TweesterTouchingPartner != NULL) {
209 lakilester->flags = N(TweesterPhysicsPtr)->prevFlags;
210 N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT;
212 }
213}
214
215void N(get_movement_from_input)(f32* outAngle, f32* outSpeed) {
216 PartnerStatus* partnerStatus = &gPartnerStatus;
217 f32 stickX = partnerStatus->stickX;
218 f32 stickY = partnerStatus->stickY;
219 f32 moveAngle = clamp_angle(atan2(0.0f, 0.0f, stickX, -stickY) + gCameras[CAM_DEFAULT].curYaw);
220 f32 moveSpeed = 0.0f;
221
222 if (dist2D(0.0f, 0.0f, stickX, -stickY) >= 1.0) {
223 moveSpeed = 3.0f;
224 if (SQ(stickX) + SQ(stickY) > SQ(55)) {
225 moveSpeed = 6.0f;
226 }
227 }
228
229 *outAngle = moveAngle;
230 *outSpeed = moveSpeed;
231}
232
233s32 N(can_dismount)(void) {
234 PlayerStatus* playerStatus = &gPlayerStatus;
235 Camera* currentCamera;
236 f32 hitDirX, hitDirZ;
237 f32 hitRx, hitRz;
238 f32 outX, outY, outZ, outLength;
239 Npc* lakilester = get_npc_unsafe(NPC_PARTNER);
240 s32 temp;
241 HitID hitID;
242 s32 canDismount;
243 s32 entityType;
244
245 if (playerStatus->animFlags & PA_FLAG_DISMOUNTING_ALLOWED) {
246 playerStatus->animFlags &= ~PA_FLAG_DISMOUNTING_ALLOWED;
247 return TRUE;
248 }
249
250 canDismount = FALSE;
251 outLength = 16.0f;
252 outY = lakilester->moveToPos.y + 7.0f;
253 outX = playerStatus->pos.x;
254 outZ = playerStatus->pos.z;
255 currentCamera = &gCameras[gCurrentCameraID];
256 add_vec2D_polar(&outX, &outZ, 2.0f, currentCamera->curYaw);
257 hitID = player_raycast_below_cam_relative(playerStatus, &outX, &outY, &outZ, &outLength, &hitRx, &hitRz,
258 &hitDirX, &hitDirZ);
259 temp = hitID;
260
261 //TODO find better match
262 if (outLength <= 16.0f && temp > NO_COLLIDER) {
263 if (!(temp & COLLISION_WITH_ENTITY_BIT) ||
264 (entityType = get_entity_type(temp),
265 !(entityType == ENTITY_TYPE_SIMPLE_SPRING || entityType == ENTITY_TYPE_SCRIPT_SPRING))
266 ) {
267 temp = get_collider_flags(temp) & COLLIDER_FLAGS_SURFACE_TYPE_MASK; //TODO 'temp' is now 'surfaceType'
268 if (!(temp == SURFACE_TYPE_WATER || temp == SURFACE_TYPE_SPIKES || temp == SURFACE_TYPE_LAVA)) {
269 if (temp != SURFACE_TYPE_SLIDE) {
270 lakilester->moveToPos.x = outX;
271 lakilester->moveToPos.y = outY;
272 lakilester->moveToPos.z = outZ;
273 canDismount = TRUE;
274 }
275 }
276 }
277 }
278 return canDismount;
279}
280
281#if !VERSION_JP
282s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) {
283 f32 x = gPlayerStatus.pos.x;
284 f32 y = gPlayerStatus.pos.y + height;
285 f32 z = gPlayerStatus.pos.z;
286 f32 depth = dist;
287 f32 hitRx, hitRz;
288 f32 hitDirX, hitDirZ;
289 f32 deltaY;
290
291 N(MountingDeltaY) = 0;
292
293 if (player_raycast_below_cam_relative(&gPlayerStatus, &x, &y, &z, &depth,
294 &hitRx, &hitRz, &hitDirX, &hitDirZ) > NO_COLLIDER)
295 {
296 deltaY = y - lakilester->moveToPos.y;
297 if (deltaY != 0.0f) {
298 if (fabs(deltaY) < 10.0) {
299 N(MountingDeltaY) = deltaY;
300 lakilester->moveToPos.y = y;
301 return TRUE;
302 } else {
303 return FALSE;
304 }
305 }
306 return TRUE;
307 }
308 return FALSE;
309}
310#endif
311
313 f32 radius = lakilester->collisionDiameter * 0.8f;
314 f32 x, y, z, yaw;
315
316 // combine testing boilerplate
317 #define TEST_MOVE_AT_ANGLE(testFunc, angle) \
318 ( \
319 yaw = clamp_angle(angle), \
320 x = lakilester->pos.x, \
321 y = lakilester->moveToPos.y, \
322 z = lakilester->pos.z, \
323 testFunc(lakilester->collisionChannel, &x, &y, &z, 0.0f, yaw, lakilester->collisionHeight, radius) \
324 )
325
328 lakilester->curWall = NpcHitQueryColliderID;
329 lakilester->pos.x = x;
330 lakilester->pos.z = z;
331 } else {
333 }
334
335 if (TEST_MOVE_AT_ANGLE(npc_test_move_taller_with_slipping, lakilester->yaw + 45.0f)) {
336 lakilester->pos.x = x;
337 lakilester->pos.z = z;
338 lakilester->flags |= NPC_FLAG_COLLDING_WITH_WORLD;
339 } else {
340 lakilester->flags &= ~NPC_FLAG_COLLDING_WITH_WORLD;
341 }
342
343 if (TEST_MOVE_AT_ANGLE(npc_test_move_taller_with_slipping, lakilester->yaw - 45.0f)) {
344 lakilester->pos.x = x;
345 lakilester->pos.z = z;
346 lakilester->flags |= NPC_FLAG_COLLDING_WITH_WORLD;
347 } else {
348 lakilester->flags &= ~NPC_FLAG_COLLDING_WITH_WORLD;
349 }
350
351 if (TEST_MOVE_AT_ANGLE(npc_test_move_simple_with_slipping, lakilester->yaw + 45.0f + 180.0f)) {
352 lakilester->flags |= NPC_FLAG_COLLDING_WITH_WORLD;
353 lakilester->pos.x = x;
354 lakilester->pos.z = z;
355 } else {
356 lakilester->flags &= ~NPC_FLAG_COLLDING_WITH_WORLD;
357 }
358
359 if (TEST_MOVE_AT_ANGLE(npc_test_move_simple_with_slipping, lakilester->yaw - 45.0f + 180.0f)) {
360 lakilester->flags |= NPC_FLAG_COLLDING_WITH_WORLD;
361 lakilester->pos.x = x;
362 lakilester->pos.z = z;
363 } else {
364 lakilester->flags &= ~NPC_FLAG_COLLDING_WITH_WORLD;
365 }
366}
367
368void N(update_riding_physics)(Npc* lakilester) {
369 PlayerStatus* playerStatus = &gPlayerStatus;
370 CollisionStatus* collisionStatus = &gCollisionStatus;
371 PartnerStatus* partnerStatus = &gPartnerStatus;
372 f32 hitDepth, sp40, sp44, sp48, sp4C, sinAngle, cosAngle;
373 f32 moveAngle, moveSpeed;
374 f32 x, y, z;
375 f32 temp_f0_3;
376 s32 raycastBelowResult;
377 s32 currentSurfaceType;
378 s32 belowSurfaceType;
379 s32 pitchShift;
380 f32 height;
381
382 moveAngle = 0.0f;
383 moveSpeed = 0.0f;
384 N(get_movement_from_input)(&moveAngle, &moveSpeed);
385
386 currentSurfaceType = get_collider_flags(lakilester->curFloor) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
387 if (currentSurfaceType == SURFACE_TYPE_LAVA) {
388 moveSpeed *= 0.5f;
389 }
390
391 if (N(CurrentGroundPitch) >= 20.0f) {
392 moveSpeed *= 0.8f;
393 }
394
395 lakilester->moveSpeed = moveSpeed;
396
397 if (moveSpeed != 0.0f) {
398 N(MoveSoundsTime)++;
399 N(MovePitchAdjustment)++;
400 if (N(MoveSoundsTime) % 8 == 0) {
401 if (N(MovePitchAdjustment) >= 120) {
402 N(MovePitchAdjustment) = 0;
403 }
404
405 if (N(MovePitchAdjustment) < 60) {
406 pitchShift = update_lerp(EASING_LINEAR, 0.0f, 100.0f, N(MovePitchAdjustment), 60);
407 sfx_play_sound_with_params(SOUND_FLIGHT, 0, 64, pitchShift);
408 } else {
409 pitchShift = update_lerp(EASING_LINEAR, 100.0f, 0.0f, N(MovePitchAdjustment) - 60, 60);
410 sfx_play_sound_with_params(SOUND_FLIGHT, 0, 64, pitchShift);
411 }
412 }
413 }
414
415 x = lakilester->pos.x;
416 y = lakilester->moveToPos.y;
417 z = lakilester->pos.z;
418
419 if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z,
420 lakilester->collisionDiameter, lakilester->yaw, lakilester->collisionHeight, lakilester->collisionDiameter))
421 {
422 collisionStatus->curInspect = (partnerStatus->pressedButtons & BUTTON_A) ? NpcHitQueryColliderID : NO_COLLIDER;
423 }
424
425 if (moveSpeed != 0.0f) {
426 lakilester->yaw = moveAngle;
427 x = lakilester->pos.x;
428 y = lakilester->moveToPos.y;
429 z = lakilester->pos.z;
430 if (npc_test_move_complex_with_slipping(lakilester->collisionChannel, &x, &y, &z,
431 lakilester->moveSpeed, lakilester->yaw, lakilester->collisionHeight, lakilester->collisionDiameter))
432 {
433 if (N(UpdatePushingWall)) {
434 collisionStatus->pushingAgainstWall = NpcHitQueryColliderID;
435 }
436 lakilester->pos.x += (x - lakilester->pos.x) / 5.0f;
437 lakilester->pos.z += (z - lakilester->pos.z) / 5.0f;
438 } else {
439 npc_move_heading(lakilester, lakilester->moveSpeed, moveAngle);
440 if (N(UpdatePushingWall)) {
441 collisionStatus->pushingAgainstWall = NO_COLLIDER;
442 }
443 }
444
445 moveAngle = clamp_angle(lakilester->yaw - 30.0f);
446 x = lakilester->pos.x;
447 y = lakilester->moveToPos.y;
448 z = lakilester->pos.z;
449 if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z,
450 lakilester->moveSpeed, moveAngle, lakilester->collisionHeight, lakilester->collisionDiameter))
451 {
452 lakilester->pos.x += (x - lakilester->pos.x) / 5.0f;
453 lakilester->pos.z += (z - lakilester->pos.z) / 5.0f;
454 }
455
456 moveAngle = clamp_angle(lakilester->yaw + 30.0f);
457 x = lakilester->pos.x;
458 y = lakilester->moveToPos.y;
459 z = lakilester->pos.z;
460 if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z,
461 lakilester->moveSpeed, moveAngle, lakilester->collisionHeight, lakilester->collisionDiameter))
462 {
463 lakilester->pos.x += (x - lakilester->pos.x) / 5.0f;
464 lakilester->pos.z += (z - lakilester->pos.z) / 5.0f;
465 }
466
468
469 } else {
470 moveAngle = 90.0f;
471 x = lakilester->pos.x;
472 y = lakilester->moveToPos.y;
473 z = lakilester->pos.z;
474 if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z,
475 4.0f, moveAngle, lakilester->collisionHeight, lakilester->collisionDiameter))
476 {
477 lakilester->pos.x += (x - lakilester->pos.x) / 5.0f;
478 lakilester->pos.z += (z - lakilester->pos.z) / 5.0f;
479 }
480
481 moveAngle = 270.0f;
482 x = lakilester->pos.x;
483 y = lakilester->moveToPos.y;
484 z = lakilester->pos.z;
485 if (npc_test_move_taller_with_slipping(lakilester->collisionChannel, &x, &y, &z,
486 4.0f, moveAngle, lakilester->collisionHeight, lakilester->collisionDiameter))
487 {
488 lakilester->pos.x += (x - lakilester->pos.x) / 5.0f;
489 lakilester->pos.z += (z - lakilester->pos.z) / 5.0f;
490 }
491 }
492
493 N(apply_riding_static_collisions)(lakilester);
494 lakilester->moveToPos.y -= lakilester->jumpScale;
495 hitDepth = lakilester->collisionHeight + 2;
496 y = lakilester->moveToPos.y + 12.0f;
497 x = playerStatus->pos.x;
498 z = playerStatus->pos.z;
499 add_vec2D_polar(&x, &z, 2.0f, gCameras[gCurrentCameraID].curYaw);
500 raycastBelowResult = player_raycast_below_cam_relative(playerStatus, &x, &y, &z, &hitDepth, &sp40,
501 &sp44, &sp48, &sp4C);
502 N(CurrentGroundPitch) = get_player_normal_pitch();
503 height = 12.0f;
504
505 if (N(CurrentGroundPitch) != 0.0f) {
506 height = 32.0f;
507 }
508
509 if (N(CurrentGroundPitch) > 0.0f && raycastBelowResult >= 0) {
510 sin_cos_rad(DEG_TO_RAD(N(CurrentGroundPitch)), &sinAngle, &cosAngle);
511 lakilester->pos.y = (lakilester->pos.y + fabs((sinAngle / cosAngle) * playerStatus->runSpeed));
512 }
513
514 if (hitDepth <= height && raycastBelowResult > NO_COLLIDER) {
515 playerStatus->lastGoodPos.x = lakilester->pos.x;
516 playerStatus->lastGoodPos.y = lakilester->pos.y;
517 playerStatus->lastGoodPos.z = lakilester->pos.z;
518 collisionStatus->curFloor = raycastBelowResult;
519
520 lakilester->curFloor = raycastBelowResult;
521 lakilester->moveToPos.y = y;
522 lakilester->moveToPos.x = x;
523 lakilester->moveToPos.z = z;
524 lakilester->jumpScale = 0.0f;
525 playerStatus->timeInAir = 0;
526
527 belowSurfaceType = get_collider_flags(raycastBelowResult) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
528 if (belowSurfaceType == SURFACE_TYPE_LAVA) {
529 lakilester->curAnim = ANIM_WorldLakilester_StrainWalk;
530 lakilester->moveSpeed = moveSpeed * 0.5f;
531 } else {
532 lakilester->curAnim = ANIM_WorldLakilester_Walk;
533 lakilester->moveSpeed = moveSpeed;
534 }
535 return;
536 }
537
538 collisionStatus->curFloor = NO_COLLIDER;
539 playerStatus->timeInAir++;
540 lakilester->curFloor = NO_COLLIDER;
541 lakilester->jumpScale += 1.8;
542
543 if (lakilester->jumpScale > 12.0f) {
544 lakilester->jumpScale = 12.0f;
545 }
546}
547
548#if VERSION_JP
549s32 N(test_mounting_height_adjustment)(Npc* lakilester, f32 height, f32 dist) {
550 f32 x = gPlayerStatus.pos.x;
551 f32 y = gPlayerStatus.pos.y + height;
552 f32 z = gPlayerStatus.pos.z;
553 f32 depth = dist;
554 f32 hitRx, hitRz;
555 f32 hitDirX, hitDirZ;
556 f32 deltaY;
557
558 N(MountingDeltaY) = 0;
559
560 if (npc_raycast_down_around(0, &x, &y, &z, &depth,
561 lakilester->yaw, lakilester->collisionDiameter))
562 {
563 deltaY = y - lakilester->moveToPos.y;
564 if (deltaY != 0.0f) {
565 if (fabs(deltaY) < 10.0) {
566 N(MountingDeltaY) = deltaY;
567 lakilester->moveToPos.y = y;
568 return TRUE;
569 } else {
570 return FALSE;
571 }
572 }
573 return TRUE;
574 }
575 return FALSE;
576}
577#endif
578
579s32 N(test_dismount_height)(f32* posY) {
580 f32 colliderHeight = gPlayerStatus.colliderHeight;
581 f32 hitDirX, hitDirZ;
582 f32 hitRx, hitRz;
583 f32 posX, posZ;
584
585 *posY = gPlayerStatus.pos.y + colliderHeight;
586 posX = gPlayerStatus.pos.x;
587 posZ = gPlayerStatus.pos.z;
588
589 return player_raycast_below_cam_relative(&gPlayerStatus, &posX, posY, &posZ,
590 &colliderHeight, &hitRx, &hitRz, &hitDirX, &hitDirZ);
591}
592
593API_CALLABLE(N(UseAbility)) {
594 PlayerStatus* playerStatus = &gPlayerStatus;
595 PartnerStatus* partnerStatus = &gPartnerStatus;
596 Camera* camera = &gCameras[CAM_DEFAULT];
597 Npc* lakilester = script->owner2.npc;
598 f32 x, y, z, dist;
599 f32 yaw, camYaw;
600 s32 i;
601
602 playerStatus->animFlags &= ~PA_FLAG_RIDING_PARTNER;
603
604 if (isInitialCall) {
605 N(try_cancel_tweester)(lakilester);
606 if (!(playerStatus->animFlags & PA_FLAG_CHANGING_MAP)) {
607 lakilester->flags = lakilester->flags & ~PA_FLAG_PULSE_STONE_VISIBLE;
608 lakilester->moveToPos.x = lakilester->pos.x;
609 lakilester->moveToPos.y = lakilester->pos.y;
610 lakilester->moveToPos.z = lakilester->pos.z;
611
613 || (playerStatus->animFlags & PA_FLAG_PARTNER_USAGE_FORCED)
614 ) {
615 if (playerStatus->animFlags & PA_FLAG_PARTNER_USAGE_FORCED) {
616 playerStatus->animFlags &= ~PA_FLAG_PARTNER_USAGE_FORCED;
617 }
618 N(AbilityState) = RIDE_STATE_MOUNT_1;
619 } else {
620 N(AbilityState) = RIDE_STATE_BEGIN;
621 }
622
623 if (!partnerStatus->shouldResumeAbility) {
625 if (playerStatus->actionState == ACTION_STATE_RIDE
626 || playerStatus->actionState == ACTION_STATE_IDLE
627 || playerStatus->actionState == ACTION_STATE_WALK
628 || playerStatus->actionState == ACTION_STATE_RUN
629 || playerStatus->actionState == ACTION_STATE_FALLING
630 ) {
631 playerStatus->flags |= PS_FLAG_PAUSE_DISABLED;
632 } else {
633 return ApiStatus_DONE2;
634 }
635 }
636 } else {
637 partnerStatus->shouldResumeAbility = FALSE;
638 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
642 suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki);
643 lakilester->curAnim = ANIM_WorldLakilester_Walk;
644 N(MountState) = MOUNT_STATE_IN_PROGRESS; // unexpected
647 partnerStatus->actingPartner = PARTNER_LAKILESTER;
650 lakilester->pos.x = playerStatus->pos.x;
651 lakilester->pos.y = lakilester->moveToPos.y;
652 lakilester->pos.z = playerStatus->pos.z;
653 lakilester->curAnim = ANIM_WorldLakilester_Walk;
654 playerStatus->pos.y = lakilester->pos.y + 10.0f;
655 lakilester->moveSpeed = 3.0f;
656 lakilester->jumpScale = 0.0f;
657 lakilester->yaw = playerStatus->targetYaw;
658 suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki);
661 N(PlayerCollisionDisabled) = TRUE;
662
663 if (!N(LockingPlayerInput)) {
665 N(LockingPlayerInput) = TRUE;
666 }
667
668 N(PlayerBounceOffset) = 0;
669 N(AbilityState) = RIDE_STATE_RIDING;
671 }
672 } else {
673 return ApiStatus_DONE2;
674 }
675 }
676
677 switch (N(AbilityState)) {
678 case RIDE_STATE_BEGIN:
679#if VERSION_JP
680 if (playerStatus->inputDisabledCount != 0) {
681#else
682 if (playerStatus->flags & PS_FLAG_HIT_FIRE || playerStatus->inputDisabledCount != 0) {
683#endif
684 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
685 return ApiStatus_DONE2;
686 }
687 script->functionTemp[1] = 3;
688 script->functionTemp[2] = disable_player_input();
689 N(LockingPlayerInput) = TRUE;
690 N(AbilityState)++; // RIDE_STATE_DELAY
691 break;
692 case RIDE_STATE_DELAY:
693#if !VERSION_JP
694 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
695 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
696 if (N(LockingPlayerInput)) {
698 N(LockingPlayerInput) = FALSE;
699 }
700 return ApiStatus_DONE2;
701 }
702#endif
703
704 if (playerStatus->animFlags & PA_FLAG_CHANGING_MAP) {
705 if (script->functionTemp[2] < playerStatus->inputDisabledCount) {
707 N(LockingPlayerInput) = FALSE;
708 }
709 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
710 return ApiStatus_DONE2;
711 }
712
713 if (script->functionTemp[1] == 0) {
714 if (script->functionTemp[2] < playerStatus->inputDisabledCount) {
716 N(LockingPlayerInput) = FALSE;
717 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
718 return ApiStatus_DONE2;
719 }
720 N(AbilityState) = RIDE_STATE_MOUNT_1;
721 break;
722 }
723 script->functionTemp[1]--;
724 break;
725 }
726
727 switch (N(AbilityState)) {
730 N(PlayerCollisionDisabled) = TRUE;
731
732 if (!N(LockingPlayerInput)) {
734 N(LockingPlayerInput) = TRUE;
735 }
736
737 lakilester->flags &= ~NPC_FLAG_FLYING;
740 N(MountState) = MOUNT_STATE_IN_PROGRESS;
742 lakilester->moveToPos.x = playerStatus->pos.x;
743 lakilester->moveToPos.y = playerStatus->pos.y;
744 lakilester->moveToPos.z = playerStatus->pos.z;
745 yaw = 0.0f;
746
747 for (i = 0; i < 4; i++) {
748 x = lakilester->moveToPos.x;
749 y = lakilester->moveToPos.y;
750 z = lakilester->moveToPos.z;
752 yaw, lakilester->collisionHeight, lakilester->collisionDiameter);
753 lakilester->moveToPos.x = x;
754 lakilester->moveToPos.y = y;
755 lakilester->moveToPos.z = z;
756 yaw += 90.0f;
757 }
758
759 lakilester->yaw = atan2(lakilester->pos.x, lakilester->pos.z, lakilester->moveToPos.x, lakilester->moveToPos.z);
760 lakilester->duration = 12;
761 lakilester->curAnim = ANIM_WorldLakilester_Walk;
762 lakilester->jumpVel = 8.0f;
763 lakilester->jumpScale = 1.4f;
764 suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump);
765 N(AbilityState) = RIDE_STATE_MOUNT_2;
766 break;
769 suggest_player_anim_allow_backward(ANIM_Mario1_Jump);
770 // fallthrough
772 N(AbilityState)++;
773 // fallthrough
775#if !VERSION_JP
776 if (!(playerStatus->flags & PS_FLAG_HIT_FIRE)) {
777#endif
778 lakilester->pos.x += (lakilester->moveToPos.x - lakilester->pos.x) / lakilester->duration;
779 lakilester->pos.z += (lakilester->moveToPos.z - lakilester->pos.z) / lakilester->duration;
780 lakilester->pos.y += (lakilester->moveToPos.y - lakilester->pos.y) / lakilester->duration;
781 playerStatus->pos.y += lakilester->jumpVel;
782 N(test_mounting_height_adjustment)(lakilester, playerStatus->colliderHeight, 2 * playerStatus->colliderHeight);
783 playerStatus->pos.y += N(MountingDeltaY);
784 lakilester->pos.y += N(MountingDeltaY);
785 lakilester->jumpVel -= lakilester->jumpScale;
786
787 if (lakilester->jumpVel <= 0.0f) {
788 suggest_player_anim_allow_backward(ANIM_Mario1_Fall);
789 }
790
791 lakilester->duration--;
792
793 if (lakilester->duration > 0) {
794 if (lakilester->duration == 1) {
795 add_vec2D_polar(&lakilester->pos.x, &lakilester->pos.z, -2.0f,
797 }
798 } else {
799 playerStatus->pos.y = lakilester->pos.y + 10.0f;
800 lakilester->moveSpeed = playerStatus->runSpeed;
801 lakilester->jumpScale = 0.0f;
802 lakilester->yaw = playerStatus->targetYaw;
803 lakilester->duration = 3;
805 suggest_player_anim_always_forward(ANIM_MarioW2_RideLaki);
807 partnerStatus->actingPartner = PARTNER_LAKILESTER;
809 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
811 N(PlayerBounceOffset) = 0;
812 N(MountState) = MOUNT_STATE_DONE;
814 N(AbilityState) = RIDE_STATE_START_RIDING;
815 playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER;
816 }
817#if !VERSION_JP
818 } else {
819 N(AbilityState) = RIDE_STATE_FINISH_1;
820 }
821#endif
822 break;
824#if !VERSION_JP
825 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
826 N(AbilityState) = RIDE_STATE_FINISH_1;
827 break;
828 }
829#endif
830 lakilester->duration--;
831 if (lakilester->duration != 0) {
832#if VERSION_JP
833 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
834 N(AbilityState) = RIDE_STATE_FINISH_1;
835 break;
836 }
837#endif
838 if (partnerStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) {
839 if (N(can_dismount)()) {
840 N(AbilityState) = RIDE_STATE_DISMOUNT_1;
841 }
842 }
843 break;
844 } else {
845 N(AbilityState) = RIDE_STATE_RIDING;
847 }
848 // fallthrough
850 N(update_riding_physics)(lakilester);
851 playerStatus->animFlags |= PA_FLAG_RIDING_PARTNER;
852 lakilester->pos.y = lakilester->moveToPos.y + 2.0f;
853
854 N(PlayerBounceOffset)++;
855 if (N(PlayerBounceOffset) >= 10) {
856 N(PlayerBounceOffset) -= 18;
857 }
858
859 if (partnerStatus->inputDisabledCount == 0) {
860 playerStatus->targetYaw = lakilester->yaw;
861 }
862 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
863 N(AbilityState) = RIDE_STATE_FINISH_1;
864 break;
865 }
866 if (partnerStatus->pressedButtons & (BUTTON_B | D_CBUTTONS)) {
867 if (N(can_dismount)()) {
868 N(AbilityState) = RIDE_STATE_DISMOUNT_1;
869 } else {
870 if (!(playerStatus->animFlags & PA_FLAG_FORCED_PARTNER_ABILITY_END)) {
872 }
873 playerStatus->animFlags &= ~PA_FLAG_FORCED_PARTNER_ABILITY_END;
874 }
875 }
876 break;
878 lakilester->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION;
879 playerStatus->flags |= PS_FLAG_PAUSE_DISABLED;
880 N(can_dismount)();
881 camYaw = camera->curYaw;
882 if (playerStatus->spriteFacingAngle >= 90.0f && playerStatus->spriteFacingAngle < 270.0f) {
883 yaw = (180.0f + camYaw) - 90.0f;
884 } else {
885 yaw = (0.0f + camYaw) - 90.0f;
886 }
887 lakilester->yaw = yaw;
888 dist = dist2D(playerStatus->pos.x, playerStatus->pos.z,
889 lakilester->moveToPos.x, lakilester->moveToPos.z);
890 lakilester->yaw = atan2(playerStatus->pos.x, playerStatus->pos.z,
891 lakilester->moveToPos.x, lakilester->moveToPos.z);
892 lakilester->duration = 14;
893 lakilester->jumpScale = 1.2f;
894
895 if (lakilester->moveToPos.y > lakilester->pos.y) {
896 lakilester->jumpVel = 6.0f + (lakilester->moveToPos.y - lakilester->pos.y) / 14.0f;
897 } else {
898 lakilester->jumpVel = 6.0f;
899 }
900
901 lakilester->moveSpeed = dist / lakilester->duration;
902 suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump);
903 N(AbilityState)++;
904 break;
906 suggest_player_anim_allow_backward(ANIM_Mario1_Jump);
907 N(AbilityState)++;
908 // fallthrough
911 playerStatus->pos.y += lakilester->jumpVel;
912 dist = playerStatus->colliderHeight * 0.5f;
913
914 x = playerStatus->pos.x;
915 y = playerStatus->pos.y + (playerStatus->colliderHeight * 0.5f);
916 z = playerStatus->pos.z;
917
918 yaw = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw;
919
920 if (player_raycast_up_corners(playerStatus, &x, &y, &z, &dist, yaw) > NO_COLLIDER) {
921 N(AbilityState) = RIDE_STATE_FINISH_1;
922 break;
923 }
924
925 lakilester->jumpVel -= lakilester->jumpScale;
926 add_vec2D_polar(&playerStatus->pos.x, &playerStatus->pos.z, lakilester->moveSpeed, lakilester->yaw);
927
929 if (N(test_dismount_height)(&y) > NO_COLLIDER) {
930 N(AbilityState) = RIDE_STATE_FINISH_1;
931 playerStatus->pos.y = y;
932 }
933 break;
934 }
935
936 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
937 gCameras[CAM_DEFAULT].targetPos.y = lakilester->moveToPos.y;
938 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
939
940 if (N(AbilityState) == RIDE_STATE_FINISH_1) {
941 N(MountState) = MOUNT_STATE_NONE;
943
944 if (N(PlayerCollisionDisabled)) {
945 N(PlayerCollisionDisabled) = FALSE;
947 }
948
951
952 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
953 partnerStatus->actingPartner = PARTNER_NONE;
955
956 if (N(LockingPlayerInput)) {
957 N(LockingPlayerInput) = FALSE;
959 }
960
963 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
964 return ApiStatus_DONE1;
965 }
966
969 N(AbilityState) = RIDE_STATE_FINISH_2;
970 return ApiStatus_BLOCK;
971 }
972
973 if (N(AbilityState) == RIDE_STATE_FINISH_2) {
975 partnerStatus->actingPartner = PARTNER_NONE;
977 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
978 if (N(LockingPlayerInput)) {
979 N(LockingPlayerInput) = FALSE;
981 }
982
985 func_800EF3D4(2);
986 return ApiStatus_DONE1;
987 }
988
989 return ApiStatus_BLOCK;
990}
991
993 Call(N(UseAbility))
994 Return
995 End
996};
997
998API_CALLABLE(N(PutAway)) {
999 PlayerStatus* playerStatus = &gPlayerStatus;
1000 PartnerStatus* partnerStatus = &gPartnerStatus;
1001 Camera* cam = &gCameras[CAM_DEFAULT];
1002 Npc* lakilester = script->owner2.npc;
1003 f32 sp20, sp24, sp28, sp2C;
1004 f32 yaw;
1005
1006 if (isInitialCall) {
1007 N(PutAwayState) = (N(MountState) == MOUNT_STATE_NONE) ? PUT_AWAY_FINISH_1 : PUT_AWAY_DISMOUNT_1;
1008 partner_init_put_away(lakilester);
1009 N(can_dismount)();
1010 playerStatus->animFlags &= ~PA_FLAG_RIDING_PARTNER;
1011 playerStatus->flags |= PS_FLAG_PAUSE_DISABLED;
1012 }
1013
1014 switch (N(PutAwayState)) {
1016 N(can_dismount)();
1017 yaw = cam->curYaw;
1018 if ((playerStatus->spriteFacingAngle >= 90.0f) && (playerStatus->spriteFacingAngle < 270.0f)) {
1019 lakilester->yaw = (yaw + 180.0f) - 90.0f;
1020 } else {
1021 lakilester->yaw = (yaw + 0.0f) - 90.0f;
1022 }
1023
1024 sp2C = dist2D(playerStatus->pos.x, playerStatus->pos.z,
1025 lakilester->moveToPos.x, lakilester->moveToPos.z);
1026 lakilester->duration = 14;
1027
1028 if (lakilester->moveToPos.y > lakilester->pos.y ) {
1029 lakilester->jumpVel = (lakilester->moveToPos.y - lakilester->pos.y) / 14.0f + 6.0f;
1030 } else {
1031 lakilester->jumpVel = 6.0f;
1032 }
1033 lakilester->jumpScale = 1.2f;
1034 lakilester->moveSpeed = sp2C / lakilester->duration;
1035 lakilester->yaw = atan2(playerStatus->pos.x, playerStatus->pos.z,
1036 lakilester->moveToPos.x, lakilester->moveToPos.z);
1037 suggest_player_anim_allow_backward(ANIM_Mario1_BeforeJump);
1038 N(PutAwayState)++;
1039 break;
1041 suggest_player_anim_allow_backward(ANIM_Mario1_Jump);
1042 N(PutAwayState)++;
1044 playerStatus->pos.y += lakilester->jumpVel;
1045 lakilester->jumpVel -= lakilester->jumpScale;
1046 add_vec2D_polar(&playerStatus->pos.x, &playerStatus->pos.z,
1047 lakilester->moveSpeed, lakilester->yaw);
1049 if (lakilester->jumpVel <= 0.0f) {
1050 playerStatus->flags |= PS_FLAG_FALLING;
1051 if (lakilester->jumpVel < -10.0) {
1052 lakilester->jumpVel = -10.0f;
1053 }
1054 }
1055 sp20 = playerStatus->pos.x;
1056 sp24 = playerStatus->pos.y + playerStatus->colliderHeight;
1057 sp28 = playerStatus->pos.z;
1058 sp2C = playerStatus->colliderHeight;
1059 if (npc_raycast_down_around(0, &sp20, &sp24, &sp28, &sp2C,
1060 lakilester->yaw, lakilester->collisionDiameter)) {
1061
1062 N(PutAwayState) = PUT_AWAY_FINISH_1;
1063 playerStatus->pos.y = sp24;
1064 }
1065 break;
1066 }
1067
1068 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
1069 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
1070 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
1071
1072 switch (N(PutAwayState)) {
1073 case PUT_AWAY_FINISH_1:
1075
1076 if (N(PlayerCollisionDisabled)) {
1077 N(PlayerCollisionDisabled) = FALSE;
1079 }
1080
1082
1083 if (playerStatus->flags & PS_FLAG_HIT_FIRE) {
1084 partnerStatus->actingPartner = PARTNER_NONE;
1085 partnerStatus->partnerActionState = PARTNER_ACTION_NONE;
1086 if (N(LockingPlayerInput)) {
1087 N(LockingPlayerInput) = FALSE;
1089 }
1090
1092 N(MountState) = MOUNT_STATE_NONE;
1095 return ApiStatus_DONE1;
1096 }
1097
1098 if (N(MountState) == MOUNT_STATE_NONE) {
1100 } else {
1103 }
1104
1105 N(PutAwayState)++;
1106 break;
1107 case PUT_AWAY_FINISH_2:
1108 partnerStatus->actingPartner = PARTNER_NONE;
1109 partnerStatus->partnerActionState = PARTNER_ACTION_NONE;
1110 playerStatus->flags &= ~PS_FLAG_PAUSE_DISABLED;
1111
1112 if (N(LockingPlayerInput)) {
1113 N(LockingPlayerInput) = FALSE;
1115 }
1117 N(MountState) = MOUNT_STATE_NONE;
1119 N(PutAwayState)++;
1120 break;
1121 case PUT_AWAY_FINISH_3:
1122 if (partner_put_away(lakilester)) {
1123 return ApiStatus_DONE1;
1124 }
1125 break;
1126 }
1127 return ApiStatus_BLOCK;
1128}
1129
1131 Call(N(PutAway))
1132 Return
1133 End
1134};
1135
1136void N(pre_battle)(Npc* lakilester) {
1137 PartnerStatus* partnerStatus = &gPartnerStatus;
1138
1139 if (N(MountState) != MOUNT_STATE_NONE) {
1140 partnerStatus->npc = *lakilester;
1141 partnerStatus->shouldResumeAbility = TRUE;
1146 }
1147
1148 partnerStatus->actingPartner = PARTNER_LAKILESTER;
1149 N(PlayerBounceOffset) = 0;
1150}
1151
1152void N(post_battle)(Npc* lakilester) {
1153 PartnerStatus* partnerStatus = &gPartnerStatus;
1154
1155 if (partnerStatus->shouldResumeAbility) {
1156 if (N(MountState) != MOUNT_STATE_NONE) {
1157 *lakilester = partnerStatus->npc;
1160 partnerStatus->actingPartner = PARTNER_NONE;
1161 partnerStatus->partnerActionState = PARTNER_ACTION_NONE;
1164 }
1165 }
1166}
1167
1168void N(offset_player_from_camera)(f32 speed) {
1169 Camera* currentCamera = &gCameras[gCurrentCameraID];
1170 PlayerStatus* playerStatus = &gPlayerStatus;
1171
1172 add_vec2D_polar(&playerStatus->pos.x, &playerStatus->pos.z, speed, currentCamera->curYaw);
1173}
1174
1175API_CALLABLE(N(EnterMap)) {
1176 PartnerStatus* partnerStatus = &gPartnerStatus;
1177 PlayerStatus* playerStatus = &gPlayerStatus;
1178 Npc* lakilester = get_npc_unsafe(NPC_PARTNER);
1179 f32 temp_f0, temp_f2, temp_f4;
1180 f32* temp_s0_2;
1181 s32 temp_v0_2;
1182
1183 if (isInitialCall) {
1184 script->functionTemp[0] = 0;
1185 }
1186
1187 switch (script->functionTemp[0]) {
1188 case 0:
1189 if (!script->varTable[12]) {
1190 temp_f0 = playerStatus->pos.x;
1191 lakilester->pos.x = temp_f0;
1192 lakilester->moveToPos.x = temp_f0;
1193 temp_f4 = playerStatus->pos.z;
1194 lakilester->pos.z = temp_f4;
1195 lakilester->moveToPos.z = temp_f4;
1196 playerStatus->pos.y = lakilester->pos.y + 10.0f;
1198 } else {
1202 lakilester->moveToPos.x = lakilester->pos.x = playerStatus->pos.x;
1203 lakilester->moveToPos.y = lakilester->pos.y = playerStatus->pos.y;
1204 lakilester->moveToPos.z = lakilester->pos.z = playerStatus->pos.z;
1205 playerStatus->pos.y = lakilester->pos.y + 10.0f;
1206 }
1207
1208 script->functionTemp[1] = script->varTable[4];
1209 temp_s0_2 = (f32*)&script->varTable[5];
1210 temp_f2 = atan2(lakilester->pos.x, lakilester->pos.z, script->varTable[1], script->varTable[3]);
1211 lakilester->yaw = temp_f2;
1212
1213 if (script->varTable[12]) {
1214 if (temp_f2 >= 0.0f && temp_f2 <= 180.0f) {
1215 lakilester->yawCamOffset = temp_f2;
1216 lakilester->isFacingAway = TRUE;
1217 }
1218 }
1219
1221 playerStatus->anim = ANIM_MarioW2_RideLaki;
1222 playerStatus->animNotifyValue = 0;
1223 playerStatus->flags |= PS_FLAG_FACE_FORWARD;
1227 lakilester->moveSpeed = *temp_s0_2;
1228 lakilester->jumpScale = 0.0f;
1229 N(UpdatePushingWall) = FALSE;
1230 N(PlayerBounceOffset) = 0;
1231 script->functionTemp[0] = 1;
1232 break;
1233
1234 case 1:
1235 npc_move_heading(lakilester, lakilester->moveSpeed, lakilester->yaw);
1236 playerStatus->pos.x = lakilester->pos.x;
1237 playerStatus->pos.y = lakilester->pos.y + 10.0f;
1238 playerStatus->pos.z = lakilester->pos.z;
1239 playerStatus->targetYaw = lakilester->yaw;
1241 script->functionTemp[1] -= 1;
1242
1243 if (script->functionTemp[1] == 0) {
1244 if (script->varTable[12]) {
1245 partnerStatus->shouldResumeAbility = TRUE;
1247 partnerStatus->actingPartner = PARTNER_NONE;
1248 partnerStatus->partnerActionState = PARTNER_ACTION_NONE;
1252 }
1253 return ApiStatus_DONE2;
1254 }
1255 }
1256
1257 return ApiStatus_BLOCK;
1258}
1259
1261 Call(N(EnterMap))
1262 Return
1263 End
1264};
s32 partner_use_ability(void)
Definition partners.c:964
b8 keepUsingPartnerOnMapChange
s32 partnerUsedTime[12]
s32 b32
s32 HitID
Bytecode EvtScript[]
#define clamp_angle
#define atan2
#define mem_clear
@ TWEESTER_PARTNER_HOLD
Definition enums.h:2477
@ TWEESTER_PARTNER_ATTRACT
Definition enums.h:2476
@ TWEESTER_PARTNER_INIT
Definition enums.h:2475
@ TWEESTER_PARTNER_RELEASE
Definition enums.h:2478
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_B
Definition enums.h:2789
@ SURFACE_TYPE_WATER
Definition enums.h:4671
@ SURFACE_TYPE_SLIDE
Definition enums.h:4675
@ SURFACE_TYPE_LAVA
Definition enums.h:4673
@ SURFACE_TYPE_SPIKES
Definition enums.h:4672
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PS_FLAG_ENTERING_BATTLE
Definition enums.h:3061
@ PS_FLAG_PAUSE_DISABLED
Definition enums.h:3044
@ PS_FLAG_CUTSCENE_MOVEMENT
Definition enums.h:3054
@ PS_FLAG_HIT_FIRE
Definition enums.h:3050
@ PS_FLAG_FACE_FORWARD
Definition enums.h:3079
@ PARTNER_ACTION_LAKILESTER_1
Definition enums.h:2941
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ COLLIDER_FLAG_IGNORE_PLAYER
Definition enums.h:4696
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
@ NPC_PARTNER
Definition enums.h:2528
@ ENTITY_TYPE_SCRIPT_SPRING
Definition enums.h:2584
@ ENTITY_TYPE_SIMPLE_SPRING
Definition enums.h:2583
@ PLAYER_COLLISION_0
Definition enums.h:4712
@ EASING_LINEAR
Definition enums.h:510
@ PA_FLAG_DISMOUNTING_ALLOWED
Definition enums.h:3123
@ PA_FLAG_RIDING_PARTNER
Definition enums.h:3116
@ PA_FLAG_CHANGING_MAP
Definition enums.h:3112
@ PA_FLAG_PARTNER_USAGE_FORCED
Definition enums.h:3115
@ PA_FLAG_FORCED_PARTNER_ABILITY_END
Definition enums.h:3125
@ SOUND_FLIGHT
Definition enums.h:1012
@ SOUND_QUICK_PLAYER_JUMP
Definition enums.h:1424
@ SOUND_MENU_ERROR
Definition enums.h:933
@ PARTNER_NONE
Definition enums.h:2885
@ PARTNER_LAKILESTER
Definition enums.h:2893
@ ACTION_STATE_RIDE
Definition enums.h:2461
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_FALLING
Definition enums.h:2435
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_HIT_FIRE
Causes Mario to fly up and take damage. Used for fire bars.
Definition enums.h:2449
@ ACTION_STATE_RUN
Definition enums.h:2428
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ SURFACE_INTERACT_RUN
Definition enums.h:4685
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
@ NPC_FLAG_FLYING
Definition enums.h:3001
@ NPC_FLAG_TOUCHES_GROUND
Definition enums.h:3020
@ NPC_FLAG_IGNORE_WORLD_COLLISION
Definition enums.h:3004
@ NPC_FLAG_IGNORE_PLAYER_COLLISION
Definition enums.h:3006
@ NPC_FLAG_COLLDING_FORWARD_WITH_WORLD
Definition enums.h:3012
@ NPC_FLAG_DIRTY_SHADOW
Definition enums.h:3014
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
Definition enums.h:3016
@ NPC_FLAG_COLLDING_WITH_WORLD
Definition enums.h:3011
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:735
f32 fabsf(f32 f)
b32 npc_raycast_down_around(s32, f32 *, f32 *, f32 *, f32 *, f32, f32)
f64 fabs(f64 f)
HitID player_raycast_below_cam_relative(PlayerStatus *playerStatus, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
Definition 77480.c:193
s32 npc_test_move_complex_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
void func_800EF3D4(s32)
Definition partners.c:2414
void partner_clear_player_tracking(Npc *partner)
Definition partners.c:2436
void partner_flying_update_player_tracking(Npc *partner)
Definition partners.c:1751
s32 disable_player_input(void)
Definition 77480.c:990
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
s32 disable_player_static_collisions(void)
Definition 77480.c:972
s32 enable_player_input(void)
Definition 77480.c:998
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void partner_kill_ability_script(void)
Definition partners.c:1109
void phys_main_collision_below(void)
Definition 7BB60.c:863
void gravity_use_fall_parms(void)
Definition 7BB60.c:302
u32 get_entity_type(s32 arg0)
Definition entity.c:568
void enable_player_shadow(void)
Definition 77480.c:964
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
b32 npc_test_move_taller_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
HitID player_raycast_up_corners(PlayerStatus *, f32 *, f32 *, f32 *, f32 *, f32)
Definition 77480.c:255
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
void partner_flying_update_motion(Npc *partner)
Definition partners.c:1777
void partner_flying_enable(Npc *partner, s32 val)
Definition partners.c:1706
f32 sin_rad(f32 x)
Definition 43F0.c:713
f32 get_player_normal_pitch(void)
Definition 43F0.c:662
s32 enable_player_static_collisions(void)
Definition 77480.c:980
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
void func_800E4AD8(s32 arg0)
Definition 7BB60.c:978
void disable_player_shadow(void)
Definition 77480.c:968
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
s32 partner_init_get_out(Npc *npc)
Definition partners.c:2252
s32 partner_init_put_away(Npc *partner)
Definition partners.c:2178
s32 partner_put_away(Npc *partner)
Definition partners.c:2185
s32 partner_force_player_flip_done(void)
Definition partners.c:2454
s32 partner_get_out(Npc *partner)
Definition partners.c:2259
void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID)
Definition sfx.c:527
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
Definition sfx.c:458
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
#define BSS
Definition macros.h:7
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define SQ(x)
Definition macros.h:166
#define NO_COLLIDER
Definition macros.h:156
#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
Vec3f targetPos
s16 collisionDiameter
f32 jumpScale
f32 jumpVel
s32 flags
f32 renderYaw
AnimID curAnim
Vec3f moveToPos
b16 isFacingAway
s16 collisionHeight
s16 yawCamOffset
Vec3f pos
f32 moveSpeed
s16 duration
Entity * TweesterTouchingPartner
Definition 7B440.c:5
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
PartnerStatus gPartnerStatus
Definition partners.c:42
GameStatus * gGameStatusPtr
Definition main_loop.c:32
s32 NpcHitQueryColliderID
Camera gCameras[4]
Definition cam_main.c:17
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
@ PUT_AWAY_FINISH_2
Definition lakilester.c:44
@ PUT_AWAY_FINISH_3
Definition lakilester.c:45
@ PUT_AWAY_DISMOUNT_3
Definition lakilester.c:42
@ PUT_AWAY_DISMOUNT_2
Definition lakilester.c:41
@ PUT_AWAY_FINISH_1
Definition lakilester.c:43
@ PUT_AWAY_DISMOUNT_1
Definition lakilester.c:40
s32 N test_dismount_height(f32 *posY)
Definition lakilester.c:579
void N try_cancel_tweester(Npc *lakilester)
Definition lakilester.c:206
EvtScript EVS_WorldLakilester_PutAway
@ RIDE_STATE_MOUNT_1
Definition lakilester.c:25
@ RIDE_STATE_START_RIDING
Definition lakilester.c:29
@ RIDE_STATE_DISMOUNT_1
Definition lakilester.c:31
@ RIDE_STATE_MOUNT_4
Definition lakilester.c:28
@ RIDE_STATE_DELAY
Definition lakilester.c:24
@ RIDE_STATE_BEGIN
Definition lakilester.c:23
@ RIDE_STATE_DISMOUNT_2
Definition lakilester.c:32
@ RIDE_STATE_FINISH_1
Definition lakilester.c:34
@ RIDE_STATE_RIDING
Definition lakilester.c:30
@ RIDE_STATE_MOUNT_3
Definition lakilester.c:27
@ RIDE_STATE_FINISH_2
Definition lakilester.c:35
@ RIDE_STATE_DISMOUNT_3
Definition lakilester.c:33
@ RIDE_STATE_MOUNT_2
Definition lakilester.c:26
void N pre_battle(Npc *lakilester)
#define TEST_MOVE_AT_ANGLE(testFunc, angle)
void N post_battle(Npc *lakilester)
EvtScript EVS_WorldLakilester_TakeOut
Definition lakilester.c:109
EvtScript EVS_WorldLakilester_UseAbility
Definition lakilester.c:992
s32 N test_mounting_height_adjustment(Npc *lakilester, f32 height, f32 dist)
Definition lakilester.c:282
void N sync_player_position(void)
Definition lakilester.c:56
void N get_movement_from_input(f32 *outAngle, f32 *outSpeed)
Definition lakilester.c:215
@ MOUNT_STATE_IN_PROGRESS
Definition lakilester.c:50
@ MOUNT_STATE_DONE
Definition lakilester.c:51
@ MOUNT_STATE_NONE
Definition lakilester.c:49
void N update_riding_physics(Npc *lakilester)
Definition lakilester.c:368
void N apply_riding_static_collisions(Npc *lakilester)
Definition lakilester.c:312
s32 N can_dismount(void)
Definition lakilester.c:233
void N offset_player_from_camera(f32 arg0)
EvtScript EVS_WorldLakilester_Update
Definition lakilester.c:200
void N init(Npc *lakilester)
Definition lakilester.c:77
EvtScript EVS_WorldLakilester_EnterMap