Mario Kart 64
Loading...
Searching...
No Matches
update.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <main.h>
3#include <code_800029B0.h>
4#include <defines.h>
5#include "collision.h"
6
13 Player *player;
14 UNUSED f32 pad9;
15 UNUSED f32 padA;
16 Vec3f somePos2;
17 Vec3f somePosVel;
18 f32 var_f2;
19 struct Controller *controller;
20 TripleShellParent *parent;
21 f32 height;
22 f32 z;
23 UNUSED f32 pad2;
24 UNUSED f32 pad3;
25 UNUSED f32 pad4;
26 UNUSED f32 pad5;
27 f32 y;
28 UNUSED f32 pad7;
29 UNUSED f32 pad8;
30
31 height = shell->pos[0];
32 y = shell->pos[1];
33 z = shell->pos[2];
34 if ((z < gCourseMinZ) || (gCourseMaxZ < z) || (height < gCourseMinX) || (gCourseMaxX < height) || (y < gCourseMinY)) {
35 destroy_destructable_actor((struct Actor *) shell);
36 }
37 shell->rotVelocity += 0x71C;
38 switch (shell->state) {
39 case HELD_SHELL:
40 player = &gPlayers[shell->playerId];
41 copy_collision(&player->collision, &shell->unk30);
42 somePosVel[0] = 0.0f;
43 somePosVel[1] = player->boundingBoxSize;
44 somePosVel[2] = -(player->boundingBoxSize + shell->boundingBoxSize + 2.0f);
46 shell->pos[0] = player->pos[0] + somePosVel[0];
47 pad2 = player->pos[1] - somePosVel[1];
48 shell->pos[2] = player->pos[2] + somePosVel[2];
49 height = calculate_surface_height(shell->pos[0], pad2, shell->pos[2], player->collision.meshIndexZX);
50 z = pad2 - height;
51 if ((z < 5.0f) && (z > -5.0f)) {
52 shell->pos[1] = shell->boundingBoxSize + height;
53 } else {
54 shell->pos[1] = pad2;
55 }
56 if ((player->type & PLAYER_HUMAN) != 0) {
57 controller = &gControllers[shell->playerId];
58 if ((controller->buttonDepressed & Z_TRIG) != 0) {
59 controller->buttonDepressed &= ~Z_TRIG;
60 if (controller->rawStickY < -0x2D) {
61 var_f2 = 8.0f;
62 if (player->unk_094 > 8.0f) {
63 var_f2 = player->unk_094 * 1.2f;
64 }
65 somePosVel[0] = 0.0f;
66 somePosVel[1] = 0.0f;
67 somePosVel[2] = -var_f2;
68 func_802B64C4(somePosVel, player->rotation[1] + player->unk_0C0);
69 shell->velocity[0] = somePosVel[0];
70 shell->velocity[1] = somePosVel[1];
71 shell->velocity[2] = somePosVel[2];
72 shell->state = 2;
73 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
74 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
76 return;
77 } else {
78 shell->state = 1;
79 if (player->unk_0C0 > 0) {
80 shell->rotAngle = 0x78E3;
81 } else {
82 shell->rotAngle = -0x78E4;
83 }
84 }
85 }
86 }
87 break;
88 case RELEASED_SHELL:
89 player = &gPlayers[shell->playerId];
90 if (shell->rotAngle > 0) {
91 shell->rotAngle -= 0xE38;
92 if (shell->rotAngle < 0) {
93 shell->state = 2;
94 shell->someTimer = 0x001E;
95 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
96 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
98 }
99 } else {
100 shell->rotAngle += 0xE38;
101 if (shell->rotAngle > 0) {
102 shell->state = 2;
103 shell->someTimer = 0x001E;
104 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
105 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
107 }
108 }
109 if (shell->state == 2) {
110 var_f2 = 8.0f;
111 if (player->unk_094 > 8.0f) {
112 var_f2 = player->unk_094 * 1.2f;
113 }
114 somePosVel[0] = 0.0f;
115 somePosVel[1] = 0.0f;
116 somePosVel[2] = var_f2;
117 func_802B64C4(somePosVel, player->rotation[1] + player->unk_0C0);
118 shell->velocity[0] = somePosVel[0];
119 shell->velocity[1] = somePosVel[1];
120 shell->velocity[2] = somePosVel[2];
121 } else {
122 somePosVel[0] = sins(shell->rotAngle) * 6.0f;
123 somePosVel[1] = shell->boundingBoxSize - player->boundingBoxSize;
124 somePosVel[2] = coss(shell->rotAngle) * 6.0f;
125 mtxf_translate_vec3f_mat3(somePosVel, player->orientationMatrix);
126 shell->pos[0] = player->pos[0] + somePosVel[0];
127 shell->pos[1] = player->pos[1] + somePosVel[1];
128 shell->pos[2] = player->pos[2] + somePosVel[2];
129 }
130 break;
131 case MOVING_SHELL:
132 if (shell->parentIndex > 0) {
133 shell->parentIndex -= 1;
134 if (shell->parentIndex == 0) {
135 shell->flags &= ~0x1000;
136 }
137 }
138 shell->velocity[1] -= 0.5f;
139 if (shell->velocity[1] < -2.0f) {
140 shell->velocity[1] = -2.0f;
141 }
142 somePos2[0] = shell->pos[0];
143 somePos2[1] = shell->pos[1];
144 somePos2[2] = shell->pos[2];
145 shell->pos[0] += shell->velocity[0];
146 shell->pos[1] += shell->velocity[1];
147 shell->pos[2] += shell->velocity[2];
148 actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]);
149 func_802B4E30((struct Actor *) shell);
150 if ((shell->unk30.surfaceDistance[0] < 0.0f) || (shell->unk30.surfaceDistance[1] < 0.0f)) {
151 shell_collision(&shell->unk30, shell->velocity);
152 func_800C98B8(shell->pos, shell->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x54));
153 shell->flags |= 0x80;
154 }
155 break;
157 player = &gPlayers[shell->playerId];
158 parent = (TripleShellParent *) &gActorList[shell->parentIndex];
159 if (parent->type != ACTOR_TRIPLE_GREEN_SHELL) {
160 destroy_destructable_actor((struct Actor *) shell);
161 } else {
162 shell->rotAngle += parent->rotVelocity;
163 somePosVel[0] = sins(shell->rotAngle) * 8.0f;
164 somePosVel[1] = shell->boundingBoxSize - player->boundingBoxSize;
165 somePosVel[2] = coss(shell->rotAngle) * 8.0f;
166 mtxf_translate_vec3f_mat3(somePosVel, player->orientationMatrix);
167 somePos2[0] = shell->pos[0];
168 somePos2[1] = shell->pos[1];
169 somePos2[2] = shell->pos[2];
170 shell->pos[0] = player->pos[0] + somePosVel[0];
171 shell->pos[1] = player->pos[1] + somePosVel[1];
172 shell->pos[2] = player->pos[2] + somePosVel[2];
173 actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]);
174 func_802B4E30((struct Actor *) shell);
175 }
176 break;
178 // Somehow, this fake match affects stack management up in case 2
179 shell->velocity[1] -= (0, 0.3f);
180 if (shell->velocity[1] < -5.0f) {
181 shell->velocity[1] = -5.0f;
182 }
183 shell->rotAngle += 0x5B0;
184 shell->someTimer -= 1;
185 shell->pos[1] += shell->velocity[1];
186 if (shell->someTimer == 0) {
187 destroy_actor((struct Actor *) shell);
188 }
189 break;
190 default:
191 break;
192 }
193}
@ ACTOR_TRIPLE_GREEN_SHELL
Definition actor_types.h:59
@ MOVING_SHELL
Definition actor_types.h:95
@ HELD_SHELL
Definition actor_types.h:93
@ RELEASED_SHELL
Definition actor_types.h:94
@ GREEN_SHELL_HIT_A_RACER
Definition actor_types.h:98
@ TRIPLE_GREEN_SHELL
Definition actor_types.h:97
void destroy_destructable_actor(struct Actor *actor)
Definition actors.c:1813
void destroy_actor(struct Actor *actor)
Definition actors.c:1290
void copy_collision(Collision *src, Collision *dest)
Definition actors_extended.c:19
void func_802B4E30(struct Actor *arg0)
Definition actors_extended.c:962
s16 gCourseMinZ
Definition code_800029B0.c:93
s16 gCourseMaxZ
Definition code_800029B0.c:92
s16 gCourseMinX
Definition code_800029B0.c:87
struct Actor gActorList[ACTOR_LIST_SIZE]
Definition code_800029B0.c:148
s16 gCourseMinY
Definition code_800029B0.c:90
s16 gCourseMaxX
Definition code_800029B0.c:86
s32 add_green_shell_in_unexpired_actor_list(s32 actorIndex)
Definition code_80005FD0.c:3255
void shell_collision(Collision *collision, Vec3f velocity)
Definition collision.c:586
f32 calculate_surface_height(f32 x, f32 y, f32 z, u16 index)
Definition collision.c:519
u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2)
Definition collision.c:1221
f32 Vec3f[3]
Definition common_structs.h:6
#define PLAYER_HUMAN
Definition defines.h:101
void func_800C9060(u8 playerId, u32 soundBits)
Definition external.c:2894
void func_800C90F4(u8 playerId, u32 soundBits)
Definition external.c:2906
void func_800C98B8(Vec3f position, Vec3f velocity, u32 soundBits)
Definition external.c:3049
void update_actor_green_shell(struct ShellActor *shell)
Updates the green shell actor.
Definition update.inc.c:12
#define UNUSED
Definition macros.h:24
Player gPlayers[NUM_PLAYERS]
Definition main.c:73
struct Controller gControllers[NUM_PLAYERS]
Definition main.c:63
f32 sins(u16 arg0)
Definition math_util.c:1055
void func_802B64C4(Vec3f arg0, s16 arg1)
Definition math_util.c:606
void mtxf_translate_vec3f_mat3(Vec3f pos, Mat3 mat)
Definition math_util.c:572
f32 coss(u16 arg0)
Definition math_util.c:1059
#define Z_TRIG
Definition os.h:398
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
Definition actor_types.h:120
Vec3f velocity
Definition actor_types.h:130
Collision unk30
Definition actor_types.h:131
s16 flags
Definition actor_types.h:122
Vec3f pos
Definition actor_types.h:129
f32 boundingBoxSize
Definition actor_types.h:126
Vec3f surfaceDistance
Definition common_structs.h:146
u16 meshIndexZX
Definition common_structs.h:145
Definition common_structs.h:71
s16 rawStickY
Definition common_structs.h:73
u16 buttonDepressed
Definition common_structs.h:76
Definition common_structs.h:255
s16 unk_0C0
Definition common_structs.h:307
f32 unk_094
Definition common_structs.h:292
Mat3 orientationMatrix
Definition common_structs.h:334
u16 characterId
Definition common_structs.h:362
Vec3s rotation
Definition common_structs.h:269
Collision collision
Definition common_structs.h:332
f32 boundingBoxSize
Definition common_structs.h:282
u16 type
Definition common_structs.h:256
Vec3f pos
Definition common_structs.h:265
Definition actor_types.h:302
s16 rotAngle
Definition actor_types.h:318
s16 rotVelocity
Definition actor_types.h:316
s16 flags
Definition actor_types.h:304
f32 boundingBoxSize
Definition actor_types.h:315
s16 state
Definition actor_types.h:313
s16 playerId
Definition actor_types.h:321
Vec3f velocity
Definition actor_types.h:324
s16 parentIndex
Definition actor_types.h:308
Vec3f pos
Definition actor_types.h:323
Collision unk30
Definition actor_types.h:325
s16 someTimer
Definition actor_types.h:309
Definition actor_types.h:286
s16 rotVelocity
Definition actor_types.h:293
s16 type
Definition actor_types.h:287
float f32
Definition ultratypes.h:34