Mario Kart 64
Loading...
Searching...
No Matches
update.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <code_800029B0.h>
3#include <main.h>
5
6void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
7#ifndef TARGET_N64
8 struct ActorSpawnData* temp_v0 = spawnData;
9#else
10 s32 segment = SEGMENT_NUMBER2(spawnData);
11 s32 offset = SEGMENT_OFFSET(spawnData);
12 struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset);
13#endif
14 Vec3s sp24 = { 60, 120, 180 };
15 temp_v0 += rock->unk_06;
16 rock->respawnTimer = sp24[rock->unk_06]; // * 2
17 rock->pos[0] = (f32) temp_v0->pos[0] * gCourseDirection;
18 rock->pos[1] = (f32) temp_v0->pos[1] + 10.0f;
19 rock->pos[2] = (f32) temp_v0->pos[2];
20 vec3f_set(rock->velocity, 0, 0, 0);
21 vec3s_set(rock->rot, 0, 0, 0);
22}
23
31void spawn_falling_rocks(struct ActorSpawnData* spawnData) {
32#ifndef TARGET_N64
33 struct ActorSpawnData* temp_s0 = spawnData;
34 sRockSpawnData = spawnData;
35#else
36 s32 addr = SEGMENT_NUMBER2(spawnData);
37 s32 offset = SEGMENT_OFFSET(spawnData);
38 // Casting this to prevent warning does not work.
39 struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset);
40#endif
41 struct FallingRock* temp_v1;
42 Vec3f startingPos;
43 Vec3f startingVelocity;
44 Vec3s startingRot;
45 s16 temp;
46
47 while (temp_s0->pos[0] != -0x8000) {
48 startingPos[0] = temp_s0->pos[0] * gCourseDirection;
49 startingPos[1] = temp_s0->pos[1] + 10.0f;
50 startingPos[2] = temp_s0->pos[2];
51 vec3f_set(startingVelocity, 0, 0, 0);
52 vec3s_set(startingRot, 0, 0, 0);
53 temp = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK);
54 temp_v1 = (struct FallingRock*) GET_ACTOR(temp);
55
56 temp_v1->unk_06 = temp_s0->someId;
57 func_802AAAAC((Collision*) &temp_v1->unk30);
58 temp_s0++;
59 }
60}
61
69 Vec3f unkVec;
70 f32 pad0;
71 f32 pad1;
72
73 if (rock->respawnTimer != 0) {
74 rock->respawnTimer -= 1;
75 return;
76 }
77 if (rock->pos[1] < CM_GetWaterLevel(rock->pos, NULL)) {
79 }
80 rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f);
81 rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f);
82 rock->velocity[1] -= 0.1;
83 if (rock->velocity[1] < (-2.0f)) {
84 rock->velocity[1] = -2.0f;
85 }
86 rock->pos[0] += rock->velocity[0];
87 rock->pos[1] += rock->velocity[1];
88 rock->pos[2] += rock->velocity[2];
89 pad1 = rock->velocity[1];
90 check_bounding_collision(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]);
91 pad0 = rock->unk30.surfaceDistance[2];
92 if (pad0 < 0.0f) {
93 unkVec[0] = -rock->unk30.orientationVector[0];
94 unkVec[1] = -rock->unk30.orientationVector[1];
95 unkVec[2] = -rock->unk30.orientationVector[2];
96 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[2];
97 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[2];
98 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[2];
99 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
100 rock->velocity[1] = -1.2f * pad1;
101 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
102 }
103 pad0 = rock->unk30.surfaceDistance[0];
104 if (pad0 < 0.0f) {
105 unkVec[1] = -rock->unk30.unk48[1];
106 if (unkVec[1] == 0.0f) {
107 rock->velocity[1] *= -1.2f;
108 return;
109 } else {
110 unkVec[0] = -rock->unk30.unk48[0];
111 unkVec[2] = -rock->unk30.unk48[2];
112 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[0];
113 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[0];
114 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[0];
115 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
116 rock->velocity[1] = -1.2f * pad1;
117 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
118 }
119 }
120 pad0 = rock->unk30.surfaceDistance[1];
121 if (pad0 < 0.0f) {
122 unkVec[1] = -rock->unk30.unk54[1];
123 if (unkVec[1] == 0.0f) {
124 rock->velocity[1] *= -1.2f;
125 } else {
126 unkVec[0] = -rock->unk30.unk54[0];
127 unkVec[2] = -rock->unk30.unk54[2];
128 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[1];
129 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[1];
130 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[1];
131 pad1 = rock->velocity[1];
132 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
133 rock->velocity[1] = -1.2f * pad1;
134 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
135 }
136 }
137}
f32 CM_GetWaterLevel(Vec3f pos, Collision *collision)
Definition Game.cpp:714
@ ACTOR_FALLING_ROCK
Definition actor_types.h:44
#define GET_ACTOR(index)
Definition actor_types.h:90
s16 add_actor_to_empty_slot(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType)
Definition actors.c:1416
f32 gCourseDirection
Definition code_800029B0.c:128
u16 check_bounding_collision(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ)
Definition collision.c:1295
void adjust_pos_orthogonally(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk)
Definition collision.c:542
void func_802AAAAC(Collision *collision)
Definition collision.c:27
f32 Vec3f[3]
Definition common_structs.h:10
s16 Vec3s[3]
Definition common_structs.h:15
void func_800C98B8(Vec3f position, Vec3f velocity, u32 soundBits)
Definition external.c:3092
void update_actor_falling_rocks(struct FallingRock *rock)
Updates the falling rock actor. Actor used in Choco Mountain.
Definition update.inc.c:68
static struct ActorSpawnData * sRockSpawnData
Spawns falling sRockSpawnData. Used in Choco Mountain.
Definition update.inc.c:30
void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock)
Definition update.inc.c:6
void spawn_falling_rocks(struct ActorSpawnData *spawnData)
Definition update.inc.c:31
#define VIRTUAL_TO_PHYSICAL2(addr)
Definition macros.h:97
uintptr_t gSegmentTable[16]
Definition main.c:135
void vec3f_set(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3)
Definition math_util.c:114
void vec3s_set(Vec3s arg0, s16 arg1, s16 arg2, s16 arg3)
Definition math_util.c:120
#define NULL
Definition miniaudio.h:3851
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
Definition SpawnData.h:8
Vec3s pos
Definition SpawnData.h:9
u16 someId
Definition SpawnData.h:11
Definition common_structs.h:147
Vec3f surfaceDistance
Definition common_structs.h:155
Vec3f orientationVector
Definition common_structs.h:158
Vec3f unk54
Definition common_structs.h:157
Vec3f unk48
Definition common_structs.h:156
Definition actor_types.h:181
Collision unk30
Definition actor_types.h:192
s16 respawnTimer
Definition actor_types.h:184
Vec3s rot
Definition actor_types.h:188
s16 unk_06
Definition actor_types.h:185
Vec3f pos
Definition actor_types.h:190
Vec3f velocity
Definition actor_types.h:191