Mario Kart 64
Loading...
Searching...
No Matches
bomb_kart.inc.c
Go to the documentation of this file.
2 UNUSED Collision* var_s2;
3 f32 startingXPos;
4 f32 startingZPos;
5 f32 startingYPos;
6 s32 var_s3;
7 TrackPathPoint* temp_v0;
8 UNUSED BombKart* var_s0;
9 BombKartSpawn* bombKartSpawn;
10
11 for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) {
12 bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3];
13 switch (gCurrentCourseId) {
15 startingXPos = bombKartSpawn->startingXPos;
16 startingZPos = bombKartSpawn->startingZPos;
17 startingYPos = get_surface_height(startingXPos, 2000.0f, startingZPos);
18 break;
20 temp_v0 = &gTrackPaths[3][bombKartSpawn->pathPointIndex];
21 startingXPos = temp_v0->posX;
22 startingYPos = temp_v0->posY;
23 startingZPos = temp_v0->posZ;
24 break;
25 default:
26 temp_v0 = &gTrackPaths[0][bombKartSpawn->pathPointIndex];
27 startingXPos = temp_v0->posX;
28 startingYPos = temp_v0->posY;
29 startingZPos = temp_v0->posZ;
30 break;
31 }
32 gBombKarts[var_s3].bombPos[0] = startingXPos;
33 gBombKarts[var_s3].bombPos[1] = startingYPos;
34 gBombKarts[var_s3].bombPos[2] = startingZPos;
35 gBombKarts[var_s3].wheel1Pos[0] = startingXPos;
36 gBombKarts[var_s3].wheel1Pos[1] = startingYPos;
37 gBombKarts[var_s3].wheel1Pos[2] = startingZPos;
38 gBombKarts[var_s3].wheel2Pos[0] = startingXPos;
39 gBombKarts[var_s3].wheel2Pos[1] = startingYPos;
40 gBombKarts[var_s3].wheel2Pos[2] = startingZPos;
41 gBombKarts[var_s3].wheel3Pos[0] = startingXPos;
42 gBombKarts[var_s3].wheel3Pos[1] = startingYPos;
43 gBombKarts[var_s3].wheel3Pos[2] = startingZPos;
44 gBombKarts[var_s3].wheel4Pos[0] = startingXPos;
45 gBombKarts[var_s3].wheel4Pos[1] = startingYPos;
46 gBombKarts[var_s3].wheel4Pos[2] = startingZPos;
47 gBombKarts[var_s3].pathPointIndex = bombKartSpawn->pathPointIndex;
48 gBombKarts[var_s3].unk_3C = bombKartSpawn->unk_04;
49 gBombKarts[var_s3].bounceTimer = 0;
50 gBombKarts[var_s3].circleTimer = 0;
51 gBombKarts[var_s3].state = bombKartSpawn->startingState;
52 gBombKarts[var_s3].unk_4A = 0;
53 gBombKarts[var_s3].unk_4C = 1;
54 gBombKarts[var_s3].yPos = startingYPos;
55 check_bounding_collision(&D_80164038[var_s3], 2.0f, startingXPos, startingYPos, startingZPos);
56 }
57}
58
59void func_8000DF8C(s32 bombKartId) {
60 UNUSED s32 stackPadding0;
61 f32 sp118;
62 f32 var_f18;
63 TrackPathPoint* temp_v0_2;
64 f32 temp_f0_3;
65 f32 sp108;
66 UNUSED s32 stackPadding1;
67 UNUSED s32 stackPadding2;
68 UNUSED s32 stackPadding3;
69 f32 temp_f14;
70 UNUSED s32 stackPadding4;
71 f32 temp_f16;
72 UNUSED s32 stackPadding5;
73 UNUSED s32 stackPadding6;
74 UNUSED s32 stackPadding7;
75 UNUSED s32 stackPadding8;
76 UNUSED s32 stackPadding9;
77 UNUSED s32 stackPaddingA;
78 UNUSED s32 stackPaddingB;
79 f32 temp_f0;
80 f32 temp_f0_4;
81 u16 spCA;
82 f32 spC4;
83 u16 spC2;
84 f32 temp_f12;
85 f32 temp_f12_3;
86 f32 temp_f12_4;
87 f32 temp_f14_2;
88 f32 spAC;
89 UNUSED s32 stackPaddingC;
90 f32 temp_f16_2;
91 f32 spA0;
92 f32 temp_f2;
93 f32 temp_f2_4;
94 f32 sp94;
95 UNUSED s32 stackPaddingD;
96 f32 var_f20;
97 f32 sp88;
98 f32 var_f22;
99 f32 var_f24;
100 u16 sp7E;
101 u16 sp7C;
102 UNUSED u16 sp4C;
103 u16 temp_t6;
104 u16 temp_t7;
105 u16 var_s1;
106 s32 var_a0;
107 UNUSED s32 stackPaddingE;
108 TrackPathPoint* temp_v0_4;
109 BombKart* bombKart;
110 BombKart* bombKart2;
111 Collision* temp_a0_4;
112 Player* var_v0;
113
114 bombKart = &gBombKarts[bombKartId];
115
116 sp7E = bombKart->state;
117
118 if (sp7E == 0) {
119 return;
120 }
121
122 if (((bombKart->unk_4A != 1) || (gCurrentCourseId == COURSE_AWARD_CEREMONY))) {
123 var_f22 = bombKart->bombPos[0];
124 var_f20 = bombKart->bombPos[1];
125 var_f24 = bombKart->bombPos[2];
126 spCA = bombKart->pathPointIndex;
127 spC4 = bombKart->unk_3C;
128 spC2 = bombKart->someRot;
129 sp7C = bombKart->bounceTimer;
130 var_s1 = bombKart->circleTimer;
131 if ((sp7E != 0) && (sp7E != 4)) {
132 if (1) {}
134 if (D_8016347E == 1) {
135 var_v0 = gPlayerFour;
136 temp_f0 = var_f22 - var_v0->pos[0];
137 temp_f2 = var_f20 - var_v0->pos[1];
138 temp_f12 = var_f24 - var_v0->pos[2];
139 if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) {
140 var_s1 = 0;
141 sp7E = 4;
142 var_v0->soundEffects |= 0x400000;
143 var_v0->type &= ~0x2000;
144 }
145 }
146 } else {
147
148 for (var_a0 = 0; var_a0 < gPlayerCount; var_a0++) {
149 var_v0 = &gPlayers[var_a0];
150 if (!(var_v0->effects & 0x80000000)) {
151 temp_f0 = var_f22 - var_v0->pos[0];
152 temp_f2 = var_f20 - var_v0->pos[1];
153 temp_f12 = var_f24 - var_v0->pos[2];
154 if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) {
155 sp7E = 4;
156 var_s1 = 0;
158 var_v0->soundEffects |= 0x01000000;
159 } else {
160 var_v0->soundEffects |= 0x400000;
161 }
162 }
163 }
164 }
165 }
166 }
167 switch (sp7E) {
168 case 1:
169 var_s1 = (var_s1 + 356) % 360;
170 temp_t6 = (var_s1 * 0xFFFF) / 360;
171 sp118 = coss(temp_t6) * 25.0;
172 temp_f0_3 = sins(temp_t6) * 25.0;
173 temp_v0_2 = &gTrackPaths[0][spCA];
174 var_f22 = temp_v0_2->posX + sp118;
175 var_f20 = bombKart->yPos + 3.5f;
176 var_f24 = temp_v0_2->posZ + temp_f0_3;
177 D_80162FB0[0] = var_f22;
178 D_80162FB0[1] = var_f20;
179 D_80162FB0[2] = var_f24;
180 temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360;
181 sp118 = coss(temp_t7) * 25.0;
182 temp_f0_3 = sins(temp_t7) * 25.0;
183 D_80162FC0[0] = temp_v0_2->posX + sp118;
184 D_80162FC0[1] = temp_v0_2->posY;
185 D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3;
186 spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520;
187 break;
188 case 2:
189 var_s1 = (var_s1 + 4) % 360;
190 temp_t6 = (var_s1 * 0xFFFF) / 360;
191 sp118 = coss(temp_t6) * 25.0;
192 temp_f0_3 = sins(temp_t6) * 25.0;
193 temp_v0_2 = &gTrackPaths[0][spCA];
194 var_f22 = temp_v0_2->posX + sp118;
195 var_f20 = bombKart->yPos + 3.5f;
196 var_f24 = temp_v0_2->posZ + temp_f0_3;
197 D_80162FB0[0] = var_f22;
198 D_80162FB0[1] = var_f20;
199 D_80162FB0[2] = var_f24;
200 temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360;
201 sp118 = coss(temp_t7) * 25.0;
202 temp_f0_3 = sins(temp_t7) * 25.0;
203 D_80162FC0[0] = temp_v0_2->posX + sp118;
204 D_80162FC0[1] = temp_v0_2->posY;
205 D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3;
206 spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520;
207 break;
208 case 3:
209 var_f20 = bombKart->yPos + 3.5f;
210 spC2 = 0;
211 break;
212
213 case 5:
214 if ((D_8016347C == 0) || (gNearestPathPointByPlayerId[3] < 5)) {
215 break;
216 } else {
217 spCA = func_8000D2B4(var_f22, var_f20, var_f24, spCA, 3);
218 if ((spCA < 0) || (gPathCountByPathIndex[3] < spCA)) {
219 spCA = 0;
220 }
221 if (((s32) spCA) < 0x1A) {
222 temp_v0_2 = &gTrackPaths[3][(spCA + 1) % gPathCountByPathIndex[3]];
223 D_80162FB0[0] = temp_v0_2->posX;
224 D_80162FB0[1] = temp_v0_2->posY;
225 D_80162FB0[2] = temp_v0_2->posZ;
226 temp_v0_4 = &gTrackPaths[3][(spCA + 2) % gPathCountByPathIndex[3]];
227 D_80162FC0[0] = temp_v0_4->posX;
228 D_80162FC0[1] = temp_v0_4->posY;
229 D_80162FC0[2] = temp_v0_4->posZ;
230 spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520;
231 } else {
232 D_80162FB0[0] = var_f22;
233 D_80162FB0[1] = var_f20;
234 D_80162FB0[2] = var_f24;
235 D_80162FC0[0] = -2409.197f;
236 D_80162FC0[1] = 0.0f;
237 D_80162FC0[2] = -355.254f;
238 spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520;
239 }
240 temp_f14 = ((D_80162FB0[0] + D_80162FC0[0]) * 0.5f) - var_f22;
241 temp_f16 = ((D_80162FB0[2] + D_80162FC0[2]) * 0.5f) - var_f24;
242 temp_f0_4 = sqrtf((temp_f14 * temp_f14) + (temp_f16 * temp_f16));
243 if (temp_f0_4 > 0.01f) {
244 var_f22 += (bombKart->unk_3C * temp_f14) / temp_f0_4;
245 var_f24 += (bombKart->unk_3C * temp_f16) / temp_f0_4;
246 } else {
247 var_f22 += temp_f14 / 5.0f;
248 var_f24 += temp_f16 / 5.0f;
249 }
250 temp_a0_4 = &D_80164038[bombKartId];
251 var_f20 = calculate_surface_height(var_f22, 2000.0f, var_f24, temp_a0_4->meshIndexZX) + 3.5f;
252 if (var_f20 < (-1000.0)) {
253 var_f20 = bombKart->bombPos[1];
254 }
255 check_bounding_collision(temp_a0_4, 10.0f, var_f22, var_f20, var_f24);
256 }
257 break;
258 case 4:
259 temp_v0_2 = &gTrackPaths[0][spCA];
260 D_80162FB0[0] = temp_v0_2->posX;
261 D_80162FB0[1] = temp_v0_2->posY;
262 D_80162FB0[2] = temp_v0_2->posZ;
263 temp_v0_4 = &gTrackPaths[0][(spCA + 1) % gPathCountByPathIndex[0]];
264 D_80162FC0[0] = temp_v0_4->posX;
265 D_80162FC0[1] = temp_v0_4->posY;
266 D_80162FC0[2] = temp_v0_4->posZ;
267 var_f20 += 3.0f - (var_s1 * 0.3f);
268 spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520;
269 break;
270 default:
271 break;
272 }
273
274 if (sp7E == 4) {
275 sp108 = 2.0f * var_s1;
276 sp118 = coss(0xFFFF - spC2) * var_s1;
277 var_f18 = sins(0xFFFF - spC2) * var_s1;
278 var_s1++;
279 temp_f2_4 = (var_f20 - 2.3f) + (sp108 / 3.0f);
280 spAC = temp_f2_4;
281 spA0 = temp_f2_4;
282 sp94 = temp_f2_4;
283 sp88 = temp_f2_4;
284 if (var_s1 >= 31) {
285 sp7E = 0;
286 }
287 } else {
288 sp118 = coss(0xFFFF - spC2) * 1.5f;
289 var_f18 = sins(0xFFFF - spC2) * 1.5f;
290 temp_f16_2 = var_f20 - 2.3f;
291 temp_f12_3 = (sp7C % 3) * 0.15f;
292 temp_f14_2 = temp_f16_2 - temp_f12_3;
293 temp_f12_4 = temp_f16_2 + temp_f12_3;
294 spAC = temp_f14_2;
295 sp94 = temp_f14_2;
296 spA0 = temp_f12_4;
297 sp88 = temp_f12_4;
298 var_f20 += sins((sp7C * 0x13FFEC) / 360);
299 sp7C = (sp7C + 1) % 18;
300 }
301 bombKart2 = bombKart;
302 bombKart2->wheel1Pos[0] = (sp118 - var_f18) + var_f22;
303 bombKart2->wheel1Pos[1] = spAC;
304 bombKart2->wheel1Pos[2] = (var_f18 + sp118) + var_f24;
305 bombKart2->wheel2Pos[0] = (var_f18 + sp118) + var_f22;
306 bombKart2->wheel2Pos[1] = spA0;
307 bombKart2->wheel2Pos[2] = (var_f18 - sp118) + var_f24;
308 bombKart2->wheel3Pos[0] = ((-sp118) - var_f18) + var_f22;
309 bombKart2->wheel3Pos[1] = sp94;
310 bombKart2->wheel3Pos[2] = ((-var_f18) + sp118) + var_f24;
311 bombKart2->wheel4Pos[0] = ((-sp118) + var_f18) + var_f22;
312 bombKart2->wheel4Pos[1] = sp88;
313 bombKart2->wheel4Pos[2] = ((-var_f18) - sp118) + var_f24;
314 bombKart2->bombPos[0] = var_f22;
315 bombKart2->bombPos[1] = var_f20;
316 bombKart2->bombPos[2] = var_f24;
317 bombKart2->pathPointIndex = spCA;
318 bombKart2->unk_3C = spC4;
319 bombKart2->someRot = spC2;
320 bombKart2->state = sp7E;
321 bombKart2->bounceTimer = sp7C;
322 bombKart2->circleTimer = var_s1;
323 }
324}
#define NUM_BOMB_KARTS_VERSUS
Definition bomb_kart.h:9
void func_8000DF8C(s32 bombKartId)
Definition bomb_kart.inc.c:59
void set_bomb_kart_spawn_positions(void)
Definition bomb_kart.inc.c:1
s16 gCurrentCourseId
Definition code_800029B0.c:30
u16 check_bounding_collision(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ)
Definition collision.c:1358
f32 calculate_surface_height(f32 x, f32 y, f32 z, u16 index)
Definition collision.c:529
f32 get_surface_height(f32 posX, f32 posY, f32 posZ)
Returns the height of the surface below the provided position. Used to set actors onto the course mes...
Definition collision.c:1470
@ COURSE_FRAPPE_SNOWLAND
Definition course.h:36
@ COURSE_YOSHI_VALLEY
Definition course.h:35
@ COURSE_AWARD_CEREMONY
Definition course.h:51
u16 gPathCountByPathIndex[4]
Definition cpu_vehicles_camera_path.c:181
Vec3f D_80162FC0
Definition cpu_vehicles_camera_path.c:53
Vec3f D_80162FB0
Definition cpu_vehicles_camera_path.c:52
Collision D_80164038[NUM_BOMB_KARTS_MAX]
Definition cpu_vehicles_camera_path.c:150
TrackPathPoint * gTrackPaths[4]
Definition cpu_vehicles_camera_path.c:174
s16 D_8016347E
Definition cpu_vehicles_camera_path.c:125
BombKart gBombKarts[NUM_BOMB_KARTS_MAX]
Definition cpu_vehicles_camera_path.c:149
u16 gNearestPathPointByPlayerId[12]
Definition cpu_vehicles_camera_path.c:163
s16 D_8016347C
Definition cpu_vehicles_camera_path.c:124
s16 func_8000D2B4(f32, f32, f32, s16, s32)
Definition path_utils.inc.c:553
#define UNUSED
Definition macros.h:23
Player gPlayers[NUM_PLAYERS]
Definition main.c:68
Player * gPlayerFour
Definition main.c:72
float sqrtf(float)
f32 sins(u16 arg0)
Definition math_util.c:1086
s32 get_angle_between_two_vectors(Vec3f arg0, Vec3f arg1)
Definition math_util.c:84
f32 coss(u16 arg0)
Definition math_util.c:1090
s8 gPlayerCount
Definition menus.c:53
BombKartSpawn gBombKartSpawns[][NUM_BOMB_KARTS_MAX]
Definition path_spawn_metadata.c:67
Definition bomb_kart.h:19
u16 startingState
Definition bomb_kart.h:21
u16 pathPointIndex
Definition bomb_kart.h:20
f32 unk_04
Definition bomb_kart.h:22
f32 startingZPos
Definition bomb_kart.h:24
f32 startingXPos
Definition bomb_kart.h:23
Definition bomb_kart.h:33
Vec3f wheel3Pos
Definition bomb_kart.h:42
u16 circleTimer
Definition bomb_kart.h:49
Vec3f wheel1Pos
Definition bomb_kart.h:40
Vec3f wheel2Pos
Definition bomb_kart.h:41
Vec3f wheel4Pos
Definition bomb_kart.h:43
u16 someRot
Definition bomb_kart.h:45
s16 unk_4C
Definition bomb_kart.h:51
u16 state
Definition bomb_kart.h:47
u16 bounceTimer
Definition bomb_kart.h:48
f32 yPos
Definition bomb_kart.h:53
f32 unk_3C
Definition bomb_kart.h:44
Vec3f bombPos
Definition bomb_kart.h:39
u16 pathPointIndex
Definition bomb_kart.h:46
u16 unk_4A
Definition bomb_kart.h:50
Definition common_structs.h:132
u16 meshIndexZX
Definition common_structs.h:139
Definition common_structs.h:249
u32 effects
Definition common_structs.h:298
u16 type
Definition common_structs.h:250
s32 soundEffects
Definition common_structs.h:256
Vec3f pos
Definition common_structs.h:259
Definition path.h:6
s16 posX
Definition path.h:7
s16 posZ
Definition path.h:9
s16 posY
Definition path.h:8
signed int s32
Definition ultratypes.h:15
float f32
Definition ultratypes.h:34
unsigned short int u16
Definition ultratypes.h:14