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_KART_AI) != 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 = gNearestWaypointByPlayerId[(u16) (player - gPlayerOne)];
34 temp_f2 = player->pos[0] - D_80164490[nearestWaypoint].posX;
35 temp_f16 = player->pos[1] - D_80164490[nearestWaypoint].posY;
36 temp_f14 = player->pos[2] - D_80164490[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));
61 D_80162DF8 = 1;
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}
TrackWaypoint * D_80164490
Definition code_80005FD0.c:166
u16 gNearestWaypointByPlayerId[12]
Definition code_80005FD0.c:162
s8 get_surface_type(u16 index)
Definition collision.c:502
#define PLAYER_KART_AI
Definition defines.h:77
#define STAR_EFFECT
Definition defines.h:323
#define GRAND_PRIX
Options for gModeSelection.
Definition defines.h:121
void func_800C9060(u8 playerId, u32 soundBits)
Definition external.c:2862
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:72
Player gPlayers[NUM_PLAYERS]
Definition main.c:71
s32 gModeSelection
Definition main.c:181
float sqrtf(float)
@ GRASS
Definition mk64.h:88
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
s32 D_80162DF8
Definition staff_ghosts.c:57
u16 unk34
Definition common_structs.h:135
u16 meshIndexZX
Definition common_structs.h:139
Definition actor_types.h:230
f32 bonkTimer
Definition actor_types.h:236
Vec3f velocity
Definition actor_types.h:244
s16 animState
Definition actor_types.h:239
s16 animTimer
Definition actor_types.h:240
s16 targetPlayer
Definition actor_types.h:234
Vec3f pos
Definition actor_types.h:243
s16 state
Definition actor_types.h:235
Definition common_structs.h:249
u32 effects
Definition common_structs.h:298
Collision collision
Definition common_structs.h:324
u16 type
Definition common_structs.h:250
Vec3f velocity
Definition common_structs.h:263
Vec3f pos
Definition common_structs.h:259
s16 posZ
Definition waypoints.h:9
s16 posY
Definition waypoints.h:8
s16 posX
Definition waypoints.h:7
signed int s32
Definition ultratypes.h:15
float f32
Definition ultratypes.h:34
unsigned short int u16
Definition ultratypes.h:14