Move penguin code to class

This commit is contained in:
MegaMech
2024-12-07 19:38:47 -07:00
parent bcf4a7f384
commit a4890f9dfc
4 changed files with 113 additions and 444 deletions
+108 -82
View File
@@ -144,28 +144,28 @@ void OPenguin::Draw(s32 cameraId) {
}
}
void OPenguin::Behaviours(s32 objectIndex, s32 arg1) {
void OPenguin::Behaviours(s32 objectIndex, s32 arg1) { // func_800850B0
Object* object;
object = &gObjectList[objectIndex];
switch (_bhv) {
case 1: // emperor
func_80085080(objectIndex);
OPenguin::func_80085080(objectIndex);
break;
case 2:
func_8008502C(objectIndex, arg1);
OPenguin::func_8008502C(objectIndex, arg1);
break;
case 3:
func_80084D2C(objectIndex, 0);
OPenguin::func_80084D2C(objectIndex, 0);
break;
case 4:
func_80084D2C(objectIndex, 1);
OPenguin::func_80084D2C(objectIndex, 1);
break;
case 5:
func_80084D2C(objectIndex, 2);
OPenguin::func_80084D2C(objectIndex, 2);
break;
case 6:
func_80084D2C(objectIndex, 3);
OPenguin::func_80084D2C(objectIndex, 3);
break;
}
if (func_80072320(objectIndex, 0x00000020) != 0) {
@@ -189,6 +189,105 @@ void OPenguin::Behaviours(s32 objectIndex, s32 arg1) {
}
}
void OPenguin::func_80084D2C(s32 objectIndex, s32 arg1) {
f32 sp24;
switch (gObjectList[objectIndex].unk_0AE) {
case 0:
break;
case 1:
gObjectList[objectIndex].direction_angle[1] =
func_800417B4(gObjectList[objectIndex].direction_angle[1], gObjectList[objectIndex].unk_0C6);
if (gObjectList[objectIndex].direction_angle[1] == gObjectList[objectIndex].unk_0C6) {
gObjectList[objectIndex].unk_09C = 4;
gObjectList[objectIndex].unk_034 = 0.4f;
func_80086FD4(objectIndex);
}
break;
case 2:
f32_step_towards(&gObjectList[objectIndex].unk_034, 0.8f, 0.02f);
if (func_80087060(objectIndex, 0x0000000F) != 0) {
func_800722A4(objectIndex, 1);
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_09C = 1;
gObjectList[objectIndex].unk_0D8 = 1;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
func_80086FD4(objectIndex);
if (func_80072354(objectIndex, 0x00000020) != 0) {
func_800722A4(objectIndex, 0x00000080);
}
}
break;
case 3:
switch (arg1) { /* switch 1; irregular */
case 0: /* switch 1 */
sp24 = 1.0f;
break;
case 1: /* switch 1 */
sp24 = 1.5f;
break;
case 2: /* switch 1 */
sp24 = 2.0f;
break;
case 3: /* switch 1 */
sp24 = 2.5f;
break;
}
f32_step_towards(&gObjectList[objectIndex].unk_034, sp24, 0.15f);
if ((func_80072354(objectIndex, 2) != 0) && (sp24 == gObjectList[objectIndex].unk_034)) {
func_80086FD4(objectIndex);
}
break;
case 4:
if (func_80087060(objectIndex, 0x0000001E) != 0) {
func_800722CC(objectIndex, 1);
func_80086FD4(objectIndex);
}
break;
case 5:
f32_step_towards(&gObjectList[objectIndex].unk_034, 0.4f, 0.2f);
if (func_80087060(objectIndex, 0x0000000A) != 0) {
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_0D8 = 2;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
func_80086FD4(objectIndex);
}
break;
case 6:
if (func_80072354(objectIndex, 2) != 0) {
gObjectList[objectIndex].unk_0D8 = 0;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
gObjectList[objectIndex].unk_0C6 += 0x8000;
func_800726CC(objectIndex, 2);
func_8008701C(objectIndex, 1);
}
break;
}
func_8008781C(objectIndex);
object_calculate_new_pos_offset(objectIndex);
}
void OPenguin::func_80085080(s32 objectIndex) {
func_8008B78C(objectIndex);
object_calculate_new_pos_offset(objectIndex);
func_800873F4(objectIndex);
}
void OPenguin::func_8008502C(s32 objectIndex, s32 arg1) {
func_80088038(objectIndex, gObjectList[objectIndex].unk_01C[1], gObjectList[objectIndex].unk_0C6);
object_calculate_new_pos_offset(objectIndex);
func_800873F4(objectIndex);
}
void OPenguin::EmperorPenguin(s32 objectIndex) {
switch (gObjectList[objectIndex].state) {
case 0:
@@ -280,6 +379,8 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
object->unk_04C = random_int(0x012CU);
set_object_flag_status_true(objectIndex, 0x04000220);
// This code has been significantly refactored from the original func_800845C8
// Into a switch statement instead of checking for the index of the penguin
switch(_bhv) {
case Behaviour::CIRCLE:
object->unk_01C[1] = Diameter;
@@ -301,81 +402,6 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
break;
}
if ((_idx > 0) && (_idx < 9)) {
if ((_idx == 1) || (_idx == 2)) {
//object->unk_0C6 = 0x0150;
//object->unk_01C[1] = 100.0f;
} else if ((_idx == 3) || (_idx == 4)) {
//object->unk_0C6 = 0x0100;
//object->unk_01C[1] = 80.0f;
} else if ((_idx == 5) || (_idx == 6)) {
//object->unk_0C6 = 0xFF00;
//object->unk_01C[1] = 80.0f;
} else if ((_idx == 7) || (_idx == 8)) {
//object->unk_0C6 = 0x0150;
//object->unk_01C[1] = 80.0f;
}
//object->unk_0C4 = (_idx << 0xF) & 0xFFFF;
//object->surfaceHeight = -80.0f;
//object->sizeScaling = 0.08f;
//object->unk_0DD = 2;
//func_800722A4(objectIndex, 8);
} else if ((_idx > 8) && (_idx < 15)) {
switch (_idx) {
case 9:
if (gGamestate != CREDITS_SEQUENCE) {
} else {
//object->sizeScaling = 0.15f;
}
//object->unk_0C6 = 0x9000;
if (gIsMirrorMode != 0) {
//object->unk_0C6 -= 0x4000;
}
//object->unk_0DD = 3;
break;
case 10:
//object->unk_0C6 = 0x5000;
if (gIsMirrorMode != 0) {
//object->unk_0C6 += 0x8000;
}
//object->unk_0DD = 4;
break;
case 11:
//object->unk_0C6 = 0xC000;
//object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
//object->unk_0C6 += 0x8000;
}
break;
case 12:
//object->unk_0C6 = 0x4000;
//object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
//object->unk_0C6 += 0x8000;
}
break;
case 13:
// object->unk_0C6 = 0x8000;
//object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
//object->unk_0C6 -= 0x4000;
}
break;
case 14:
//object->unk_0C6 = 0x9000;
//object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
//object->unk_0C6 -= 0x4000;
}
break;
default:
break;
}
//set_obj_direction_angle(objectIndex, 0U, object->unk_0C6 + 0x8000, 0U);
//object->surfaceHeight = 5.0f;
//object->sizeScaling = 0.04f;
//func_800722A4(objectIndex, 0x00000014);
}
func_80086EF0(objectIndex);
object->unk_034 = 0.0f;
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
+5
View File
@@ -56,10 +56,15 @@ public:
private:
void Behaviours(s32 objectIndex, s32 arg1);
void EmperorPenguin(s32 objectIndex);
void func_80085080(s32 objectIndex);
void func_8008502C(s32 objectIndex, s32 arg1);
void func_80084D2C(s32 objectIndex, s32 arg1);
void InitEmperorPenguin(s32 objectIndex);
void OtherPenguin(s32 objectIndex);
void InitOtherPenguin(s32 objectIndex);
s32 _idx;
PenguinType _type;
Behaviour _bhv;
-361
View File
@@ -6512,367 +6512,6 @@ void func_800842C8(void) {
}
}
void func_80084430(s32 objectIndex, UNUSED s32 arg1) {
Object* object;
object = &gObjectList[objectIndex];
object->unk_0D8 = 0;
object->model = (Gfx*) d_course_sherbet_land_unk_data1;
object->vertex = (Vtx*) d_course_sherbet_land_unk_data11;
object->sizeScaling = 0.2f;
object->boundingBoxSize = 0x000C;
object->unk_09C = 1;
set_obj_origin_pos(objectIndex, xOrientation * -383.0, 2.0f, -690.0f);
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
object->unk_0DD = 1;
func_80086EF0(objectIndex);
object->spline = D_800E672C[0];
set_object_flag_status_true(objectIndex, 0x04000800);
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
object_next_state(objectIndex);
}
void func_8008453C(s32 objectIndex, s32 arg1) {
switch (gObjectList[objectIndex].state) { /* irregular */
case 0:
break;
case 1:
if (gPlayerCountSelection1 == 1) {
func_80084430(objectIndex, arg1);
}
break;
case 2:
func_80072E54(objectIndex, 0, gObjectList[objectIndex].type, 1, 0, -1);
break;
}
}
void func_800845C8(s32 objectIndex, s32 arg1) {
Object* object;
object = &gObjectList[objectIndex];
object->unk_0D8 = 0;
object->model = (Gfx*) d_course_sherbet_land_unk_data1;
object->vertex = (Vtx*) d_course_sherbet_land_unk_data11;
object->boundingBoxSize = 4;
object->unk_09C = 2;
object->unk_04C = random_int(0x012CU);
set_object_flag_status_true(objectIndex, 0x04000220);
if ((arg1 > 0) && (arg1 < 9)) {
if ((arg1 == 1) || (arg1 == 2)) {
set_obj_origin_pos(objectIndex, xOrientation * -2960.0, -80.0f, 1521.0f);
object->unk_0C6 = 0x0150;
object->unk_01C[1] = 100.0f;
} else if ((arg1 == 3) || (arg1 == 4)) {
set_obj_origin_pos(objectIndex, xOrientation * -2490.0, -80.0f, 1612.0f);
object->unk_0C6 = 0x0100;
object->unk_01C[1] = 80.0f;
} else if ((arg1 == 5) || (arg1 == 6)) {
set_obj_origin_pos(objectIndex, xOrientation * -2098.0, -80.0f, 1624.0f);
object->unk_0C6 = 0xFF00;
object->unk_01C[1] = 80.0f;
} else if ((arg1 == 7) || (arg1 == 8)) {
set_obj_origin_pos(objectIndex, xOrientation * -2080.0, -80.0f, 1171.0f);
object->unk_0C6 = 0x0150;
object->unk_01C[1] = 80.0f;
}
object->unk_0C4 = (arg1 << 0xF) & 0xFFFF;
object->surfaceHeight = -80.0f;
object->sizeScaling = 0.08f;
object->unk_0DD = 2;
func_800722A4(objectIndex, 8);
} else if ((arg1 > 8) && (arg1 < 15)) {
switch (arg1) { /* irregular */
case 9:
if (gGamestate != 9) {
set_obj_origin_pos(objectIndex, xOrientation * 146.0, 0.0f, -380.0f);
} else {
set_obj_origin_pos(objectIndex, xOrientation * 380.0, 0.0f, -535.0f);
object->sizeScaling = 0.15f;
}
object->unk_0C6 = 0x9000;
if (gIsMirrorMode != 0) {
object->unk_0C6 -= 0x4000;
}
object->unk_0DD = 3;
break;
case 10:
set_obj_origin_pos(objectIndex, xOrientation * 380.0, 0.0f, -766.0f);
object->unk_0C6 = 0x5000;
if (gIsMirrorMode != 0) {
object->unk_0C6 += 0x8000;
}
object->unk_0DD = 4;
break;
case 11:
set_obj_origin_pos(objectIndex, xOrientation * -2300.0, 0.0f, -210.0f);
object->unk_0C6 = 0xC000;
object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
object->unk_0C6 += 0x8000;
}
break;
case 12:
set_obj_origin_pos(objectIndex, xOrientation * -2500.0, 0.0f, -250.0f);
object->unk_0C6 = 0x4000;
object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
object->unk_0C6 += 0x8000;
}
break;
case 13:
set_obj_origin_pos(objectIndex, xOrientation * -535.0, 0.0f, 875.0f);
object->unk_0C6 = 0x8000;
object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
object->unk_0C6 -= 0x4000;
}
break;
case 14:
set_obj_origin_pos(objectIndex, xOrientation * -250.0, 0.0f, 953.0f);
object->unk_0C6 = 0x9000;
object->unk_0DD = 6;
if (gIsMirrorMode != 0) {
object->unk_0C6 -= 0x4000;
}
break;
default:
break;
}
set_obj_direction_angle(objectIndex, 0U, object->unk_0C6 + 0x8000, 0U);
object->surfaceHeight = 5.0f;
object->sizeScaling = 0.04f;
func_800722A4(objectIndex, 0x00000014);
}
func_80086EF0(objectIndex);
object->unk_034 = 0.0f;
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
object_next_state(objectIndex);
}
void func_80084B7C(s32 objectIndex, s32 arg1) {
Object* object;
object = &gObjectList[objectIndex];
switch (object->state) {
case 0:
break;
case 1:
func_800845C8(objectIndex, arg1);
break;
case 2:
func_80072E54(objectIndex, 0, (s32) object->type, (s32) object->unk_09C, 0, -1);
if (func_80072354(objectIndex, 0x00000020) != 0) {
if (object->unk_084[6] == 0) {
object->unk_084[6] = random_int(0x005AU) + 0x5A;
func_800722A4(objectIndex, 0x00000080);
} else {
object->unk_084[6]--;
}
}
break;
case 3:
func_80072E54(objectIndex, 0, object->type, 1, 0, 0);
break;
case 4:
func_800722CC(objectIndex, 2);
object_next_state(objectIndex);
break;
}
if (func_80072320(objectIndex, 0x00000020) != 0) {
if (object->unk_084[6] == 0) {
func_800722A4(objectIndex, 0x00000080);
object->unk_084[6] = 0x0010;
} else {
object->unk_084[6]--;
}
}
if (func_80072320(objectIndex, 0x00000080) != 0) {
func_800722CC(objectIndex, 0x00000080);
if (func_80072320(objectIndex, 0x00000010) != 0) {
func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x49));
} else {
func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x17));
}
}
}
void func_80084D2C(s32 objectIndex, s32 arg1) {
f32 sp24;
switch (gObjectList[objectIndex].unk_0AE) {
case 0:
break;
case 1:
gObjectList[objectIndex].direction_angle[1] =
func_800417B4(gObjectList[objectIndex].direction_angle[1], gObjectList[objectIndex].unk_0C6);
if (gObjectList[objectIndex].direction_angle[1] == gObjectList[objectIndex].unk_0C6) {
gObjectList[objectIndex].unk_09C = 4;
gObjectList[objectIndex].unk_034 = 0.4f;
func_80086FD4(objectIndex);
}
break;
case 2:
f32_step_towards(&gObjectList[objectIndex].unk_034, 0.8f, 0.02f);
if (func_80087060(objectIndex, 0x0000000F) != 0) {
func_800722A4(objectIndex, 1);
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_09C = 1;
gObjectList[objectIndex].unk_0D8 = 1;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
func_80086FD4(objectIndex);
if (func_80072354(objectIndex, 0x00000020) != 0) {
func_800722A4(objectIndex, 0x00000080);
}
}
break;
case 3:
switch (arg1) { /* switch 1; irregular */
case 0: /* switch 1 */
sp24 = 1.0f;
break;
case 1: /* switch 1 */
sp24 = 1.5f;
break;
case 2: /* switch 1 */
sp24 = 2.0f;
break;
case 3: /* switch 1 */
sp24 = 2.5f;
break;
}
f32_step_towards(&gObjectList[objectIndex].unk_034, sp24, 0.15f);
if ((func_80072354(objectIndex, 2) != 0) && (sp24 == gObjectList[objectIndex].unk_034)) {
func_80086FD4(objectIndex);
}
break;
case 4:
if (func_80087060(objectIndex, 0x0000001E) != 0) {
func_800722CC(objectIndex, 1);
func_80086FD4(objectIndex);
}
break;
case 5:
f32_step_towards(&gObjectList[objectIndex].unk_034, 0.4f, 0.2f);
if (func_80087060(objectIndex, 0x0000000A) != 0) {
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_0D8 = 2;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
func_80086FD4(objectIndex);
}
break;
case 6:
if (func_80072354(objectIndex, 2) != 0) {
gObjectList[objectIndex].unk_0D8 = 0;
gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
gObjectList[objectIndex].unk_0C6 += 0x8000;
func_800726CC(objectIndex, 2);
func_8008701C(objectIndex, 1);
}
break;
}
func_8008781C(objectIndex);
object_calculate_new_pos_offset(objectIndex);
}
void func_80085024(void) {
}
void func_8008502C(s32 objectIndex, UNUSED s32 arg1) {
func_80088038(objectIndex, gObjectList[objectIndex].unk_01C[1], gObjectList[objectIndex].unk_0C6);
object_calculate_new_pos_offset(objectIndex);
func_800873F4(objectIndex);
}
void func_80085080(s32 objectIndex) {
func_8008B78C(objectIndex);
object_calculate_new_pos_offset(objectIndex);
func_800873F4(objectIndex);
}
void func_800850B0(s32 objectIndex, s32 arg1) {
Object* object;
object = &gObjectList[objectIndex];
switch (object->unk_0DD) {
case 1:
func_80085080(objectIndex);
break;
case 2:
func_8008502C(objectIndex, arg1);
break;
case 3:
func_80084D2C(objectIndex, 0);
break;
case 4:
func_80084D2C(objectIndex, 1);
break;
case 5:
func_80084D2C(objectIndex, 2);
break;
case 6:
func_80084D2C(objectIndex, 3);
break;
}
if (func_80072320(objectIndex, 0x00000020) != 0) {
if (func_80072320(objectIndex, 0x00000040) != 0) {
func_800722CC(objectIndex, 0x00000040);
object->unk_084[6] = 0;
object->unk_084[7] = 0x0096;
}
if (object->unk_084[7] == 0) {
func_800722CC(objectIndex, 0x00000020);
} else {
object->unk_084[7]--;
object->orientation[0] = object->direction_angle[0];
object->orientation[1] += 0x2000;
object->orientation[2] = object->direction_angle[2];
}
} else {
object->orientation[0] = object->direction_angle[0];
object->orientation[1] = object->direction_angle[1];
object->orientation[2] = object->direction_angle[2];
}
}
void update_penguins(void) {
UNUSED s32 var_s2;
s32 objectIndex;
s32 var_s1;
for (var_s1 = 0; var_s1 < NUM_PENGUINS; var_s1++) {
objectIndex = indexObjectList1[var_s1];
if (gObjectList[objectIndex].state != 0) {
if (var_s1 == 0) {
func_8008453C(objectIndex, var_s1);
} else {
func_80084B7C(objectIndex, var_s1);
}
func_800850B0(objectIndex, var_s1);
}
if (func_80072320(objectIndex, 1) != 0) {
func_80089820(objectIndex, 1.75f, 1.5f, 0x1900A046U);
} else if (func_80072320(objectIndex, 8) != 0) {
func_80089820(objectIndex, 1.3f, 1.0f, 0x1900A046U);
} else {
func_80089820(objectIndex, 1.5f, 1.25f, 0x1900A046U);
}
if ((is_obj_flag_status_active(objectIndex, 0x02000000) != 0) &&
(func_80072354(objectIndex, 0x00000020) != 0)) {
func_800722A4(objectIndex, 0x00000060);
set_object_flag_status_false(objectIndex, 0x02000000);
}
}
}
void init_hot_air_balloon(s32 objectIndex) {
gObjectList[objectIndex].sizeScaling = 1.0f;
gObjectList[objectIndex].model = d_course_luigi_raceway_dl_F960;
-1
View File
@@ -336,7 +336,6 @@ void func_80084430(s32, s32);
void func_8008453C(s32, s32);
void func_800845C8(s32, s32);
void func_80084B7C(s32, s32);
void func_80084D2C(s32, s32);
void func_80085024(void);
void func_8008502C(s32, s32);
void func_80085080(s32);