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 <defines.h>
4#include <waypoints.h>
5
13 Player* player;
14 f32 temp_f2;
15 f32 temp_f16;
16 f32 temp_f14;
17 f32 temp_f12;
18 s32 nearestWaypoint;
19
20 player = &gPlayers[fruit->targetPlayer];
21 if (((player->type & PLAYER_CPU) != 0) || (player->collision.unk34 == 0)) {
22 fruit->state = 0;
23 return;
24 }
25 switch (fruit->state) { /* irregular */
26 case 0:
27 if ((get_surface_type(player->collision.meshIndexZX) & 0xFF) != GRASS) {
28 return;
29 }
30 fruit->state = 1;
31 fruit->velocity[0] = 80.0f;
32 case 1:
33 nearestWaypoint = gNearestPathPointByPlayerId[(u16) (player - gPlayerOne)];
34 temp_f2 = player->pos[0] - gCurrentTrackPath[nearestWaypoint].posX;
35 temp_f16 = player->pos[1] - gCurrentTrackPath[nearestWaypoint].posY;
36 temp_f14 = player->pos[2] - gCurrentTrackPath[nearestWaypoint].posZ;
37 temp_f12 = fruit->velocity[0] / sqrtf((temp_f2 * temp_f2) + (temp_f16 * temp_f16) + (temp_f14 * temp_f14));
38 temp_f2 *= temp_f12;
39 temp_f16 *= temp_f12;
40 temp_f14 *= temp_f12;
41 fruit->pos[0] = player->pos[0] + temp_f2;
42 fruit->pos[1] = player->pos[1] + temp_f16;
43 fruit->pos[2] = player->pos[2] + temp_f14;
44 fruit->velocity[0] -= 2.0f;
45 if (fruit->velocity[0] <= 0.0f) {
46 fruit->state = 2;
47 fruit->bonkTimer = 30.0f;
48 fruit->velocity[0] = 0.0f;
49 fruit->velocity[1] = 2.3f;
50 fruit->velocity[2] = 0.0f;
51 if ((player->effects & STAR_EFFECT) != 0) {
52 func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0xA0, 0x52));
53 } else {
54 player->effects |= 0x8000;
55 player->pos[0] -= temp_f2 * 4.0f;
56 player->pos[2] -= temp_f14 * 4.0f;
57 player->velocity[0] -= temp_f2 * 0.7f;
58 player->velocity[2] -= temp_f14 * 0.7f;
59 func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x18));
62 }
63 }
64 }
65 break;
66 case 2:
67 fruit->velocity[1] -= 0.3f;
68 fruit->pos[0] += fruit->velocity[0];
69 fruit->pos[1] += fruit->velocity[1];
70 fruit->pos[2] += fruit->velocity[2];
71 fruit->bonkTimer -= 1.0f;
72 if (fruit->bonkTimer < 0.0f) {
73 fruit->state = 0;
74 }
75 break;
76 default:
77 break;
78 }
79 if (fruit->state != 0) {
80 fruit->animTimer += 1;
81 if (fruit->animTimer == 8) {
82 fruit->animTimer = 0;
83 fruit->animState += 1;
84 if (fruit->animState == 3) {
85 fruit->animState = 0;
86 }
87 }
88 }
89}
TrackPathPoint * gCurrentTrackPath
Definition code_80005FD0.c:176
u16 gNearestPathPointByPlayerId[12]
Definition code_80005FD0.c:172
s8 get_surface_type(u16 index)
Definition collision.c:432
#define STAR_EFFECT
Definition defines.h:376
#define GRAND_PRIX
Options for gModeSelection.
Definition defines.h:144
#define PLAYER_CPU
Definition defines.h:100
void func_800C9060(u8 playerId, u32 soundBits)
Definition external.c:2927
void update_actor_kiwano_fruit(struct KiwanoFruit *fruit)
Updates the kiwano fruit actor. Actor used in DK's Jungle Parkway.
Definition update.inc.c:12
Player * gPlayerOne
Definition main.c:79
Player gPlayers[NUM_PLAYERS]
Definition main.c:78
s32 gModeSelection
Definition main.c:186
float sqrtf(float)
@ GRASS
Definition mk64.h:96
s32 gPostTimeTrialReplayCannotSave
Definition replays.c:57
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
u16 unk34
Definition common_structs.h:150
u16 meshIndexZX
Definition common_structs.h:154
Definition actor_types.h:241
f32 bonkTimer
Definition actor_types.h:247
Vec3f velocity
Definition actor_types.h:255
s16 animState
Definition actor_types.h:250
s16 animTimer
Definition actor_types.h:251
s16 targetPlayer
Definition actor_types.h:245
Vec3f pos
Definition actor_types.h:254
s16 state
Definition actor_types.h:246
Definition common_structs.h:264
u32 effects
Definition common_structs.h:313
Collision collision
Definition common_structs.h:339
u16 type
Definition common_structs.h:265
Vec3f velocity
Definition common_structs.h:278
Vec3f pos
Definition common_structs.h:274