mirror of https://github.com/AxioDL/metaforce.git
CScriptMazeNode: Working implementation
This commit is contained in:
parent
2cca2b8513
commit
eb124a9470
|
@ -2749,9 +2749,9 @@ TUniqueId CStateManager::AllocateUniqueId() {
|
||||||
s16 ourIndex;
|
s16 ourIndex;
|
||||||
do {
|
do {
|
||||||
ourIndex = x0_nextFreeIndex;
|
ourIndex = x0_nextFreeIndex;
|
||||||
x0_nextFreeIndex = (x0_nextFreeIndex + 1) & 0x3ff;
|
x0_nextFreeIndex = (ourIndex + 1) & 0x3ff;
|
||||||
if (x0_nextFreeIndex == lastIndex) {
|
if (x0_nextFreeIndex == lastIndex) {
|
||||||
LogModule.report(logvisor::Fatal, FMT_STRING("Object List Full!"));
|
LogModule.report(logvisor::Fatal, FMT_STRING("Object list full!"));
|
||||||
}
|
}
|
||||||
} while (GetAllObjectList().GetObjectByIndex(ourIndex) != nullptr);
|
} while (GetAllObjectList().GetObjectByIndex(ourIndex) != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Runtime/World/CScriptMazeNode.hpp"
|
#include "Runtime/World/CScriptMazeNode.hpp"
|
||||||
|
|
||||||
#include "Runtime/Character/CModelData.hpp"
|
|
||||||
#include "Runtime/CStateManager.hpp"
|
#include "Runtime/CStateManager.hpp"
|
||||||
|
#include "Runtime/Character/CModelData.hpp"
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/World/CActorParameters.hpp"
|
#include "Runtime/World/CActorParameters.hpp"
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ CScriptMazeNode::CScriptMazeNode(TUniqueId uid, std::string_view name, const CEn
|
||||||
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(),
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(),
|
||||||
kInvalidUniqueId)
|
kInvalidUniqueId)
|
||||||
, xe8_col(w1)
|
, xe8_col(w1)
|
||||||
, xec_row(w1)
|
, xec_row(w2)
|
||||||
, xf0_(w2)
|
, xf0_(w3)
|
||||||
, x100_actorPos(actorPos)
|
, x100_actorPos(actorPos)
|
||||||
, x110_triggerPos(triggerPos)
|
, x110_triggerPos(triggerPos)
|
||||||
, x120_effectPos(effectPos) {}
|
, x120_effectPos(effectPos) {}
|
||||||
|
@ -68,6 +68,7 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
|
||||||
actor->SetTranslation(origin + x120_effectPos);
|
actor->SetTranslation(origin + x120_effectPos);
|
||||||
mgr.SendScriptMsg(actor, GetUniqueId(), EScriptObjectMessage::Activate);
|
mgr.SendScriptMsg(actor, GetUniqueId(), EScriptObjectMessage::Activate);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x13c_24_) {
|
if (x13c_24_) {
|
||||||
|
@ -376,14 +377,15 @@ void CScriptMazeState::sub_802899c8() {
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 iVar5 = x0_rand.Next();
|
auto GetRandom = [this](s32 offset) constexpr {
|
||||||
s32 iVar1 = ((iVar5 / 5) * -5) + 9;
|
s32 tmp = x0_rand.Next();
|
||||||
s32 iVar6 = x0_rand.Next();
|
return tmp + ((tmp / 5) * -5) + offset;
|
||||||
s32 iVar2 = ((iVar6 / 5) * -5) + 21;
|
};
|
||||||
s32 iVar7 = x0_rand.Next();
|
s32 rand1 = GetRandom(9);
|
||||||
s32 iVar3 = ((iVar7 / 5) * -5) + 33;
|
s32 rand2 = GetRandom(21);
|
||||||
s32 iVar16 = ((x0_rand.Next() / 5) * -5) + 13;
|
s32 rand3 = GetRandom(33);
|
||||||
s32 iVar9 = ((x0_rand.Next() / 5) * -5) + 29;
|
s32 rand4 = GetRandom(13);
|
||||||
|
s32 rand5 = GetRandom(29);
|
||||||
|
|
||||||
u32 uVar10 = -1;
|
u32 uVar10 = -1;
|
||||||
s32 idx = 0;
|
s32 idx = 0;
|
||||||
|
@ -395,7 +397,7 @@ void CScriptMazeState::sub_802899c8() {
|
||||||
|
|
||||||
s32 nextCol;
|
s32 nextCol;
|
||||||
while (col != x8c_ || row != x90_) {
|
while (col != x8c_ || row != x90_) {
|
||||||
if (idx == iVar5 + iVar1 || idx == iVar6 + iVar2 || idx == iVar7 + iVar3) {
|
if (idx == rand1 || idx == rand2 || idx == rand3) {
|
||||||
if (uVar10 == 2) {
|
if (uVar10 == 2) {
|
||||||
GetCell(col, row).x0_28_ = true;
|
GetCell(col, row).x0_28_ = true;
|
||||||
GetCell(prevCol, prevRow).x0_30_ = true;
|
GetCell(prevCol, prevRow).x0_30_ = true;
|
||||||
|
@ -444,12 +446,12 @@ void CScriptMazeState::sub_802899c8() {
|
||||||
uVar10 = 0;
|
uVar10 = 0;
|
||||||
nextRow = row - 1;
|
nextRow = row - 1;
|
||||||
}
|
}
|
||||||
if (idx == iVar16 || idx == iVar9) {
|
if (idx == rand4 || idx == rand5) {
|
||||||
if (col == 0 || row == 0 || col == 8 || row == 6) {
|
if (col == 0 || row == 0 || col == 8 || row == 6) {
|
||||||
if (idx == iVar16) {
|
if (idx == rand4) {
|
||||||
iVar16++;
|
rand4++;
|
||||||
} else {
|
} else {
|
||||||
iVar9++;
|
rand5++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto& cell = GetCell(col, row);
|
auto& cell = GetCell(col, row);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class CScriptMazeNode : public CActor {
|
||||||
s32 xec_row;
|
s32 xec_row;
|
||||||
s32 xf0_;
|
s32 xf0_;
|
||||||
TUniqueId xf4_ = kInvalidUniqueId;
|
TUniqueId xf4_ = kInvalidUniqueId;
|
||||||
float xf8_msgTimer = 0.f;
|
float xf8_msgTimer = 1.f;
|
||||||
TUniqueId xfc_actorId = kInvalidUniqueId;
|
TUniqueId xfc_actorId = kInvalidUniqueId;
|
||||||
zeus::CVector3f x100_actorPos;
|
zeus::CVector3f x100_actorPos;
|
||||||
TUniqueId x10c_triggerId = kInvalidUniqueId;
|
TUniqueId x10c_triggerId = kInvalidUniqueId;
|
||||||
|
@ -62,13 +62,14 @@ class CScriptMazeNode : public CActor {
|
||||||
TUniqueId x11c_effectId = kInvalidUniqueId;
|
TUniqueId x11c_effectId = kInvalidUniqueId;
|
||||||
zeus::CVector3f x120_effectPos;
|
zeus::CVector3f x120_effectPos;
|
||||||
std::vector<TUniqueId> x12c_;
|
std::vector<TUniqueId> x12c_;
|
||||||
bool x13c_24_ : 1 = true;
|
bool x13c_24_ : 1 = false;
|
||||||
bool x13c_25_ : 1 = false;
|
bool x13c_25_ : 1 = false;
|
||||||
bool x13c_26_ : 1 = false;
|
bool x13c_26_ : 1 = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScriptMazeNode(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, bool, s32, s32, s32,
|
CScriptMazeNode(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&);
|
bool active, s32 w1, s32 w2, s32 w3, const zeus::CVector3f& actorPos,
|
||||||
|
const zeus::CVector3f& triggerPos, const zeus::CVector3f& effectPos);
|
||||||
|
|
||||||
void Accept(IVisitor& visitor) override;
|
void Accept(IVisitor& visitor) override;
|
||||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
||||||
|
|
Loading…
Reference in New Issue