diff --git a/Runtime/MP1/CMakeLists.txt b/Runtime/MP1/CMakeLists.txt index 40d0fe6b2..52c4bde4a 100644 --- a/Runtime/MP1/CMakeLists.txt +++ b/Runtime/MP1/CMakeLists.txt @@ -9,6 +9,7 @@ set(MP1_SOURCES CNewIntroBoss.hpp CNewIntroBoss.cpp CBeetle.hpp CBeetle.cpp CWarWasp.hpp CWarWasp.cpp + CSpacePirate.hpp CSpacePirate.cpp MP1.hpp MP1.cpp) runtime_add_list(MP1 MP1_SOURCES) diff --git a/Runtime/World/CAnimationParameters.hpp b/Runtime/World/CAnimationParameters.hpp index 271ccd177..d0a3748e9 100644 --- a/Runtime/World/CAnimationParameters.hpp +++ b/Runtime/World/CAnimationParameters.hpp @@ -23,6 +23,7 @@ public: u32 GetACSFile() const { return x0_ancs; } u32 GetCharacter() const { return x4_charIdx; } u32 GetInitialAnimation() const { return x8_defaultAnim; } + void SetCharacter(u32 charIdx) { x4_charIdx = charIdx; } }; } diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index 41d910365..32850e49b 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -19,8 +19,10 @@ class CPatterned : public CAi public: enum class EUnknown { + Zero = 0, Three = 3, TwentyThree = 23, + ThirtyFour = 34, ThirtyNine }; enum class EFlavorType diff --git a/Runtime/World/CPatternedInfo.hpp b/Runtime/World/CPatternedInfo.hpp index 1fc1762a2..2617be295 100644 --- a/Runtime/World/CPatternedInfo.hpp +++ b/Runtime/World/CPatternedInfo.hpp @@ -60,6 +60,7 @@ public: CPatternedInfo(CInputStream& in, u32 pcount); static std::pair HasCorrectParameterCount(CInputStream& in); + CAnimationParameters& GetAnimationParameters() { return xec_animParams; } const CAnimationParameters& GetAnimationParameters() const {return xec_animParams;} }; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index b7b9cf834..f88a3c475 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -45,6 +45,7 @@ #include "MP1/CNewIntroBoss.hpp" #include "MP1/CBeetle.hpp" #include "MP1/CWarWasp.hpp" +#include "MP1/CSpacePirate.hpp" #include "CPatternedInfo.hpp" #include "CSimplePool.hpp" #include "Collision/CCollidableOBBTreeGroup.hpp" @@ -1321,7 +1322,29 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadSpacePirate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 34, "SpacePirate")) + return nullptr; + SScaledActorHead head = LoadScaledActorHead(in, mgr); + std::pair verifyPair = CPatternedInfo::HasCorrectParameterCount(in); + if (!verifyPair.first) + return nullptr; + + CPatternedInfo pInfo(in, verifyPair.second); + CActorParameters aParams = LoadActorParameters(in); + CAnimationParameters& animParms = pInfo.GetAnimationParameters(); + + if (g_ResFactory->GetResourceTypeById(animParms.GetACSFile()) != SBIG('ANCS')) + return nullptr; + + if (animParms.GetCharacter() == 0) + { + Log.report(logvisor::Warning, "SpacePirate <%s> has AnimationInformation property with invalid character selected"); + animParms.SetCharacter(2); + } + + CModelData mData(CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), head.x40_scale, animParms.GetInitialAnimation(), true)); + + return new MP1::CSpacePirate(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(mData), aParams, pInfo, in, propCount); } CEntity* ScriptLoader::LoadFlyingPirate(CStateManager& mgr, CInputStream& in,