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
12
void
update_actor_kiwano_fruit
(
struct
KiwanoFruit
*
fruit
) {
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->
unk_110
.
unk34
== 0)) {
22
fruit
->state = 0;
23
return
;
24
}
25
switch
(
fruit
->state) {
/* irregular */
26
case
0:
27
if
((
get_surface_type
(player->
unk_110
.
unk3A
) & 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));
60
if
(
gModeSelection
!=
GRAND_PRIX
) {
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
}
actors.h
gCourseMaxZ
s16 gCourseMaxZ
Definition
code_800029B0.c:92
D_80164490
TrackWaypoint * D_80164490
Definition
code_80005FD0.c:166
gNearestWaypointByPlayerId
u16 gNearestWaypointByPlayerId[12]
Definition
code_80005FD0.c:162
get_surface_type
s8 get_surface_type(u16 index)
Definition
collision.c:495
defines.h
PLAYER_KART_AI
#define PLAYER_KART_AI
Definition
defines.h:97
STAR_EFFECT
#define STAR_EFFECT
Definition
defines.h:365
GRAND_PRIX
#define GRAND_PRIX
Options for gModeSelection.
Definition
defines.h:134
func_800C9060
void func_800C9060(u8 playerId, u32 soundBits)
Definition
external.c:2894
update_actor_kiwano_fruit
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
gPlayerOne
Player * gPlayerOne
Definition
main.c:74
gPlayers
Player gPlayers[NUM_PLAYERS]
Definition
main.c:73
gModeSelection
s32 gModeSelection
Definition
main.c:182
main.h
sqrtf
float sqrtf(float)
GRASS
@ GRASS
Definition
mk64.h:81
SOUND_ARG_LOAD
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition
sounds.h:14
D_80162DF8
s32 D_80162DF8
Definition
staff_ghosts.c:57
Collision::unk3A
u16 unk3A
Definition
common_structs.h:145
Collision::unk34
u16 unk34
Definition
common_structs.h:141
KiwanoFruit
Definition
actor_types.h:230
Player
Definition
common_structs.h:269
Player::unk_110
Collision unk_110
Definition
common_structs.h:346
Player::effects
u32 effects
Definition
common_structs.h:320
Player::type
u16 type
Definition
common_structs.h:270
Player::velocity
Vec3f velocity
Definition
common_structs.h:285
Player::pos
Vec3f pos
Definition
common_structs.h:279
TrackWaypoint::posZ
s16 posZ
Definition
waypoints.h:9
TrackWaypoint::posY
s16 posY
Definition
waypoints.h:8
TrackWaypoint::posX
s16 posX
Definition
waypoints.h:7
s32
signed int s32
Definition
ultratypes.h:15
f32
float f32
Definition
ultratypes.h:33
u16
unsigned short int u16
Definition
ultratypes.h:14
waypoints.h
src
actors
kiwano_fruit
update.inc.c
Generated by
1.10.0