Clear unknowns in Act2Actor (#1687)

This commit is contained in:
Fabian Neundorf
2025-09-12 21:22:48 +02:00
committed by GitHub
parent 0832bedbf2
commit 6c83ceb549
4 changed files with 242 additions and 227 deletions

View File

@@ -14,7 +14,13 @@ public:
MxFloat m_position[3]; // 0x00 MxFloat m_position[3]; // 0x00
MxFloat m_direction[3]; // 0x0c MxFloat m_direction[3]; // 0x0c
const char* m_boundary; // 0x18 const char* m_boundary; // 0x18
MxBool m_unk0x1c; // 0x1c MxBool m_cleared; // 0x1c
};
enum VoiceOver {
e_head = 0,
e_behind = 1,
e_interrupt = 2,
}; };
Act2Actor(); Act2Actor();
@@ -25,7 +31,7 @@ public:
// FUNCTION: LEGO1 0x1001a180 // FUNCTION: LEGO1 0x1001a180
MxS32 VTable0x68(Vector3& p_v1, Vector3& p_v2, Vector3& p_v3) override MxS32 VTable0x68(Vector3& p_v1, Vector3& p_v2, Vector3& p_v3) override
{ {
if (m_unk0x1f) { if (m_animatingHit) {
return 0; return 0;
} }
@@ -35,16 +41,16 @@ public:
void Animate(float p_time) override; // vtable+0x70 void Animate(float p_time) override; // vtable+0x70
MxResult HitActor(LegoPathActor*, MxBool) override; // vtable+0x94 MxResult HitActor(LegoPathActor*, MxBool) override; // vtable+0x94
MxResult VTable0x9c() override; // vtable+0x9c MxResult VTable0x9c() override; // vtable+0x9c
MxS32 VTable0xa0() override; // vtable+0xa0 MxS32 NextTargetLocation() override; // vtable+0xa0
void FUN_10018980(); void InitializeNextShot();
void FUN_10019250(MxFloat p_speed, MxFloat p_param2); void SetWorldSpeed(MxFloat p_speed, MxFloat p_resetWorldSpeedAt);
void FUN_10019520(); void GoingToHide();
void FUN_10019560(); void Hide();
MxU32 FUN_10019700(MxFloat p_param); MxU32 UpdateShot(MxFloat p_time);
void FUN_100199f0(MxS8 p_param); void PlayNextVoiceOver(MxS8 p_voiceOverType);
void FUN_100192a0(undefined4 p_location); void FindPath(MxU32 p_location);
LegoEntity* FUN_10019b90(MxBool* p_param); LegoEntity* GetNextEntity(MxBool* p_isBuilding);
// SYNTHETIC: LEGO1 0x1001a0a0 // SYNTHETIC: LEGO1 0x1001a0a0
// Act2Actor::`scalar deleting destructor' // Act2Actor::`scalar deleting destructor'
@@ -54,22 +60,31 @@ public:
// `vbtable' // `vbtable'
private: private:
undefined m_unk0x1c; // 0x1c enum {
MxS8 m_unk0x1d; // 0x1d e_readyToShoot = 0,
undefined m_unk0x1e; // 0x1e e_endShot = 1,
MxBool m_unk0x1f; // 0x1f e_roaming = 2,
MxFloat m_unk0x20; // 0x20 e_createdBrick = 3,
MxFloat m_unk0x24; // 0x24 e_goingToHide = 4,
MxS8 m_unk0x28; // 0x28 e_hiding = 5,
MxFloat m_unk0x2c; // 0x2c };
MxFloat m_unk0x30; // 0x30
LegoAnimActorStruct* m_shootAnim; // 0x34 MxBool m_skipAnimation; // 0x1c
LegoCacheSound* m_unk0x38; // 0x38 MxS8 m_targetLocation; // 0x1d
undefined4 m_unk0x3c; // 0x3c MxU8 m_state; // 0x1e
undefined m_unk0x40; // 0x40 MxBool m_animatingHit; // 0x1f
MxFloat m_unk0x44; // 0x44 MxFloat m_animationDuration; // 0x20
MxS8 m_unk0x48; // 0x48 MxFloat m_createBrickTime; // 0x24
LegoEntity* m_unk0x4c; // 0x4c MxS8 m_baseWorldSpeed; // 0x28
MxFloat m_shootAnimEnd; // 0x2c
MxFloat m_entityAnimationTime; // 0x30
LegoAnimActorStruct* m_shootAnim; // 0x34
LegoCacheSound* m_cachedShootSound; // 0x38
undefined4 m_unk0x3c; // 0x3c
MxBool m_initializing; // 0x40
MxFloat m_resetWorldSpeedAt; // 0x44
MxS8 m_visitedLocations; // 0x48
LegoEntity* m_nextEntity; // 0x4c
}; };
// TEMPLATE: LEGO1 0x100194f0 // TEMPLATE: LEGO1 0x100194f0

View File

@@ -99,7 +99,7 @@ public:
// FUNCTION: LEGO1 0x10002d60 // FUNCTION: LEGO1 0x10002d60
// FUNCTION: BETA10 0x1000f820 // FUNCTION: BETA10 0x1000f820
virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 virtual MxS32 NextTargetLocation() { return 0; } // vtable+0xa0
virtual void VTable0xa4(MxBool& p_und1, MxS32& p_und2); // vtable+0xa4 virtual void VTable0xa4(MxBool& p_und1, MxS32& p_und2); // vtable+0xa4
virtual void VTable0xa8(); // vtable+0xa8 virtual void VTable0xa8(); // vtable+0xa8

View File

