-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSHELL.diff
More file actions
808 lines (748 loc) · 29.4 KB
/
SHELL.diff
File metadata and controls
808 lines (748 loc) · 29.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
diff --git a/include/sm64.h b/include/sm64.h
index 7b8bb683..fe631bc6 100644
--- a/include/sm64.h
+++ b/include/sm64.h
@@ -123,7 +123,8 @@ enum GroundStep {
GROUND_STEP_NONE,
GROUND_STEP_HIT_WALL,
GROUND_STEP_HIT_WALL_STOP_QSTEPS = GROUND_STEP_HIT_WALL,
- GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS
+ GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS,
+ GROUND_STEP_ENTERED_WATER
};
enum AirStepCheck {
@@ -140,7 +141,8 @@ enum AirStep {
AIR_STEP_GRABBED_CEILING,
AIR_STEP_UNK,
AIR_STEP_HIT_LAVA_WALL,
- AIR_STEP_HIT_CEILING
+ AIR_STEP_HIT_CEILING,
+ AIR_STEP_SHELL_ENTERED_WATER
};
enum WaterStep {
diff --git a/src/game/behaviors/koopa_shell.inc.c b/src/game/behaviors/koopa_shell.inc.c
index becfbe34..9b2b2903 100644
--- a/src/game/behaviors/koopa_shell.inc.c
+++ b/src/game/behaviors/koopa_shell.inc.c
@@ -60,34 +60,33 @@ void koopa_shell_spawn_sparkles(f32 a) {
}
void bhv_koopa_shell_loop(void) {
- struct Surface *floor;
+ struct Surface *sp34;
obj_set_hitbox(o, &sKoopaShellHitbox);
cur_obj_scale(1.0f);
switch (o->oAction) {
- case KOOPA_SHELL_ACT_MARIO_NOT_RIDING:
+ case 0:
cur_obj_update_floor_and_walls();
cur_obj_if_hit_wall_bounce_away();
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
- o->oAction = KOOPA_SHELL_ACT_MARIO_RIDING;
+ o->oAction++;
}
o->oFaceAngleYaw += 0x1000;
cur_obj_move_standard(-20);
koopa_shell_spawn_sparkles(10.0f);
- shell_despawn();
break;
- case KOOPA_SHELL_ACT_MARIO_RIDING:
+ case 1:
obj_copy_pos(o, gMarioObject);
- floor = cur_obj_update_floor_height_and_get_floor();
+ sp34 = cur_obj_update_floor_height_and_get_floor();
if (absf(find_water_level(o->oPosX, o->oPosZ) - o->oPosY) < 10.0f) {
koopa_shell_spawn_water_drop();
} else if (absf(o->oPosY - o->oFloorHeight) < 5.0f) {
- if (floor != NULL && floor->type == SURFACE_BURNING) {
+ if (sp34 != NULL && sp34->type == 1) {
bhv_koopa_shell_flame_spawn();
} else {
koopa_shell_spawn_sparkles(10.0f);
@@ -95,16 +94,17 @@ void bhv_koopa_shell_loop(void) {
} else {
koopa_shell_spawn_sparkles(10.0f);
}
-
+ o->oFaceAngleRoll = 0;
+ o->oFaceAnglePitch = 0;
o->oFaceAngleYaw = gMarioObject->oMoveAngleYaw;
if (o->oInteractStatus & INT_STATUS_STOP_RIDING) {
obj_mark_for_deletion(o);
spawn_mist_particles();
- o->oAction = KOOPA_SHELL_ACT_MARIO_NOT_RIDING;
+ o->oAction = 0;
}
break;
}
- o->oInteractStatus = INT_STATUS_NONE;
+ o->oInteractStatus = 0;
}
diff --git a/src/game/mario.c b/src/game/mario.c
index 90f4da1d..c699185c 100644
--- a/src/game/mario.c
+++ b/src/game/mario.c
@@ -1131,23 +1131,41 @@ s32 set_water_plunge_action(struct MarioState *m) {
m->forwardVel = m->forwardVel / 4.0f;
m->vel[1] = m->vel[1] / 2.0f;
-#ifdef WATER_PLUNGE_UPWARP
+ #ifdef WATER_PLUNGE_UPWARP
m->pos[1] = m->waterLevel - 100;
-#endif
+ #endif
m->faceAngle[2] = 0;
- vec3_zero(m->angleVel);
+ vec3s_set(m->angleVel, 0, 0, 0);
if (!(m->action & ACT_FLAG_DIVING)) {
m->faceAngle[0] = 0;
}
- if (m->area->camera->mode != WATER_SURFACE_CAMERA_MODE) {
- set_camera_mode(m->area->camera, WATER_SURFACE_CAMERA_MODE, 1);
+ if (m->area->camera->mode != CAMERA_MODE_WATER_SURFACE) {
+ set_camera_mode(m->area->camera, CAMERA_MODE_WATER_SURFACE, 1);
}
+ if (m->actionState == 4 || (m->actionState == 6 && m->heldObj)) {
+ //do the water plunge stuff without entering the water plunge action
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ if (m->peakHeight - m->pos[1] > 1150.0f) {
+ play_sound(SOUND_MARIO_HAHA_WATER, m->marioObj->header.gfx.cameraToObject);
+ }
+ m->pos[1] -= 200.0f;
+ m->vel[1] = -30.0f;
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+#if ENABLE_RUMBLE
+ if (m->prevAction & ACT_FLAG_AIR) {
+ queue_rumble_data(5, 80);
+ }
+#endif
+//cut straight to water shell swimming to avoid being slowed down and action transition hell
+ return set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
+ }
return set_mario_action(m, ACT_WATER_PLUNGE, 0);
+
}
/**
@@ -1164,7 +1182,9 @@ void squish_mario_model(struct MarioState *m) {
if (m->squishTimer != 0xFF) {
// If no longer squished, scale back to default.
if (m->squishTimer == 0) {
+ if (m->action != ACT_RIDING_SHELL_FALL && m->action != ACT_RIDING_SHELL_JUMP) {
vec3f_set(m->marioObj->header.gfx.scale, 1.0f, 1.0f, 1.0f);
+ }
}
// If timer is less than 16, rubber-band Mario's size scale up and down.
else if (m->squishTimer <= 16) {
diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c
index 13c2b626..249553a0 100644
--- a/src/game/mario_actions_airborne.c
+++ b/src/game/mario_actions_airborne.c
@@ -14,6 +14,7 @@
#include "mario_step.h"
#include "save_file.h"
#include "rumble_init.h"
+#include "behavior_data.h"
#include "config.h"
@@ -663,11 +664,103 @@ s32 act_riding_shell_air(struct MarioState *m) {
play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, 0);
set_mario_animation(m, MARIO_ANIM_JUMP_RIDING_SHELL);
+ // transfer the timer from the previous action
+ if (m->actionArg > 0) {
+ m->actionTimer = m->actionArg;
+ m->actionArg = 0;
+ } else {
+ // double jump
+ // putting this in an else statement ensures that the same A press is not used for the double
+ // jump
+ if (m->input & INPUT_A_PRESSED && m->actionState != 2 && m->actionState != 3) {
+ m->actionState = 2;
+ m->vel[1] = 60.0f;
+ m->particleFlags |= PARTICLE_MIST_CIRCLE;
+ play_sound(SOUND_GENERAL_WING_FLAP, m->marioObj->header.gfx.cameraToObject);
+ }
+ }
+
+ //this is in place for the transition from water shell to air shell
+ if (!m->riddenObj) {
+ m->faceAngle[0] = 0;
+ m->faceAngle[2] = 0;
+ m->interactObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShell);
+ m->usedObj = m->interactObj;
+ m->riddenObj = m->interactObj;
+
+ attack_object(m->interactObj, 0x40);
+ }
+
+ m->actionTimer++;
+
+
+ //ground pound
+ if (m->input & INPUT_Z_PRESSED && m->actionState != 3) {
+ m->actionState = 3;
+ m->forwardVel *= 0.7f;
+ // the timer is set to 40 so that the dash will be ready when you get back to the ground
+ m->actionTimer = 40;
+
+ play_sound(SOUND_ACTION_SPIN, m->marioObj->header.gfx.cameraToObject);
+ }
+
+ if (m->actionState == 3) {
+ // stall in the air for a bit
+ if (m->actionTimer < 45) {
+ m->marioObj->header.gfx.angle[1] += 0x3333;
+ }
+ if (m->actionTimer < 50) {
+ m->vel[1] = 12.0f;
+ }
+ // shoot downward
+ if (m->actionTimer == 50) {
+ m->vel[1] = -90.0f;
+ }
+ }
+
+ // manual deceleration in air during a dash
+ if (m->forwardVel < 128.0f && m->forwardVel > 64.0f) {
+ m->forwardVel -= (f32) m->actionTimer / 15.0f;
+ }
+ if (m->forwardVel > 128.0f) {
+ m->forwardVel = 128.0f;
+ }
+
+ // accelerate downwards during pound
+ if (m->actionState == 3) {
+ m->vel[1] -= 10.0f;
+ if (m->vel[1] < -90.0f) {
+ m->marioObj->header.gfx.scale[1] = 1.0f + (-1.0f * m->vel[1] / 180.0f);
+ }
+ }
+
update_air_without_turn(m);
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
- set_mario_action(m, ACT_RIDING_SHELL_GROUND, 1);
+ if (m->actionState == 3) {
+
+ // ground pounds go straight into water
+ if (m->floor == &gWaterSurfacePseudoFloor) {
+ if (m->riddenObj != NULL) {
+ m->riddenObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ m->riddenObj = NULL;
+ }
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+ m->pos[1] -= 50;
+ m->usedObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShellUnderwater);
+ mario_grab_used_object(m);
+ m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
+ set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
+ } else {
+ m->particleFlags |= PARTICLE_MIST_CIRCLE;
+ play_sound(SOUND_OBJ_POUNDING1, m->marioObj->header.gfx.cameraToObject);
+ set_mario_action(m, ACT_RIDING_SHELL_GROUND, m->actionTimer);
+ }
+ } else {
+ set_mario_action(m, ACT_RIDING_SHELL_GROUND, m->actionTimer);
+ }
break;
case AIR_STEP_HIT_WALL:
@@ -677,6 +770,18 @@ s32 act_riding_shell_air(struct MarioState *m) {
case AIR_STEP_HIT_LAVA_WALL:
lava_boost_on_wall(m);
break;
+
+ case AIR_STEP_SHELL_ENTERED_WATER:
+ if (m->riddenObj != NULL) {
+ m->riddenObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ m->riddenObj = NULL;
+ }
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+ m->pos[1] -= 50;
+ //changes action but doesnt spawn a shell. the shell will spawn in the action itself.
+ set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
+ break;
}
m->marioObj->header.gfx.pos[1] += 42.0f;
@@ -862,21 +967,69 @@ s32 act_water_jump(struct MarioState *m) {
}
s32 act_hold_water_jump(struct MarioState *m) {
- if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
- return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
+ // transfer actionArg to actionState if holding a shell
+ if (m->actionArg == 4) {
+ m->vel[1] = m->forwardVel * 1.9f;
+ m->forwardVel *= 1.6f;
+ m->actionArg = 0;
+ m->actionState = 4;
+
+ // the water cam is awful for this, just use the normal one instead
+ set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
}
+ m->actionTimer += 1;
if (m->forwardVel < 15.0f) {
mario_set_forward_vel(m, 15.0f);
}
+ //if Z is pressed midair, mario will do a flip and then go back to riding his shell
+ if (m->input & INPUT_Z_PRESSED && m->actionState != 6) {
+ m->actionState = 6;
+ m->actionTimer = 0;
+ }
+
+ // apparently air step doesnt use fvel???
+ m->vel[0] = m->forwardVel * coss(m->faceAngle[0]) * sins(m->faceAngle[1]);
+ m->vel[2] = m->forwardVel * coss(m->faceAngle[0]) * coss(m->faceAngle[1]);
+
play_mario_sound(m, SOUND_ACTION_WATER_JUMP, 0);
- set_mario_animation(m, MARIO_ANIM_JUMP_WITH_LIGHT_OBJ);
+
+ // if holding the shell, do a midair spin instead of a normal jump
+ if (m->actionState == 4) {
+ set_mario_animation(m, MARIO_ANIM_SLIDE_DIVE);
+ m->marioObj->header.gfx.angle[2] += 0x2000;
+ m->marioObj->header.gfx.angle[0] = -0x80 * m->vel[1];
+ } else {
+ set_mario_animation(m, MARIO_ANIM_JUMP_WITH_LIGHT_OBJ);
+ }
+
+ //frontflip a few times and then go into the air shell action
+ if (m->actionState == 6) {
+ if (m->actionTimer < 10) {
+ m->marioObj->header.gfx.angle[0] += 0x3333;
+ m->marioObj->header.gfx.angle[2] = 0;
+ }
+ else {
+ m->heldObj = NULL;
+ set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
+ return set_mario_action(m, ACT_RIDING_SHELL_JUMP, m->actionTimer);
+ }
+ }
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
- set_mario_action(m, ACT_HOLD_JUMP_LAND, 0);
- set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
+ // only under extreme circumstances would you be able to hold something other than a shell
+ // underwater. still, better safe than sorry
+ if (m->actionState == 4 || m->actionState == 6) {
+ set_mario_action(m, ACT_RIDING_SHELL_GROUND, m->actionState);
+ m->heldObj = NULL;
+
+ set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
+ } else {
+ set_mario_action(m, ACT_HOLD_JUMP_LAND, m->actionState);
+ set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
+ }
break;
case AIR_STEP_HIT_WALL:
diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c
index 23dc7a87..6ba5a948 100644
--- a/src/game/mario_actions_moving.c
+++ b/src/game/mario_actions_moving.c
@@ -336,9 +336,9 @@ void update_shell_speed(struct MarioState *m) {
f32 targetSpeed;
if (m->floorHeight < m->waterLevel) {
- set_mario_floor(m, &gWaterSurfacePseudoFloor, m->waterLevel);
+ m->floorHeight = m->waterLevel;
+ m->floor = &gWaterSurfacePseudoFloor;
m->floor->originOffset = -m->waterLevel;
- // m->floor->originOffset = m->waterLevel; //! (Original code) Negative origin offset
}
if (m->floor != NULL && m->floor->type == SURFACE_SLOW) {
@@ -351,7 +351,8 @@ void update_shell_speed(struct MarioState *m) {
if (targetSpeed > maxTargetSpeed) {
targetSpeed = maxTargetSpeed;
}
- if (targetSpeed < 24.0f) {
+ //make sure a minimum speed isnt being set when braking
+ if (targetSpeed < 24.0f && !(m->input & INPUT_Z_DOWN)) {
targetSpeed = 24.0f;
}
@@ -363,9 +364,27 @@ void update_shell_speed(struct MarioState *m) {
m->forwardVel -= 1.0f;
}
+ if (m->actionState == 1) {
+ m->forwardVel -= (f32) m->actionTimer / 10.0f;
+ //increase max speed for the shell dash
+ if (m->forwardVel > 128.0f) {
+ m->forwardVel = 128.0f;
+ }
+ if (m->forwardVel < 64.0f) {
+ m->actionState = 0;
+ }
+ }
//! No backward speed cap (shell hyperspeed)
- if (m->forwardVel > 64.0f) {
- m->forwardVel = 64.0f;
+ else {
+ //use vanilla speed
+ if (m->forwardVel > 64.0f) {
+ m->forwardVel = 64.0f;
+ }
+ }
+
+ //braking
+ if (m->input & INPUT_Z_DOWN) {
+ m->forwardVel *= 0.9;
}
m->faceAngle[1] =
@@ -1196,11 +1215,46 @@ s32 act_hold_decelerating(struct MarioState *m) {
s32 act_riding_shell_ground(struct MarioState *m) {
s16 startYaw = m->faceAngle[1];
+ //transfer the timer from the previous action
+ if (m->actionArg > 0) {
+ m->actionTimer = m->actionArg;
+ m->actionArg = 0;
+ }
+
+ //this is in place for the transition from water shell to ground shell
+ if (!m->riddenObj) {
+ m->faceAngle[0] = 0;
+ m->faceAngle[2] = 0;
+ m->interactObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShell);
+ m->usedObj = m->interactObj;
+ m->riddenObj = m->interactObj;
+
+ attack_object(m->interactObj, 0x40);
+ }
+
+ m->actionTimer++;
+
if (m->input & INPUT_A_PRESSED) {
- return set_mario_action(m, ACT_RIDING_SHELL_JUMP, 0);
+ return set_mario_action(m, ACT_RIDING_SHELL_JUMP, m->actionTimer);
+ }
+
+ //shell dash
+ if (m->input & INPUT_B_PRESSED && m->actionState != 1 && m->actionTimer >= 60) {
+ m->particleFlags |= PARTICLE_VERTICAL_STAR;
+ play_sound(SOUND_OBJ_WATER_BOMB_CANNON, m->marioObj->header.gfx.cameraToObject);
+ set_camera_shake_from_hit(SHAKE_HIT_FROM_BELOW);
+ //make mario go at least max shell speed
+ m->forwardVel *= 2.0f;
+ if (m->forwardVel < 64.0f) {
+ m->forwardVel = 64.0f;
+ }
+ //set state to shell dash, reset timer
+ m->actionState = 1;
+ m->actionTimer = 0;
}
- if (m->input & INPUT_Z_PRESSED) {
+ //get off the shell
+ if (m->input & INPUT_Z_DOWN && m->input & INPUT_B_PRESSED) {
mario_stop_riding_object(m);
if (m->forwardVel < 24.0f) {
mario_set_forward_vel(m, 24.0f);
@@ -1217,12 +1271,32 @@ s32 act_riding_shell_ground(struct MarioState *m) {
break;
case GROUND_STEP_HIT_WALL:
+ //no more shell breaking! instead, mario will just lose all speed
+ /*
mario_stop_riding_object(m);
play_sound(m->flags & MARIO_METAL_CAP ? SOUND_ACTION_METAL_BONK : SOUND_ACTION_BONK,
m->marioObj->header.gfx.cameraToObject);
m->particleFlags |= PARTICLE_VERTICAL_STAR;
set_mario_action(m, ACT_BACKWARD_GROUND_KB, 0);
+ */
+ m->forwardVel = 0;
break;
+
+ case GROUND_STEP_ENTERED_WATER:
+ return FALSE;
+ }
+
+ //if mario presses Z over a water surface, switch to the water shell
+ if (m->floor == &gWaterSurfacePseudoFloor && m->input & INPUT_Z_PRESSED) {
+ if (m->riddenObj != NULL) {
+ m->riddenObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ m->riddenObj = NULL;
+ }
+ m->usedObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShellUnderwater);
+ mario_grab_used_object(m);
+ m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
+ m->pos[1] -= 50;
+ set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
}
tilt_body_ground_shell(m, startYaw);
@@ -1235,7 +1309,7 @@ s32 act_riding_shell_ground(struct MarioState *m) {
adjust_sound_for_speed(m);
#if ENABLE_RUMBLE
- reset_rumble_timers_slip();
+ reset_rumble_timers();
#endif
return FALSE;
}
diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c
index 2fb2238f..7a97daa2 100644
--- a/src/game/mario_actions_submerged.c
+++ b/src/game/mario_actions_submerged.c
@@ -228,6 +228,11 @@ static void update_swimming_speed(struct MarioState *m, f32 decelThreshold) {
f32 buoyancy = get_buoyancy(m);
f32 maxSpeed = 28.0f;
+ //if mario is using a shell he can go much faster
+ if (m->heldObj) {
+ maxSpeed = 130.0f;
+ }
+
if (m->action & ACT_FLAG_STATIONARY) {
m->forwardVel -= 2.0f;
}
@@ -487,17 +492,30 @@ static void play_swimming_noise(struct MarioState *m) {
static s32 check_water_jump(struct MarioState *m) {
s32 probe = (s32)(m->pos[1] + 1.5f);
-
- if (m->input & INPUT_A_PRESSED) {
+
+ if (m->input & INPUT_A_PRESSED || m->action == ACT_WATER_SHELL_SWIMMING) {
if (probe >= m->waterLevel - 80 && m->faceAngle[0] >= 0 && m->controller->stickY < -60.0f) {
- vec3_zero(m->angleVel);
+ vec3s_set(m->angleVel, 0, 0, 0);
m->vel[1] = 62.0f;
if (m->heldObj == NULL) {
return set_mario_action(m, ACT_WATER_JUMP, 0);
} else {
- return set_mario_action(m, ACT_HOLD_WATER_JUMP, 0);
+ //mario is doing a water dash and going WAY too fast. cut his speed a bit
+ if (m->actionState == 5) {
+ m->forwardVel *= 0.6f;
+ if (m->forwardVel < 40.0f) {
+ m->forwardVel = 40.0f;
+ }
+ }
+ if (m->forwardVel > 50.0f) {
+ m->forwardVel = 50.0f;
+ }
+ m->actionState = 4;
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+ return set_mario_action(m, ACT_HOLD_WATER_JUMP, 4);
}
}
}
@@ -742,26 +760,73 @@ static s32 act_hold_flutter_kick(struct MarioState *m) {
}
static s32 act_water_shell_swimming(struct MarioState *m) {
+
+ //transfer forward velocity when entering water
+ if (((s32)m->actionArg > 0)) {
+ m->forwardVel = ((s32)m->actionArg);
+ m->actionArg = 0;
+ }
+
+ if (!m->heldObj) {
+ m->usedObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShellUnderwater);
+ mario_grab_used_object(m);
+ m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
+ }
+
+ m->actionTimer += 1;
+
+
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT) {
return drop_and_set_mario_action(m, ACT_WATER_IDLE, 0);
}
- if (m->input & INPUT_B_PRESSED) {
- return set_mario_action(m, ACT_WATER_THROW, 0);
+ //underwater shell dash
+ if (m->input & INPUT_B_PRESSED && m->actionState != 5) {
+ //return set_mario_action(m, ACT_WATER_THROW, 0);
+ m->particleFlags |= PARTICLE_VERTICAL_STAR;
+ play_sound(SOUND_OBJ_WATER_BOMB_CANNON, m->marioObj->header.gfx.cameraToObject);
+ m->actionState = 5;
+ m->forwardVel *= 2;
}
+ //water shell timer is really stupid tbh
+/*
if (m->actionTimer++ == 240) {
m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
m->heldObj = NULL;
stop_shell_music();
set_mario_action(m, ACT_FLUTTER_KICK, 0);
}
+ */
- m->forwardVel = approach_f32(m->forwardVel, 30.0f, 2.0f, 1.0f);
+
+
+ if (m->forwardVel <= 40.0f) {
+ if (m->actionState == 5) {
+ m->actionState = 0;
+ }
+ //braking
+ if (m->input & INPUT_Z_DOWN) {
+ m->forwardVel = approach_f32(m->forwardVel, 0.0f, 2.0f, 0.2f);
+ }
+ //normal speed
+ else {
+ m->forwardVel = approach_f32(m->forwardVel, 40.0f, 2.0f, 1.0f);
+ }
+ }
+ //if dashing, approach the normal speed faster
+ else {
+ m->forwardVel = approach_f32(m->forwardVel, 40.0f, 2.0f, 1.0f);
+ //m->marioObj->header.gfx.angle[2] += 0x2000;
+ }
play_swimming_noise(m);
set_mario_animation(m, MARIO_ANIM_FLUTTERKICK_WITH_OBJ);
- common_swimming_step(m, 300);
+ //check to see if mario wants to do the spin jump out of the water
+ if (m->actionTimer > 5) {
+ check_water_jump(m);
+ }
+ common_swimming_step(m, 0x012C);
return FALSE;
}
@@ -1497,19 +1562,38 @@ static s32 check_common_submerged_cancels(struct MarioState *m) {
if (waterHeight > m->floorHeight) {
if (m->pos[1] - waterHeight < 50) {
m->pos[1] = waterHeight; // lock mario to top if the falloff isn't big enough
- } else {
+ }
+ else if (m->action == ACT_WATER_SHELL_SWIMMING && m->heldObj != NULL) {
+ if (m->forwardVel > 50.0f) {
+ m->forwardVel = 50.0f;
+ }
+ m->actionState = 4;
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+ return set_mario_action(m, ACT_HOLD_WATER_JUMP, 40);
+ }
+ else {
// m->pos[1] = m->waterLevel - 80; // Vanilla bug: Downwarp swimming out of waterfalls
return transition_submerged_to_airborne(m);
}
} else {
- //! If you press B to throw the shell, there is a ~5 frame window
- // where your held object is the shell, but you are not in the
- // water shell swimming action. This allows you to hold the water
- // shell on land (used for cloning in DDD).
if (m->action == ACT_WATER_SHELL_SWIMMING && m->heldObj != NULL) {
- m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ if (m->pos[1] - m->floorHeight > 100) {
+ //exit the water in the shell spin state
+ if (m->forwardVel > 50.0f) {
+ m->forwardVel = 50.0f;
+ }
+ m->actionState = 4;
+ play_sound(SOUND_ACTION_WATER_PLUNGE, m->marioObj->header.gfx.cameraToObject);
+ m->particleFlags |= PARTICLE_WATER_SPLASH;
+ return set_mario_action(m, ACT_HOLD_WATER_JUMP, 40);
+ }
+ else {
+ //exit the water in a generic air shell state
m->heldObj = NULL;
- stop_shell_music();
+ set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
+ return set_mario_action(m, ACT_RIDING_SHELL_JUMP, m->actionTimer);
+ }
}
return transition_submerged_to_walking(m);
diff --git a/src/game/mario_step.c b/src/game/mario_step.c
index 2b1ceb08..f0c8bc55 100644
--- a/src/game/mario_step.c
+++ b/src/game/mario_step.c
@@ -9,6 +9,7 @@
#include "game_init.h"
#include "interaction.h"
#include "mario_step.h"
+#include "behavior_data.h"
#include "config.h"
@@ -291,10 +292,27 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
return GROUND_STEP_HIT_WALL_STOP_QSTEPS;
}
- if ((m->action & ACT_FLAG_RIDING_SHELL) && floorHeight < waterLevel) {
- floorHeight = waterLevel;
- floor = &gWaterSurfacePseudoFloor;
- floor->originOffset = -floorHeight;
+ if (m->action & ACT_FLAG_RIDING_SHELL) {
+ if (m->pos[1] < waterLevel - 100) {
+ if (m->riddenObj != NULL) {
+ m->riddenObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ m->riddenObj = NULL;
+ }
+
+ m->usedObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShellUnderwater);
+ mario_grab_used_object(m);
+ m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
+ set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
+ m->pos[0] = nextPos[0];
+ m->pos[1] = MIN(m->pos[1], waterLevel - 120);
+ m->pos[2] = nextPos[2];
+ return GROUND_STEP_ENTERED_WATER;
+ }
+ else if (floorHeight < waterLevel) {
+ floorHeight = waterLevel;
+ floor = &gWaterSurfacePseudoFloor;
+ floor->originOffset = -floorHeight;
+ }
}
if (nextPos[1] > floorHeight + 100.0f) {
@@ -356,7 +374,11 @@ s32 perform_ground_step(struct MarioState *m) {
intendedPos[1] = m->pos[1];
stepResult = perform_ground_quarter_step(m, intendedPos);
- if (stepResult == GROUND_STEP_LEFT_GROUND || stepResult == GROUND_STEP_HIT_WALL_STOP_QSTEPS) {
+ if (
+ stepResult == GROUND_STEP_LEFT_GROUND
+ || stepResult == GROUND_STEP_HIT_WALL_STOP_QSTEPS
+ || stepResult == GROUND_STEP_ENTERED_WATER
+ ) {
break;
}
}
@@ -482,10 +504,27 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
return AIR_STEP_HIT_WALL;
}
- if ((m->action & ACT_FLAG_RIDING_SHELL) && floorHeight < waterLevel) {
- floorHeight = waterLevel;
- floor = &gWaterSurfacePseudoFloor;
- floor->originOffset = -floorHeight;
+ if (m->action & ACT_FLAG_RIDING_SHELL) {
+ if (m->pos[1] < waterLevel - 100) {
+ if (m->riddenObj != NULL) {
+ m->riddenObj->oInteractStatus = INT_STATUS_STOP_RIDING;
+ m->riddenObj = NULL;
+ }
+
+ m->usedObj = spawn_object(m->marioObj, MODEL_KOOPA_SHELL, bhvKoopaShellUnderwater);
+ mario_grab_used_object(m);
+ m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
+ set_mario_action(m, ACT_WATER_SHELL_SWIMMING, (u32)(s32)m->forwardVel);
+ m->pos[0] = nextPos[0];
+ m->pos[1] = MIN(m->pos[1], waterLevel - 120);
+ m->pos[2] = nextPos[2];
+ return AIR_STEP_SHELL_ENTERED_WATER;
+ }
+ else if (floorHeight < waterLevel) {
+ floorHeight = waterLevel;
+ floor = &gWaterSurfacePseudoFloor;
+ floor->originOffset = -floorHeight;
+ }
}
//! This check uses f32, but findFloor uses short (overflow jumps)
@@ -694,9 +733,13 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
stepResult = quarterStepResult;
}
- if (quarterStepResult == AIR_STEP_LANDED || quarterStepResult == AIR_STEP_GRABBED_LEDGE
+ if (
+ quarterStepResult == AIR_STEP_LANDED
+ || quarterStepResult == AIR_STEP_GRABBED_LEDGE
|| quarterStepResult == AIR_STEP_GRABBED_CEILING
- || quarterStepResult == AIR_STEP_HIT_LAVA_WALL) {
+ || quarterStepResult == AIR_STEP_HIT_LAVA_WALL
+ || quarterStepResult == AIR_STEP_SHELL_ENTERED_WATER
+ ) {
break;
}
}
@@ -713,7 +756,17 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
apply_vertical_wind(m);
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
- vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
+
+ //stop copying rotations if mario is doing a shell ground pound or a water shell spin.
+ if (
+ m->action != ACT_RIDING_SHELL_JUMP
+ && m->action != ACT_RIDING_SHELL_FALL
+ && m->action != ACT_HOLD_WATER_JUMP
+ && m->actionState != 3
+ && m->actionState != 4
+ ) {
+ vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
+ }
return stepResult;
}