diff --git a/Runtime/MP1/CBeetle.cpp b/Runtime/MP1/CBeetle.cpp new file mode 100644 index 000000000..da4d6243a --- /dev/null +++ b/Runtime/MP1/CBeetle.cpp @@ -0,0 +1,20 @@ +#include "CBeetle.hpp" +#include "World/CDamageInfo.hpp" + +namespace urde +{ +namespace MP1 +{ + +CBeetle::CBeetle(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, + const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CBeetle::EEntranceType, const CDamageInfo&, + const CDamageVulnerability&, const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, + const CActorParameters& aParams, const rstl::optional_object) + : CPatterned(EUnknown::Three, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, + EColliderType::One, EBodyType::One, aParams, bool(flavor)) +{ + +} + +} +} diff --git a/Runtime/MP1/CBeetle.hpp b/Runtime/MP1/CBeetle.hpp new file mode 100644 index 000000000..32b8c4bb3 --- /dev/null +++ b/Runtime/MP1/CBeetle.hpp @@ -0,0 +1,28 @@ +#ifndef CBEETLE_HPP +#define CBEETLE_HPP + +#include "World/CPatterned.hpp" + +namespace urde +{ +class CDamageInfo; + +namespace MP1 +{ +class CBeetle : public CPatterned +{ +public: + enum EEntranceType + { + }; +private: +public: + CBeetle(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, + const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&, + const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&, + const rstl::optional_object); +}; +} +} + +#endif // CBEETLE_HPP diff --git a/Runtime/MP1/CMakeLists.txt b/Runtime/MP1/CMakeLists.txt index 1d053f4f8..40d0fe6b2 100644 --- a/Runtime/MP1/CMakeLists.txt +++ b/Runtime/MP1/CMakeLists.txt @@ -7,6 +7,7 @@ set(MP1_SOURCES CPlayMovie.hpp CPlayMovie.cpp CFrontEndUI.hpp CFrontEndUI.cpp CNewIntroBoss.hpp CNewIntroBoss.cpp + CBeetle.hpp CBeetle.cpp CWarWasp.hpp CWarWasp.cpp MP1.hpp MP1.cpp) diff --git a/Runtime/MP1/CNewIntroBoss.cpp b/Runtime/MP1/CNewIntroBoss.cpp index 82232b07b..d720075c6 100644 --- a/Runtime/MP1/CNewIntroBoss.cpp +++ b/Runtime/MP1/CNewIntroBoss.cpp @@ -10,7 +10,7 @@ CNewIntroBoss::CNewIntroBoss(TUniqueId uid, const std::string& name, const CEnti const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo, u32, u32, u32, u32) : CPatterned(EUnknown::TwentyThree, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, - EMovementType::Flyer, EColliderType::One, EBodyType::Two, actParms, 1) + EMovementType::Flyer, EColliderType::One, EBodyType::Two, actParms, true) { } diff --git a/Runtime/MP1/CWarWasp.cpp b/Runtime/MP1/CWarWasp.cpp index 13021eccd..e5cdc85c3 100644 --- a/Runtime/MP1/CWarWasp.cpp +++ b/Runtime/MP1/CWarWasp.cpp @@ -9,7 +9,7 @@ CWarWasp::CWarWasp(TUniqueId uid, const std::string& name, const CEntityInfo& in CPatterned::EColliderType collider, const CDamageInfo& dInfo1, const CActorParameters& actorParms, ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3) : CPatterned(EUnknown::ThirtyNine, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, collider, EBodyType::Three, - actorParms, 0) + actorParms, false) { } diff --git a/Runtime/World/CAiFuncMap.hpp b/Runtime/World/CAiFuncMap.hpp index 0d21e4fed..db04e13e7 100644 --- a/Runtime/World/CAiFuncMap.hpp +++ b/Runtime/World/CAiFuncMap.hpp @@ -16,8 +16,8 @@ typedef void (CAi::*CAiStateFunc)(CStateManager&, EStateMsg, float); typedef bool (CAi::*CAiTriggerFunc)(CStateManager&, float); class CAiFuncMap { - std::map x0_stateFuncs; - std::map x10_triggerFuncs; + std::unordered_map x0_stateFuncs; + std::unordered_map x10_triggerFuncs; public: CAiFuncMap(); CAiStateFunc GetStateFunc(const char*); diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index 5d5296f8d..7718794b0 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -37,6 +37,9 @@ set(WORLD_SOURCES CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp CScriptCameraHint.hpp CScriptCameraHint.cpp CScriptPickup.hpp CScriptPickup.cpp + CScriptMemoryRelay.hpp CScriptMemoryRelay.cpp + CScriptRandomRelay.hpp CScriptRandomRelay.cpp + CScriptRelay.hpp CScriptRelay.cpp CScriptDamageableTrigger.hpp CScriptDamageableTrigger.cpp CScriptActorRotate.hpp CScriptActorRotate.cpp CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index b7c0c30f9..b84424640 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -17,7 +17,7 @@ CMaterialList gkPatternedFlyerMaterialList(EMaterialTypes::ThirtyThree, CPatterned::CPatterned(EUnknown, TUniqueId uid, const std::string& name, CPatterned::EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EMovementType moveType, CPatterned::EColliderType, - EBodyType, const CActorParameters& actorParms, u32) + EBodyType, const CActorParameters& actorParms, bool) : CAi(uid, pInfo.xf8_active, name, info, xf, std::move(mData), zeus::CAABox(pInfo.xcc_bodyOrigin - zeus::CVector3f{pInfo.xc4_halfExtent, pInfo.xc4_halfExtent, 0.f}, pInfo.xcc_bodyOrigin + zeus::CVector3f{pInfo.xc4_halfExtent, pInfo.xc4_halfExtent, pInfo.xc8_height}), diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index 848ac62b0..41d910365 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -9,6 +9,7 @@ class CPatternedInfo; enum class EBodyType { + One, Two = 2, Three }; @@ -18,12 +19,14 @@ class CPatterned : public CAi public: enum class EUnknown { + Three = 3, TwentyThree = 23, ThirtyNine }; enum class EFlavorType { - Zero = 0 + Zero = 0, + One = 1 }; enum class EMovementType { @@ -40,7 +43,7 @@ public: CPatterned(EUnknown unk, TUniqueId uid, const std::string& name, EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo, CPatterned::EMovementType movement, EColliderType collider, - EBodyType body, const CActorParameters& params, u32 w1); + EBodyType body, const CActorParameters& params, bool b1); virtual void Death(const zeus::CVector3f& , CStateManager& ) {} virtual void KnockBack(const zeus::CVector3f &, CStateManager &) {} diff --git a/Runtime/World/CScriptMemoryRelay.cpp b/Runtime/World/CScriptMemoryRelay.cpp new file mode 100644 index 000000000..7af52d1a0 --- /dev/null +++ b/Runtime/World/CScriptMemoryRelay.cpp @@ -0,0 +1,14 @@ +#include "CScriptMemoryRelay.hpp" + +namespace urde +{ + +CScriptMemoryRelay::CScriptMemoryRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, bool b1, bool b2, bool b3) + : CEntity(uid, info, true, name), + x34_24_(b1), + x34_25_(b2), + x34_26_(b3) +{ +} + +} diff --git a/Runtime/World/CScriptMemoryRelay.hpp b/Runtime/World/CScriptMemoryRelay.hpp new file mode 100644 index 000000000..34ff8cd17 --- /dev/null +++ b/Runtime/World/CScriptMemoryRelay.hpp @@ -0,0 +1,25 @@ +#ifndef CSCRIPTMEMORYRELAY_HPP +#define CSCRIPTMEMORYRELAY_HPP + +#include "CEntity.hpp" + +namespace urde +{ +class CScriptMemoryRelay : public CEntity +{ + union + { + struct + { + bool x34_24_; + bool x34_25_; + bool x34_26_; + }; + u8 dummy = 0; + }; +public: + CScriptMemoryRelay(TUniqueId, const std::string& name, const CEntityInfo&, bool, bool, bool); +}; +} + +#endif // CSCRIPTMEMORYRELAY_HPP diff --git a/Runtime/World/CScriptRandomRelay.cpp b/Runtime/World/CScriptRandomRelay.cpp new file mode 100644 index 000000000..a5ac06b7b --- /dev/null +++ b/Runtime/World/CScriptRandomRelay.cpp @@ -0,0 +1,13 @@ +#include "CScriptRandomRelay.hpp" + +namespace urde +{ +CScriptRandomRelay::CScriptRandomRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, s32 connCount, s32 variance, + bool clamp, bool active) + : CEntity(uid, info, active, name), + x34_connectionCount((clamp && connCount > 100) ? 100 : connCount), + x38_variance(variance), + x3c_clamp(clamp) +{ +} +} diff --git a/Runtime/World/CScriptRandomRelay.hpp b/Runtime/World/CScriptRandomRelay.hpp new file mode 100644 index 000000000..d4a28a1a1 --- /dev/null +++ b/Runtime/World/CScriptRandomRelay.hpp @@ -0,0 +1,18 @@ +#ifndef CSCRIPTRANDOMRELAY_HPP +#define CSCRIPTRANDOMRELAY_HPP + +#include "CEntity.hpp" + +namespace urde +{ +class CScriptRandomRelay : public CEntity +{ + u32 x34_connectionCount; + u32 x38_variance; + bool x3c_clamp; +public: + CScriptRandomRelay(TUniqueId, const std::string&, const CEntityInfo&, s32, s32, bool, bool); +}; +} + +#endif // CSCRIPTRANDOMRELAY_HPP diff --git a/Runtime/World/CScriptRelay.cpp b/Runtime/World/CScriptRelay.cpp new file mode 100644 index 000000000..bbb03f4ff --- /dev/null +++ b/Runtime/World/CScriptRelay.cpp @@ -0,0 +1,11 @@ +#include "CScriptRelay.hpp" + +namespace urde +{ + +CScriptRelay::CScriptRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, bool active) + : CEntity(uid, info, active, name) +{ +} + +} diff --git a/Runtime/World/CScriptRelay.hpp b/Runtime/World/CScriptRelay.hpp new file mode 100644 index 000000000..778bd40fc --- /dev/null +++ b/Runtime/World/CScriptRelay.hpp @@ -0,0 +1,17 @@ +#ifndef CSCRIPTRELAY_HPP +#define CSCRIPTRELAY_HPP + +#include "CEntity.hpp" + +namespace urde +{ +class CScriptRelay : public CEntity +{ + TUniqueId x34_ = kInvalidUniqueId; + u32 x38_ = 0; +public: + CScriptRelay(TUniqueId, const std::string&, const CEntityInfo&, bool); +}; +} + +#endif // CSCRIPTRELAY_HPP diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 9e19ddc11..69ad17625 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -31,11 +31,15 @@ #include "CScriptSpawnPoint.hpp" #include "CScriptCameraHint.hpp" #include "CScriptPickup.hpp" +#include "CScriptMemoryRelay.hpp" +#include "CScriptRandomRelay.hpp" +#include "CScriptRelay.hpp" #include "CScriptDamageableTrigger.hpp" #include "CScriptActorRotate.hpp" #include "CScriptSpecialFunction.hpp" #include "Camera/CCinematicCamera.hpp" #include "MP1/CNewIntroBoss.hpp" +#include "MP1/CBeetle.hpp" #include "MP1/CWarWasp.hpp" #include "CPatternedInfo.hpp" #include "CSimplePool.hpp" @@ -924,21 +928,85 @@ CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadMemoryRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 3, "MemoryRelay") || propCount > 4) + return nullptr; + + const std::string* name = mgr.HashInstanceName(in); + bool b1 = in.readBool(); + bool b2 = in.readBool(); + bool b3 = false; + if (propCount > 3) + b3 = in.readBool(); + + return new CScriptMemoryRelay(mgr.AllocateUniqueId(), *name, info, b1, b2, b3); } CEntity* ScriptLoader::LoadRandomRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 5, "RandomRelay")) + return nullptr; + const std::string* name = mgr.HashInstanceName(in); + u32 w1 = in.readUint32Big(); + u32 w2 = in.readUint32Big(); + bool b1 = in.readBool(); + bool b2 = in.readBool(); + + return new CScriptRandomRelay(mgr.AllocateUniqueId(), *name, info, w1, w2, b1, b2); } CEntity* ScriptLoader::LoadRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 2, "Relay") || propCount > 3) + return nullptr; + + const std::string* name = mgr.HashInstanceName(in); + if (propCount >= 3) + in.readUint32Big(); + bool b1 = in.readBool(); + + return new CScriptRelay(mgr.AllocateUniqueId(), *name, info, b1); } CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 16, "Beetle")) + return nullptr; + const std::string* name = mgr.HashInstanceName(in); + CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big()); + zeus::CTransform xfrm = LoadEditorTransform(in); + zeus::CVector3f scale = zeus::CVector3f::ReadBig(in); + std::pair pcount = CPatternedInfo::HasCorrectParameterCount(in); + if (!pcount.first) + return nullptr; + + CPatternedInfo pInfo(in, pcount.second); + CActorParameters aParams = LoadActorParameters(in); + CDamageInfo dInfo(in); + zeus::CVector3f v1 = zeus::CVector3f::ReadBig(in); + float f1 = in.readFloatBig(); + CDamageVulnerability dVuln1(in); + CDamageVulnerability dVuln2(in); + ResId abdomen = in.readUint32Big(); + MP1::CBeetle::EEntranceType entrance = MP1::CBeetle::EEntranceType(in.readUint32Big()); + float f2 = in.readFloatBig(); + float f3 = in.readFloatBig(); + + FourCC animType = g_ResFactory->GetResourceTypeById(pInfo.GetAnimationParameters().GetACSFile()); + if (animType != SBIG('ANCS')) + return nullptr; + + rstl::optional_object abdomenRes; + if (flavor == CPatterned::EFlavorType::One) + abdomenRes.emplace(CStaticRes(abdomen, scale)); + + const CAnimationParameters& animParams = pInfo.GetAnimationParameters(); + CAnimRes animRes(animParams.GetACSFile(), animParams.GetCharacter(), scale, animParams.GetInitialAnimation(), true); + + return new MP1::CBeetle(mgr.AllocateUniqueId(), *name, info, xfrm, animRes, pInfo, flavor, entrance, dInfo, dVuln2, v1, f2, + f3, f1, dVuln1, aParams, abdomenRes); } CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in,