Reimplementing objects

This commit is contained in:
MegaMech
2024-12-11 20:58:18 -07:00
parent a4890f9dfc
commit 95b8cca500
51 changed files with 1306 additions and 935 deletions
@@ -1,5 +1,5 @@
#include <libultraship.h>
#include "OBombKart.h"
#include "BombKart.h"
#include <vector>
#include "port/Game.h"
@@ -358,7 +358,7 @@ void OBombKart::Draw(s32 cameraId) {
} else if (gGamestate != ENDING) {
Unk_4A = 1;
}
set_object_flag_status_false(ObjectIndex, 0x00200000);
clear_object_flag(ObjectIndex, 0x00200000);
}
// huh???
@@ -369,7 +369,7 @@ void OBombKart::Draw(s32 cameraId) {
gObjectList[ObjectIndex].pos[2] = Pos[2];
temp_s4 = func_8008A364(ObjectIndex, cameraId, 0x31C4U, 0x000001F4);
if (is_obj_flag_status_active(ObjectIndex, VISIBLE) != 0) {
set_object_flag_status_true(ObjectIndex, 0x00200000);
set_object_flag(ObjectIndex, 0x00200000);
D_80183E80[0] = 0;
D_80183E80[1] = func_800418AC(Pos[0], Pos[2], camera->pos);
D_80183E80[2] = 0x8000;
+175
View File
@@ -0,0 +1,175 @@
#include <libultraship.h>
#include <libultra/gbi.h>
#include "Crab.h"
#include <vector>
#include "port/Game.h"
extern "C" {
#include "macros.h"
#include "main.h"
#include "defines.h"
#include "camera.h"
#include "update_objects.h"
#include "render_objects.h"
#include "actors.h"
#include "code_80057C60.h"
#include "code_80086E70.h"
#include "math_util.h"
#include "math_util_2.h"
#include "code_80005FD0.h"
#include "some_data.h"
#include "ceremony_and_credits.h"
#include "assets/koopa_troopa_beach_data.h"
}
OCrab::OCrab(s32 i, Vec3f pos) {
s32 objectId;
//for (i = 0; i < NUM_CRABS; i++) {
_idx = i;
objectId = indexObjectList1[i];
init_object(objectId, 0);
gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] =
gCrabSpawns[i].startX * xOrientation;
gObjectList[objectId].unk_01C[0] = gCrabSpawns[i].patrolX * xOrientation;
gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gCrabSpawns[i].startZ;
gObjectList[objectId].unk_01C[2] = gCrabSpawns[i].patrolZ;
}
void OCrab::Tick(void) {
s32 objectIndex;
//for (var_s1 = 0; var_s1 < NUM_CRABS; var_s1++) {
objectIndex = indexObjectList1[_idx];
if (gObjectList[objectIndex].state != 0) {
OCrab::func_80082B34(objectIndex);
func_8008A6DC(objectIndex, 500.0f);
OCrab::func_80082C30(objectIndex);
OCrab::func_80082E18(objectIndex);
}
//}
}
void OCrab::Draw(s32 objectIndex, s32 cameraId) {
Camera* camera;
if (gObjectList[objectIndex].state >= 2) {
Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
camera = &camera1[cameraId];
func_8004A6EC(objectIndex, 0.5f);
gObjectList[objectIndex].orientation[1] =
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
draw_2d_texture_at(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation,
gObjectList[objectIndex].sizeScaling, (u8*) gObjectList[objectIndex].activeTLUT,
(uint8_t*)gObjectList[objectIndex].activeTexture, vtx, 64, 64,
64, 32);
}
}
void OCrab::DrawModel(s32 cameraId) {
s32 someIndex;
s32 test;
//for (someIndex = 0; someIndex < NUM_CRABS; someIndex++) {
test = indexObjectList1[_idx];
func_8008A364(test, cameraId, 0x2AABU, 800);
if (is_obj_flag_status_active(test, VISIBLE) != 0) {
Camera *camera;
s32 objectIndex;
if (gObjectList[objectIndex].state >= 2) {
camera = &camera1[cameraId];
func_8004A6EC(objectIndex, 0.5f);
gObjectList[objectIndex].orientation[1] = func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
draw_2d_texture_at(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation, gObjectList[objectIndex].sizeScaling, (u8*) gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, (Vtx*)common_vtx_hedgehog, 0x00000040, 0x00000040, 0x00000040, 0x00000020);
}
}
//}
}
void OCrab::init_ktb_crab(s32 objectIndex) {
Object* object;
init_texture_object(objectIndex, (uint8_t*) d_course_koopa_troopa_beach_crab_tlut,
(const char**) d_course_koopa_troopa_beach_crab_frames, 64, (u16) 64);
object = &gObjectList[objectIndex];
object->sizeScaling = 0.15f;
object->textureListIndex = 0;
object_next_state(objectIndex);
object->boundingBoxSize = 1;
set_object_flag(objectIndex, 0x04000420);
func_80086EAC(objectIndex, 0, 1);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
object->unk_034 = 1.5f;
set_object_flag(objectIndex, 0x00000200);
}
void OCrab::func_80082B34(s32 objectIndex) {
switch (gObjectList[objectIndex].state) { /* irregular */
case 0:
break;
case 1:
OCrab::init_ktb_crab(objectIndex);
break;
case 2:
func_80072E54(objectIndex, 0, 3, 1, 2, -1);
break;
case 3:
func_80072E54(objectIndex, 4, 6, 1, 2, -1);
break;
}
if (gObjectList[objectIndex].state >= 2) {
func_80073514(objectIndex);
}
}
void OCrab::func_80082C30(s32 objectIndex) {
switch (gObjectList[objectIndex].unk_0AE) {
case 1:
if (func_80087A0C(objectIndex, gObjectList[objectIndex].origin_pos[0], gObjectList[objectIndex].unk_01C[0],
gObjectList[objectIndex].origin_pos[2], gObjectList[objectIndex].unk_01C[2]) != 0) {
func_800726CC(objectIndex, 3);
func_80086FD4(objectIndex);
}
break;
case 2:
if (func_80087104(objectIndex, 0x003CU) != 0) {
gObjectList[objectIndex].unk_034 = 0.8f;
func_800726CC(objectIndex, 2);
func_80086FD4(objectIndex);
}
break;
case 3:
if (func_80087954(objectIndex, 0x0000003C) != 0) {
func_80086FD4(objectIndex);
func_800726CC(objectIndex, 3);
}
break;
case 4:
if (func_80087104(objectIndex, 0x003CU) != 0) {
func_800726CC(objectIndex, 2);
func_80086FD4(objectIndex);
}
break;
case 5:
if (func_8008789C(objectIndex, 0x0000003C) != 0) {
func_800726CC(objectIndex, 3);
func_8008701C(objectIndex, 2);
}
break;
}
object_calculate_new_pos_offset(objectIndex);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
func_80088538(objectIndex);
gObjectList[objectIndex].pos[1] = (f32) (gObjectList[objectIndex].surfaceHeight + 2.5);
}
}
void OCrab::func_80082E18(s32 objectIndex) {
if (gObjectList[objectIndex].state >= 2) {
func_80089F24(objectIndex);
}
}
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include <libultraship.h>
#include <vector>
extern "C" {
#include "macros.h"
#include "main.h"
#include "vehicles.h"
#include "waypoints.h"
#include "common_structs.h"
#include "objects.h"
#include "course_offsets.h"
#include "some_data.h"
}
class OCrab {
public:
enum Behaviour : uint16_t {
};
public:
f32 Diameter = 0.0f; // Waddle in a circle around the spawn point at this diameter.
uint16_t MirrorModeAngleOffset;
explicit OCrab(s32 i, Vec3f pos);
void Tick();
void Draw(s32 objectIndex, s32 cameraId);
void DrawModel(s32 cameraId);
void init_ktb_crab(s32 objectIndex);
void func_80082B34(s32 objectIndex);
void func_80082C30(s32 objectIndex);
void func_80082E18(s32 objectIndex);
private:
s32 _idx;
};
+20
View File
@@ -0,0 +1,20 @@
#include <libultraship.h>
#include "GameObject.h"
#include "World.h"
extern "C" {
#include "camera.h"
}
//GameActor()
GameObject::GameObject() {}
// Virtual functions to be overridden by derived classes
void GameObject::Tick() { }
void GameObject::Draw(Camera* camera) { }
void GameObject::Collision() {}
void GameObject::Expire() { }
void GameObject::Destroy() { }
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include <libultraship.h>
extern "C" {
#include "camera.h"
#include "objects.h"
}
class GameObject {
public:
uint8_t uuid[16];
Object o;
virtual ~GameObject() = default;
explicit GameObject();
virtual void Tick();
virtual void Draw(Camera* camera);
virtual void Collision();
virtual void Expire();
virtual void Destroy();
};
+422
View File
@@ -0,0 +1,422 @@
#include <libultraship.h>
#include <libultra/gbi.h>
#include "Mole.h"
extern "C" {
#include "macros.h"
#include "main.h"
#include "defines.h"
#include "camera.h"
#include "update_objects.h"
#include "render_objects.h"
#include "actors.h"
#include "code_80057C60.h"
#include "code_80086E70.h"
#include "math_util.h"
#include "math_util_2.h"
#include "code_80005FD0.h"
#include "some_data.h"
#include "ceremony_and_credits.h"
#include "assets/moo_moo_farm_data.h"
#include "sounds.h"
#include "external.h"
}
OMole::OMole(Vec3f pos) {
find_unused_obj_index(&indexObjectList1[0]);
}
void OMole::Tick() {
s32 var_s1;
s32 objectIndex;
for (var_s1 = 0; var_s1 < D_8018D1C8; var_s1++) {
objectIndex = indexObjectList1[var_s1];
if (gObjectList[objectIndex].state == 0) {
if (func_8008A8B0(8, 9) != 0) {
func_80081FF4(objectIndex, 1);
}
} else {
OMole::func_800821AC(objectIndex, 1);
}
}
for (var_s1 = 0; var_s1 < D_8018D1D0; var_s1++) {
objectIndex = indexObjectList2[var_s1];
if (gObjectList[objectIndex].state == 0) {
if (func_8008A8B0(0x0010, 0x0013) != 0) {
OMole::func_80081FF4(objectIndex, 2);
}
} else {
OMole::func_800821AC(objectIndex, 2);
}
}
for (var_s1 = 0; var_s1 < D_8018D1D8; var_s1++) {
objectIndex = indexObjectList3[var_s1];
if (gObjectList[objectIndex].state == 0) {
if (func_8008A8B0(0x0011, 0x0014) != 0) {
func_80081FF4(objectIndex, 3);
}
} else {
OMole::func_800821AC(objectIndex, 3);
}
}
for (var_s1 = 0; var_s1 < gObjectParticle2_SIZE; var_s1++) {
objectIndex = gObjectParticle2[var_s1];
if (gObjectList[objectIndex].state != 0) {
OMole::func_80081790(objectIndex);
}
}
}
void OMole::Draw(Camera* camera) {
}
void OMole::func_80081790(s32 objectIndex) {
switch (gObjectList[objectIndex].state) {
case 0:
break; /* irregular */
case 1:
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.3f, gObjectList[objectIndex].unk_034,
gObjectList[objectIndex].orientation[1], 0x00000032) != 0) {
object_next_state(objectIndex);
}
object_calculate_new_pos_offset(objectIndex);
break;
case 2:
func_80072428(objectIndex);
func_80086F60(objectIndex);
break;
}
}
void OMole::func_80081AFC(s32 objectIndex, s32 arg1) {
s8* sp2C;
Object* object;
object = &gObjectList[objectIndex];
switch (object->state) {
case 0x1:
OMole::func_80081848(objectIndex);
break;
case 0x2:
if (object->unk_04C == 0) {
func_80086EAC(objectIndex, 2, 1);
object_next_state(objectIndex);
set_object_flag(objectIndex, 0x00000200);
} else {
object->unk_04C--;
}
break;
case 0x3:
if (object->unk_0AE == 0) {
func_80086EAC(objectIndex, 2, 4);
func_8008153C(objectIndex);
object_next_state(objectIndex);
func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x07));
}
break;
case 0x4:
if (func_80072E54(objectIndex, 1, 6, 1, 2, 0) != 0) {
func_800726CC(objectIndex, 0x00000064);
}
break;
case 0xA:
func_80072E54(objectIndex, 1, 6, 1, 0, -1);
if (object->unk_0AE == 0) {
func_800726CC(objectIndex, 0x00000064);
}
break;
case 0x64:
if (object->unk_0AE == 0) {
clear_object_flag(objectIndex, 0x00000200);
func_80072428(objectIndex);
switch (arg1) { /* switch 1; irregular */
case 1: /* switch 1 */
sp2C = D_8018D198;
break;
case 2: /* switch 1 */
sp2C = D_8018D1A8;
break;
case 3: /* switch 1 */
sp2C = D_8018D1B8;
break;
}
sp2C[object->type] = 0;
}
break;
case 0:
default:
break;
}
if (object->state >= 2) {
func_80073514(objectIndex);
}
}
void OMole::func_80081D34(s32 objectIndex) {
Player* player;
Camera* var_s4;
s32 var_s2;
s32 var_s5;
Object* object;
var_s5 = 0;
player = gPlayerOne;
var_s4 = camera1;
for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, player++, var_s4++) {
if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(player->effects & 0x80000000) &&
(has_collided_with_player(objectIndex, player) != 0)) {
if ((player->type & 0x8000) && !(player->type & 0x100)) {
var_s5 = 1;
object = &gObjectList[objectIndex];
if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) {
func_80072180();
}
if (player->effects & 0x200) {
func_800C9060(var_s2, 0x1900A046U);
} else {
player->soundEffects |= 2;
}
object->direction_angle[1] = var_s4->rot[1];
object->velocity[1] = (player->unk_094 / 2) + 3.0;
object->unk_034 = player->unk_094 + 1.0;
if (object->velocity[1] >= 5.0) {
object->velocity[1] = 5.0f;
}
if (object->unk_034 >= 4.0) {
object->velocity[1] = 4.0f;
}
}
}
}
if (var_s5 != 0) {
object = &gObjectList[objectIndex];
clear_object_flag(objectIndex, 0x00000200);
func_80086F60(objectIndex);
set_obj_origin_pos(objectIndex, object->pos[0], object->pos[1], object->pos[2]);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
func_80086EAC(objectIndex, 2, 0x000A);
func_800726CC(objectIndex, 0x0000000A);
}
}
void OMole::func_80081FF4(s32 objectIndex, s32 arg1) {
UNUSED s32 stackPadding0;
UNUSED s32 stackPadding1;
s32 moleCount;
s16 var_v1;
s16 offset;
s32 var_a0;
s8* var_a2;
init_object(objectIndex, 0);
gObjectList[objectIndex].unk_04C = random_int(0x001EU) + 5;
switch (arg1) { /* irregular */
case 1:
var_a2 = D_8018D198;
moleCount = NUM_GROUP1_MOLES;
offset = 0;
break;
case 2:
var_a2 = D_8018D1A8;
moleCount = NUM_GROUP2_MOLES;
offset = 24;
// offset = NUM_GROUP1_MOLES;
break;
case 3:
var_a2 = D_8018D1B8;
moleCount = NUM_GROUP3_MOLES;
offset = 57;
// offset = NUM_GROUP1_MOLES + NUM_GROUP2_MOLES;
break;
}
var_v1 = random_int(moleCount);
for (var_a0 = 0; var_a0 < moleCount; var_a0++) {
if (var_a2[var_v1] != 0) {
var_v1++;
if (var_v1 == moleCount) {
var_v1 = 0;
}
} else {
var_a2[var_v1] = 1;
gObjectList[objectIndex].type = var_v1;
break;
}
}
/*
Ideally `gMoleSpawns` wouldn't be a union at all and its just be a list of Vec3s
Even more ideally each mole group would have its own array for its spawns
gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asVec3sList[offset + var_v1][0] * xOrientation;
gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asVec3sList[offset + var_v1][1] - 9.0;
gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asVec3sList[offset + var_v1][2];
*/
gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 0] * xOrientation;
gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 1] - 9.0;
gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 2];
}
void OMole::func_80081848(s32 objectIndex) {
u8* mole = (u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_frames);
u8* tlut = (u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_tlut);
init_texture_object(objectIndex, (u8*)d_course_moo_moo_farm_mole_tlut, (const char**) mole, 0x20U, (u16) 0x00000040);
gObjectList[objectIndex].sizeScaling = 0.15f;
gObjectList[objectIndex].textureListIndex = 0;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
gObjectList[objectIndex].boundingBoxSize = 6;
gObjectList[objectIndex].velocity[1] = 4.0f;
set_object_flag(objectIndex, 0x04000000);
object_next_state(objectIndex);
}
void OMole::func_80081924(s32 objectIndex) {
switch (gObjectList[objectIndex].unk_0AE) {
case 1:
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], 9.0f, 0.7f) != 0) {
func_80086FD4(objectIndex);
}
break;
case 2:
func_800871AC(objectIndex, 0x0000000A);
break;
case 3:
if (f32_step_down_towards(&gObjectList[objectIndex].offset[1], 3.0f, 1.0f) != 0) {
func_80086F60(objectIndex);
}
break;
case 4:
func_80087D24(objectIndex, 3.6f, 0.25f, 0.0f);
break;
case 5:
func_80086F60(objectIndex);
break;
case 10:
gObjectList[objectIndex].orientation[2] += 0x1000;
gObjectList[objectIndex].velocity[1] -= 0.184;
func_8008751C(objectIndex);
object_add_velocity_offset_xyz(objectIndex);
if (gObjectList[objectIndex].pos[1] <= -10.0) {
func_80086F60(objectIndex);
}
break;
case 0:
default:
break;
}
}
void OMole::func_80081A88(s32 objectIndex) {
switch (gObjectList[objectIndex].unk_0DD) { /* irregular */
case 0:
break;
case 1:
func_8008B724(objectIndex);
break;
case 2:
OMole::func_80081924(objectIndex);
break;
}
object_calculate_new_pos_offset(objectIndex);
}
void OMole::func_800821AC(s32 objectIndex, s32 arg1) {
if (gObjectList[objectIndex].state != 0) {
OMole::func_80081AFC(objectIndex, arg1);
OMole::func_80081A88(objectIndex);
OMole::func_80081D34(objectIndex);
}
}
void OMole::func_80054E10(s32 objectIndex) {
if (gObjectList[objectIndex].state > 0) {
if (is_obj_flag_status_active(objectIndex, 0x00800000) != 0) {
D_80183E50[0] = gObjectList[objectIndex].pos[0];
D_80183E50[1] = gObjectList[objectIndex].surfaceHeight + 0.8;
D_80183E50[2] = gObjectList[objectIndex].pos[2];
D_80183E70[0] = gObjectList[objectIndex].velocity[0];
D_80183E70[1] = gObjectList[objectIndex].velocity[1];
D_80183E70[2] = gObjectList[objectIndex].velocity[2];
func_8004A9B8(gObjectList[objectIndex].sizeScaling);
}
}
}
// Almost certainly responsible for spawning/handling the moles on Moo Moo farm
void OMole::func_80054EB8() {
s32 someIndex;
for (someIndex = 0; someIndex < NUM_TOTAL_MOLES; someIndex++) {
func_80054E10(gObjectParticle1[someIndex]);
}
}
void OMole::func_80054D00(s32 objectIndex, s32 cameraId) {
Camera* camera;
camera = &camera1[cameraId];
if (gObjectList[objectIndex].state >= 3) {
func_8008A364(objectIndex, cameraId, 0x2AABU, 0x0000012C);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
D_80183E80[0] = (s16) gObjectList[objectIndex].orientation[0];
D_80183E80[1] =
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
D_80183E80[2] = (u16) gObjectList[objectIndex].orientation[2];
func_80048130(gObjectList[objectIndex].pos, (u16*) D_80183E80, gObjectList[objectIndex].sizeScaling,
(u8*) gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture,
(Vtx*)LOAD_ASSET_RAW(D_0D0062B0), 0x00000020, 0x00000040, 0x00000020, 0x00000040, 5);
}
}
}
void OMole::func_80054F04(s32 cameraId) {
s32 var_s2;
s32 objectIndex;
Camera* sp44;
Object* object;
sp44 = &camera1[cameraId];
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0079C8);
load_texture_block_rgba16_mirror((u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_dirt), 0x00000010, 0x00000010);
for (var_s2 = 0; var_s2 < gObjectParticle2_SIZE; var_s2++) {
objectIndex = gObjectParticle2[var_s2];
object = &gObjectList[objectIndex];
if (object->state > 0) {
func_8008A364(objectIndex, cameraId, 0x2AABU, 0x000000C8);
if ((is_obj_flag_status_active(objectIndex, VISIBLE) != 0) && (gMatrixHudCount <= MTX_HUD_POOL_SIZE_MAX)) {
object->orientation[1] = func_800418AC(object->pos[0], object->pos[2], sp44->pos);
rsp_set_matrix_gObjectList(objectIndex);
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D006980);
}
}
}
gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF);
}
void OMole::render_object_moles(s32 cameraId) {
s32 i;
for (i = 0; i < NUM_GROUP1_MOLES; i++) {
OMole::func_80054D00(indexObjectList1[i], cameraId);
}
for (i = 0; i < NUM_GROUP2_MOLES; i++) {
OMole::func_80054D00(indexObjectList2[i], cameraId);
}
for (i = 0; i < NUM_GROUP3_MOLES; i++) {
OMole::func_80054D00(indexObjectList3[i], cameraId);
}
OMole::func_80054EB8();
OMole::func_80054F04(cameraId);
}
+52
View File
@@ -0,0 +1,52 @@
#pragma once
#include <libultraship.h>
#include <vector>
#include "GameObject.h"
extern "C" {
#include "macros.h"
#include "main.h"
#include "vehicles.h"
#include "waypoints.h"
#include "common_structs.h"
#include "objects.h"
#include "course_offsets.h"
#include "some_data.h"
}
class OMole : public GameObject {
public:
enum Behaviour : uint16_t {
};
public:
explicit OMole(Vec3f pos);
virtual void Tick() override;
virtual void Draw(Camera*) override;
void func_80054E10(s32 objectIndex);
void func_80054EB8();
void func_80054F04(s32 cameraId);
void render_object_moles(s32 cameraId);
void func_80054D00(s32 objectIndex, s32 cameraId);
void func_800821AC(s32 objectIndex, s32 arg1);
void func_80081FF4(s32 objectIndex, s32 arg1);
void func_80081D34(s32 objectIndex);
void func_80081AFC(s32 objectIndex, s32 arg1);
void func_80081A88(s32 objectIndex);
void func_80081924(s32 objectIndex);
void func_80081848(s32 objectIndex);
void func_80081790(s32 objectIndex);
private:
s32 _idx;
s32 _state;
s32 _timer;
s32 _status;
bool _toggle;
SplineData *spline;
};
@@ -1,6 +1,6 @@
#include <libultraship.h>
#include <libultra/gbi.h>
#include "OPenguin.h"
#include "Penguin.h"
#include <vector>
#include "port/Game.h"
@@ -98,7 +98,7 @@ void OPenguin::Tick(void) {
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);
clear_object_flag(objectIndex, 0x02000000);
}
}
@@ -315,7 +315,7 @@ void OPenguin::InitEmperorPenguin(s32 objectIndex) {
object->unk_0DD = 1;
func_80086EF0(objectIndex);
object->spline = D_800E672C[0];
set_object_flag_status_true(objectIndex, 0x04000800);
set_object_flag(objectIndex, 0x04000800);
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
object_next_state(objectIndex);
}
@@ -377,7 +377,7 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
//object->boundingBoxSize = 4;
object->unk_09C = 2;
object->unk_04C = random_int(0x012CU);
set_object_flag_status_true(objectIndex, 0x04000220);
set_object_flag(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
@@ -13,19 +13,6 @@ extern "C" {
#include "course_offsets.h"
}
//! @todo Make shadow size bigger if thwomp is scaled up
//! @todo make adjustable properties for squishSize and boundingBoxSize
/**
* Thwomp GameObject
*
* The game automatically places the actor on the ground so you do not need to provide a Y coordinate value.
*
* @arg direction the rotational direction the thwomp is facing.
* @arg behaviour the behaviour of the thwomp, uses values 1-6.
* @arg primAlpha unknown
* @arg boundingBoxSize optional. The size of the bounding box for the thwomp. Default value is 12
*/
class OPenguin {
public:
enum PenguinType : uint32_t {
+194
View File
@@ -0,0 +1,194 @@
#include <libultraship.h>
#include <libultra/gbi.h>
#include "Seagull.h"
#include "engine/Actor.h"
#include "ObjectReimpl.h"
#include <vector>
#include "port/Game.h"
extern "C" {
#include "macros.h"
#include "main.h"
#include "defines.h"
#include "camera.h"
#include "update_objects.h"
#include "render_objects.h"
#include "actors.h"
#include "code_80057C60.h"
#include "code_80086E70.h"
#include "math_util.h"
#include "math_util_2.h"
#include "code_80005FD0.h"
#include "some_data.h"
#include "ceremony_and_credits.h"
extern SplineData D_800E6034;
extern SplineData D_800E60F0;
extern SplineData D_800E61B4;
extern SplineData D_800E6280;
}
SplineData* D_800E633C[] = { &D_800E6034, &D_800E60F0, &D_800E61B4, &D_800E6280 };
OSeagull::OSeagull(s32 i, Vec3f pos) {
size_t objectId;
_idx = i;
s16 randZ;
s16 randX;
s16 randY;
randX = random_int(200) + -100.0;
randY = random_int(20);
randZ = random_int(200) + -100.0;
SpawnPos[0] = pos[0] + randX;
SpawnPos[1] = pos[1] + randY;
SpawnPos[2] = pos[2] + randZ;
//for (i = 0; i < NUM_SEAGULLS; i++) {
//objectId = indexObjectList2[i];
//init_object(objectId, 0);
//set_obj_origin_pos(objectId, pos[0], pos[1], pos[2]);
//if (i < (NUM_SEAGULLS / 2)) {
//gObjectList[objectId].unk_0D5 = 0;
//} else {
// gObjectList[objectId].unk_0D5 = 1;
//}
//}
}
bool OSeagull::IsMod() { return true; }
void OSeagull::Tick() {
Object* object;
UNUSED s32* var_s4;
s32 temp_s0;
//for (var_s3 = 0; var_s3 < NUM_SEAGULLS; var_s3++) {
//temp_s0 = indexObjectList2[_idx];
//object = &gObjectList[temp_s0];
if (_state == 0) {
return;
}
OSeagull::func_80082714(temp_s0, _idx);
OSeagull::func_8008275C(temp_s0);
if (_toggle) {
_toggle = false;
if (D_80165A90 != 0) {
D_80165A90 = 0;
D_80183E40[0] = 0.0f;
D_80183E40[1] = 0.0f;
D_80183E40[2] = 0.0f;
if (gGamestate != CREDITS_SEQUENCE) {
func_800C98B8(Pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43));
} else {
//temp_s0 = indexObjectList2[1];
//! @todo confirm this is equivallent to indexObjectList2[1];
if (_idx == 1) {
if (gCutsceneShotTimer <= 150) {
//object = &gObjectList[temp_s0];
func_800C98B8(Pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43));
}
}
}
}
}
//}
if (D_80165900 != 0) {
D_80165900 -= 1;
} else {
if (gGamestate != CREDITS_SEQUENCE) {
D_80165900 = 60;
} else {
D_80165900 = 15;
}
if ((D_80165908 != 0) && (D_80165A90 == 0)) {
D_80165A90 = 1;
}
}
D_80165908 = 0;
}
void OSeagull::Draw(Camera* camera) { // render_object_seagulls
s32 var_s1;
//for (i = 0; i < NUM_SEAGULLS; i++) {
var_s1 = indexObjectList2[_idx];
//! @todo: Quick hack to let seagull work in actor system. Should be cameraId not camera->playerId
//if (func_8008A364(var_s1, camera->playerId, 0x5555U, 0x000005DC) < 0x9C401 && CVarGetInteger("gNoCulling", 0) == 0) {
D_80165908 = 1;
_toggle = true;
//}
//if (is_obj_flag_status_active(var_s1, VISIBLE) != 0) {
func_800552BC(var_s1);
//}
//}
}
void OSeagull::func_8008275C(s32 objectIndex) {
UNUSED s32 stackPadding;
switch (gObjectList[objectIndex].unk_0DD) {
case 1:
func_8008B78C(objectIndex);
ObjectImpl::CalculateNewPosOffset(this);
break;
case 2:
func_8008B78C(objectIndex);
vec3f_copy(gObjectList[objectIndex].unk_01C, gObjectList[objectIndex].pos);
func_8000D940(SpawnPos, (s16*) &gObjectList[objectIndex].unk_0C6,
gObjectList[objectIndex].unk_034, 0.0f, 0);
Offset[0] *= 2.0;
Offset[1] *= 2.5;
Offset[2] *= 2.0;
ObjectImpl::CalculateNewPosOffset(this);
gObjectList[objectIndex].direction_angle[1] =
get_angle_between_two_vectors(gObjectList[objectIndex].unk_01C, gObjectList[objectIndex].pos);
break;
}
func_800873F4(objectIndex);
}
void OSeagull::func_8008241C(s32 objectIndex, s32 arg1) {
UNUSED s16 stackPadding0;
gObjectList[objectIndex].unk_0D8 = 1;
gObjectList[objectIndex].model = (Gfx*) d_course_koopa_troopa_beach_unk4;
gObjectList[objectIndex].vertex = (Vtx*) d_course_koopa_troopa_beach_unk_data5;
gObjectList[objectIndex].sizeScaling = 0.2f;
gObjectList[objectIndex].unk_0DD = 1;
// if (gGamestate == CREDITS_SEQUENCE) {
// set_obj_origin_pos(objectIndex, randX + -360.0, randY + 60.0, randZ + -1300.0);
// } else if (gObjectList[objectIndex].unk_0D5 != 0) {
// set_obj_origin_pos(objectIndex, (randX + 328.0) * xOrientation, randY + 20.0, randZ + 2541.0);
// } else {
// set_obj_origin_pos(objectIndex, (randX + -985.0) * xOrientation, randY + 15.0, randZ + 1200.0);
// }
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
gObjectList[objectIndex].unk_034 = 1.0f;
func_80086EF0(objectIndex);
//gObjectList[objectIndex].spline = D_800E633C[arg1 % 4];
spline = D_800E633C[arg1 % 4];
//set_object_flag(objectIndex, 0x800);
//object_next_state(objectIndex);
_status |= 0x800;
_timer = 0;
_status &= ~0x2000;
_state++;
}
void OSeagull::func_80082714(s32 objectIndex, s32 arg1) {
switch (gObjectList[objectIndex].state) {
case 1:
OSeagull::func_8008241C(objectIndex, arg1);
break;
case 0:
default:
break;
}
}
+44
View File
@@ -0,0 +1,44 @@
#pragma once
#include <libultraship.h>
#include <vector>
#include "engine/Actor.h"
extern "C" {
#include "macros.h"
#include "main.h"
#include "vehicles.h"
#include "waypoints.h"
#include "common_structs.h"
#include "objects.h"
#include "course_offsets.h"
#include "some_data.h"
}
class OSeagull : public AActor {
public:
enum Behaviour : uint16_t {
};
public:
explicit OSeagull(s32 i, Vec3f pos);
virtual void Tick() override;
virtual void Draw(Camera*) override;
void func_8008275C(s32 objectIndex);
void func_8008241C(s32 objectIndex, s32 arg1);
void func_80082714(s32 objectIndex, s32 arg1);
virtual bool IsMod() override;
Vec3f Offset;
Vec3f SpawnPos;
private:
s32 _idx;
s32 _state;
s32 _timer;
s32 _status;
bool _toggle;
SplineData *spline;
};
@@ -1,6 +1,6 @@
#include <libultraship.h>
#include <libultra/gbi.h>
#include "OThwomp.h"
#include "Thwomp.h"
#include <vector>
#include "port/Game.h"
@@ -305,17 +305,17 @@ void OThwomp::SetVisibility(s32 objectIndex) { // func_8008A4CC
s32 loopIndex;
Camera* camera;
set_object_flag_status_false(objectIndex, 0x00070000);
clear_object_flag(objectIndex, 0x00070000);
for (loopIndex = 0, camera = camera1; loopIndex < gPlayerCountSelection1; loopIndex++, camera++) {
if (gObjectList[objectIndex].state != 0) {
if ((D_8018CF68[loopIndex] >= (gObjectList[objectIndex].unk_0DF - 1)) &&
((gObjectList[objectIndex].unk_0DF + 1) >= D_8018CF68[loopIndex])) {
set_object_flag_status_true(objectIndex, 0x00010000);
set_object_flag(objectIndex, 0x00010000);
if (D_8018CF68[loopIndex] == gObjectList[objectIndex].unk_0DF) {
set_object_flag_status_true(objectIndex, 0x00020000);
set_object_flag(objectIndex, 0x00020000);
}
if (is_object_visible_on_camera(objectIndex, camera, 0x2AABU) != 0) {
set_object_flag_status_true(objectIndex, VISIBLE);
set_object_flag(objectIndex, VISIBLE);
}
}
}
@@ -619,7 +619,7 @@ void OThwomp::func_80080B28(s32 objectIndex, s32 playerId) {
}
OThwomp::func_80080DE4(objectIndex);
func_80075304(gObjectList[objectIndex].pos, 3, 3, D_8018D3C4);
set_object_flag_status_false(objectIndex, 0x00000200);
clear_object_flag(objectIndex, 0x00000200);
func_800722A4(objectIndex, 0x00000040);
func_80086F60(objectIndex);
func_800726CC(objectIndex, 0x000000C8);
@@ -666,7 +666,7 @@ void OThwomp::Draw(s32 cameraId) {
camera = &camera1[cameraId];
if (cameraId == PLAYER_ONE) {
objectIndex = indexObjectList1[_idx];
set_object_flag_status_false(objectIndex, 0x00070000);
clear_object_flag(objectIndex, 0x00070000);
func_800722CC(objectIndex, 0x00000110);
}
@@ -831,7 +831,7 @@ void OThwomp::func_8007EC30(s32 objectIndex) {
0x10U, (u16) 0x00000040);
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
object->unk_01C[1] = 30.0f;
set_object_flag_status_true(objectIndex, 0x05000220);
set_object_flag(objectIndex, 0x05000220);
object->type = 0;
object->unk_0DF = 6;
func_800724DC(objectIndex);
@@ -868,7 +868,7 @@ void OThwomp::func_8007EE5C(s32 objectIndex) {
0x10U, (u16) 0x00000040);
object = &gObjectList[objectIndex];
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
set_object_flag_status_true(objectIndex, 0x04000220);
set_object_flag(objectIndex, 0x04000220);
object->type = 0;
object->unk_0DF = 6;
func_80086E70(objectIndex);
@@ -921,7 +921,7 @@ void OThwomp::func_8007FA08(s32 objectIndex) {
0x10U, (u16) 0x00000040);
object = &gObjectList[objectIndex];
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
set_object_flag_status_true(objectIndex, 0x04000220);
set_object_flag(objectIndex, 0x04000220);
object->type = 0;
object->surfaceHeight = 0.0f;
object->origin_pos[1] = 0.0f;
@@ -1087,7 +1087,7 @@ void OThwomp::func_80080078(s32 objectIndex) { // func_80080078
0x10U, (u16) 0x00000040);
object = &gObjectList[objectIndex];
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
set_object_flag_status_true(objectIndex, 0x04000220);
set_object_flag(objectIndex, 0x04000220);
object->type = 2;
object->unk_0DF = 8;
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
@@ -1159,7 +1159,7 @@ void OThwomp::func_800802C0(s32 objectIndex) {
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
object->textureListIndex = 0;
//object->sizeScaling = 1.5f;
set_object_flag_status_true(objectIndex, 0x05000220);
set_object_flag(objectIndex, 0x05000220);
object->type = 1;
object->unk_0DF = 6;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
@@ -1269,7 +1269,7 @@ void OThwomp::func_80080524(s32 objectIndex) {
object = &gObjectList[objectIndex];
object->model = (Gfx*)d_course_bowsers_castle_dl_thwomp;
object->textureListIndex = 0;
set_object_flag_status_true(objectIndex, 0x04000220);
set_object_flag(objectIndex, 0x04000220);
object->type = 0;
object->unk_0DF = 0x0A;
func_80086E70(objectIndex);
@@ -1302,7 +1302,7 @@ void OThwomp::func_8007E63C(s32 objectIndex) {
case 0x32:
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], gObjectList[objectIndex].unk_01C[1] + 15.0,
1.5f) != 0) {
set_object_flag_status_true(objectIndex, 0x00000200);
set_object_flag(objectIndex, 0x00000200);
func_800722A4(objectIndex, 1);
func_800722CC(objectIndex, 2);
object_next_state(objectIndex);
@@ -1345,7 +1345,7 @@ void OThwomp::func_8007E63C(s32 objectIndex) {
}
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], gObjectList[objectIndex].unk_01C[1], 0.5f) !=
0) {
set_object_flag_status_false(objectIndex, 0x00000200);
clear_object_flag(objectIndex, 0x00000200);
func_8007266C(objectIndex);
}
break;
@@ -1417,7 +1417,7 @@ void OThwomp::func_8007E63C(s32 objectIndex) {
case 0x6C:
if (set_and_run_timer_object(objectIndex, 0x00000064) != 0) {
func_800722CC(objectIndex, 2);
set_object_flag_status_false(objectIndex, 0x00000200);
clear_object_flag(objectIndex, 0x00000200);
func_8007266C(objectIndex);
}
break;