2024-07-07 08:10:46 -04:00
|
|
|
#include "legoracers.h"
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-07-07 08:10:46 -04:00
|
|
|
#include "anim/legoanim.h"
|
2024-07-17 10:03:02 -04:00
|
|
|
#include "carrace.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "define.h"
|
2024-07-17 10:03:02 -04:00
|
|
|
#include "legocachesoundmanager.h"
|
2024-07-07 08:10:46 -04:00
|
|
|
#include "legocameracontroller.h"
|
2024-07-18 16:20:59 -04:00
|
|
|
#include "legonavcontroller.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "legorace.h"
|
2024-07-17 10:03:02 -04:00
|
|
|
#include "legosoundmanager.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "misc.h"
|
2024-07-17 10:03:02 -04:00
|
|
|
#include "mxdebug.h"
|
2024-03-22 21:30:58 -04:00
|
|
|
#include "mxmisc.h"
|
|
|
|
#include "mxnotificationmanager.h"
|
2024-07-26 13:53:09 -04:00
|
|
|
#include "mxtimer.h"
|
2024-07-01 14:39:31 -04:00
|
|
|
#include "mxutilities.h"
|
2024-07-18 16:20:59 -04:00
|
|
|
#include "mxvariabletable.h"
|
2024-07-17 10:03:02 -04:00
|
|
|
#include "raceskel.h"
|
2024-03-22 21:30:58 -04:00
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
DECOMP_SIZE_ASSERT(EdgeReference, 0x08)
|
2024-07-17 10:03:02 -04:00
|
|
|
DECOMP_SIZE_ASSERT(SkeletonKickPhase, 0x10)
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoRaceCar, 0x200)
|
|
|
|
|
2024-11-14 15:42:38 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f0bac
|
|
|
|
static undefined4 g_unk0x100f0bac = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0bb0
|
|
|
|
static undefined4 g_unk0x100f0bb0 = 0;
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0a20
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5e34
|
|
|
|
EdgeReference LegoRaceCar::g_skBMap[] = {
|
2024-07-01 14:39:31 -04:00
|
|
|
{// STRING: LEGO1 0x100f0a10
|
|
|
|
"EDG03_772",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f0a04
|
|
|
|
"EDG03_773",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09f8
|
|
|
|
"EDG03_774",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09ec
|
|
|
|
"EDG03_775",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09e0
|
|
|
|
"EDG03_776",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{// STRING: LEGO1 0x100f09d4
|
|
|
|
"EDG03_777",
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0a50
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5e60
|
2024-07-17 10:03:02 -04:00
|
|
|
const SkeletonKickPhase LegoRaceCar::g_skeletonKickPhases[] = {
|
2024-07-27 12:24:36 -04:00
|
|
|
{&LegoRaceCar::g_skBMap[0], 0.1, 0.2, LEGORACECAR_KICK2},
|
|
|
|
{&LegoRaceCar::g_skBMap[1], 0.2, 0.3, LEGORACECAR_KICK2},
|
|
|
|
{&LegoRaceCar::g_skBMap[2], 0.3, 0.4, LEGORACECAR_KICK2},
|
|
|
|
{&LegoRaceCar::g_skBMap[2], 0.6, 0.7, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[1], 0.7, 0.8, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[0], 0.8, 0.9, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[3], 0.1, 0.2, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[4], 0.2, 0.3, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[5], 0.3, 0.4, LEGORACECAR_KICK1},
|
|
|
|
{&LegoRaceCar::g_skBMap[5], 0.6, 0.7, LEGORACECAR_KICK2},
|
|
|
|
{&LegoRaceCar::g_skBMap[4], 0.7, 0.8, LEGORACECAR_KICK2},
|
|
|
|
{&LegoRaceCar::g_skBMap[3], 0.8, 0.9, LEGORACECAR_KICK2},
|
2024-07-17 10:03:02 -04:00
|
|
|
};
|
|
|
|
|
2024-07-18 16:20:59 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0b10
|
|
|
|
// STRING: LEGO1 0x100f09cc
|
2024-07-26 13:53:09 -04:00
|
|
|
const char* LegoRaceCar::g_strSpeed = "SPEED";
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b18
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f28
|
2024-07-26 13:53:09 -04:00
|
|
|
const char* LegoRaceCar::g_srtsl18to29[] = {
|
|
|
|
"srt018sl",
|
|
|
|
"srt019sl",
|
|
|
|
"srt020sl",
|
|
|
|
"srt021sl",
|
|
|
|
"srt022sl",
|
|
|
|
"srt023sl",
|
|
|
|
"srt024sl",
|
|
|
|
"srt025sl",
|
|
|
|
"srt026sl",
|
|
|
|
"srt027sl",
|
|
|
|
"srt028sl",
|
|
|
|
"srt029sl"
|
|
|
|
};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b48
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f58
|
2024-07-26 13:53:09 -04:00
|
|
|
const char* LegoRaceCar::g_srtsl6to10[] = {"srt006sl", "srt007sl", "srt008sl", "srt009sl", "srt010sl"};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b5c
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f6c
|
2024-07-26 13:53:09 -04:00
|
|
|
const char* LegoRaceCar::g_emptySoundKeyList[] = {NULL};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b60
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f70
|
2024-07-26 13:53:09 -04:00
|
|
|
const char* LegoRaceCar::g_srtrh[] = {"srt004rh", "srt005rh", "srt006rh"};
|
2024-07-18 16:20:59 -04:00
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b6c
|
|
|
|
// STRING: LEGO1 0x100f08c4
|
|
|
|
const char* LegoRaceCar::g_srt001ra = "srt001ra";
|
|
|
|
|
2024-07-17 10:03:02 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0b70
|
|
|
|
// STRING: LEGO1 0x100f08bc
|
|
|
|
const char* LegoRaceCar::g_soundSkel3 = "skel3";
|
2024-07-01 14:39:31 -04:00
|
|
|
|
2024-07-26 13:53:09 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0b74
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f80
|
2024-07-26 13:53:09 -04:00
|
|
|
MxU32 LegoRaceCar::g_srtsl18to29Index = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b78
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f84
|
2024-07-26 13:53:09 -04:00
|
|
|
MxU32 LegoRaceCar::g_srtsl6to10Index = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b7c
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f88
|
2024-07-26 13:53:09 -04:00
|
|
|
MxU32 LegoRaceCar::g_emptySoundKeyListIndex = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b80
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f8c
|
2024-07-26 13:53:09 -04:00
|
|
|
MxU32 LegoRaceCar::g_srtrhIndex = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b84
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x101f5f90
|
2024-07-26 13:53:09 -04:00
|
|
|
MxLong LegoRaceCar::g_timeLastSoundPlayed = 0;
|
|
|
|
|
2024-07-18 16:20:59 -04:00
|
|
|
// GLOBAL: LEGO1 0x100f0b88
|
|
|
|
// GLOBAL: BETA10 0x101f5f94
|
|
|
|
MxS32 LegoRaceCar::g_unk0x100f0b88 = 0;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f0b8c
|
|
|
|
// GLOBAL: BETA10 0x101f5f98
|
|
|
|
MxBool LegoRaceCar::g_unk0x100f0b8c = TRUE;
|
|
|
|
|
2024-07-26 13:53:09 -04:00
|
|
|
// Initialized at LEGO1 0x10012db0
|
|
|
|
// GLOBAL: LEGO1 0x10102af0
|
2024-07-27 12:24:36 -04:00
|
|
|
// GLOBAL: BETA10 0x102114c0
|
2024-07-26 13:53:09 -04:00
|
|
|
Mx3DPointFloat LegoRaceCar::g_unk0x10102af0 = Mx3DPointFloat(0.0f, 2.0f, 0.0f);
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012950
|
|
|
|
LegoRaceCar::LegoRaceCar()
|
|
|
|
{
|
2024-07-07 08:10:46 -04:00
|
|
|
m_userState = 0;
|
2024-07-27 12:24:36 -04:00
|
|
|
m_skelKick1Anim = 0;
|
|
|
|
m_skelKick2Anim = 0;
|
2024-03-22 21:30:58 -04:00
|
|
|
m_unk0x5c.Clear();
|
|
|
|
m_unk0x58 = 0;
|
2024-07-27 12:24:36 -04:00
|
|
|
m_kick1B = 0;
|
|
|
|
m_kick2B = 0;
|
2024-03-22 21:30:58 -04:00
|
|
|
NotificationManager()->Register(this);
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012c80
|
2024-06-10 13:04:40 -04:00
|
|
|
LegoRaceCar::~LegoRaceCar()
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
NotificationManager()->Unregister(this);
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012d90
|
2024-06-10 13:04:40 -04:00
|
|
|
MxLong LegoRaceCar::Notify(MxParam& p_param)
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
return LegoRaceMap::Notify(p_param);
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-11-14 15:42:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10012de0
|
|
|
|
void LegoRaceCar::FUN_10012de0()
|
|
|
|
{
|
|
|
|
g_unk0x100f0b8c = TRUE;
|
|
|
|
g_timeLastSoundPlayed = 0;
|
|
|
|
g_unk0x100f0b88 = 0;
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012e60
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: BETA10 0x100cb191
|
2024-06-10 13:04:40 -04:00
|
|
|
void LegoRaceCar::SetWorldSpeed(MxFloat p_worldSpeed)
|
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
if (!m_userNavFlag) {
|
|
|
|
if (!LegoCarRaceActor::m_unk0x0c) {
|
|
|
|
m_maxLinearVel = p_worldSpeed;
|
|
|
|
}
|
|
|
|
LegoAnimActor::SetWorldSpeed(p_worldSpeed);
|
|
|
|
}
|
|
|
|
else {
|
2024-07-27 12:24:36 -04:00
|
|
|
LegoEntity::SetWorldSpeed(p_worldSpeed);
|
2024-07-01 14:39:31 -04:00
|
|
|
}
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ea0
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: BETA10 0x100cb220
|
2024-07-01 14:39:31 -04:00
|
|
|
void LegoRaceCar::SetMaxLinearVelocity(float p_maxLinearVelocity)
|
2024-03-22 21:30:58 -04:00
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
if (p_maxLinearVelocity < 0) {
|
2024-03-22 21:30:58 -04:00
|
|
|
LegoCarRaceActor::m_unk0x0c = 2;
|
2024-06-06 11:45:37 -04:00
|
|
|
m_maxLinearVel = 0;
|
2024-03-22 21:30:58 -04:00
|
|
|
SetWorldSpeed(0);
|
|
|
|
}
|
|
|
|
else {
|
2024-07-01 14:39:31 -04:00
|
|
|
m_maxLinearVel = p_maxLinearVelocity;
|
2024-03-22 21:30:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ef0
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: BETA10 0x100cb2aa
|
2024-07-01 14:39:31 -04:00
|
|
|
void LegoRaceCar::ParseAction(char* p_extra)
|
2024-06-10 13:04:40 -04:00
|
|
|
{
|
2024-07-01 14:39:31 -04:00
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
LegoAnimActor::ParseAction(p_extra);
|
|
|
|
LegoRaceMap::ParseAction(p_extra);
|
|
|
|
LegoRace* currentWorld = (LegoRace*) CurrentWorld();
|
|
|
|
|
|
|
|
if (KeyValueStringParse(buffer, g_strCOMP, p_extra) && currentWorld) {
|
|
|
|
currentWorld->VTable0x7c(this, atoi(buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_userNavFlag) {
|
2024-07-27 12:24:36 -04:00
|
|
|
MxS32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < m_animMaps.size(); i++) {
|
|
|
|
// It appears that the implementation in BETA10 does not use this variable
|
2024-07-01 14:39:31 -04:00
|
|
|
LegoAnimActorStruct* animMap = m_animMaps[i];
|
|
|
|
|
|
|
|
if (animMap->m_unk0x00 == -1.0f) {
|
2024-07-27 12:24:36 -04:00
|
|
|
m_skelKick1Anim = animMap;
|
2024-07-01 14:39:31 -04:00
|
|
|
}
|
|
|
|
else if (animMap->m_unk0x00 == -2.0f) {
|
2024-07-27 12:24:36 -04:00
|
|
|
m_skelKick2Anim = animMap;
|
2024-07-01 14:39:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-27 12:24:36 -04:00
|
|
|
assert(m_skelKick1Anim && m_skelKick2Anim);
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// STRING: LEGO1 0x100f0bc4
|
|
|
|
const char* edge0344 = "EDG03_44";
|
2024-07-27 12:24:36 -04:00
|
|
|
m_kick1B = currentWorld->FindPathBoundary(edge0344);
|
|
|
|
assert(m_kick1B);
|
|
|
|
|
2024-07-01 14:39:31 -04:00
|
|
|
// STRING: LEGO1 0x100f0bb8
|
|
|
|
const char* edge0354 = "EDG03_54";
|
2024-07-27 12:24:36 -04:00
|
|
|
m_kick2B = currentWorld->FindPathBoundary(edge0354);
|
|
|
|
assert(m_kick2B);
|
2024-07-01 14:39:31 -04:00
|
|
|
|
2024-07-27 12:24:36 -04:00
|
|
|
for (i = 0; i < sizeOfArray(g_skBMap); i++) {
|
|
|
|
assert(g_skBMap[i].m_name);
|
|
|
|
g_skBMap[i].m_b = currentWorld->FindPathBoundary(g_skBMap[i].m_name);
|
|
|
|
assert(g_skBMap[i].m_b);
|
2024-07-01 14:39:31 -04:00
|
|
|
}
|
|
|
|
}
|
2024-06-10 13:04:40 -04:00
|
|
|
}
|
|
|
|
|
2024-07-07 08:10:46 -04:00
|
|
|
// FUNCTION: LEGO1 0x10012ff0
|
|
|
|
// FUNCTION: BETA10 0x100cb60e
|
|
|
|
void LegoRaceCar::FUN_10012ff0(float p_param)
|
2024-03-22 21:30:58 -04:00
|
|
|
{
|
2024-07-07 08:10:46 -04:00
|
|
|
LegoAnimActorStruct* a; // called `a` in BETA10
|
|
|
|
float deltaTime;
|
|
|
|
|
2024-07-17 10:03:02 -04:00
|
|
|
if (m_userState == LEGORACECAR_KICK1) {
|
2024-07-27 12:24:36 -04:00
|
|
|
a = m_skelKick1Anim;
|
2024-07-07 08:10:46 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-07-17 10:03:02 -04:00
|
|
|
assert(m_userState == LEGORACECAR_KICK2);
|
2024-07-27 12:24:36 -04:00
|
|
|
a = m_skelKick2Anim;
|
2024-07-07 08:10:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(a && a->GetAnimTreePtr() && a->GetAnimTreePtr()->GetCamAnim());
|
|
|
|
|
|
|
|
if (a->GetAnimTreePtr()) {
|
|
|
|
deltaTime = p_param - m_unk0x58;
|
|
|
|
|
|
|
|
if (a->GetDuration() <= deltaTime || deltaTime < 0.0) {
|
2024-07-17 10:03:02 -04:00
|
|
|
if (m_userState == LEGORACECAR_KICK1) {
|
2024-08-04 15:13:12 -04:00
|
|
|
LegoUnknown100db7f4** edges = m_kick1B->GetEdges();
|
|
|
|
m_destEdge = edges[2];
|
2024-07-27 12:24:36 -04:00
|
|
|
m_boundary = m_kick1B;
|
2024-07-07 08:10:46 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-08-04 15:13:12 -04:00
|
|
|
LegoUnknown100db7f4** edges = m_kick1B->GetEdges();
|
|
|
|
m_destEdge = edges[1];
|
2024-07-27 12:24:36 -04:00
|
|
|
m_boundary = m_kick2B;
|
2024-07-07 08:10:46 -04:00
|
|
|
}
|
|
|
|
|
2024-07-18 16:20:59 -04:00
|
|
|
m_userState = LEGORACECAR_UNKNOWN_0;
|
2024-07-07 08:10:46 -04:00
|
|
|
}
|
|
|
|
else if (a->GetAnimTreePtr()->GetCamAnim()) {
|
|
|
|
MxMatrix transformationMatrix;
|
|
|
|
|
|
|
|
LegoWorld* r = CurrentWorld(); // called `r` in BETA10
|
|
|
|
assert(r);
|
|
|
|
|
|
|
|
transformationMatrix.SetIdentity();
|
|
|
|
|
|
|
|
// Possible bug in the original code: The first argument is not initialized
|
|
|
|
a->GetAnimTreePtr()->GetCamAnim()->FUN_1009f490(deltaTime, transformationMatrix);
|
|
|
|
|
|
|
|
if (r->GetCamera()) {
|
|
|
|
r->GetCamera()->FUN_100123e0(transformationMatrix, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_roi->FUN_100a58f0(transformationMatrix);
|
|
|
|
}
|
|
|
|
}
|
2024-03-22 21:30:58 -04:00
|
|
|
}
|
|
|
|
|
2024-07-17 10:03:02 -04:00
|
|
|
// FUNCTION: LEGO1 0x10013130
|
|
|
|
// FUNCTION: BETA10 0x100cce50
|
|
|
|
MxU32 LegoRaceCar::HandleSkeletonKicks(float p_param1)
|
2024-03-22 21:30:58 -04:00
|
|
|
{
|
2024-07-17 10:03:02 -04:00
|
|
|
const SkeletonKickPhase* current = g_skeletonKickPhases;
|
|
|
|
|
|
|
|
CarRace* r = (CarRace*) CurrentWorld(); // called `r` in BETA10
|
|
|
|
assert(r);
|
|
|
|
|
2024-08-21 16:30:27 -04:00
|
|
|
RaceSkel* s = r->GetSkeleton(); // called `s` in BETA10
|
2024-07-17 10:03:02 -04:00
|
|
|
assert(s);
|
|
|
|
|
|
|
|
float skeletonCurAnimPosition;
|
|
|
|
float skeletonCurAnimDuration;
|
|
|
|
|
|
|
|
s->GetCurrentAnimData(&skeletonCurAnimPosition, &skeletonCurAnimDuration);
|
|
|
|
|
|
|
|
float skeletonCurAnimPhase = skeletonCurAnimPosition / skeletonCurAnimDuration;
|
|
|
|
|
|
|
|
for (MxS32 i = 0; i < sizeOfArray(g_skeletonKickPhases); i++) {
|
2024-07-27 12:24:36 -04:00
|
|
|
if (m_boundary == current->m_edgeRef->m_b && current->m_lower <= skeletonCurAnimPhase &&
|
2024-07-17 10:03:02 -04:00
|
|
|
skeletonCurAnimPhase <= current->m_upper) {
|
|
|
|
m_userState = current->m_userState;
|
|
|
|
}
|
|
|
|
current = ¤t[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_userState != LEGORACECAR_KICK1 && m_userState != LEGORACECAR_KICK2) {
|
|
|
|
MxTrace(
|
|
|
|
// STRING: BETA10 0x101f64c8
|
|
|
|
"Got kicked in boundary %s %d %g:%g %g\n",
|
|
|
|
m_boundary->GetName(),
|
|
|
|
skeletonCurAnimPosition,
|
|
|
|
skeletonCurAnimDuration,
|
|
|
|
skeletonCurAnimPhase
|
|
|
|
);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x58 = p_param1;
|
|
|
|
SoundManager()->GetCacheSoundManager()->Play(g_soundSkel3, NULL, FALSE);
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-07-18 16:20:59 -04:00
|
|
|
// FUNCTION: LEGO1 0x100131f0
|
|
|
|
// FUNCTION: BETA10 0x100cb88a
|
2024-06-10 13:04:40 -04:00
|
|
|
void LegoRaceCar::VTable0x70(float p_float)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-07-18 16:20:59 -04:00
|
|
|
if (m_userNavFlag && (m_userState == LEGORACECAR_KICK1 || m_userState == LEGORACECAR_KICK2)) {
|
|
|
|
FUN_10012ff0(p_float);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LegoCarRaceActor::VTable0x70(p_float);
|
|
|
|
|
|
|
|
if (m_userNavFlag && m_userState == LEGORACECAR_UNKNOWN_1) {
|
|
|
|
if (HandleSkeletonKicks(p_float)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LegoCarRaceActor::m_unk0x0c == 1) {
|
|
|
|
FUN_1005d4b0();
|
|
|
|
|
|
|
|
if (!m_userNavFlag) {
|
|
|
|
FUN_10080590(p_float);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float absoluteSpeed = abs(m_worldSpeed);
|
|
|
|
float maximumSpeed = NavController()->GetMaxLinearVel();
|
|
|
|
char buffer[200];
|
|
|
|
|
|
|
|
sprintf(buffer, "%g", absoluteSpeed / maximumSpeed);
|
|
|
|
|
2024-07-26 13:53:09 -04:00
|
|
|
VariableTable()->SetVariable(g_strSpeed, buffer);
|
2024-07-18 16:20:59 -04:00
|
|
|
|
|
|
|
if (m_sound) {
|
|
|
|
// pitches up the engine sound based on the velocity
|
|
|
|
if (absoluteSpeed > 0.83 * maximumSpeed) {
|
|
|
|
m_frequencyFactor = 1.9f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// this value seems to simulate RPM based on the gear
|
|
|
|
MxS32 gearRpmFactor = (MxS32) (6.0 * absoluteSpeed) % 100;
|
|
|
|
m_frequencyFactor = gearRpmFactor / 80.0 + 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (absoluteSpeed != 0.0f) {
|
|
|
|
g_unk0x100f0b88 = p_float;
|
|
|
|
g_unk0x100f0b8c = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_float - g_unk0x100f0b88 > 5000.0f && !g_unk0x100f0b8c) {
|
|
|
|
SoundManager()->GetCacheSoundManager()->Play(g_srt001ra, NULL, 0);
|
|
|
|
g_unk0x100f0b8c = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-07-26 13:53:09 -04:00
|
|
|
// FUNCTION: LEGO1 0x100133c0
|
|
|
|
// FUNCTION: BETA10 0x100cbb84
|
2024-06-10 13:04:40 -04:00
|
|
|
MxResult LegoRaceCar::VTable0x94(LegoPathActor* p_actor, MxBool p_bool)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-08-03 01:29:21 -04:00
|
|
|
// Note: Code duplication with LegoRaceActor::VTable0x94
|
2024-07-26 13:53:09 -04:00
|
|
|
if (!p_actor->GetUserNavFlag()) {
|
|
|
|
if (p_actor->GetState()) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_bool) {
|
|
|
|
LegoROI* roi = p_actor->GetROI(); // name verified by BETA10 0x100cbbf5
|
|
|
|
assert(roi);
|
|
|
|
MxMatrix matr;
|
|
|
|
matr = roi->GetLocal2World();
|
|
|
|
|
|
|
|
Vector3(matr[3]).Add(g_unk0x10102af0);
|
|
|
|
roi->FUN_100a58f0(matr);
|
|
|
|
|
|
|
|
p_actor->SetState(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_userNavFlag) {
|
|
|
|
MxBool actorIsStuds = strcmpi(p_actor->GetROI()->GetName(), "studs") == 0;
|
|
|
|
MxBool actorIsRhoda = strcmpi(p_actor->GetROI()->GetName(), "rhoda") == 0;
|
|
|
|
MxLong time = Timer()->GetTime();
|
|
|
|
|
|
|
|
const char* soundKey = NULL;
|
|
|
|
MxLong timeElapsed = time - g_timeLastSoundPlayed;
|
|
|
|
|
|
|
|
if (timeElapsed > 3000) {
|
|
|
|
if (p_bool) {
|
|
|
|
if (actorIsStuds) {
|
|
|
|
soundKey = g_srtsl18to29[g_srtsl18to29Index++];
|
|
|
|
if (g_srtsl18to29Index >= sizeOfArray(g_srtsl18to29)) {
|
|
|
|
g_srtsl18to29Index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (actorIsRhoda) {
|
|
|
|
soundKey = g_emptySoundKeyList[g_emptySoundKeyListIndex++];
|
|
|
|
if (g_emptySoundKeyListIndex >= sizeOfArray(g_emptySoundKeyList)) {
|
|
|
|
g_emptySoundKeyListIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (actorIsStuds) {
|
|
|
|
soundKey = g_srtsl6to10[g_srtsl6to10Index++];
|
|
|
|
if (g_srtsl6to10Index >= sizeOfArray(g_srtsl6to10)) {
|
|
|
|
g_srtsl6to10Index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (actorIsRhoda) {
|
|
|
|
soundKey = g_srtrh[g_srtrhIndex++];
|
|
|
|
if (g_srtrhIndex >= sizeOfArray(g_srtrh)) {
|
|
|
|
g_srtrhIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (soundKey) {
|
|
|
|
SoundManager()->GetCacheSoundManager()->Play(soundKey, NULL, FALSE);
|
|
|
|
g_timeLastSoundPlayed = g_unk0x100f3308 = time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_bool && m_worldSpeed != 0) {
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SUCCESS;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: LEGO1 0x10013600
|
|
|
|
// FUNCTION: BETA10 0x100cbe60
|
2024-06-10 13:04:40 -04:00
|
|
|
MxResult LegoRaceCar::VTable0x9c()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-07-27 12:24:36 -04:00
|
|
|
MxResult result;
|
|
|
|
|
|
|
|
if (m_userNavFlag) {
|
|
|
|
result = LegoCarRaceActor::VTable0x9c();
|
|
|
|
|
|
|
|
if (m_boundary) {
|
|
|
|
MxS32 bVar2 = 0;
|
|
|
|
|
|
|
|
for (MxS32 i = 0; i < sizeOfArray(g_skBMap); i++) {
|
|
|
|
assert(g_skBMap[i].m_b);
|
|
|
|
if (m_boundary == g_skBMap[i].m_b) {
|
|
|
|
bVar2 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_userState == LEGORACECAR_UNKNOWN_1) {
|
|
|
|
if (!bVar2) {
|
|
|
|
m_userState = LEGORACECAR_UNKNOWN_0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_userState = LEGORACECAR_UNKNOWN_1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = LegoCarRaceActor::VTable0x9c();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-11-14 15:42:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10013670
|
|
|
|
void LegoRaceCar::FUN_10013670()
|
|
|
|
{
|
|
|
|
g_unk0x100f0bac = (rand() & 0xc) >> 2;
|
|
|
|
|
|
|
|
// Inlining the `rand()` causes this function to mismatch
|
|
|
|
MxU32 uVar1 = rand();
|
|
|
|
g_unk0x100f0bb0 = uVar1 % 0xc >> 2;
|
|
|
|
}
|
|
|
|
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: LEGO1 0x10014500
|
|
|
|
// FUNCTION: BETA10 0x100cd5e0
|
2024-04-17 06:34:21 -04:00
|
|
|
MxU32 LegoRaceCar::VTable0x6c(
|
|
|
|
LegoPathBoundary* p_boundary,
|
|
|
|
Vector3& p_v1,
|
|
|
|
Vector3& p_v2,
|
|
|
|
float p_f1,
|
|
|
|
float p_f2,
|
|
|
|
Vector3& p_v3
|
|
|
|
)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-07-27 12:24:36 -04:00
|
|
|
return LegoCarRaceActor::VTable0x6c(p_boundary, p_v1, p_v2, p_f1, p_f2, p_v3);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-07-27 12:24:36 -04:00
|
|
|
// FUNCTION: LEGO1 0x10014560
|
|
|
|
// FUNCTION: BETA10 0x100cd660
|
2024-05-20 14:27:00 -04:00
|
|
|
void LegoRaceCar::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-07-27 12:24:36 -04:00
|
|
|
LegoCarRaceActor::SwitchBoundary(p_boundary, p_edge, p_unk0xe4);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|