PoliceState: Create script enum + implement FUN_1005ea40

This commit is contained in:
Joshua Peisach 2024-02-15 10:48:00 -05:00
parent 1b696e4bd8
commit a5af9ded7e
No known key found for this signature in database
GPG Key ID: 41C3D4189AFEDB5A
4 changed files with 49 additions and 7 deletions

View File

@ -13,6 +13,11 @@
// Radio at 0xf8
class Police : public LegoWorld {
public:
enum PoliceScript {
c_nickAnim = 500,
c_lauraAnim = 501,
};
Police();
~Police() override; // vtable+0x00

View File

@ -32,8 +32,10 @@ class PoliceState : public LegoState {
inline undefined4 GetUnknown0x0c() { return m_unk0x0c; }
inline void SetUnknown0x0c(undefined4 p_unk0x0c) { m_unk0x0c = p_unk0x0c; }
void FUN_1005ea40();
private:
undefined4 m_unk0x08; // 0x08
undefined4 m_action; // 0x08
undefined4 m_unk0x0c; // 0x0c
};

View File

@ -123,7 +123,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param)
MxLong result = 0;
if (p_param.GetKey() == ' ' && m_policeState->GetUnknown0x0c() == 1) {
DeleteObjects(&m_atom, 500, 501);
DeleteObjects(&m_atom, PoliceScript::c_nickAnim, PoliceScript::c_lauraAnim);
m_policeState->SetUnknown0x0c(0);
return 1;
}
@ -150,7 +150,7 @@ void Police::Enable(MxBool p_enable)
// FUNCTION: LEGO1 0x1005e790
MxBool Police::VTable0x64()
{
DeleteObjects(&m_atom, 500, 510);
DeleteObjects(&m_atom, c_nickAnim, 510);
m_transitionDestination = LegoGameState::e_infomain;
return TRUE;
}

View File

@ -1,5 +1,11 @@
#include "policestate.h"
#include "islepathactor.h"
#include "legoomni.h"
#include "mxdsaction.h"
#include "mxomni.h"
#include "police.h"
#include <stdlib.h>
DECOMP_SIZE_ASSERT(PoliceState, 0x10)
@ -8,7 +14,7 @@ DECOMP_SIZE_ASSERT(PoliceState, 0x10)
PoliceState::PoliceState()
{
m_unk0x0c = 0;
m_unk0x08 = (rand() % 2 == 0) ? 501 : 500;
m_action = (rand() % 2 == 0) ? Police::PoliceScript::c_lauraAnim : Police::PoliceScript::c_nickAnim;
}
// FUNCTION: LEGO1 0x1005e990
@ -19,12 +25,41 @@ MxResult PoliceState::VTable0x1c(LegoFile* p_legoFile)
}
if (p_legoFile->IsReadMode()) {
p_legoFile->Read(&m_unk0x08, sizeof(m_unk0x08));
p_legoFile->Read(&m_action, sizeof(m_action));
}
else {
undefined4 unk0x08 = m_unk0x08;
p_legoFile->Write(&unk0x08, sizeof(m_unk0x08));
undefined4 unk0x08 = m_action;
p_legoFile->Write(&unk0x08, sizeof(m_action));
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1005ea40
void PoliceState::FUN_1005ea40()
{
MxS32 actionId;
if (m_unk0x0c == 1)
return;
switch (CurrentVehicle()->VTable0x60()) {
case 4:
actionId = Police::PoliceScript::c_lauraAnim;
break;
case 5:
actionId = Police::PoliceScript::c_nickAnim;
break;
default:
actionId = m_action;
m_action = m_action == Police::PoliceScript::c_lauraAnim ? Police::PoliceScript::c_nickAnim
: Police::PoliceScript::c_lauraAnim;
goto playAction;
}
m_action = actionId;
playAction:
MxDSAction action;
action.SetObjectId(actionId);
action.SetAtomId(*g_policeScript);
Start(&action);
m_unk0x0c = 1;
}