Fix Crab Impl

This commit is contained in:
MegaMech
2024-12-29 21:37:06 -07:00
parent 64b9dcbb30
commit 08e4bf3797
4 changed files with 53 additions and 42 deletions
+14 -13
View File
@@ -7,6 +7,7 @@
#include "World.h"
#include "engine/actors/AFinishline.h"
#include "engine/objects/BombKart.h"
#include "engine/objects/Crab.h"
#include "assets/koopa_troopa_beach_data.h"
extern "C" {
@@ -144,6 +145,19 @@ void KoopaTroopaBeach::SpawnActors() {
init_actor_hot_air_balloon_item_box(328.0f * gCourseDirection, 70.0f, 2541.0f);
spawn_all_item_boxes((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_koopa_troopa_beach_item_box_spawns));
spawn_palm_trees((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_koopa_troopa_beach_tree_spawn));
if (gGamestate != CREDITS_SEQUENCE) {
gWorldInstance.AddObject(new OCrab(FVector2D(-1809, 625), FVector2D(-1666, 594)));
gWorldInstance.AddObject(new OCrab(FVector2D(-1852, 757), FVector2D(-1620, 740)));
gWorldInstance.AddObject(new OCrab(FVector2D(-1478, 1842), FVector2D(-1453, 1833)));
gWorldInstance.AddObject(new OCrab(FVector2D(-1418, 1967), FVector2D(-1455, 1962)));
gWorldInstance.AddObject(new OCrab(FVector2D(-1472, 2112), FVector2D(-1417, 2100)));
gWorldInstance.AddObject(new OCrab(FVector2D(-1389, 2152), FVector2D(-1335, 2136)));
gWorldInstance.AddObject(new OCrab(FVector2D(218, 693), FVector2D(69, 696)));
gWorldInstance.AddObject(new OCrab(FVector2D(235, 528), FVector2D(24, 501)));
gWorldInstance.AddObject(new OCrab(FVector2D(268, 406), FVector2D(101, 394)));
gWorldInstance.AddObject(new OCrab(FVector2D(223, 318), FVector2D(86, 308)));
}
}
void KoopaTroopaBeach::SpawnVehicles() {
@@ -173,19 +187,6 @@ void KoopaTroopaBeach::InitCourseObjects() {
size_t objectId;
size_t i;
if (gGamestate != CREDITS_SEQUENCE) {
for (i = 0; i < NUM_CRABS; 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;
}
}
if (gGamestate == CREDITS_SEQUENCE) {
Vec3f pos = {-360.0f, 60.0f, -1300.0f};
for (size_t i = 0; i < NUM_SEAGULLS; i++) {
+4 -1
View File
@@ -21,6 +21,7 @@
#include "engine/objects/Hedgehog.h"
#include "engine/objects/Flagpole.h"
#include "engine/objects/HotAirBalloon.h"
#include "engine/objects/Crab.h"
#include "engine/particles/StarEmitter.h"
extern "C" {
@@ -211,7 +212,9 @@ void TestCourse::SpawnActors() {
//gWorldInstance.AddEmitter(new StarEmitter(FVector(0,50,0)));
//gWorldInstance.AddObject(new OHedgehog(FVector(0, 0, 0), FVector2D(0, -200), 9));
//gWorldInstance.AddObject(new OFlagpole(FVector(0, 0, -200), 0x400));
gWorldInstance.AddObject(new OHotAirBalloon(FVector(0.0, 20.0f, -200.0f)));
// gWorldInstance.AddObject(new OHotAirBalloon(FVector(0.0, 20.0f, -200.0f)));
gWorldInstance.AddObject(new OCrab(FVector2D(0, 0), FVector2D(0, -200)));
}
// Likely sets minimap boundaries
+15 -15
View File
@@ -23,25 +23,28 @@ extern "C" {
#include "assets/koopa_troopa_beach_data.h"
}
OCrab::OCrab(s32 i, Vec3f pos) {
size_t OCrab::_count = 0;
OCrab::OCrab(const FVector2D& start, const FVector2D& end) {
s32 objectId;
//for (i = 0; i < NUM_CRABS; i++) {
_idx = i;
objectId = indexObjectList1[i];
_idx = _count;
_start = start;
_end = end;
objectId = indexObjectList1[_idx];
init_object(objectId, 0);
gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] =
gCrabSpawns[i].startX * xOrientation;
gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = start.x * xOrientation;
gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = start.z;
gObjectList[objectId].unk_01C[0] = gCrabSpawns[i].patrolX * xOrientation;
gObjectList[objectId].unk_01C[0] = end.x * xOrientation;
gObjectList[objectId].unk_01C[2] = end.z;
gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gCrabSpawns[i].startZ;
gObjectList[objectId].unk_01C[2] = gCrabSpawns[i].patrolZ;
_count++;
}
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);
@@ -49,12 +52,11 @@ void OCrab::Tick(void) {
OCrab::func_80082C30(objectIndex);
OCrab::func_80082E18(objectIndex);
}
//}
}
void OCrab::Draw(s32 objectIndex, s32 cameraId) {
void OCrab::Draw(s32 cameraId) {
Camera* camera;
s32 objectIndex = indexObjectList1[_idx];
if (gObjectList[objectIndex].state >= 2) {
Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
camera = &camera1[cameraId];
@@ -72,7 +74,6 @@ 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) {
@@ -86,7 +87,6 @@ void OCrab::DrawModel(s32 cameraId) {
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) {
+20 -13
View File
@@ -2,6 +2,8 @@
#include <libultraship.h>
#include <vector>
#include "engine/objects/Object.h"
#include "World.h"
extern "C" {
#include "macros.h"
@@ -14,20 +16,23 @@ extern "C" {
#include "some_data.h"
}
class OCrab {
/**
* @arg start x and z spawn location
* @arg end x and z patrol location
*
* Crab patrols between start and end.
* The game automatically places the actor on the course surface.
* Therefore, providing a Y height is unnecessary.
*
* Crab appears to have a maximum patrolling distance and will patrol between
* end --> max distance rather than start --> end or start --> max distance.
*/
class OCrab : public OObject {
public:
enum Behaviour : uint16_t {
};
explicit OCrab(const FVector2D& start, const FVector2D& end);
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);
virtual void Tick() override;
virtual void Draw(s32 cameraId) override;
void DrawModel(s32 cameraId);
void init_ktb_crab(s32 objectIndex);
@@ -36,6 +41,8 @@ public:
void func_80082E18(s32 objectIndex);
private:
FVector2D _start;
FVector2D _end;
static size_t _count;
s32 _idx;
};