@@ -42,95 +42,95 @@ Act2Actor::Location g_brickstrLocations[] = {
}; };
// GLOBAL: LEGO1 0x100f0f1c // GLOBAL: LEGO1 0x100f0f1c
MxFloat g_unk0x100f0f1c = 0.0f; MxFloat g_lastAnimationTime = 0.0f;
// GLOBAL: LEGO1 0x100f0f20 // GLOBAL: LEGO1 0x100f0f20
// GLOBAL: BETA10 0x101dbe40 // GLOBAL: BETA10 0x101dbe40
MxBool g_unk0x100f0f20 = FALSE; MxBool g_nextEntityIsBuilding = FALSE;
// GLOBAL: LEGO1 0x100f0f24 // GLOBAL: LEGO1 0x100f0f24
MxBool g_unk0x100f0f24 = FALSE; MxBool g_unk0x100f0f24 = FALSE;
// GLOBAL: LEGO1 0x100f0f28 // GLOBAL: LEGO1 0x100f0f28
// GLOBAL: BETA10 0x101dbe44 // GLOBAL: BETA10 0x101dbe44
MxBool g_unk0x100f0f28 = FALSE; MxBool g_playedShootSound = FALSE;
// --- All of these are indices into g_plantInfo (0x10103180) --- // --- All of these are indices into g_plantInfo (0x10103180) ---
// GLOBAL: LEGO1 0x100f0f30 // GLOBAL: LEGO1 0x100f0f30
// GLOBAL: BETA10 0x101dbe48 // GLOBAL: BETA10 0x101dbe48
MxS32 g_stage0Plants[] = {2, 23, 32, 66, 71, 72, 73, -1}; MxS32 g_location0Plants[] = {2, 23, 32, 66, 71, 72, 73, -1};
// GLOBAL: LEGO1 0x100f0f50 // GLOBAL: LEGO1 0x100f0f50
// GLOBAL: BETA10 0x101dbe68 // GLOBAL: BETA10 0x101dbe68
MxS32 g_stage1Plants[] = {0, 7, 16, 18, 20, 21, 34, 49, 58, 59, 63, 65, 69, 74, -1}; MxS32 g_location1Plants[] = {0, 7, 16, 18, 20, 21, 34, 49, 58, 59, 63, 65, 69, 74, -1};
// GLOBAL: LEGO1 0x100f0f90 // GLOBAL: LEGO1 0x100f0f90
// GLOBAL: BETA10 0x101dbea8 // GLOBAL: BETA10 0x101dbea8
MxS32 g_stage2Plants[] = {12, 19, 24, 48, 60, -1}; MxS32 g_location2Plants[] = {12, 19, 24, 48, 60, -1};
// GLOBAL: LEGO1 0x100f0fa8 // GLOBAL: LEGO1 0x100f0fa8
// GLOBAL: BETA10 0x101dbec0 // GLOBAL: BETA10 0x101dbec0
MxS32 g_stage3Plants[] = {8, 15, 46, -1}; MxS32 g_location3Plants[] = {8, 15, 46, -1};
// GLOBAL: LEGO1 0x100f0fb8 // GLOBAL: LEGO1 0x100f0fb8
// GLOBAL: BETA10 0x101dbed0 // GLOBAL: BETA10 0x101dbed0
MxS32 g_stage4Plants[] = {25, 26, 28, 29, 38, 39, 42, 50, 51, 56, -1}; MxS32 g_location4Plants[] = {25, 26, 28, 29, 38, 39, 42, 50, 51, 56, -1};
// GLOBAL: LEGO1 0x100f0fe8 // GLOBAL: LEGO1 0x100f0fe8
// GLOBAL: BETA10 0x101dbf00 // GLOBAL: BETA10 0x101dbf00
MxS32 g_stage5Plants[] = {3, 40, 53, 55, -1}; MxS32 g_location5Plants[] = {3, 40, 53, 55, -1};
// GLOBAL: LEGO1 0x100f1000 // GLOBAL: LEGO1 0x100f1000
// GLOBAL: BETA10 0x101dbf18 // GLOBAL: BETA10 0x101dbf18
MxS32 g_stage6Plants[] = {22, 33, 41, 45, 67, -1}; MxS32 g_location6Plants[] = {22, 33, 41, 45, 67, -1};
// GLOBAL: LEGO1 0x100f1018 // GLOBAL: LEGO1 0x100f1018
// GLOBAL: BETA10 0x101dbf30 // GLOBAL: BETA10 0x101dbf30
MxS32 g_stage7Plants[] = {13, 30, 31, 62, -1}; MxS32 g_location7Plants[] = {13, 30, 31, 62, -1};
// GLOBAL: LEGO1 0x100f1030 // GLOBAL: LEGO1 0x100f1030
// GLOBAL: BETA10 0x101dbf48 // GLOBAL: BETA10 0x101dbf48
MxS32 g_stage8Plants[] = {1, 27, 37, 44, 47, 54, 61, 64, -1}; MxS32 g_location8Plants[] = {1, 27, 37, 44, 47, 54, 61, 64, -1};
// --- End of indices into g_plantInfo --- // --- End of indices into g_plantInfo ---
// GLOBAL: LEGO1 0x10102b1c // GLOBAL: LEGO1 0x10102b1c
// GLOBAL: BETA10 0x10209f60 // GLOBAL: BETA10 0x10209f60
undefined4 g_nextHeadWavIndex = 0; MxU32 g_nextHeadWavIndex = 0;
// GLOBAL: LEGO1 0x10102b20 // GLOBAL: LEGO1 0x10102b20
// GLOBAL: BETA10 0x10209f64 // GLOBAL: BETA10 0x10209f64
undefined4 g_nextBehindWavIndex = 0; MxU32 g_nextBehindWavIndex = 0;
// GLOBAL: LEGO1 0x10102b24 // GLOBAL: LEGO1 0x10102b24
// GLOBAL: BETA10 0x10209f68 // GLOBAL: BETA10 0x10209f68
undefined4 g_nextInterruptWavIndex = 0; MxU32 g_nextInterruptWavIndex = 0;
// FUNCTION: LEGO1 0x100187e0 // FUNCTION: LEGO1 0x100187e0
// FUNCTION: BETA10 0x1000c7fb // FUNCTION: BETA10 0x1000c7fb
Act2Actor::Act2Actor() Act2Actor::Act2Actor()
{ {
m_unk0x1c = 0; m_skipAnimation = FALSE;
m_unk0x1d = 0; m_targetLocation = 0;
m_unk0x1f = FALSE; m_animatingHit = FALSE;
m_unk0x24 = 0; m_createBrickTime = 0;
m_unk0x20 = 0; m_animationDuration = 0;
m_unk0x1e = 0; m_state = e_readyToShoot;
m_unk0x28 = 4; m_baseWorldSpeed = 4;
m_unk0x2c = 0; m_shootAnimEnd = 0;
m_unk0x30 = 0; m_entityAnimationTime = 0;
m_shootAnim = NULL; m_shootAnim = NULL;
m_unk0x44 = 0; m_resetWorldSpeedAt = 0;
m_unk0x40 = 1; m_initializing = TRUE;
m_unk0x48 = 0; m_visitedLocations = 0;
m_unk0x4c = NULL; m_nextEntity = NULL;
m_unk0x38 = NULL; m_cachedShootSound = NULL;
m_unk0x3c = 0; m_unk0x3c = 0;
// Odd: The code says < 10, but there are 11 entries in the array // Odd: The code says < 10, but there are 11 entries in the array
for (MxS32 i = 0; i < 10; i++) { for (MxS32 i = 0; i < 10; i++) {
g_brickstrLocations[i].m_unk0x1c = FALSE; g_brickstrLocations[i].m_cleared = FALSE;
} }
} }
@@ -143,7 +143,7 @@ void Act2Actor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2)
// FUNCTION: LEGO1 0x10018980 // FUNCTION: LEGO1 0x10018980
// FUNCTION: BETA10 0x1000c963 // FUNCTION: BETA10 0x1000c963
void Act2Actor::FUN_10018980() void Act2Actor::InitializeNextShot()
{ {
for (MxS32 i = 0; i < m_animMaps.size(); i++) { for (MxS32 i = 0; i < m_animMaps.size(); i++) {
if (m_animMaps[i]->GetWorldSpeed() == -1.0f) { if (m_animMaps[i]->GetWorldSpeed() == -1.0f) {
@@ -153,14 +153,14 @@ void Act2Actor::FUN_10018980()
assert(m_shootAnim); assert(m_shootAnim);
m_unk0x38 = SoundManager()->GetCacheSoundManager()->FindSoundByKey("xarrow"); m_cachedShootSound = SoundManager()->GetCacheSoundManager()->FindSoundByKey("xarrow");
#ifdef BETA10 #ifdef BETA10
// actually 0x2c and 0x30 // actually 0x2c and 0x30
m_unk0x38 = SoundManager()->GetCacheSoundManager()->FindSoundByKey("bcrash"); m_cachedShootSound = SoundManager()->GetCacheSoundManager()->FindSoundByKey("bcrash");
m_unk0x38->SetDistance(35, 60); m_cachedShootSound->SetDistance(35, 60);
m_unk0x38->SetDistance(35, 60); m_cachedShootSound->SetDistance(35, 60);
#else #else
m_unk0x38->SetDistance(45, 55); m_cachedShootSound->SetDistance(45, 55);
m_roi->SetVisibility(TRUE); m_roi->SetVisibility(TRUE);
#endif #endif
} }
@@ -169,9 +169,9 @@ void Act2Actor::FUN_10018980()
// FUNCTION: BETA10 0x1000ca64 // FUNCTION: BETA10 0x1000ca64
MxResult Act2Actor::HitActor(LegoPathActor*, MxBool) MxResult Act2Actor::HitActor(LegoPathActor*, MxBool)
{ {
if (m_unk0x1f == FALSE) { if (m_animatingHit == FALSE) {
m_unk0x1f = TRUE; m_animatingHit = TRUE;
m_unk0x20 = 0; m_animationDuration = 0;
} }
SoundManager()->GetCacheSoundManager()->Play("hitactor", NULL, FALSE); SoundManager()->GetCacheSoundManager()->Play("hitactor", NULL, FALSE);
@@ -187,7 +187,7 @@ MxResult Act2Actor::VTable0x9c()
return SUCCESS; return SUCCESS;
} }
else { else {
if (m_unk0x1f) { if (m_animatingHit) {
MxMatrix matrix = m_roi->GetLocal2World(); MxMatrix matrix = m_roi->GetLocal2World();
matrix[3][1] -= 3.0f; matrix[3][1] -= 3.0f;
m_roi->UpdateTransformationRelativeToParent(matrix); m_roi->UpdateTransformationRelativeToParent(matrix);
@@ -209,28 +209,28 @@ void Act2Actor::Animate(float p_time)
int dummy1; // for BETA10, not sure what it is being used for int dummy1; // for BETA10, not sure what it is being used for
#ifndef BETA10 #ifndef BETA10
MxFloat local48float = 0.0f; MxFloat timeSinceLastAnimate = 0.0f;
if (g_unk0x100f0f1c != 0.0f) { if (g_lastAnimationTime != 0.0f) {
local48float = p_time - g_unk0x100f0f1c; timeSinceLastAnimate = p_time - g_lastAnimationTime;
} }
g_unk0x100f0f1c = p_time; g_lastAnimationTime = p_time;
#endif #endif
LegoAnimActor::Animate(p_time); LegoAnimActor::Animate(p_time);
if (m_unk0x44 != 0.0f && m_unk0x44 < p_time) { if (m_resetWorldSpeedAt != 0.0f && m_resetWorldSpeedAt < p_time) {
SetWorldSpeed(m_unk0x28); SetWorldSpeed(m_baseWorldSpeed);
} }
if (m_unk0x1f) { if (m_animatingHit) {
if (m_unk0x20 > 600.0f) { if (m_animationDuration > 600.0f) {
m_unk0x1f = FALSE; m_animatingHit = FALSE;
m_unk0x20 = 0; m_animationDuration = 0;
} }
else { else {
#ifndef BETA10 #ifndef BETA10
m_unk0x20 += local48float; m_animationDuration += timeSinceLastAnimate;
#endif #endif
MxMatrix matrix = m_roi->GetLocal2World(); MxMatrix matrix = m_roi->GetLocal2World();
matrix[3][1] += 3.0f; matrix[3][1] += 3.0f;
@@ -247,41 +247,41 @@ void Act2Actor::Animate(float p_time)
} }
if (!m_grec) { if (!m_grec) {
if (m_unk0x1e == 2) { if (m_state == e_roaming) {
m_unk0x1e = 0; m_state = e_readyToShoot;
m_unk0x2c = m_shootAnim->GetDuration() + p_time; m_shootAnimEnd = m_shootAnim->GetDuration() + p_time;
m_unk0x30 = m_unk0x2c - 1300.0f; m_entityAnimationTime = m_shootAnimEnd - 1300.0f;
SetWorldSpeed(0); SetWorldSpeed(0);
m_unk0x1c = FALSE; m_skipAnimation = FALSE;
} }
else if (m_unk0x1e == 1) { else if (m_state == e_endShot) {
FindROI("pwrbrik")->SetVisibility(FALSE); FindROI("pwrbrik")->SetVisibility(FALSE);
FindROI("debrick")->SetVisibility(FALSE); FindROI("debrick")->SetVisibility(FALSE);
FindROI("ray")->SetVisibility(FALSE); FindROI("ray")->SetVisibility(FALSE);
m_unk0x4c = NULL; m_nextEntity = NULL;
m_unk0x1e = 2; m_state = e_roaming;
VTable0xa0(); NextTargetLocation();
FUN_10019250(m_unk0x28 + 3, p_time + 3000.0f); SetWorldSpeed(m_baseWorldSpeed + 3, p_time + 3000.0f);
} }
else if (m_unk0x1e == 0) { else if (m_state == e_readyToShoot) {
if (m_unk0x40) { if (m_initializing) {
m_unk0x40 = 0; m_initializing = FALSE;
m_unk0x2c = m_shootAnim->GetDuration() + p_time; m_shootAnimEnd = m_shootAnim->GetDuration() + p_time;
m_unk0x30 = m_unk0x2c - 1300.0f; m_entityAnimationTime = m_shootAnimEnd - 1300.0f;
} }
if (FUN_10019700(p_time) == TRUE) { if (UpdateShot(p_time) == TRUE) {
return; return;
} }
} }
else if (m_unk0x1e == 5) { else if (m_state == e_hiding) {
FindROI("brickstr")->SetVisibility(FALSE); FindROI("brickstr")->SetVisibility(FALSE);
GetROI()->SetVisibility(FALSE); GetROI()->SetVisibility(FALSE);
CurrentWorld()->RemoveActor(this); CurrentWorld()->RemoveActor(this);
return; return;
} }
#ifndef BETA10 #ifndef BETA10
else if (m_unk0x1e == 4) { else if (m_state == e_goingToHide) {
if (m_worldSpeed == 0.0f) { if (m_worldSpeed == 0.0f) {
return; return;
} }
@@ -293,14 +293,14 @@ void Act2Actor::Animate(float p_time)
#endif #endif
} }
if (m_unk0x1e == 5 || m_unk0x1e == 4) { if (m_state == e_hiding || m_state == e_goingToHide) {
return; return;
} }
if (m_unk0x1e == 3) { if (m_state == e_createdBrick) {
if (p_time - m_unk0x24 > 600.0f) { if (p_time - m_createBrickTime > 600.0f) {
m_unk0x1e = 2; m_state = e_roaming;
FUN_10019250(m_unk0x28 + 4, p_time + 15000.0f); SetWorldSpeed(m_baseWorldSpeed + 4, p_time + 15000.0f);
} }
} }
else { else {
@@ -325,38 +325,38 @@ void Act2Actor::Animate(float p_time)
const MxFloat* pepperWorldPosition = roiPepper->GetWorldPosition(); const MxFloat* pepperWorldPosition = roiPepper->GetWorldPosition();
const MxFloat* worldPosition = m_roi->GetWorldPosition(); const MxFloat* worldPosition = m_roi->GetWorldPosition();
MxFloat distance1 = DISTSQRD3(pepperWorldPosition, worldPosition); MxFloat distanceToAmbulance = DISTSQRD3(pepperWorldPosition, worldPosition);
if (distance1 < 75.0f) { if (distanceToAmbulance < 75.0f) {
if (!m_unk0x1c) { if (!m_skipAnimation) {
m_unk0x1c = 1; m_skipAnimation = TRUE;
if (!m_unk0x1e) { if (!m_state) {
FUN_100199f0(2); PlayNextVoiceOver(VoiceOver::e_interrupt);
m_unk0x1e = 1; m_state = e_endShot;
} }
else { else {
LegoROI* childROI = m_roi->FindChildROI("windsd", m_roi); LegoROI* childROI = m_roi->FindChildROI("windsd", m_roi);
const MxFloat* childPosition = childROI->GetWorldPosition(); const MxFloat* childPosition = childROI->GetWorldPosition();
MxFloat distance2 = DISTSQRD3(pepperWorldPosition, childPosition); MxFloat distanceToWindshield = DISTSQRD3(pepperWorldPosition, childPosition);
childROI = m_roi->FindChildROI("reardr", m_roi); childROI = m_roi->FindChildROI("reardr", m_roi);
childPosition = childROI->GetWorldPosition(); childPosition = childROI->GetWorldPosition();
MxFloat distance3 = DISTSQRD3(pepperWorldPosition, childPosition); MxFloat distanceToRearDoor = DISTSQRD3(pepperWorldPosition, childPosition);
if (distance3 > distance2) { if (distanceToRearDoor > distanceToWindshield) {
FUN_100199f0(0); PlayNextVoiceOver(VoiceOver::e_head);
} }
else else
#ifndef BETA10 #ifndef BETA10
if (p_time - m_unk0x24 > 3000.0f) { if (p_time - m_createBrickTime > 3000.0f) {
#endif #endif
SetWorldSpeed(m_unk0x28 - 1); SetWorldSpeed(m_baseWorldSpeed - 1);
m_unk0x1e = 3; m_state = e_createdBrick;
m_unk0x24 = p_time; m_createBrickTime = p_time;
if (((LegoAct2*) CurrentWorld())->CreateBrick() == SUCCESS) { if (((LegoAct2*) CurrentWorld())->CreateBrick() == SUCCESS) {
FUN_100199f0(1); PlayNextVoiceOver(VoiceOver::e_behind);
} }
#ifndef BETA10 #ifndef BETA10
} }
@@ -365,8 +365,8 @@ void Act2Actor::Animate(float p_time)
} }
} }
else { else {
if (m_unk0x1c) { if (m_skipAnimation) {
m_unk0x1c = 0; m_skipAnimation = FALSE;
} }
} }
} }
@@ -377,11 +377,11 @@ void Act2Actor::Animate(float p_time)
// FUNCTION: LEGO1 0x10019250 // FUNCTION: LEGO1 0x10019250
// FUNCTION: BETA10 0x1000d45c // FUNCTION: BETA10 0x1000d45c
void Act2Actor::FUN_10019250(MxFloat p_speed, MxFloat p_param2) void Act2Actor::SetWorldSpeed(MxFloat p_speed, MxFloat p_resetWorldSpeedAt)
{ {
// The arguments have been changed from BETA10 to LEGO1 // The arguments have been changed from BETA10 to LEGO1
SetWorldSpeed(p_speed); SetWorldSpeed(p_speed);
m_unk0x44 = p_param2; m_resetWorldSpeedAt = p_resetWorldSpeedAt;
} }
// FUNCTION: LEGO1 0x10019280 // FUNCTION: LEGO1 0x10019280
@@ -389,12 +389,12 @@ void Act2Actor::FUN_10019250(MxFloat p_speed, MxFloat p_param2)
void Act2Actor::SetWorldSpeed(MxFloat p_worldSpeed) void Act2Actor::SetWorldSpeed(MxFloat p_worldSpeed)
{ {
LegoAnimActor::SetWorldSpeed(p_worldSpeed); LegoAnimActor::SetWorldSpeed(p_worldSpeed);
m_unk0x44 = 0; m_resetWorldSpeedAt = 0;
} }
// FUNCTION: LEGO1 0x100192a0 // FUNCTION: LEGO1 0x100192a0
// FUNCTION: BETA10 0x1000d4d6 // FUNCTION: BETA10 0x1000d4d6
void Act2Actor::FUN_100192a0(undefined4 p_location) void Act2Actor::FindPath(MxU32 p_location)
{ {
Mx3DPointFloat newPosition(0.0, 0.0, 0.0); Mx3DPointFloat newPosition(0.0, 0.0, 0.0);
Mx3DPointFloat newDirection(0.0, 0.0, 0.0); Mx3DPointFloat newDirection(0.0, 0.0, 0.0);
@@ -431,37 +431,37 @@ void Act2Actor::FUN_100192a0(undefined4 p_location)
} }
// FUNCTION: LEGO1 0x10019520 // FUNCTION: LEGO1 0x10019520
void Act2Actor::FUN_10019520() void Act2Actor::GoingToHide()
{ {
m_unk0x1e = 4; m_state = e_goingToHide;
SetWorldSpeed(m_unk0x28 + 3); SetWorldSpeed(m_baseWorldSpeed + 3);
FUN_100192a0(10); FindPath(10);
} }
// FUNCTION: LEGO1 0x10019560 // FUNCTION: LEGO1 0x10019560
void Act2Actor::FUN_10019560() void Act2Actor::Hide()
{ {
m_unk0x1e = 5; m_state = e_hiding;
SetWorldSpeed(m_unk0x28 + 5); SetWorldSpeed(m_baseWorldSpeed + 5);
FUN_100192a0(9); FindPath(9);
} }
// FUNCTION: LEGO1 0x100195a0 // FUNCTION: LEGO1 0x100195a0
// FUNCTION: BETA10 0x1000d7d3 // FUNCTION: BETA10 0x1000d7d3
MxS32 Act2Actor::VTable0xa0() MxS32 Act2Actor::NextTargetLocation()
{ {
undefined4 newLocation; MxU32 newLocation;
assert(!m_grec); assert(!m_grec);
CurrentWorld(); CurrentWorld();
MxU16 randomVal = rand() / (RAND_MAX / 2) + 1; MxU16 randomVal = rand() / (RAND_MAX / 2) + 1;
if (m_unk0x48 == 8 && m_unk0x1d != 8) { if (m_visitedLocations == 8 && m_targetLocation != 8) {
newLocation = 8; newLocation = 8;
} }
else { else {
switch (m_unk0x1d) { switch (m_targetLocation) {
case 0: case 0:
if (randomVal == 1) { if (randomVal == 1) {
newLocation = 3; newLocation = 3;
@@ -536,10 +536,10 @@ MxS32 Act2Actor::VTable0xa0()
} }
} }
undefined4 firstChoice = newLocation; MxU32 firstChoice = newLocation;
if (m_unk0x48 < 7 || g_brickstrLocations[m_unk0x1d].m_unk0x1c) { if (m_visitedLocations < 7 || g_brickstrLocations[m_targetLocation].m_cleared) {
while (g_brickstrLocations[newLocation].m_unk0x1c || m_unk0x1d == newLocation) { while (g_brickstrLocations[newLocation].m_cleared || m_targetLocation == newLocation) {
if (newLocation == 7) { if (newLocation == 7) {
newLocation = 0; newLocation = 0;
} }
@@ -551,8 +551,8 @@ MxS32 Act2Actor::VTable0xa0()
} }
} }
m_unk0x1d = newLocation; m_targetLocation = newLocation;
FUN_100192a0(newLocation); FindPath(newLocation);
if (m_grec) { if (m_grec) {
return SUCCESS; return SUCCESS;
@@ -564,64 +564,64 @@ MxS32 Act2Actor::VTable0xa0()
// FUNCTION: LEGO1 0x10019700 // FUNCTION: LEGO1 0x10019700
// FUNCTION: BETA10 0x1000dd27 // FUNCTION: BETA10 0x1000dd27
MxU32 Act2Actor::FUN_10019700(MxFloat p_param) MxU32 Act2Actor::UpdateShot(MxFloat p_time)
{ {
if (!m_unk0x4c) { if (!m_nextEntity) {
g_unk0x100f0f20 = FALSE; g_nextEntityIsBuilding = FALSE;
m_unk0x4c = FUN_10019b90(&g_unk0x100f0f20); m_nextEntity = GetNextEntity(&g_nextEntityIsBuilding);
g_unk0x100f0f24 = FALSE; g_unk0x100f0f24 = FALSE;
g_unk0x100f0f28 = FALSE; g_playedShootSound = FALSE;
} }
if (!m_unk0x4c) { if (!m_nextEntity) {
MxTrace("nothing left to destroy at location %d\n", m_unk0x1d); MxTrace("nothing left to destroy at location %d\n", m_targetLocation);
m_unk0x1e = 1; m_state = e_endShot;
if (m_unk0x1d == 8) { if (m_targetLocation == 8) {
((LegoAct2*) CurrentWorld())->BadEnding(); ((LegoAct2*) CurrentWorld())->BadEnding();
} }
return TRUE; return TRUE;
} }
if (!g_unk0x100f0f28 && m_unk0x30 < p_param) { if (!g_playedShootSound && m_entityAnimationTime < p_time) {
g_unk0x100f0f28 = TRUE; g_playedShootSound = TRUE;
assert(SoundManager()->GetCacheSoundManager()); assert(SoundManager()->GetCacheSoundManager());
SoundManager()->GetCacheSoundManager()->Play(m_unk0x38, "brickstr", FALSE); SoundManager()->GetCacheSoundManager()->Play(m_cachedShootSound, "brickstr", FALSE);
if (g_unk0x100f0f20) { if (g_nextEntityIsBuilding) {
BuildingManager()->ScheduleAnimation(m_unk0x4c, 800, TRUE, FALSE); BuildingManager()->ScheduleAnimation(m_nextEntity, 800, TRUE, FALSE);
} }
else { else {
PlantManager()->ScheduleAnimation(m_unk0x4c, 800); PlantManager()->ScheduleAnimation(m_nextEntity, 800);
} }
} }
if (m_unk0x2c < p_param) { if (m_shootAnimEnd < p_time) {
g_unk0x100f0f20 = FALSE; g_nextEntityIsBuilding = FALSE;
m_unk0x4c = FUN_10019b90(&g_unk0x100f0f20); m_nextEntity = GetNextEntity(&g_nextEntityIsBuilding);
m_unk0x2c = m_shootAnim->GetDuration() + p_param; m_shootAnimEnd = m_shootAnim->GetDuration() + p_time;
m_unk0x30 = m_unk0x2c - 1300.0f; m_entityAnimationTime = m_shootAnimEnd - 1300.0f;
g_unk0x100f0f24 = FALSE; g_unk0x100f0f24 = FALSE;
g_unk0x100f0f28 = FALSE; g_playedShootSound = FALSE;
return FALSE; return FALSE;
} }
m_lastTime = p_param; m_lastTime = p_time;
LegoROI* brickstrROI = FindROI("brickstr"); LegoROI* brickstrROI = FindROI("brickstr");
MxMatrix matrix = m_roi->GetLocal2World(); MxMatrix initialTransform = m_roi->GetLocal2World();
matrix[3][1] += 1.0f; initialTransform[3][1] += 1.0f;
brickstrROI->SetLocal2World(matrix); brickstrROI->SetLocal2World(initialTransform);
brickstrROI->WrappedUpdateWorldData(); brickstrROI->WrappedUpdateWorldData();
Vector3 col0(matrix[0]); Vector3 col0(initialTransform[0]);
Vector3 col1(matrix[1]); Vector3 col1(initialTransform[1]);
Vector3 col2(matrix[2]); Vector3 col2(initialTransform[2]);
Vector3 col3(matrix[3]); Vector3 col3(initialTransform[3]);
col2 = col3; col2 = col3;
col2 -= m_unk0x4c->GetROI()->GetWorldPosition(); col2 -= m_nextEntity->GetROI()->GetWorldPosition();
col2.Unitize(); col2.Unitize();
col0.EqualsCross(col1, col2); col0.EqualsCross(col1, col2);
col0.Unitize(); col0.Unitize();
@@ -630,10 +630,10 @@ MxU32 Act2Actor::FUN_10019700(MxFloat p_param)
assert(!m_cameraFlag); assert(!m_cameraFlag);
LegoTreeNode* root = m_shootAnim->GetAnimTreePtr()->GetRoot(); LegoTreeNode* root = m_shootAnim->GetAnimTreePtr()->GetRoot();
MxFloat time = p_param - (m_unk0x2c - m_shootAnim->GetDuration()); MxFloat time = p_time - (m_shootAnimEnd - m_shootAnim->GetDuration());
for (MxS32 i = 0; i < root->GetNumChildren(); i++) { for (MxS32 i = 0; i < root->GetNumChildren(); i++) {
LegoROI::ApplyAnimationTransformation(root->GetChild(i), matrix, time, m_shootAnim->GetROIMap()); LegoROI::ApplyAnimationTransformation(root->GetChild(i), initialTransform, time, m_shootAnim->GetROIMap());
} }
return FALSE; return FALSE;
@@ -641,10 +641,10 @@ MxU32 Act2Actor::FUN_10019700(MxFloat p_param)
// FUNCTION: LEGO1 0x100199f0 // FUNCTION: LEGO1 0x100199f0
// FUNCTION: BETA10 0x1000e11a // FUNCTION: BETA10 0x1000e11a
void Act2Actor::FUN_100199f0(MxS8 p_param) void Act2Actor::PlayNextVoiceOver(MxS8 p_voiceOverType)
{ {
switch (p_param) { switch (p_voiceOverType) {
case 0: case VoiceOver::e_head:
switch (g_nextHeadWavIndex) { switch (g_nextHeadWavIndex) {
case 0: case 0:
((LegoAct2*) CurrentWorld()) ((LegoAct2*) CurrentWorld())
@@ -659,7 +659,7 @@ void Act2Actor::FUN_100199f0(MxS8 p_param)
break; break;
} }
break; break;
case 1: case VoiceOver::e_behind:
switch (g_nextBehindWavIndex) { switch (g_nextBehindWavIndex) {
case 0: case 0:
((LegoAct2*) CurrentWorld()) ((LegoAct2*) CurrentWorld())
@@ -683,7 +683,7 @@ void Act2Actor::FUN_100199f0(MxS8 p_param)
break; break;
} }
break; break;
case 2: case VoiceOver::e_interrupt:
switch (g_nextInterruptWavIndex) { switch (g_nextInterruptWavIndex) {
case 0: case 0:
((LegoAct2*) CurrentWorld()) ((LegoAct2*) CurrentWorld())
@@ -711,27 +711,27 @@ void Act2Actor::FUN_100199f0(MxS8 p_param)
// FUNCTION: LEGO1 0x10019b90 // FUNCTION: LEGO1 0x10019b90
// FUNCTION: BETA10 0x1000e374 // FUNCTION: BETA10 0x1000e374
LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param) LegoEntity* Act2Actor::GetNextEntity(MxBool* p_isBuilding)
{ {
MxS32 i; MxS32 i;
LegoBuildingInfo* buildingInfo = BuildingManager()->GetInfoArray(i); LegoBuildingInfo* buildingInfo = BuildingManager()->GetInfoArray(i);
LegoPlantInfo* plantInfo = PlantManager()->GetInfoArray(i); LegoPlantInfo* plantInfo = PlantManager()->GetInfoArray(i);
LegoEntity* result = 0; LegoEntity* result = 0;
switch (m_unk0x1d) { switch (m_targetLocation) {
case 0: case 0:
if (buildingInfo[12].m_counter) { if (buildingInfo[12].m_counter) {
result = buildingInfo[12].m_entity; result = buildingInfo[12].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else if (buildingInfo[14].m_counter) { else if (buildingInfo[14].m_counter) {
result = buildingInfo[14].m_entity; result = buildingInfo[14].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage0Plants[i] != -1; i++) { for (i = 0; g_location0Plants[i] != -1; i++) {
if (plantInfo[g_stage0Plants[i]].m_counter) { if (plantInfo[g_location0Plants[i]].m_counter) {
result = plantInfo[g_stage0Plants[i]].m_entity; result = plantInfo[g_location0Plants[i]].m_entity;
break; break;
} }
} }
@@ -740,12 +740,12 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 1: case 1:
if (buildingInfo[13].m_counter) { if (buildingInfo[13].m_counter) {
result = buildingInfo[13].m_entity; result = buildingInfo[13].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage1Plants[i] != -1; i++) { for (i = 0; g_location1Plants[i] != -1; i++) {
if (plantInfo[g_stage1Plants[i]].m_counter) { if (plantInfo[g_location1Plants[i]].m_counter) {
result = plantInfo[g_stage1Plants[i]].m_entity; result = plantInfo[g_location1Plants[i]].m_entity;
break; break;
} }
} }
@@ -754,16 +754,16 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 2: case 2:
if (buildingInfo[9].m_counter) { if (buildingInfo[9].m_counter) {
result = buildingInfo[9].m_entity; result = buildingInfo[9].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else if (buildingInfo[11].m_counter) { else if (buildingInfo[11].m_counter) {
result = buildingInfo[11].m_entity; result = buildingInfo[11].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage2Plants[i] != -1; i++) { for (i = 0; g_location2Plants[i] != -1; i++) {
if (plantInfo[g_stage2Plants[i]].m_counter) { if (plantInfo[g_location2Plants[i]].m_counter) {
result = plantInfo[g_stage2Plants[i]].m_entity; result = plantInfo[g_location2Plants[i]].m_entity;
break; break;
} }
} }
@@ -772,20 +772,20 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 3: case 3:
if (buildingInfo[7].m_counter) { if (buildingInfo[7].m_counter) {
result = buildingInfo[7].m_entity; result = buildingInfo[7].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else if (buildingInfo[8].m_counter) { else if (buildingInfo[8].m_counter) {
result = buildingInfo[8].m_entity; result = buildingInfo[8].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else if (buildingInfo[3].m_counter) { else if (buildingInfo[3].m_counter) {
result = buildingInfo[3].m_entity; result = buildingInfo[3].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage3Plants[i] != -1; i++) { for (i = 0; g_location3Plants[i] != -1; i++) {
if (plantInfo[g_stage3Plants[i]].m_counter) { if (plantInfo[g_location3Plants[i]].m_counter) {
result = plantInfo[g_stage3Plants[i]].m_entity; result = plantInfo[g_location3Plants[i]].m_entity;
break; break;
} }
} }
@@ -794,16 +794,16 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 4: case 4:
if (buildingInfo[5].m_counter) { if (buildingInfo[5].m_counter) {
result = buildingInfo[5].m_entity; result = buildingInfo[5].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else if (buildingInfo[10].m_counter) { else if (buildingInfo[10].m_counter) {
result = buildingInfo[10].m_entity; result = buildingInfo[10].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage4Plants[i] != -1; i++) { for (i = 0; g_location4Plants[i] != -1; i++) {
if (plantInfo[g_stage4Plants[i]].m_counter) { if (plantInfo[g_location4Plants[i]].m_counter) {
result = plantInfo[g_stage4Plants[i]].m_entity; result = plantInfo[g_location4Plants[i]].m_entity;
break; break;
} }
} }
@@ -812,12 +812,12 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 5: case 5:
if (buildingInfo[4].m_counter) { if (buildingInfo[4].m_counter) {
result = buildingInfo[4].m_entity; result = buildingInfo[4].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage5Plants[i] != -1; i++) { for (i = 0; g_location5Plants[i] != -1; i++) {
if (plantInfo[g_stage5Plants[i]].m_counter) { if (plantInfo[g_location5Plants[i]].m_counter) {
result = plantInfo[g_stage5Plants[i]].m_entity; result = plantInfo[g_location5Plants[i]].m_entity;
break; break;
} }
} }
@@ -826,12 +826,12 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 6: case 6:
if (buildingInfo[2].m_counter) { if (buildingInfo[2].m_counter) {
result = buildingInfo[2].m_entity; result = buildingInfo[2].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage6Plants[i] != -1; i++) { for (i = 0; g_location6Plants[i] != -1; i++) {
if (plantInfo[g_stage6Plants[i]].m_counter) { if (plantInfo[g_location6Plants[i]].m_counter) {
result = plantInfo[g_stage6Plants[i]].m_entity; result = plantInfo[g_location6Plants[i]].m_entity;
break; break;
} }
} }
@@ -840,21 +840,21 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
case 7: case 7:
if (buildingInfo[6].m_counter) { if (buildingInfo[6].m_counter) {
result = buildingInfo[6].m_entity; result = buildingInfo[6].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
else { else {
for (i = 0; g_stage7Plants[i] != -1; i++) { for (i = 0; g_location7Plants[i] != -1; i++) {
if (plantInfo[g_stage7Plants[i]].m_counter) { if (plantInfo[g_location7Plants[i]].m_counter) {
result = plantInfo[g_stage7Plants[i]].m_entity; result = plantInfo[g_location7Plants[i]].m_entity;
break; break;
} }
} }
} }
break; break;
case 8: case 8:
for (i = 0; g_stage8Plants[i] != -1; i++) { for (i = 0; g_location8Plants[i] != -1; i++) {
if (plantInfo[g_stage8Plants[i]].m_counter) { if (plantInfo[g_location8Plants[i]].m_counter) {
result = plantInfo[g_stage8Plants[i]].m_entity; result = plantInfo[g_location8Plants[i]].m_entity;
break; break;
} }
} }
@@ -865,14 +865,14 @@ LegoEntity* Act2Actor::FUN_10019b90(MxBool* p_param)
if (buildingInfo[15].m_counter) { if (buildingInfo[15].m_counter) {
result = buildingInfo[15].m_entity; result = buildingInfo[15].m_entity;
*p_param = TRUE; *p_isBuilding = TRUE;
} }
break; break;
} }
if (!result && !g_brickstrLocations[m_unk0x1d].m_unk0x1c) { if (!result && !g_brickstrLocations[m_targetLocation].m_cleared) {
g_brickstrLocations[m_unk0x1d].m_unk0x1c = TRUE; g_brickstrLocations[m_targetLocation].m_cleared = TRUE;
m_unk0x48++; m_visitedLocations++;
} }
return result; return result;

View File

@@ -246,7 +246,7 @@ MxResult LegoAct2::Tickle()
else { else {
m_state = LegoAct2::e_goingToHide; m_state = LegoAct2::e_goingToHide;
m_timeSinceLastStage = 0; m_timeSinceLastStage = 0;
m_unk0x1138->FUN_10019520(); m_unk0x1138->GoingToHide();
} }
} }
@@ -631,7 +631,7 @@ MxLong LegoAct2::HandlePathStruct(LegoPathStructNotificationParam& p_param)
m_currentAction = Act2mainScript::c_VOhide_PlayWav; m_currentAction = Act2mainScript::c_VOhide_PlayWav;
} }
m_unk0x1138->FUN_10019560(); m_unk0x1138->Hide();
m_state = LegoAct2::e_hidden; m_state = LegoAct2::e_hidden;
m_timeSinceLastStage = 0; m_timeSinceLastStage = 0;
@@ -1223,6 +1223,6 @@ MxResult LegoAct2::InitializeShooting()
ap->FUN_1006d680(m_unk0x1138, -1.0f); ap->FUN_1006d680(m_unk0x1138, -1.0f);
actor->SetWorldSpeed(0.0f); actor->SetWorldSpeed(0.0f);
m_unk0x1138->FUN_10018980(); m_unk0x1138->InitializeNextShot();
return SUCCESS; return SUCCESS;
} }