Rename cpu behaviour related symbols (#586)

* Rename cpu related symbols
This commit is contained in:
coco875
2024-04-06 19:35:13 +02:00
committed by GitHub
parent c4d596d297
commit 2b66867af1
26 changed files with 997 additions and 951 deletions
+113 -113
View File
@@ -36,7 +36,7 @@ Collision D_80162E70;
s16 D_80162EB0; // Possibly a float.
s16 D_80162EB2; // possibly [3]
UnkCommonTextureStruct0 *D_80162EB8[20];
KartAIBehaviour *gCoursesKartAIBehaviour[NUM_COURSES-1];
// more padding?
s32 D_80162F08[2];
@@ -91,17 +91,17 @@ u16 D_80163240[12];
u16 D_80163258[12];
u16 D_80163270[12];
s32 D_80163288[10];
UnkCommonTextureStruct0 *D_801632B0;
u16 D_801632B8[12];
u16 D_801632D0[12];
u16 D_801632E8[12];
KartAIBehaviour *sCurrentKartAIBehaviour;
u16 gCurrentKartAIBehaviourId[12];
u16 gPreviousKartAIBehaviourId[12];
u16 gKartAIBehaviourState[12];
s16 D_80163300[12];
u16 D_80163318[12];
u16 D_80163330[10];
u16 D_80163344[2];
u16 D_80163348[2];
u16 D_8016334C[2];
u16 D_80163350[12];
u16 gSpeedKartAIBehaviour[12];
s32 D_80163368[4];
s32 D_80163378;
s32 D_8016337C;
@@ -1111,22 +1111,22 @@ void func_80008424(s32 playerId, f32 arg1, Player *player) {
}
} else {
var_a1 = 1;
switch (D_80163350[playerId]) { /* switch 1; irregular */
case 1: /* switch 1 */
switch (gSpeedKartAIBehaviour[playerId]) { /* switch 1; irregular */
case SPEED_KART_AI_BEHAVIOUR_FAST: /* switch 1 */
player->effects &= ~0x00200000;
player_speed(player);
break;
case 3: /* switch 1 */
case SPEED_KART_AI_BEHAVIOUR_MAX: /* switch 1 */
player->effects |= 0x200000;
player_speed(player);
break;
case 2: /* switch 1 */
case SPEED_KART_AI_BEHAVIOUR_SLOW: /* switch 1 */
if (((var_f2 / 18.0f) * 216.0f) > 20.0f) {
arg1 = 1.6666666f;
}
var_a1 = 0;
break;
case 0: /* switch 1 */
case SPEED_KART_AI_BEHAVIOUR_NORMAL: /* switch 1 */
default: /* switch 1 */
var_a1 = 0;
break;
@@ -1521,7 +1521,7 @@ void func_8000929C(s32 playerId, Player *player) {
}
D_80163240[playerId] = 1;
func_80008F38(playerId);
func_80011AE4(playerId);
reset_kart_ai_behaviour(playerId);
D_801642D8[playerId].unk_06 = 0;
if ((D_8016348C == 0) && !(player->type & 0x800)) {
gTimePlayerLastTouchedFinishLine[playerId] = func_80009258(playerId, someTemp0, tempPos2);
@@ -1683,7 +1683,7 @@ void func_80009B60(s32 playerId) {
f32 athing = 1.5f;
player = &gPlayers[playerId];
if ((s32) D_800DCA4C[gCurrentCourseId] >= 0) {
if ((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] >= 0) {
D_80163100[playerId] += 1;
if (playerId == 0) {
D_80163378++;
@@ -1736,15 +1736,15 @@ void func_80009B60(s32 playerId) {
player->unk_044 &= ~0x0001;
}
func_8000929C(playerId, player);
if ((gCurrentCourseId != 0x0014) && ((D_80163240[playerId] == 1) || (playerId == 0))) {
if ((gCurrentCourseId != COURSE_AWARD_CEREMONY) && ((D_80163240[playerId] == 1) || (playerId == 0))) {
set_places();
}
if (player->type & 0x1000) {
if ((D_801630E2 == 1) && (gCurrentCourseId != 0x0014)) {
func_80011E38(playerId);
if ((D_801630E2 == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) {
kart_ai_behaviour(playerId);
}
if ((playerId & 1) != (D_80163378 & 1)) {
cpu_use_item_strategy(playerId);
kart_ai_use_item_strategy(playerId);
}
func_800099EC(playerId, player);
D_80162FD0 = 0;
@@ -1974,7 +1974,7 @@ void func_80009B60(s32 playerId) {
}
break;
}
if ((D_801632E8[playerId] == 2) && ((D_80163068[playerId] > 0.9f) || (D_80163068[playerId] < -0.9f))) {
if ((gKartAIBehaviourState[playerId] == KART_AI_BEHAVIOUR_STATE_RUNNING) && ((D_80163068[playerId] > 0.9f) || (D_80163068[playerId] < -0.9f))) {
D_801630E8[playerId] = 0;
player->effects &= ~0x10;
}
@@ -2194,7 +2194,7 @@ f32 func_8000B874(f32 posX, f32 posZ, u16 waypointIndex, s32 pathIndex) {
void func_8000B95C(s32 playerId, u16 waypointIndex, s32 pathIndex) {
UNUSED Vec3f pad;
D_80163068[playerId] = 0.0f;
if ((s32) D_800DCA4C[gCurrentCourseId] >= 0) {
if ((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] >= 0) {
if ((gPlayers[playerId].type & 0x8000) != 0) {
D_80163068[playerId] = func_8000B874(gPlayers[playerId].pos[0], gPlayers[playerId].pos[2], waypointIndex, pathIndex);
}
@@ -3553,12 +3553,12 @@ void func_8000F628(void) {
D_80163068[i] = 0.0f;
D_80163090[i] = 0.0f;
var_s5 = &D_801634F8[i];
var_s5->unkC = D_800DCAA0[gCurrentCourseId] * (f32) (((i + 1) % 3) - 1);
var_s5->unkC = gKartAICourseMinimumWaypointSeparation[gCurrentCourseId] * (f32) (((i + 1) % 3) - 1);
var_s5->unk4 = var_s5->unkC;
var_s5->unk0 = 0.0f;
var_s5->unk8 = 0.015f;
func_80011AB8(i);
D_80163350[i] = 0;
reset_kart_ai_behaviour_none(i);
gSpeedKartAIBehaviour[i] = 0;
D_801644F8[i] = 0;
D_80163398[i] = 0;
D_801633B0[i] = 0;
@@ -3658,7 +3658,7 @@ void func_8000F628(void) {
}
}
}
func_80011A5C();
copy_courses_kart_ai_behaviour();
}
// @arg index from 0 to 3.
@@ -3678,7 +3678,7 @@ void func_800100F0(s32 pathIndex) {
s32 i;
// cast required
if ((s32)D_800DCA4C[gCurrentCourseId] >= 0) {
if ((s32)gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] >= 0) {
pathDest = D_80164550[pathIndex];
bInvalidPath = 1;
if (gCurrentCourseId != COURSE_AWARD_CEREMONY) {
@@ -3729,8 +3729,8 @@ void func_80010218(s32 pathIndex) {
TrackWaypoint *var_s1;
TrackWaypoint *var_s2;
if (((s32) D_800DCA4C[gCurrentCourseId]) >= 0) {
waypointWidth = D_800DCA4C[gCurrentCourseId];
if (((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId]) >= 0) {
waypointWidth = gKartAICourseMaximumWaypointSeparation[gCurrentCourseId];
waypoint = &D_80164550[pathIndex][0];
var_s1 = &D_80164560[pathIndex][0];
var_s2 = &D_80164570[pathIndex][0];
@@ -3779,7 +3779,7 @@ f32 func_80010480(s32 pathIndex, u16 waypointIndex) {
f32 root2;
f32 root1;
if ((s32) D_800DCA4C[gCurrentCourseId] < 0) {
if ((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] < 0) {
return 0.0f;
}
waypointCount = gWaypointCountByPathIndex[pathIndex];
@@ -3821,7 +3821,7 @@ void func_800107C4(s32 pathIndex) {
s32 var_a3;
s16 *wut;
if ((s32) D_800DCA4C[gCurrentCourseId] >= 0) {
if ((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] >= 0) {
var_a3 = gWaypointCountByPathIndex[pathIndex];
var_t4 = &D_80164580[pathIndex][0];
for(var_s0 = 0; var_s0 < var_a3; var_s0++, var_t4++) {
@@ -3889,7 +3889,7 @@ void func_80010DBC(s32 pathIndex) {
s32 waypointIndex;
u16 *angle;
if ((s32) D_800DCA4C[gCurrentCourseId] >= 0) {
if ((s32) gKartAICourseMaximumWaypointSeparation[gCurrentCourseId] >= 0) {
for (angle = &D_80164590[pathIndex][0], waypointIndex = 0; waypointIndex < gWaypointCountByPathIndex[pathIndex]; waypointIndex++, angle++) {
*angle = func_80010CB0(pathIndex, waypointIndex);
}
@@ -4166,121 +4166,121 @@ s32 func_8001168C(PathNoY *pathDest, TrackWaypoint *pathSrc, s32 numWaypoints) {
return count;
}
void func_80011A5C(void) {
void copy_courses_kart_ai_behaviour(void) {
s32 i;
for (i = 0; i < 20; i++) {
D_80162EB8[i] = segmented_to_virtual_dupe_2(D_800DC720[i]);
for (i = 0; i < NUM_COURSES-1; i++) {
gCoursesKartAIBehaviour[i] = segmented_to_virtual_dupe_2(gKartAIBehaviourLUT[i]);
}
}
void func_80011AB8(s32 index) {
D_801632B8[index] = 0;
D_801632D0[index] = 0;
D_801632E8[index] = 0;
void reset_kart_ai_behaviour_none(s32 playerIndex) {
gCurrentKartAIBehaviourId[playerIndex] = 0;
gPreviousKartAIBehaviourId[playerIndex] = 0;
gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_NONE;
}
void func_80011AE4(s32 index) {
D_801632B8[index] = 0;
D_801632D0[index] = 0;
D_801632E8[index] = 1;
void reset_kart_ai_behaviour(s32 playerIndex) {
gCurrentKartAIBehaviourId[playerIndex] = 0;
gPreviousKartAIBehaviourId[playerIndex] = 0;
gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START;
}
void func_80011B14(s32 playerId, Player *player) {
u16 sp2E;
s16 temp_t1;
s16 temp_t2;
s32 temp_t3;
void kart_ai_behaviour_start(s32 playerId, Player *player) {
u16 playerWaypoint;
s16 waypointStart;
s16 waypointEnd;
s32 behaviourType;
s32 test;
D_801632B0 = D_80162EB8[gCurrentCourseId] + D_801632B8[playerId];
sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][gCurrentKartAIBehaviourId[playerId]];
sp2E = gNearestWaypointByPlayerId[playerId];
playerWaypoint = gNearestWaypointByPlayerId[playerId];
temp_t1 = D_801632B0->waypointId1;
temp_t2 = D_801632B0->waypointId2;
temp_t3 = D_801632B0->unk4;
waypointStart = sCurrentKartAIBehaviour->waypointStart;
waypointEnd = sCurrentKartAIBehaviour->waypointEnd;
behaviourType = sCurrentKartAIBehaviour->type;
if ((temp_t1 == -1) && (temp_t2 == -1)) {
D_801632B0 = D_80162EB8[gCurrentCourseId];
func_80011AB8(playerId);
if ((waypointStart == -1) && (waypointEnd == -1)) {
sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][0];
reset_kart_ai_behaviour_none(playerId);
return;
}
if ((u32)sp2E == temp_t1) {
D_801632E8[playerId] = 2;
D_801632D0[playerId] = D_801632B8[playerId];
D_801632B8[playerId] += 1;
switch (temp_t3) {
case 1:
func_80011EC0(playerId, player, player->unk_07C >> 0x10, sp2E);
if ((u32)playerWaypoint == waypointStart) {
gKartAIBehaviourState[playerId] = KART_AI_BEHAVIOUR_STATE_RUNNING;
gPreviousKartAIBehaviourId[playerId] = gCurrentKartAIBehaviourId[playerId];
gCurrentKartAIBehaviourId[playerId]++;
switch (behaviourType) {
case BEHAVIOUR_1:
func_80011EC0(playerId, player, player->unk_07C >> 0x10, playerWaypoint);
break;
case 2:
func_8002AA50(player);
case BEHAVIOUR_HOP:
kart_hop(player);
player->effects &= ~0x10;
D_801630E8[playerId] = 0;
break;
case 3:
case BEHAVIOUR_3:
D_801634F8[playerId].unk4 = 0.0f;
break;
case 4:
case BEHAVIOUR_4:
D_801634F8[playerId].unk4 = -0.6f;
break;
case 5:
case BEHAVIOUR_5:
D_801634F8[playerId].unk4 = 0.6f;
break;
case 6:
D_80163350[playerId] = 0;
case BEHAVIOUR_NORMAL_SPEED:
gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_NORMAL;
break;
case 7:
D_80163350[playerId] = 1;
case BEHAVIOUR_FAST_SPEED:
gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_FAST;
break;
case 8:
D_80163350[playerId] = 2;
case BEHAVIOUR_SLOW_SPEED:
gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_SLOW;
break;
case 11:
D_80163350[playerId] = 3;
case BEHAVIOUR_MAX_SPEED:
gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_MAX;
break;
case 9:
case BEHAVIOUR_9:
D_801633F8[playerId] = 1;
D_801631E0[playerId] = 0;
gPlayers[playerId].effects &= ~0x1000;
break;
case 10:
case BEHAVIOUR_10:
D_801633F8[playerId] = 0;
break;
}
}
}
void func_80011D48(s32 playerIndex, Player *player) {
void kart_ai_behaviour_end(s32 playerIndex, Player *player) {
u16 nearestWaypoint;
u32 thing;
s32 temp_a2;
u32 waypointEnd;
s32 behaviourType;
D_801632B0 = &D_80162EB8[gCurrentCourseId][D_801632D0[playerIndex]];
sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][gPreviousKartAIBehaviourId[playerIndex]];
nearestWaypoint = gNearestWaypointByPlayerId[playerIndex];
temp_a2 = D_801632B0->unk4;
thing = D_801632B0->waypointId2;
if (nearestWaypoint >= thing) {
switch (temp_a2) {
case 1:
behaviourType = sCurrentKartAIBehaviour->type;
waypointEnd = sCurrentKartAIBehaviour->waypointEnd;
if (nearestWaypoint >= waypointEnd) {
switch (behaviourType) {
case BEHAVIOUR_1:
player->effects &= ~0x10;
D_801630E8[playerIndex] = 0;
D_801632E8[playerIndex] = 1;
gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START;
break;
case 3:
case 4:
case 5:
case BEHAVIOUR_3:
case BEHAVIOUR_4:
case BEHAVIOUR_5:
D_801634F8[playerIndex].unk4 = D_801634F8[playerIndex].unkC;
D_801632E8[playerIndex] = 1;
gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START;
break;
case 2:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
D_801632E8[playerIndex] = 1;
case BEHAVIOUR_HOP:
case BEHAVIOUR_NORMAL_SPEED:
case BEHAVIOUR_FAST_SPEED:
case BEHAVIOUR_SLOW_SPEED:
case BEHAVIOUR_9:
case BEHAVIOUR_10:
case BEHAVIOUR_MAX_SPEED:
gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START;
break;
default:
break;
@@ -4288,17 +4288,17 @@ void func_80011D48(s32 playerIndex, Player *player) {
}
}
void func_80011E38(s32 playerIndex) {
void kart_ai_behaviour(s32 playerIndex) {
Player *player = gPlayerOne + playerIndex;
switch(D_801632E8[playerIndex]) {
case 0:
switch(gKartAIBehaviourState[playerIndex]) {
case KART_AI_BEHAVIOUR_STATE_NONE:
break;
case 1:
func_80011B14(playerIndex, player);
case KART_AI_BEHAVIOUR_STATE_START:
kart_ai_behaviour_start(playerIndex, player);
break;
case 2:
func_80011D48(playerIndex, player);
case KART_AI_BEHAVIOUR_STATE_RUNNING:
kart_ai_behaviour_end(playerIndex, player);
break;
}
}
@@ -4310,7 +4310,7 @@ void func_80011EC0(s32 arg0, Player *player, s32 arg2, u16 arg3) {
case 2:
if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) {
if ((D_80163068[arg0] > -0.8) && (D_80163068[arg0] < 0.5)) {
func_8002AA50(player);
kart_hop(player);
player->effects |= 0x10;
D_801630E8[arg0] = 1;
break;
@@ -4322,7 +4322,7 @@ void func_80011EC0(s32 arg0, Player *player, s32 arg2, u16 arg3) {
case 3:
if ((arg2 < 0xA) && (D_80162FF8[arg0] == 0)) {
if ((D_80163068[arg0] > -0.5) && (D_80163068[arg0] < 0.8)) {
func_8002AA50(player);
kart_hop(player);
player->effects |= 0x10;
D_801630E8[arg0] = -1;
break;
@@ -5074,7 +5074,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3
f32 spBC;
if (((D_801631E0[playerId] != 1) || ((
((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_CPU))) && !(player->effects & 0x01000000)) {
((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_KART_AI))) && !(player->effects & 0x01000000)) {
spC4 = player->pos[0];
spC0 = player->pos[1];
@@ -5095,7 +5095,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3
}
}
}
if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_CPU)) {
if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_KART_AI)) {
if (((temp_f12) > -300.0) && ((temp_f12) < 300.0) && (
(temp_f22 > -20.0)) && (temp_f22 < 20.0) && (((temp_f14) > -300.0)) && ((temp_f14) < 300.0)) {
if ((D_801631C8 > 0) && (vehicle->someFlags == 0)) {
@@ -6999,7 +6999,7 @@ void func_8001AB00(void) {
}
}
void cpu_decisions_branch_item(s32 arg0, s16 *arg1, s32 arg2) {
void kart_ai_decisions_branch_item(s32 arg0, s16 *arg1, s32 arg2) {
s32 value = -1;
switch (arg2) {
case ITEM_FAKE_ITEM_BOX:
@@ -7044,11 +7044,11 @@ void func_8001ABEC(struct struct_801642D8 *arg0) {
}
#ifdef NON_MATCHING
// By the looks of this function is probably something like `cpu_player_use_item`
// By the looks of this function is probably something like `kart_ai_use_item_strategy`
// The use of several different actor types might make getting a match hard(er),
// might have to get creative/ugly with just a single generic `Actor` variable.
// https://decomp.me/scratch/FOlbG
void cpu_use_item_strategy(s32 playerId) {
void kart_ai_use_item_strategy(s32 playerId) {
s32 var_v0;
Player *player;
TrackWaypoint *waypoint;
@@ -7066,7 +7066,7 @@ void cpu_use_item_strategy(s32 playerId) {
case 0:
temp_s0->actorIndex = -1;
if ((((playerId * 0x14) + 0x64) < D_80164450[playerId]) && (temp_s0->unk_04 >= 0x259) && (temp_s0->unk_06 < 3) && (gLapCountByPlayerId[playerId] < 3)) {
cpu_decisions_branch_item(playerId, &temp_s0->unk_00, gen_random_item_cpu((s16)gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerId[playerId]));
kart_ai_decisions_branch_item(playerId, &temp_s0->unk_00, kart_ai_gen_random_item((s16)gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerId[playerId]));
} else {
func_8001ABE0(playerId, temp_s0);
}
@@ -7497,7 +7497,7 @@ void cpu_use_item_strategy(s32 playerId) {
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80005FD0/cpu_use_item_strategy.s")
GLOBAL_ASM("asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s")
#endif
void func_8001BE78(void) {