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 <defines.h>
4#include <main.h>
5
11void update_actor_banana(struct BananaActor *banana) {
12 UNUSED f32 pad;
13 Player *player;
14 struct BananaActor *elderBanana;
15 struct Controller *controller;
16 Vec3f someOtherVelocity;
17 Vec3f someVelocity;
18 f32 temp_f0;
19 UNUSED f32 var_f8;
20 UNUSED f32 pad2;
21 UNUSED f32 pad3;
22 UNUSED f32 pad4[2];
23 f32 temp_f12;
24 f32 temp_f2;
25 f32 temp_f14;
26 f32 temp_f16;
27 f32 unkX;
28 f32 unkY;
29 f32 unkZ;
30
31 player = &gPlayers[banana->rot[0]];
32 switch (banana->state) {
33 case HELD_BANANA:
34 temp_f2 = player->pos[0] - banana->pos[0];
35 temp_f14 = player->pos[1] - banana->pos[1];
36 temp_f16 = player->pos[2] - banana->pos[2];
37 temp_f12 = sqrtf((temp_f2 * temp_f2) + (temp_f14 * temp_f14) + (temp_f16 * temp_f16)) / 10.0f;
38 if (temp_f12 == 0.0f) {
39 banana->pos[0] = player->pos[0] + 0.2f;
40 banana->pos[1] = player->pos[1] + 0.2f;
41 banana->pos[2] = player->pos[2] + 0.2f;
42 } else {
43 temp_f2 /= temp_f12;
44 temp_f14 /= temp_f12;
45 temp_f16 /= temp_f12;
46 banana->pos[0] = player->pos[0] - temp_f2;
47 banana->pos[1] = player->pos[1] - temp_f14 - 2.0f;
48 banana->pos[2] = player->pos[2] - temp_f16;
49 }
50 func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
51 func_802B4E30((struct Actor *) banana);
52 if ((player->type & PLAYER_HUMAN) != 0) {
53 if (gDemoMode) {
54 controller = gControllerOne;
55 } else {
56 controller = &gControllers[banana->rot[0]];
57 }
58 if ((controller->buttonDepressed & Z_TRIG) != 0) {
59 controller->buttonDepressed &= ~Z_TRIG;
60 banana->state = 1;
61 banana->unk_04 = 0x00B4;
62 player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT;
63 func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12));
64 pad3 = controller->rawStickY;
65 if ((pad3 > 30.0f) && (controller->rawStickX < 10) && (controller->rawStickX >= -9)) {
66 pad3 = pad3 - ((f32) 30);
67 pad3 = (pad3 / 20.0f) + 0.5f;
68 if (player->unk_094 < 2.0f) {
69 temp_f0 = 4.0f;
70 } else {
71 temp_f0 = (player->unk_094 * 0.75f) + 3.5f + pad3;
72 }
73 vec3f_set(someVelocity, 0, pad3, temp_f0);
74 func_802B64C4(someVelocity, player->rotation[1] + player->unk_0C0);
75 banana->velocity[0] = someVelocity[0];
76 banana->velocity[1] = someVelocity[1];
77 banana->velocity[2] = someVelocity[2];
78 } else {
79 banana->velocity[0] = 0;
80 banana->velocity[1] = 1.5f;
81 banana->velocity[2] = 0;
82 }
83 }
84 }
85 break;
86 case DROPPED_BANANA:
87 if (banana->unk_04 != 0) {
88 banana->unk_04 -= 1;
89 if (banana->unk_04 == 0) {
90 banana->flags &= ~0x1000;
91 }
92 }
93 banana->pos[0] += banana->velocity[0];
94 banana->pos[2] += banana->velocity[2];
95 if (banana->velocity[1] > -1.0f) {
96 banana->velocity[1] -= 0.15f;
97 }
98 banana->pos[1] += banana->velocity[1];
99 if ((banana->pos[2] < (f32) gCourseMinZ) || ((f32) gCourseMaxZ < banana->pos[2]) || (banana->pos[0] < (f32) gCourseMinX) || ((f32) gCourseMaxX < banana->pos[0]) || (banana->pos[1] < (f32) gCourseMinY)) {
101 } else {
102 func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
103 banana->unk30.unk34 = 1;
104 if ((banana->unk30.unk34 != 0) && (banana->unk30.unk3C[2] < 0.0f)) {
105 someOtherVelocity[0] = -banana->unk30.orientationVector[0];
106 someOtherVelocity[1] = -banana->unk30.orientationVector[1];
107 someOtherVelocity[2] = -banana->unk30.orientationVector[2];
108 banana->pos[0] += someOtherVelocity[0] * banana->unk30.unk3C[2];
109 banana->pos[1] += someOtherVelocity[1] * banana->unk30.unk3C[2];
110 banana->pos[2] += someOtherVelocity[2] * banana->unk30.unk3C[2];
111 banana->flags &= ~0x1000;
112 banana->state = 4;
113 }
114 }
115 break;
117 someVelocity[0] = 0.0f;
118 someVelocity[1] = 0.0f;
119 someVelocity[2] = -5.0f;
120 func_802B64C4(someVelocity, player->rotation[1] + player->unk_0C0);
121 unkX = player->pos[0] + someVelocity[0];
122 unkY = player->pos[1] + someVelocity[1];
123 unkZ = player->pos[2] + someVelocity[2];
124 temp_f2 = unkX - banana->pos[0];
125 temp_f14 = unkY - banana->pos[1];
126 temp_f16 = unkZ - banana->pos[2];
128 if (temp_f0 == 0.0f) {
129 banana->pos[0] = player->pos[0] + 0.2f;
130 banana->pos[1] = player->pos[1] + 0.2f;
131 banana->pos[2] = player->pos[2] + 0.2f;
132 } else {
133 temp_f2 /= temp_f0;
134 temp_f14 /= temp_f0;
135 temp_f16 /= temp_f0;
136 banana->pos[0] = someVelocity[0] + (unkX - temp_f2);
137 banana->pos[1] = unkY - temp_f14 - 2.0f;
138 banana->pos[2] = unkZ - temp_f16;
139 }
140 func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
141 func_802B4E30((struct Actor *) banana);
142 break;
144 elderBanana = (struct BananaActor*)&gActorList[banana->elderIndex];
145 temp_f2 = elderBanana->pos[0] - banana->pos[0];
146 temp_f14 = elderBanana->pos[1] - banana->pos[1];
147 temp_f16 = elderBanana->pos[2] - banana->pos[2];
149 if (temp_f12 == 0.0f) {
150 banana->pos[0] = elderBanana->pos[0] + 0.2f;
151 banana->pos[1] = elderBanana->pos[1] + 0.2f;
152 banana->pos[2] = elderBanana->pos[2] + 0.2f;
153 } else {
154 temp_f2 /= temp_f12;
157 banana->pos[0] = elderBanana->pos[0] - temp_f2;
158 banana->pos[1] = elderBanana->pos[1] - temp_f14 - 2.0f;
159 banana->pos[2] = elderBanana->pos[2] - temp_f16;
160 }
161 var_f8 = banana->pos[2];
162 func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
163 func_802B4E30((struct Actor *) banana);
164 break;
165 case DESTROYED_BANANA:
166 banana->velocity[1] -= 0.3f;
167 if (banana->velocity[1] < -5.0f) {
168 banana->velocity[1] = -5.0f;
169 }
170 banana->pos[1] += banana->velocity[1];
171 banana->rot[0] += 0x16C;
172 banana->rot[1] -= 0x5B0;
173 banana->rot[2] += 0x38E;
174 banana->unk_04 -= 1;
175 if (banana->unk_04 == 0) {
176 destroy_actor((struct Actor *) banana);
177 }
178 break;
179 case BANANA_ON_GROUND:
180 banana->flags |= 0xC000;
181 banana->flags &= ~0x1000;
182 break;
183 default:
184 break;
185 }
186}
@ BANANA_ON_GROUND
Definition actor_types.h:111
@ DROPPED_BANANA
Definition actor_types.h:108
@ DESTROYED_BANANA
Definition actor_types.h:112
@ HELD_BANANA
Definition actor_types.h:107
@ BANANA_BUNCH_BANANA
Definition actor_types.h:110
@ FIRST_BANANA_BUNCH_BANANA
Definition actor_types.h:109
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 update_actor_banana(struct BananaActor *banana)
Update the banana actor.
Definition update.inc.c:11
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
u16 func_802ADDC8(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ)
Definition collision.c:1349
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:2894
#define UNUSED
Definition macros.h:24
Player * gPlayerOne
Definition main.c:74
Player gPlayers[NUM_PLAYERS]
Definition main.c:73
struct Controller gControllers[NUM_PLAYERS]
Definition main.c:63
u16 gDemoMode
Definition main.c:173
struct Controller * gControllerOne
Definition main.c:64
float sqrtf(float)
void func_802B64C4(Vec3f arg0, s16 arg1)
Definition math_util.c:606
void vec3f_set(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3)
Definition math_util.c:101
#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
s16 state
Definition actor_types.h:124
Vec3s rot
Definition actor_types.h:127
Vec3f velocity
Definition actor_types.h:130
s16 unk_04
Definition actor_types.h:123
s16 flags
Definition actor_types.h:122
Vec3f pos
Definition actor_types.h:129
Definition actor_types.h:377
Vec3s rot
Definition actor_types.h:386
Collision unk30
Definition actor_types.h:396
f32 boundingBoxSize
Definition actor_types.h:384
Vec3f pos
Definition actor_types.h:394
s16 state
Definition actor_types.h:381
Definition common_structs.h:71
s16 rawStickY
Definition common_structs.h:73
s16 rawStickX
Definition common_structs.h:72
u16 buttonDepressed
Definition common_structs.h:76
Definition common_structs.h:269
s16 unk_0C0
Definition common_structs.h:321
f32 unk_094
Definition common_structs.h:306
Vec3s rotation
Definition common_structs.h:283
u16 type
Definition common_structs.h:270
s32 soundEffects
Definition common_structs.h:276
Vec3f pos
Definition common_structs.h:279
float f32
Definition ultratypes.h:33