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 <types.h>
4#include <code_800029B0.h>
5#include <defines.h>
6#include "collision.h"
7
14 Player *player;
16 UNUSED f32 padA;
19 f32 var_f2;
20 struct Controller *controller;
22 UNUSED f32 pad0;
23 UNUSED f32 pad1;
24 UNUSED f32 pad2;
25 UNUSED f32 pad3;
31
32 pad0 = shell->pos[0];
33 pad6 = shell->pos[1];
34 pad1 = shell->pos[2];
35 if ((pad1 < gCourseMinZ) || (gCourseMaxZ < pad1) || (pad0 < gCourseMinX) || (gCourseMaxX < pad0) || (pad6 < gCourseMinY)) {
37 }
38 shell->rotVelocity += 0x71C;
39 switch (shell->state) {
40 case HELD_SHELL:
41 player = &gPlayers[shell->playerId];
42 copy_collision(&player->unk_110, &shell->unk30);
43 somePosVel[0] = 0.0f;
44 somePosVel[1] = player->boundingBoxSize;
45 somePosVel[2] = -(player->boundingBoxSize + shell->boundingBoxSize + 2.0f);
47 shell->pos[0] = player->pos[0] + somePosVel[0];
48 pad2 = player->pos[1] - somePosVel[1];
49 shell->pos[2] = player->pos[2] + somePosVel[2];
50 pad0 = func_802ABE30(shell->pos[0], pad2, shell->pos[2], player->unk_110.unk3A);
51 pad1 = pad2 - pad0;
52 if ((pad1 < 5.0f) && (pad1 > -5.0f)) {
53 shell->pos[1] = shell->boundingBoxSize + pad0;
54 } else {
55 shell->pos[1] = pad2;
56 }
57 if ((player->type & PLAYER_HUMAN) != 0) {
58 controller = &gControllers[shell->playerId];
59 if ((controller->buttonDepressed & Z_TRIG) != 0) {
61 if (controller->rawStickY < -0x2D) {
62 var_f2 = 8.0f;
63 if (player->unk_094 > 8.0f) {
64 var_f2 = player->unk_094 * 1.2f;
65 }
66 somePosVel[0] = 0.0f;
67 somePosVel[1] = 0.0f;
68 somePosVel[2] = -var_f2;
69 func_802B64C4(somePosVel, player->rotation[1] + player->unk_0C0);
70 shell->velocity[0] = somePosVel[0];
71 shell->velocity[1] = somePosVel[1];
72 shell->velocity[2] = somePosVel[2];
73 shell->state = 2;
74 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
75 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
77 return;
78 } else {
79 shell->state = 1;
80 if (player->unk_0C0 > 0) {
81 shell->rotAngle = 0x78E3;
82 } else {
83 shell->rotAngle = -0x78E4;
84 }
85 }
86 }
87 }
88 break;
89 case RELEASED_SHELL:
90 player = &gPlayers[shell->playerId];
91 if (shell->rotAngle > 0) {
92 shell->rotAngle -= 0xE38;
93 if (shell->rotAngle < 0) {
94 shell->state = 2;
95 shell->someTimer = 0x001E;
96 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
97 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
99 }
100 } else {
101 shell->rotAngle += 0xE38;
102 if (shell->rotAngle > 0) {
103 shell->state = 2;
104 shell->someTimer = 0x001E;
105 func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04));
106 func_800C90F4(shell->playerId, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x00));
108 }
109 }
110 if (shell->state == 2) {
111 var_f2 = 8.0f;
112 if (player->unk_094 > 8.0f) {
113 var_f2 = player->unk_094 * 1.2f;
114 }
115 somePosVel[0] = 0.0f;
116 somePosVel[1] = 0.0f;
117 somePosVel[2] = var_f2;
118 func_802B64C4(somePosVel, player->rotation[1] + player->unk_0C0);
119 shell->velocity[0] = somePosVel[0];
120 shell->velocity[1] = somePosVel[1];
121 shell->velocity[2] = somePosVel[2];
122 } else {
123 somePosVel[0] = sins(shell->rotAngle) * 6.0f;
124 somePosVel[1] = shell->boundingBoxSize - player->boundingBoxSize;
125 somePosVel[2] = coss(shell->rotAngle) * 6.0f;
127 shell->pos[0] = player->pos[0] + somePosVel[0];
128 shell->pos[1] = player->pos[1] + somePosVel[1];
129 shell->pos[2] = player->pos[2] + somePosVel[2];
130 }
131 break;
132 case MOVING_SHELL:
133 if (shell->parentIndex > 0) {
134 shell->parentIndex -= 1;
135 if (shell->parentIndex == 0) {
136 shell->flags &= ~0x1000;
137 }
138 }
139 shell->velocity[1] -= 0.5f;
140 if (shell->velocity[1] < -2.0f) {
141 shell->velocity[1] = -2.0f;
142 }
143 somePos2[0] = shell->pos[0];
144 somePos2[1] = shell->pos[1];
145 somePos2[2] = shell->pos[2];
146 shell->pos[0] += shell->velocity[0];
147 shell->pos[1] += shell->velocity[1];
148 shell->pos[2] += shell->velocity[2];
149 func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]);
150 func_802B4E30((struct Actor *) shell);
151 if ((shell->unk30.unk3C[0] < 0.0f) || (shell->unk30.unk3C[1] < 0.0f)) {
152 shell_collision(&shell->unk30, shell->velocity);
153 func_800C98B8(shell->pos, shell->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x54));
154 shell->flags |= 0x80;
155 }
156 break;
158 player = &gPlayers[shell->playerId];
159 parent = (TripleShellParent *) &gActorList[shell->parentIndex];
160 if (parent->type != ACTOR_TRIPLE_GREEN_SHELL) {
162 } else {
163 shell->rotAngle += parent->rotVelocity;
164 somePosVel[0] = sins(shell->rotAngle) * 8.0f;
165 somePosVel[1] = shell->boundingBoxSize - player->boundingBoxSize;
166 somePosVel[2] = coss(shell->rotAngle) * 8.0f;
168 somePos2[0] = shell->pos[0];
169 somePos2[1] = shell->pos[1];
170 somePos2[2] = shell->pos[2];
171 shell->pos[0] = player->pos[0] + somePosVel[0];
172 shell->pos[1] = player->pos[1] + somePosVel[1];
173 shell->pos[2] = player->pos[2] + somePosVel[2];
174 func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]);
175 func_802B4E30((struct Actor *) shell);
176 }
177 break;
179 // Somehow, this fake match affects stack management up in case 2
180 shell->velocity[1] -= (0, 0.3f);
181 if (shell->velocity[1] < -5.0f) {
182 shell->velocity[1] = -5.0f;
183 }
184 shell->rotAngle += 0x5B0;
185 shell->someTimer -= 1;
186 shell->pos[1] += shell->velocity[1];
187 if (shell->someTimer == 0) {
188 destroy_actor((struct Actor *) shell);
189 }
190 break;
191 default:
192 break;
193 }
194}
@ 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:1814
void destroy_actor(struct Actor *actor)
Definition actors.c:1291
void func_802B4E30(struct Actor *arg0)
Definition actors_extended.c:962
void copy_collision(Collision *arg0, Collision *arg1)
Definition actors_extended.c:19
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:3296
u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2)
Definition collision.c:1233
void shell_collision(Collision *collision, Vec3f velocity)
Definition collision.c:587
f32 func_802ABE30(f32 x, f32 y, f32 z, u16 index)
Definition collision.c:520
f32 Vec3f[3]
Definition common_structs.h:6
#define PLAYER_HUMAN
Definition defines.h:99
void func_800C9060(u8 playerId, u32 soundBits)
Definition external.c:3167
void func_800C90F4(u8 playerId, u32 soundBits)
Definition external.c:3179
void func_800C98B8(Vec3f position, Vec3f velocity, u32 soundBits)
Definition external.c:3322
void update_actor_green_shell(struct ShellActor *shell)
Updates the green shell actor.
Definition update.inc.c:13
#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:1053
void func_802B64C4(Vec3f arg0, s16 arg1)
Definition math_util.c:604
void mtxf_translate_vec3f_mat3(Vec3f pos, Mat3 mat)
Definition math_util.c:570
f32 coss(u16 arg0)
Definition math_util.c:1057
#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
u16 unk30
Definition common_structs.h:118
u16 unk3A
Definition common_structs.h:124
Definition types.h:43
u16 buttonDepressed
Definition types.h:48
Definition common_structs.h:248
s16 unk_0C0
Definition common_structs.h:300
Collision unk_110
Definition common_structs.h:325
f32 unk_094
Definition common_structs.h:285
Mat3 orientationMatrix
Definition common_structs.h:327
u16 characterId
Definition common_structs.h:355
Vec3s rotation
Definition common_structs.h:262
f32 boundingBoxSize
Definition common_structs.h:275
u16 type
Definition common_structs.h:249
Vec3f pos
Definition common_structs.h:258
Definition actor_types.h:302
Definition actor_types.h:286
float f32
Definition ultratypes.h:33