Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behaviors/bowser_falling_platform.inc.c
7861 views
1
struct BowserFallingPlatformData {
2
const Collision *collision;
3
s16 posX;
4
s16 posZ;
5
s16 angle;
6
};
7
8
struct BowserFallingPlatformData sBowserFallingPlatform[] = {
9
{ NULL, 0, 0, 0 },
10
{ bowser_3_seg7_collision_07004B94, -800, -1000, -20992 },
11
{ bowser_3_seg7_collision_07004C18, -1158, 390, -18432 },
12
{ bowser_3_seg7_collision_07004C9C, -1158, 390, -7680 },
13
{ bowser_3_seg7_collision_07004D20, 0, 1240, -6144 },
14
{ bowser_3_seg7_collision_07004DA4, 0, 1240, 6144 },
15
{ bowser_3_seg7_collision_07004E28, 1158, 390, 7680 },
16
{ bowser_3_seg7_collision_07004EAC, 1158, 390, 18432 },
17
{ bowser_3_seg7_collision_07004F30, 800, -1000, 20992 },
18
{ bowser_3_seg7_collision_07004FB4, 800, -1000, -31744 },
19
{ bowser_3_seg7_collision_07005038, -800, -1000, 31744 }
20
};
21
22
void falling_bowser_plat_act_start(void) {
23
o->oBitsPlatformBowser = cur_obj_nearest_object_with_behavior(bhvBowser);
24
obj_set_collision_data(o, sBowserFallingPlatform[o->oBehParams2ndByte].collision);
25
if (o->oBitsPlatformBowser != 0)
26
o->oAction = BOWSER_BITS_PLAT_ACT_CHECK;
27
}
28
29
void falling_bowser_plat_act_check(void) {
30
UNUSED s32 unused;
31
struct Object *bowser = o->oBitsPlatformBowser;
32
if (bowser->platform == o) {
33
if (bowser->oAction == BOWSER_ACT_BIG_JUMP && bowser->oBowserStatus & BOWSER_STATUS_BIG_JUMP) {
34
o->oAction = BOWSER_BITS_PLAT_ACT_FALL;
35
}
36
}
37
if (bowser->oHealth == 1 && (bowser->oAction == BOWSER_ACT_DANCE || bowser->oHeldState != HELD_FREE)) {
38
o->oSubAction = 1;
39
}
40
if (o->oSubAction == 0) {
41
o->oBitsPlatformTimer = 0;
42
} else {
43
if ((gDebugInfo[4][6] + 20) * (o->oBehParams2ndByte - 1) < o->oBitsPlatformTimer)
44
o->oAction = BOWSER_BITS_PLAT_ACT_FALL;
45
o->oBitsPlatformTimer++;
46
}
47
}
48
49
void falling_bowser_plat_act_fall(void) {
50
Vec3f pos;
51
s16 angle;
52
f32 val;
53
UNUSED struct Object *bowser = o->oBitsPlatformBowser;
54
if (o->oTimer == 0 || o->oTimer == 22) {
55
cur_obj_play_sound_2(SOUND_GENERAL_BOWSER_PLATFORM_2);
56
}
57
if (o->oTimer < 22) {
58
set_environmental_camera_shake(SHAKE_ENV_FALLING_BITS_PLAT);
59
o->oVelY = 8.0f;
60
o->oGravity = 0.0f;
61
} else
62
o->oGravity = -4.0f;
63
if ((o->oTimer & 1) == 0 && o->oTimer < 14) {
64
angle = sBowserFallingPlatform[o->oBehParams2ndByte].angle + (gDebugInfo[4][1] << 8);
65
val = -(o->oTimer / 2) * 290 + 1740;
66
vec3f_copy_2(pos, &o->oPosX);
67
o->oPosX = sBowserFallingPlatform[o->oBehParams2ndByte].posX + sins(angle + 0x14B0) * val;
68
o->oPosZ = sBowserFallingPlatform[o->oBehParams2ndByte].posZ + coss(angle + 0x14B0) * val;
69
o->oPosY = 307.0f;
70
spawn_mist_particles_variable(4, 0, 100.0f);
71
o->oPosX = sBowserFallingPlatform[o->oBehParams2ndByte].posX + sins(angle - 0x14B0) * val;
72
o->oPosZ = sBowserFallingPlatform[o->oBehParams2ndByte].posZ + coss(angle - 0x14B0) * val;
73
spawn_mist_particles_variable(4, 0, 100);
74
vec3f_copy_2(&o->oPosX, pos);
75
}
76
cur_obj_move_using_fvel_and_gravity();
77
if (o->oTimer > 300) {
78
obj_mark_for_deletion(o);
79
}
80
}
81
82
void (*sFallingBowserPlatformActions[])(void) = {
83
falling_bowser_plat_act_start,
84
falling_bowser_plat_act_check,
85
falling_bowser_plat_act_fall,
86
};
87
88
void bhv_falling_bowser_platform_loop(void) {
89
cur_obj_call_action_function(sFallingBowserPlatformActions);
90
}
91
92