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#ifndef TARGET_N64
16 temp_v0 += rock->unk_06;
17#endif
18 rock->respawnTimer = sp24[rock->unk_06]; // * 2
19 rock->pos[0] = (f32) temp_v0[rock->unk_06].pos[0] * gCourseDirection;
20 rock->pos[1] = (f32) temp_v0[rock->unk_06].pos[1] + 10.0f;
21 rock->pos[2] = (f32) temp_v0[rock->unk_06].pos[2];
22 vec3f_set(rock->velocity, 0, 0, 0);
23 vec3s_set(rock->rot, 0, 0, 0);
24}
25
33void spawn_falling_rocks(struct ActorSpawnData* spawnData) {
34#ifndef TARGET_N64
35 struct ActorSpawnData* temp_s0 = spawnData;
36 sRockSpawnData = spawnData;
37#else
38 s32 addr = SEGMENT_NUMBER2(spawnData);
39 s32 offset = SEGMENT_OFFSET(spawnData);
40 // Casting this to prevent warning does not work.
41 struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset);
42#endif
43 struct FallingRock* temp_v1;
44 Vec3f startingPos;
45 Vec3f startingVelocity;
46 Vec3s startingRot;
47 s16 temp;
48
49 while (temp_s0->pos[0] != -0x8000) {
50 startingPos[0] = temp_s0->pos[0] * gCourseDirection;
51 startingPos[1] = temp_s0->pos[1] + 10.0f;
52 startingPos[2] = temp_s0->pos[2];
53 vec3f_set(startingVelocity, 0, 0, 0);
54 vec3s_set(startingRot, 0, 0, 0);
55 temp = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK);
56 temp_v1 = (struct FallingRock*) GET_ACTOR(temp);
57
58 temp_v1->unk_06 = temp_s0->someId;
59 func_802AAAAC((Collision*) &temp_v1->unk30);
60 temp_s0++;
61 }
62}
63
71 Vec3f unkVec;
72 f32 pad0;
73 f32 pad1;
74
75 if (rock->respawnTimer != 0) {
76 rock->respawnTimer -= 1;
77 return;
78 }
79 if (rock->pos[1] < CM_GetWaterLevel(rock->pos, NULL)) {
81 }
82 rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f);
83 rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f);
84 rock->velocity[1] -= 0.1;
85 if (rock->velocity[1] < (-2.0f)) {
86 rock->velocity[1] = -2.0f;
87 }
88 rock->pos[0] += rock->velocity[0];
89 rock->pos[1] += rock->velocity[1];
90 rock->pos[2] += rock->velocity[2];
91 pad1 = rock->velocity[1];
92 check_bounding_collision(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]);
93 pad0 = rock->unk30.surfaceDistance[2];
94 if (pad0 < 0.0f) {
95 unkVec[0] = -rock->unk30.orientationVector[0];
96 unkVec[1] = -rock->unk30.orientationVector[1];
97 unkVec[2] = -rock->unk30.orientationVector[2];
98 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[2];
99 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[2];
100 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[2];
101 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
102 rock->velocity[1] = -1.2f * pad1;
103 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
104 }
105 pad0 = rock->unk30.surfaceDistance[0];
106 if (pad0 < 0.0f) {
107 unkVec[1] = -rock->unk30.unk48[1];
108 if (unkVec[1] == 0.0f) {
109 rock->velocity[1] *= -1.2f;
110 return;
111 } else {
112 unkVec[0] = -rock->unk30.unk48[0];
113 unkVec[2] = -rock->unk30.unk48[2];
114 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[0];
115 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[0];
116 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[0];
117 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
118 rock->velocity[1] = -1.2f * pad1;
119 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
120 }
121 }
122 pad0 = rock->unk30.surfaceDistance[1];
123 if (pad0 < 0.0f) {
124 unkVec[1] = -rock->unk30.unk54[1];
125 if (unkVec[1] == 0.0f) {
126 rock->velocity[1] *= -1.2f;
127 } else {
128 unkVec[0] = -rock->unk30.unk54[0];
129 unkVec[2] = -rock->unk30.unk54[2];
130 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[1];
131 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[1];
132 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[1];
133 pad1 = rock->velocity[1];
134 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
135 rock->velocity[1] = -1.2f * pad1;
136 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
137 }
138 }
139}
f32 CM_GetWaterLevel(Vec3f pos, Collision *collision)
Definition Game.cpp:701
@ 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:1290
void adjust_pos_orthogonally(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk)
Definition collision.c:537
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:3084
void update_actor_falling_rocks(struct FallingRock *rock)
Updates the falling rock actor. Actor used in Choco Mountain.
Definition update.inc.c:70
static struct ActorSpawnData * sRockSpawnData
Spawns falling sRockSpawnData. Used in Choco Mountain.
Definition update.inc.c:32
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:33
#define VIRTUAL_TO_PHYSICAL2(addr)
Definition macros.h:97
uintptr_t gSegmentTable[16]
Definition main.c:143
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 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