2024-01-20 18:04:46 -05:00
|
|
|
#include "legoact2.h"
|
|
|
|
|
2024-11-25 17:24:46 -05:00
|
|
|
#include "act2actor.h"
|
2024-11-11 13:30:34 -05:00
|
|
|
#include "act2main_actions.h"
|
2024-11-25 17:24:46 -05:00
|
|
|
#include "actions/act2main_actions.h"
|
2024-11-29 15:04:50 -05:00
|
|
|
#include "actions/infomain_actions.h"
|
2024-11-11 13:30:34 -05:00
|
|
|
#include "islepathactor.h"
|
2024-06-08 19:17:33 -04:00
|
|
|
#include "legoanimationmanager.h"
|
2024-11-11 12:48:45 -05:00
|
|
|
#include "legogamestate.h"
|
2024-06-08 19:17:33 -04:00
|
|
|
#include "legoinputmanager.h"
|
2024-11-25 17:24:46 -05:00
|
|
|
#include "legomain.h"
|
2024-06-08 19:17:33 -04:00
|
|
|
#include "misc.h"
|
2024-11-11 13:30:34 -05:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2024-06-08 19:17:33 -04:00
|
|
|
#include "mxmisc.h"
|
|
|
|
#include "mxnotificationmanager.h"
|
|
|
|
#include "mxticklemanager.h"
|
|
|
|
|
2024-11-25 17:24:46 -05:00
|
|
|
#include <vec.h>
|
|
|
|
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoAct2, 0x1154)
|
2024-06-03 12:53:25 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoAct2State, 0x10)
|
2024-03-22 21:30:58 -04:00
|
|
|
|
2024-11-25 17:24:46 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f4474
|
2024-11-26 18:33:18 -05:00
|
|
|
undefined4 g_unk0x100f4474 = 0;
|
2024-11-25 17:24:46 -05:00
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f43f0
|
|
|
|
// GLOBAL: BETA10 0x101e14a8
|
2024-11-26 18:33:18 -05:00
|
|
|
MxS32 g_unk0x100f43f0[] = {
|
2024-11-25 17:24:46 -05:00
|
|
|
Act2mainScript::c_tns030bd_RunAnim,
|
|
|
|
Act2mainScript::c_tns030pg_RunAnim,
|
|
|
|
Act2mainScript::c_tns030rd_RunAnim,
|
|
|
|
Act2mainScript::c_tns030sy_RunAnim,
|
2024-11-26 18:33:18 -05:00
|
|
|
Act2mainScript::c_snsx35ro_RunAnim,
|
|
|
|
Act2mainScript::c_snsx36ro_RunAnim,
|
|
|
|
Act2mainScript::c_snsx37ro_RunAnim,
|
2024-11-25 17:24:46 -05:00
|
|
|
Act2mainScript::c_snsx48cl_RunAnim
|
|
|
|
};
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100f4410
|
2024-11-26 18:33:18 -05:00
|
|
|
LegoChar* g_unk0x100f4410[] = {"bd", "pg", "rd", "sy", "ro", "cl"};
|
2024-11-25 17:24:46 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1004fce0
|
|
|
|
// FUNCTION: BETA10 0x1003a5a0
|
2024-06-12 20:02:47 -04:00
|
|
|
LegoAct2::LegoAct2()
|
|
|
|
{
|
2024-11-25 17:24:46 -05:00
|
|
|
m_unk0x10c4 = 0;
|
|
|
|
m_gameState = NULL;
|
|
|
|
m_unk0x10d8 = NULL;
|
|
|
|
m_unk0x1128 = 0;
|
|
|
|
m_unk0x10c2 = 0;
|
|
|
|
m_unk0x1130 = 0;
|
|
|
|
m_unk0x10c0 = 0;
|
|
|
|
m_unk0x10c1 = 0;
|
|
|
|
m_unk0x1138 = NULL;
|
|
|
|
m_unk0x1140 = 0;
|
|
|
|
m_unk0x1144 = 0;
|
|
|
|
m_unk0x1150 = 0;
|
|
|
|
m_unk0x10c8 = 0;
|
2024-11-29 15:04:50 -05:00
|
|
|
m_siFile = "";
|
2024-11-25 17:24:46 -05:00
|
|
|
m_unk0x113c = 5;
|
|
|
|
NotificationManager()->Register(this);
|
2024-06-12 20:02:47 -04:00
|
|
|
}
|
|
|
|
|
2024-02-07 06:13:20 -05:00
|
|
|
// FUNCTION: LEGO1 0x1004fe10
|
2024-01-20 18:04:46 -05:00
|
|
|
MxBool LegoAct2::VTable0x5c()
|
|
|
|
{
|
2024-02-07 06:13:20 -05:00
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-06-08 19:17:33 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004fe40
|
|
|
|
// FUNCTION: BETA10 0x1003a6f0
|
|
|
|
LegoAct2::~LegoAct2()
|
|
|
|
{
|
|
|
|
if (m_unk0x10c2) {
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10051900();
|
|
|
|
InputManager()->UnRegister(this);
|
2024-06-12 09:13:52 -04:00
|
|
|
if (UserActor()) {
|
|
|
|
Remove(UserActor());
|
2024-06-08 19:17:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
NotificationManager()->Unregister(this);
|
|
|
|
}
|
|
|
|
|
2024-11-11 12:48:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1004ff20
|
|
|
|
// FUNCTION: BETA10 0x1003a7ff
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult LegoAct2::Create(MxDSAction& p_dsAction)
|
|
|
|
{
|
2024-11-11 12:48:45 -05:00
|
|
|
GameState()->FindLoadedAct();
|
|
|
|
|
|
|
|
MxResult result = LegoWorld::Create(p_dsAction);
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
AnimationManager()->EnableCamAnims(FALSE);
|
|
|
|
|
|
|
|
LegoGameState* gameState = GameState();
|
|
|
|
LegoAct2State* state = (LegoAct2State*) gameState->GetState("LegoAct2State");
|
|
|
|
|
|
|
|
if (state == NULL) {
|
|
|
|
state = (LegoAct2State*) gameState->CreateState("LegoAct2State");
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gameState = state;
|
|
|
|
m_gameState->m_unk0x08 = 0;
|
|
|
|
|
|
|
|
switch (GameState()->GetLoadedAct()) {
|
|
|
|
case LegoGameState::e_act2:
|
|
|
|
GameState()->StopArea(LegoGameState::e_infomain);
|
|
|
|
GameState()->StopArea(LegoGameState::e_act2main);
|
|
|
|
break;
|
|
|
|
case LegoGameState::e_act3:
|
|
|
|
GameState()->StopArea(LegoGameState::e_infomain);
|
|
|
|
GameState()->StopArea(LegoGameState::e_act3script);
|
|
|
|
break;
|
|
|
|
case LegoGameState::e_act1:
|
|
|
|
case LegoGameState::e_actNotFound:
|
|
|
|
GameState()->StopArea(LegoGameState::e_undefined);
|
|
|
|
if (GameState()->GetPreviousArea() == LegoGameState::e_infomain) {
|
|
|
|
GameState()->StopArea(LegoGameState::e_isle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameState()->m_currentArea = LegoGameState::e_act2main;
|
|
|
|
GameState()->SetCurrentAct(LegoGameState::e_act2);
|
|
|
|
InputManager()->Register(this);
|
|
|
|
GameState()->SetDirty(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-11-25 17:24:46 -05:00
|
|
|
// FUNCTION: LEGO1 0x10050040
|
|
|
|
// FUNCTION: BETA10 0x1003a976
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult LegoAct2::Tickle()
|
|
|
|
{
|
2024-11-25 17:24:46 -05:00
|
|
|
MxFloat distance;
|
|
|
|
|
|
|
|
if (!m_worldStarted) {
|
|
|
|
LegoWorld::Tickle();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (m_unk0x10c4) {
|
|
|
|
case 0:
|
|
|
|
m_unk0x10c4 = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
((LegoPathActor*) m_unk0x10d8->GetEntity())->SetState(LegoPathActor::c_bit3);
|
|
|
|
|
|
|
|
switch (rand() % 3) {
|
|
|
|
case 0:
|
|
|
|
g_unk0x100f4474 = Act2mainScript::c_tns002br_RunAnim;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
g_unk0x100f4474 = Act2mainScript::c_tns003br_RunAnim;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
g_unk0x100f4474 = Act2mainScript::c_tns004br_RunAnim;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUN_10052560(g_unk0x100f4474, TRUE, TRUE, NULL, NULL, NULL);
|
|
|
|
m_unk0x10d0 = 0;
|
|
|
|
m_unk0x10c4 = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (g_unk0x100f4474) {
|
|
|
|
if (AnimationManager()->FUN_10064ee0(g_unk0x100f4474)) {
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
g_unk0x100f4474 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
|
|
|
|
m_unk0x10d0 = 0;
|
|
|
|
m_unk0x10c4 = 4;
|
|
|
|
FUN_10052560(Act2mainScript::c_tja009ni_RunAnim, TRUE, TRUE, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
AnimationManager()->EnableCamAnims(TRUE);
|
|
|
|
AnimationManager()->FUN_1005f6d0(TRUE);
|
|
|
|
AnimationManager()->FUN_100604f0(g_unk0x100f43f0, sizeOfArray(g_unk0x100f43f0));
|
|
|
|
AnimationManager()->FUN_10060480(g_unk0x100f4410, sizeOfArray(g_unk0x100f4410));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
|
|
|
|
if (m_unk0x10d0 == 20000) {
|
|
|
|
const MxFloat* pepperPosition = FindROI("pepper")->GetWorldPosition();
|
|
|
|
MxFloat otherPoint[] = {-52.0f, 5.25f, -16.5f};
|
|
|
|
|
|
|
|
distance = DISTSQRD3(pepperPosition, otherPoint);
|
|
|
|
|
|
|
|
if (m_unk0x1144 == 0 && distance > 50.0f && pepperPosition[0] > -57.0f) {
|
|
|
|
FUN_10052560(Act2mainScript::c_Avo906In_PlayWav, FALSE, FALSE, NULL, NULL, NULL);
|
|
|
|
m_unk0x1144 = Act2mainScript::c_Avo906In_PlayWav;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_unk0x10d0 >= 90000 && m_unk0x10d0 % 90000 == 0 && m_unk0x1144 == 0) {
|
|
|
|
FUN_10052560(Act2mainScript::c_Avo908In_PlayWav, FALSE, FALSE, NULL, NULL, NULL);
|
|
|
|
m_unk0x1144 = Act2mainScript::c_Avo908In_PlayWav;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
|
|
|
|
if (m_unk0x10d0 >= 200) {
|
|
|
|
if (m_unk0x10c0 < 5) {
|
|
|
|
m_unk0x10c4 = 7;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x10c4 = 10;
|
|
|
|
m_unk0x10d0 = 0;
|
|
|
|
m_unk0x1138->FUN_10019520();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
m_unk0x10d0 += 50;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-01-20 18:04:46 -05:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10050380
|
2024-11-25 17:24:46 -05:00
|
|
|
// STUB: BETA10 0x1003b049
|
2024-01-20 18:04:46 -05:00
|
|
|
MxLong LegoAct2::Notify(MxParam& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10050a80
|
2024-01-27 15:18:35 -05:00
|
|
|
void LegoAct2::ReadyWorld()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x10050cf0
|
2024-11-25 17:24:46 -05:00
|
|
|
// STUB: BETA10 0x1003bb2d
|
2024-02-02 12:18:46 -05:00
|
|
|
void LegoAct2::Enable(MxBool p_enable)
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-06-08 19:17:33 -04:00
|
|
|
// FUNCTION: LEGO1 0x10051900
|
|
|
|
// FUNCTION: BETA10 0x1003bed1
|
|
|
|
void LegoAct2::FUN_10051900()
|
|
|
|
{
|
|
|
|
if (AnimationManager()) {
|
|
|
|
AnimationManager()->Suspend();
|
|
|
|
AnimationManager()->Resume();
|
|
|
|
AnimationManager()->FUN_10060540(FALSE);
|
|
|
|
AnimationManager()->FUN_100604d0(FALSE);
|
|
|
|
AnimationManager()->EnableCamAnims(FALSE);
|
|
|
|
AnimationManager()->FUN_1005f6d0(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-11 13:30:34 -05:00
|
|
|
// FUNCTION: LEGO1 0x100519c0
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAct2::VTable0x60()
|
|
|
|
{
|
2024-11-11 13:30:34 -05:00
|
|
|
// empty
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-11-11 13:30:34 -05:00
|
|
|
// FUNCTION: LEGO1 0x100519d0
|
2024-05-24 20:41:57 -04:00
|
|
|
MxBool LegoAct2::Escape()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-11-11 13:30:34 -05:00
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
AnimationManager()->FUN_10061010(FALSE);
|
|
|
|
DeleteObjects(&m_atomId, Act2mainScript::c_snsx50bu_RunAnim, 999);
|
|
|
|
|
|
|
|
if (UserActor() != NULL) {
|
|
|
|
if (UserActor()->GetActorId() != GameState()->GetActorId()) {
|
|
|
|
((IslePathActor*) UserActor())->Exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_gameState != NULL) {
|
|
|
|
m_gameState->m_unk0x0c = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x1150 = 2;
|
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
2024-11-25 17:24:46 -05:00
|
|
|
|
2024-11-29 15:04:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x10052560
|
|
|
|
// FUNCTION: BETA10 0x100145c6
|
2024-11-25 17:24:46 -05:00
|
|
|
undefined4 LegoAct2::FUN_10052560(
|
2024-11-29 15:04:50 -05:00
|
|
|
MxS32 p_param1,
|
2024-11-25 17:24:46 -05:00
|
|
|
MxBool p_param2,
|
|
|
|
MxBool p_param3,
|
2024-11-29 15:04:50 -05:00
|
|
|
Mx3DPointFloat* p_location,
|
|
|
|
Mx3DPointFloat* p_direction,
|
2024-11-25 17:24:46 -05:00
|
|
|
Mx3DPointFloat* p_param6
|
|
|
|
)
|
|
|
|
{
|
2024-11-29 15:04:50 -05:00
|
|
|
|
|
|
|
if (m_unk0x1140 == 0 || p_param3) {
|
|
|
|
assert(strlen(m_siFile));
|
|
|
|
|
|
|
|
if (!p_param2) {
|
|
|
|
MxDSAction action;
|
|
|
|
|
|
|
|
action.SetObjectId(p_param1);
|
|
|
|
// not entirely sure about the constant
|
|
|
|
action.SetAtomId(*Lego()->GetWorldAtom(InfomainScript::c_Cop_Ctl));
|
|
|
|
|
|
|
|
if (p_location) {
|
|
|
|
action.SetUp(Mx3DPointFloat(0.0f, 1.0f, 0.0f));
|
|
|
|
action.SetLocation(*p_location);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_direction) {
|
|
|
|
action.SetDirection(*p_direction);
|
|
|
|
}
|
|
|
|
|
|
|
|
StartActionIfUnknown0x13c(action);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
MxMatrix matrix;
|
|
|
|
|
|
|
|
matrix.SetIdentity();
|
|
|
|
MxBool oneVectorNotNull = FALSE;
|
|
|
|
|
|
|
|
if (p_location) {
|
|
|
|
matrix[3][0] = (*p_location)[0];
|
|
|
|
matrix[3][1] = (*p_location)[1];
|
|
|
|
matrix[3][2] = (*p_location)[2];
|
|
|
|
oneVectorNotNull = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_direction) {
|
|
|
|
matrix[2][0] = (*p_direction)[0];
|
|
|
|
matrix[2][1] = (*p_direction)[1];
|
|
|
|
matrix[2][2] = (*p_direction)[2];
|
|
|
|
oneVectorNotNull = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_param6) {
|
|
|
|
matrix[1][0] = (*p_param6)[0];
|
|
|
|
matrix[1][1] = (*p_param6)[1];
|
|
|
|
matrix[1][2] = (*p_param6)[2];
|
|
|
|
oneVectorNotNull = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3 firstColumn(matrix[0]);
|
|
|
|
Vector3 secondColumn(matrix[1]);
|
|
|
|
Vector3 thirdColumn(matrix[2]);
|
|
|
|
|
|
|
|
firstColumn.EqualsCross(&secondColumn, &thirdColumn);
|
|
|
|
firstColumn.Unitize();
|
|
|
|
|
|
|
|
MxMatrix* pmatrix = NULL;
|
|
|
|
|
|
|
|
if (oneVectorNotNull) {
|
|
|
|
pmatrix = &matrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxResult result;
|
|
|
|
|
|
|
|
if (p_param1 == Act2mainScript::c_tja009ni_RunAnim) {
|
|
|
|
result = AnimationManager()->FUN_10060dc0(p_param1, pmatrix, TRUE, FALSE, NULL, TRUE, TRUE, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result =
|
|
|
|
AnimationManager()->FUN_10060dc0(p_param1, pmatrix, TRUE, FALSE, NULL, TRUE, TRUE, TRUE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
m_unk0x1140 = p_param1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-25 17:24:46 -05:00
|
|
|
return 0;
|
|
|
|
}
|