Mario Kart 64
Loading...
Searching...
No Matches
behaviour_utils.inc.c
Go to the documentation of this file.
2 s32 i;
3 for (i = 0; i < NUM_COURSES - 1; i++) {
5 }
6}
7
8void reset_cpu_behaviour_none(s32 playerIndex) {
9 gCurrentCPUBehaviourId[playerIndex] = 0;
10 gPreviousCPUBehaviourId[playerIndex] = 0;
12}
13
14void reset_cpu_behaviour(s32 playerIndex) {
15 gCurrentCPUBehaviourId[playerIndex] = 0;
16 gPreviousCPUBehaviourId[playerIndex] = 0;
18}
19
20void cpu_behaviour_start(s32 playerId, Player* player) {
21 u16 playerPathPoint;
22 s16 pathPointStart;
23 s16 pathPointEnd;
24 s32 behaviourType;
26
28
29 playerPathPoint = gNearestPathPointByPlayerId[playerId];
30
31 pathPointStart = sCurrentCPUBehaviour->pathPointStart;
32 pathPointEnd = sCurrentCPUBehaviour->pathPointEnd;
33 behaviourType = sCurrentCPUBehaviour->type;
34
35 if ((pathPointStart == -1) && (pathPointEnd == -1)) {
38 return;
39 }
40 if ((u32) playerPathPoint == (u32) pathPointStart) {
43 gCurrentCPUBehaviourId[playerId]++;
44 switch (behaviourType) {
45 case BEHAVIOUR_1:
46 func_80011EC0(playerId, player, player->unk_07C >> 0x10, playerPathPoint);
47 break;
48 case BEHAVIOUR_HOP:
49 kart_hop(player);
50 player->effects &= ~0x10;
51 D_801630E8[playerId] = 0;
52 break;
55 break;
58 break;
61 break;
64 break;
67 break;
70 break;
73 break;
74 case BEHAVIOUR_9:
75 D_801633F8[playerId] = 1;
76 D_801631E0[playerId] = false;
77 gPlayers[playerId].effects &= ~UNKNOWN_EFFECT_0x1000;
78 break;
79 case BEHAVIOUR_10:
80 D_801633F8[playerId] = 0;
81 break;
82 }
83 }
84}
85
86void cpu_behaviour_end(s32 playerIndex, Player* player) {
87 u16 nearestPathPoint;
88 u32 pathPointEnd;
89 s32 behaviourType;
90
92 nearestPathPoint = gNearestPathPointByPlayerId[playerIndex];
93 behaviourType = sCurrentCPUBehaviour->type;
94 pathPointEnd = sCurrentCPUBehaviour->pathPointEnd;
95 if (nearestPathPoint >= pathPointEnd) {
96 switch (behaviourType) {
97 case BEHAVIOUR_1:
98 player->effects &= ~0x10;
99 D_801630E8[playerIndex] = 0;
101 break;
108 break;
109 case BEHAVIOUR_HOP:
113 case BEHAVIOUR_9:
114 case BEHAVIOUR_10:
117 break;
118 default:
119 break;
120 }
121 }
122}
123
124void cpu_behaviour(s32 playerIndex) {
125 Player* player = gPlayerOne + playerIndex;
126
127 switch (cpu_BehaviourState[playerIndex]) {
129 break;
131 cpu_behaviour_start(playerIndex, player);
132 break;
134 cpu_behaviour_end(playerIndex, player);
135 break;
136 }
137}
138
139void func_80011EC0(s32 arg0, Player* player, s32 arg2, UNUSED u16 arg3) {
140 if ((((player->speed / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[arg0] == 0)) {
143 case RIGHT_CURVE:
144 if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) {
145 if ((gTrackPositionFactor[arg0] > -0.8) && (gTrackPositionFactor[arg0] < 0.5)) {
146 kart_hop(player);
147 player->effects |= UNKNOWN_EFFECT_0x10;
148 D_801630E8[arg0] = 1;
149 break;
150 }
151 }
152 D_801630E8[arg0] = 2;
153 break;
155 case LEFT_CURVE:
156 if ((arg2 < 0xA) && (D_80162FF8[arg0] == 0)) {
157 if ((gTrackPositionFactor[arg0] > -0.5) && (gTrackPositionFactor[arg0] < 0.8)) {
158 kart_hop(player);
159 player->effects |= UNKNOWN_EFFECT_0x10;
160 D_801630E8[arg0] = -1;
161 break;
162 }
163 }
164 D_801630E8[arg0] = -2;
165 break;
166 }
167 } else {
168 D_801630E8[arg0] = 3;
169 }
170}
void cpu_behaviour_end(s32 playerIndex, Player *player)
Definition behaviour_utils.inc.c:86
void reset_cpu_behaviour_none(s32 playerIndex)
Definition behaviour_utils.inc.c:8
void cpu_behaviour(s32 playerIndex)
Definition behaviour_utils.inc.c:124
void cpu_behaviour_start(s32 playerId, Player *player)
Definition behaviour_utils.inc.c:20
void reset_cpu_behaviour(s32 playerIndex)
Definition behaviour_utils.inc.c:14
void copy_courses_cpu_behaviour(void)
Definition behaviour_utils.inc.c:1
void func_80011EC0(s32 arg0, Player *player, s32 arg2, UNUSED u16 arg3)
Definition behaviour_utils.inc.c:139
s16 gCurrentCourseId
Definition code_800029B0.c:30
#define GET_COURSE_AIBehaviour
Definition course.h:99
@ NUM_COURSES
Definition course.h:52
u16 gCurrentCPUBehaviourId[12]
Definition cpu_vehicles_camera_path.c:96
s16 * gCurrentTrackSectionTypesPath
Definition cpu_vehicles_camera_path.c:84
CPUBehaviour * gCoursesCPUBehaviour[NUM_COURSES - 1]
Definition cpu_vehicles_camera_path.c:40
CPUBehaviour * sCurrentCPUBehaviour
Definition cpu_vehicles_camera_path.c:95
u16 D_801631E0[12]
Definition cpu_vehicles_camera_path.c:86
u16 gPreviousCPUBehaviourId[12]
Definition cpu_vehicles_camera_path.c:97
s16 D_801633F8[12]
Definition cpu_vehicles_camera_path.c:114
u16 cpu_BehaviourState[12]
Definition cpu_vehicles_camera_path.c:98
s16 D_801630E8[10]
Definition cpu_vehicles_camera_path.c:73
f32 gTrackPositionFactor[10]
Definition cpu_vehicles_camera_path.c:68
TrackPositionFactorInstruction gPlayerTrackPositionFactorInstruction[10]
Definition cpu_vehicles_camera_path.c:137
s16 D_80162FF8[12]
Definition cpu_vehicles_camera_path.c:64
u16 gSpeedCPUBehaviour[12]
Definition cpu_vehicles_camera_path.c:105
s16 sSomeNearestPathPoint
Definition cpu_vehicles_camera_path.c:55
u16 gNearestPathPointByPlayerId[12]
Definition cpu_vehicles_camera_path.c:163
@ SPEED_cpu_BEHAVIOUR_MAX
Definition cpu_vehicles_camera_path.h:350
@ SPEED_cpu_BEHAVIOUR_FAST
Definition cpu_vehicles_camera_path.h:350
@ SPEED_cpu_BEHAVIOUR_NORMAL
Definition cpu_vehicles_camera_path.h:350
@ SPEED_cpu_BEHAVIOUR_SLOW
Definition cpu_vehicles_camera_path.h:350
@ cpu_BEHAVIOUR_STATE_START
Definition cpu_vehicles_camera_path.h:340
@ cpu_BEHAVIOUR_STATE_RUNNING
Definition cpu_vehicles_camera_path.h:340
@ cpu_BEHAVIOUR_STATE_NONE
Definition cpu_vehicles_camera_path.h:340
@ BEHAVIOUR_FAST_SPEED
Definition defines.h:284
@ BEHAVIOUR_NORMAL_SPEED
Definition defines.h:283
@ BEHAVIOUR_DRIVE_CENTER
Definition defines.h:280
@ BEHAVIOUR_SLOW_SPEED
Definition defines.h:285
@ BEHAVIOUR_MAX_SPEED
Definition defines.h:288
@ BEHAVIOUR_DRIVE_OUTER
Definition defines.h:282
@ BEHAVIOUR_HOP
Definition defines.h:279
@ BEHAVIOUR_9
Definition defines.h:286
@ BEHAVIOUR_DRIVE_LEFT
Definition defines.h:281
@ BEHAVIOUR_1
Definition defines.h:278
@ BEHAVIOUR_10
Definition defines.h:287
#define UNKNOWN_EFFECT_0x10
Definition defines.h:328
#define UNUSED
Definition macros.h:23
Player * gPlayerOne
Definition main.c:69
Player gPlayers[NUM_PLAYERS]
Definition main.c:68
@ RIGHT_LEANING_CURVE
Definition path.h:14
@ RIGHT_CURVE
Definition path.h:16
@ LEFT_LEANING_CURVE
Definition path.h:15
@ LEFT_CURVE
Definition path.h:17
void kart_hop(Player *player)
Definition player_controller.c:1166
s32 type
Definition common_structs.h:32
s16 pathPointStart
Definition common_structs.h:30
s16 pathPointEnd
Definition common_structs.h:31
Definition common_structs.h:249
f32 speed
Definition common_structs.h:284
s32 unk_07C
Definition common_structs.h:278
u32 effects
Definition common_structs.h:298
f32 target
Definition cpu_vehicles_camera_path.h:23
f32 unkC
Definition cpu_vehicles_camera_path.h:25
Definition actors.c:1474
signed int s32
Definition ultratypes.h:15
unsigned int u32
Definition ultratypes.h:16
signed short int s16
Definition ultratypes.h:13
unsigned short int u16
Definition ultratypes.h:14