PASDatabase imps

Add SpecialFunction loader
This commit is contained in:
Phillip Stephens 2016-04-27 12:59:38 -07:00
parent 6e0fad8489
commit c55db47941
24 changed files with 406 additions and 125 deletions

View File

@ -43,11 +43,8 @@ public:
inline s32 Range(s32 min, s32 max) inline s32 Range(s32 min, s32 max)
{ {
s32 diff = max - min; const s32 rand = Next();
s32 rand = -1; return min + (rand / ((min - max) + 1)) - rand;
while (rand < 0)
rand = s32((Next() << 16) | Next());
return rand % diff + min;
} }
static CRandom16* GetRandomNumber() {return g_randomNumber;} static CRandom16* GetRandomNumber() {return g_randomNumber;}

View File

@ -46,7 +46,7 @@ CCharacterFactoryBuilder::CCharacterFactoryBuilder() : x4_dummyStore(x0_dummyFac
TToken<CCharacterFactory> CCharacterFactoryBuilder::GetFactory(const CAnimRes& res) TToken<CCharacterFactory> CCharacterFactoryBuilder::GetFactory(const CAnimRes& res)
{ {
return x4_dummyStore.GetObj({SBIG('ANCS'), res.x0_ancsId}); return x4_dummyStore.GetObj({SBIG('ANCS'), res.GetId()});
} }
} }

View File

@ -28,6 +28,7 @@ set(CHARACTER_SOURCES
CPASParmInfo.hpp CPASParmInfo.cpp CPASParmInfo.hpp CPASParmInfo.cpp
CPASAnimInfo.hpp CPASAnimInfo.cpp CPASAnimInfo.hpp CPASAnimInfo.cpp
CPASAnimParm.hpp CPASAnimParm.cpp CPASAnimParm.hpp CPASAnimParm.cpp
CPASAnimParmData.hpp CPASAnimParmData.cpp
CEffectComponent.hpp CEffectComponent.cpp CEffectComponent.hpp CEffectComponent.cpp
CAnimation.hpp CAnimation.cpp CAnimation.hpp CAnimation.cpp
CAnimationManager.hpp CAnimationManager.cpp CAnimationManager.hpp CAnimationManager.cpp

View File

@ -23,16 +23,16 @@ CModelData::CModelData() {}
CModelData CModelData::CModelDataNull() {return CModelData();} CModelData CModelData::CModelDataNull() {return CModelData();}
CModelData::CModelData(const CStaticRes& res) CModelData::CModelData(const CStaticRes& res)
: x0_particleScale(res.x4_scale) : x0_particleScale(res.GetScale())
{ {
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.x0_cmdlId}); x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
} }
CModelData::CModelData(const CAnimRes& res) CModelData::CModelData(const CAnimRes& res)
: x0_particleScale(res.x8_scale) : x0_particleScale(res.GetScale())
{ {
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res); TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
xc_animData = factory->CreateCharacter(res.x4_charIdx, res.x14_, factory, res.x18_defaultAnim); xc_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim());
} }
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a,

View File

@ -21,19 +21,44 @@ class CModel;
class CSkinnedModel; class CSkinnedModel;
struct SAdvancementDeltas; struct SAdvancementDeltas;
struct CStaticRes class CStaticRes
{ {
ResId x0_cmdlId = 0; ResId x0_cmdlId = 0;
zeus::CVector3f x4_scale; zeus::CVector3f x4_scale;
public:
CStaticRes(ResId id, const zeus::CVector3f& scale)
: x0_cmdlId(id),
x4_scale(scale)
{}
ResId GetId() const { return x0_cmdlId; }
const zeus::CVector3f& GetScale() const { return x4_scale; }
}; };
struct CAnimRes class CAnimRes
{ {
ResId x0_ancsId = 0; ResId x0_ancsId = -1;
s32 x4_charIdx = 0; s32 x4_charIdx = -1;
zeus::CVector3f x8_scale; zeus::CVector3f x8_scale;
bool x14_ = false; bool x14_canLoop = false;
s32 x18_defaultAnim = 0; /* NOTE: x18_bodyType - Removed in retail */
s32 x18_defaultAnim = -1; /* NOTE: used to be x1c in demo */
public:
CAnimRes() = default;
CAnimRes(ResId ancs, s32 charIdx, const zeus::CVector3f& scale, const s32 defaultAnim, bool loop)
: x0_ancsId(ancs),
x4_charIdx(charIdx),
x8_scale(scale),
x14_canLoop(loop),
x18_defaultAnim(defaultAnim)
{
}
ResId GetId() const { return x0_ancsId; }
s32 GetCharacterNodeId() const { return x4_charIdx; }
const zeus::CVector3f& GetScale() const { return x8_scale; }
bool CanLoop() const { return x14_canLoop; }
s32 GetDefaultAnim() const { return x18_defaultAnim; }
}; };
class CModelData class CModelData

View File

@ -6,4 +6,35 @@ namespace urde
CPASAnimInfo::CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms) CPASAnimInfo::CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms)
: x0_id(id), x4_parms(std::move(parms)) {} : x0_id(id), x4_parms(std::move(parms)) {}
CPASAnimParm::UParmValue CPASAnimInfo::GetAnimParmValue(u32 idx) const
{
if (idx >= x4_parms.size())
return CPASAnimParm::UParmValue{};
return x4_parms.at(idx);
}
CPASAnimParm CPASAnimInfo::GetAnimParmData(u32 idx, CPASAnimParm::EParmType type) const
{
if (idx >= x4_parms.size())
return CPASAnimParm::NoParameter();
const CPASAnimParm::UParmValue& parm = x4_parms.at(idx);
switch(type)
{
case CPASAnimParm::EParmType::Int32:
return CPASAnimParm::FromInt32(parm.m_int);
case CPASAnimParm::EParmType::UInt32:
return CPASAnimParm::FromUint32(parm.m_uint);
case CPASAnimParm::EParmType::Float:
return CPASAnimParm::FromReal32(parm.m_float);
case CPASAnimParm::EParmType::Bool:
return CPASAnimParm::FromBool(parm.m_bool);
case CPASAnimParm::EParmType::Enum:
return CPASAnimParm::FromEnum(parm.m_int);
default:
return CPASAnimParm::NoParameter();
}
}
} }

View File

@ -14,7 +14,9 @@ class CPASAnimInfo
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> x4_parms; rstl::reserved_vector<CPASAnimParm::UParmValue, 8> x4_parms;
public: public:
CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms); CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms);
u32 GetId() const {return x0_id;} u32 GetAnimId() const {return x0_id;}
CPASAnimParm::UParmValue GetAnimParmValue(u32 idx) const;
CPASAnimParm GetAnimParmData(u32, CPASAnimParm::EParmType) const;
}; };
} }

View File

@ -0,0 +1,31 @@
#include "CPASAnimParmData.hpp"
namespace urde
{
CPASAnimParmData::CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1, const CPASAnimParm& parm2, const CPASAnimParm& parm3,
const CPASAnimParm& parm4, const CPASAnimParm& parm5, const CPASAnimParm& parm6,
const CPASAnimParm& parm7, const CPASAnimParm& parm8)
: x0_stateId(stateId)
{
x4_parms.push_back(parm1);
x4_parms.push_back(parm2);
x4_parms.push_back(parm3);
x4_parms.push_back(parm4);
x4_parms.push_back(parm5);
x4_parms.push_back(parm6);
x4_parms.push_back(parm7);
x4_parms.push_back(parm8);
}
s32 CPASAnimParmData::GetStateId()
{
return x0_stateId;
}
const std::vector<CPASAnimParm>& CPASAnimParmData::GetAnimParmData() const
{
return x4_parms;
}
}

View File

@ -0,0 +1,22 @@
#ifndef CPASANIMPARMDATA_HPP
#define CPASANIMPARMDATA_HPP
#include "RetroTypes.hpp"
#include "CPASAnimParm.hpp"
namespace urde
{
class CPASAnimParmData
{
s32 x0_stateId;
rstl::reserved_vector<CPASAnimParm,8> x4_parms;
public:
CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1, const CPASAnimParm& parm2, const CPASAnimParm& parm3,
const CPASAnimParm& parm4, const CPASAnimParm& parm5, const CPASAnimParm& parm6, const CPASAnimParm& parm7,
const CPASAnimParm& parm8);
s32 GetStateId();
const std::vector<CPASAnimParm>& GetAnimParmData() const;
};
}
#endif // CPASANIMPARMDATA_HPP

View File

@ -18,7 +18,7 @@ CPASAnimState::CPASAnimState(CInputStream& in)
for (u32 i=0 ; i<animCount ; ++i) for (u32 i=0 ; i<animCount ; ++i)
{ {
u32 id = in.readUint32Big(); s32 id = in.readUint32Big();
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> parms; rstl::reserved_vector<CPASAnimParm::UParmValue, 8> parms;
for (const CPASParmInfo& parm : x4_parms) for (const CPASParmInfo& parm : x4_parms)
{ {
@ -46,9 +46,12 @@ CPASAnimState::CPASAnimState(CInputStream& in)
} }
auto search = std::lower_bound(x14_anims.begin(), x14_anims.end(), id, auto search = std::lower_bound(x14_anims.begin(), x14_anims.end(), id,
[](const CPASAnimInfo& item, const u32& testId) -> bool {return item.GetId() < testId;}); [](const CPASAnimInfo& item, const u32& testId) -> bool {return item.GetAnimId() < testId;});
x14_anims.emplace(search, id, std::move(parms)); x14_anims.emplace(search, id, std::move(parms));
} }
} }
std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vector<CPASAnimParm, 8>&, CRandom16&, s32) const
{
}
} }

View File

@ -7,16 +7,23 @@
namespace urde namespace urde
{ {
class CRandom16;
class CPASAnimParmData;
class CPASAnimState class CPASAnimState
{ {
u32 x0_id; s32 x0_id;
std::vector<CPASParmInfo> x4_parms; std::vector<CPASParmInfo> x4_parms;
std::vector<CPASAnimInfo> x14_anims; std::vector<CPASAnimInfo> x14_anims;
std::vector<u32> x24_; std::vector<u32> x24_;
public: public:
CPASAnimState(CInputStream& in); CPASAnimState(CInputStream& in);
u32 GetId() const {return x0_id;} s32 GetStateId() const {return x0_id;}
s32 GetNumAnims() const { return x14_anims.size(); }
const CPASAnimParmData& GetAnimParmData(s32, u32) const;
std::pair<float,s32> FindBestAnimation(const rstl::reserved_vector<CPASAnimParm,8>&, CRandom16&, s32) const;
float ComputeExactMatchWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
float ComputePercentErrorWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
float ComputeAngularPercentErrorWeight(u32, const CPASAnimParm&, CPASAnimParm::UParmValue) const;
}; };
} }

View File

@ -6,7 +6,7 @@ namespace urde
void CPASDatabase::AddAnimState(CPASAnimState&& state) void CPASDatabase::AddAnimState(CPASAnimState&& state)
{ {
auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state, auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state,
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetId() < test.GetId();}); [](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetStateId() < test.GetStateId();});
x0_states.insert(it, std::move(state)); x0_states.insert(it, std::move(state));
} }

View File

@ -7,14 +7,44 @@
namespace urde namespace urde
{ {
class CRandom16;
class CPASAnimParmData;
class CPASDatabase class CPASDatabase
{ {
std::vector<CPASAnimState> x0_states; std::vector<CPASAnimState> x0_states;
u32 x10_defaultState; s32 x10_defaultState;
void AddAnimState(CPASAnimState&& state); void AddAnimState(CPASAnimState&& state);
void SetDefaultState(u32 state) {x10_defaultState = state;} void SetDefaultState(s32 state) {x10_defaultState = state;}
public: public:
CPASDatabase(CInputStream& in); CPASDatabase(CInputStream& in);
void FindBestAnimation(const CPASAnimParmData&, int) const;
void FindBestAnimation(const CPASAnimParmData&, CRandom16&, int) const;
s32 GetDefaultState() const { return x10_defaultState; }
s32 GetNumAnimStates() const { return x0_states.size(); }
const CPASAnimState* GetAnimState(s32 id) const
{
for (const CPASAnimState& state : x0_states)
if (id == state.GetStateId())
return &state;
return nullptr;
}
const CPASAnimState* GetAnimStateByIndex(s32 index) const
{
if (index < 0 || index >= x0_states.size())
return nullptr;
return &x0_states.at(index);
}
bool HasState(s32 id) const
{
for (const CPASAnimState& state : x0_states)
return true;
return false;
}
}; };
} }

View File

@ -20,14 +20,14 @@ CRayCastResult CCollidableOBBTree::CastRayInternal(const CInternalRayCastStructu
} }
zeus::CAABox CCollidableOBBTree::CalculateAABox(const zeus::CTransform&) const zeus::CAABox CCollidableOBBTree::CalculateAABox(const zeus::CTransform& xf) const
{ {
return x10_tree->CalculateLocalAABox(); return x10_tree->CalculateAABox(xf);
} }
zeus::CAABox CCollidableOBBTree::CalculateLocalAABox() const zeus::CAABox CCollidableOBBTree::CalculateLocalAABox() const
{ {
return x10_tree->CalculateLocalAABox();
} }
} }

View File

@ -24,19 +24,24 @@ CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in)
x10_aabbs.push_back(CCollidableOBBTree(tree.get(), CMaterialList()).CalculateLocalAABox()); x10_aabbs.push_back(CCollidableOBBTree(tree.get(), CMaterialList()).CalculateLocalAABox());
} }
u32 CCollidableOBBTreeGroup::GetTableIndex() const void CCollidableOBBTreeGroup::ResetTestStats() const
{ {
} }
zeus::CAABox CCollidableOBBTreeGroup::CalculateAABox(const zeus::CTransform&) const u32 CCollidableOBBTreeGroup::GetTableIndex() const
{ {
return sTableIndex;
}
zeus::CAABox CCollidableOBBTreeGroup::CalculateAABox(const zeus::CTransform& xf) const
{
return x10_aabbs.front().getTransformedAABox(xf);
} }
zeus::CAABox CCollidableOBBTreeGroup::CalculateLocalAABox() const zeus::CAABox CCollidableOBBTreeGroup::CalculateLocalAABox() const
{ {
return x10_aabbs.front();
} }
FourCC CCollidableOBBTreeGroup::GetPrimType() const FourCC CCollidableOBBTreeGroup::GetPrimType() const

View File

@ -16,25 +16,30 @@ class CDecalDescription;
enum class EWeaponCollisionResponseTypes enum class EWeaponCollisionResponseTypes
{ {
Unknown0, Unknown1, Unknown2, Unknown3, Unknown4, Unknown0, Unknown1, Metal, Grass,
Unknown5, Unknown6, Unknown7, Unknown8, Unknown9, Ice, Goo, Wood, Water,
Unknown10,Unknown11,Unknown12,Unknown13,Unknown14, Mud, Lava, Sand,Unknown11,
Unknown15,Unknown16,Unknown17,Unknown18,Unknown19, Unknown12,Unknown13,Unknown14,Unknown15,
Unknown20,Unknown21,Unknown22,Unknown23,Unknown24, Unknown16,Unknown17,Unknown18,Unknown19,
Unknown25,Unknown26,Unknown27,Unknown28,Unknown29, Unknown20,Unknown21,Unknown22,Unknown23,
Unknown30,Unknown31,Unknown32,Unknown33,Unknown34, Unknown24,Unknown25,Unknown26,Unknown27,
Unknown35,Unknown36,Unknown37,Unknown38,Unknown39, Unknown28,Unknown29,Unknown30,Unknown31,
Unknown40,Unknown41,Unknown42,Unknown43,Unknown44, Unknown32,Unknown33,Unknown34,Unknown35,
Unknown45,Unknown46,Unknown47,Unknown48,Unknown49, Unknown36,Unknown37,Unknown38,Unknown39,
Unknown50,Unknown51,Unknown52,Unknown53,Unknown54, Unknown40,Unknown41,Unknown42,Unknown43,
Unknown55,Unknown56,Unknown57,Unknown58,Unknown59, Unknown44,Unknown45,Unknown46,Unknown47,
Unknown60,Unknown61,Unknown62,Unknown63,Unknown64, Unknown48,Unknown49,Unknown50,Unknown51,
Unknown65,Unknown66,Unknown67,Unknown68,Unknown69, Unknown52,Unknown53,Unknown54,Unknown55,
Unknown70,Unknown71,Unknown72,Unknown73,Unknown74, Unknown56,Unknown57,Unknown58,Unknown59,
Unknown75,Unknown76,Unknown77,Unknown78,Unknown79, Unknown60,Unknown61,Unknown62,Unknown63,
Unknown80,Unknown81,Unknown82,Unknown83,Unknown84, Unknown64,Unknown65,Unknown66,Unknown67,
Unknown85,Unknown86,Unknown87,Unknown88,Unknown89, Unknown68,Unknown69,Unknown70,Unknown71,
Unknown90,Unknown91,Unknown92,Unknown93 Unknown72,Unknown73,Unknown74,Unknown75,
Unknown76,Unknown77,Unknown78,Unknown79,
Unknown80,Unknown81,Unknown82,Unknown83,
Unknown84,Unknown85,Unknown86,Unknown87,
Unknown88,Unknown89,Unknown90,Unknown91,
Unknown92
}; };
class CCollisionResponseData class CCollisionResponseData

View File

@ -5,15 +5,11 @@
#include "zeus/zeus.hpp" #include "zeus/zeus.hpp"
#include "Collision/CMaterialFilter.hpp" #include "Collision/CMaterialFilter.hpp"
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Particle/CCollisionResponseData.hpp"
namespace urde namespace urde
{ {
enum class ECollisionResponseType
{
Unknown12 = 0xC,
};
class CActorParameters; class CActorParameters;
class CWeaponMode; class CWeaponMode;
class CHealthInfo; class CHealthInfo;
@ -86,7 +82,7 @@ public:
virtual const zeus::CAABox* GetTouchBounds() const { return nullptr; } virtual const zeus::CAABox* GetTouchBounds() const { return nullptr; }
virtual ECollisionResponseType GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) { return ECollisionResponseType::Unknown12; } virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) { return EWeaponCollisionResponseTypes::Unknown13; }
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&);

View File

@ -8,17 +8,21 @@ namespace urde
class CAnimationParameters class CAnimationParameters
{ {
public:
ResId x0_ancs = -1; ResId x0_ancs = -1;
s32 x4_charIdx = -1; u32 x4_charIdx = -1;
u32 x8_defaultAnim = -1; u32 x8_defaultAnim = -1;
public:
CAnimationParameters() = default; CAnimationParameters() = default;
CAnimationParameters(ResId ancs, s32 charIdx, u32 defaultAnim) CAnimationParameters(ResId ancs, u32 charIdx, u32 defaultAnim)
: x0_ancs(ancs), x4_charIdx(charIdx), x8_defaultAnim(defaultAnim) {} : x0_ancs(ancs), x4_charIdx(charIdx), x8_defaultAnim(defaultAnim) {}
CAnimationParameters(CInputStream& in) CAnimationParameters(CInputStream& in)
: x0_ancs(in.readUint32Big()), : x0_ancs(in.readUint32Big()),
x4_charIdx(in.readUint32Big()), x4_charIdx(in.readUint32Big()),
x8_defaultAnim(in.readUint32Big()) {} x8_defaultAnim(in.readUint32Big()) {}
u32 GetACSFile() const { return x0_ancs; }
u32 GetCharacter() const { return x4_charIdx; }
u32 GetInitialAnimation() const { return x8_defaultAnim; }
}; };
} }

View File

@ -35,6 +35,8 @@ set(WORLD_SOURCES
CScriptCameraWaypoint.hpp CScriptCameraWaypoint.cpp CScriptCameraWaypoint.hpp CScriptCameraWaypoint.cpp
CScriptCoverPoint.hpp CScriptCoverPoint.cpp CScriptCoverPoint.hpp CScriptCoverPoint.cpp
CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp
CScriptActorRotate.hpp CScriptActorRotate.cpp
CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp
CGrappleParameters.hpp CGrappleParameters.hpp
CActorParameters.hpp CActorParameters.hpp
CLightParameters.hpp CLightParameters.hpp

View File

@ -0,0 +1,10 @@
#include "CScriptActorRotate.hpp"
namespace urde
{
CScriptActorRotate::CScriptActorRotate(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CVector3f& rotation, float scale, bool, bool, bool active)
: CEntity(uid, info, active, name)
{
}
}

View File

@ -0,0 +1,32 @@
#ifndef CSCRIPTACTORROTATE_HPP
#define CSCRIPTACTORROTATE_HPP
#include "CEntity.hpp"
#include "zeus/CTransform.hpp"
namespace urde
{
class CScriptActorRotate : public CEntity
{
zeus::CVector3f x34_rotation;
float x40_;
float x44_;
std::map<TUniqueId, zeus::CTransform> x48_actors;
union
{
struct
{
bool x58_24_ : 1;
bool x58_25_ : 1;
bool x58_26_ : 1;
bool x58_27_ : 1;
};
u32 dummy = 0;
};
public:
CScriptActorRotate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool, bool, bool);
};
}
#endif // CSCRIPTACTORROTATE_HPP

View File

@ -0,0 +1,17 @@
#include "CScriptSpecialFunction.hpp"
#include "Character/CModelData.hpp"
#include "CActorParameters.hpp"
namespace urde
{
CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, ESpecialFunction,
const std::string&, float, float, float, float, const zeus::CVector3f&,
const zeus::CColor&, bool active, const CDamageInfo&, u32, u32, u32, u16, u16, u16)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId)
{
}
}

View File

@ -0,0 +1,63 @@
#ifndef __URDE_CSCRIPTSPECIALFUNCTION_HPP__
#define __URDE_CSCRIPTSPECIALFUNCTION_HPP__
#include "CActor.hpp"
#include "CDamageInfo.hpp"
#include "zeus/CTransform.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
class CScriptSpecialFunction : public CActor
{
public:
enum class ESpecialFunction
{
What,
PlayerFollowLocator,
SpinnerController,
ObjectFollowLocator,
Four,
InventoryActivator,
MapStation,
SaveStation,
IntroBossRingController,
ViewFrustumTester,
ShotSpinnerController,
EscapeSequence,
BossEnergyBar,
EndGame,
HUDFadeIn,
CinematicSkip,
ScriptLayerController,
RainSimulator,
AreaDamage,
ObjectFollowObject,
RedundantHintSystem,
DropBomb,
TwentyTwo,
MissileStation,
Billboard,
PlayerInAreaRelay,
HUDTarget,
FogFader,
EnterLogbook,
PowerBombStation,
Ending,
FusionRelay,
WeaponSwitch,
FourtySeven = 47,
FourtyEight = 48
};
private:
public:
CScriptSpecialFunction(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, ESpecialFunction,
const std::string&, float, float, float, float, const zeus::CVector3f&, const zeus::CColor&, bool,
const CDamageInfo&, u32, u32, u32, u16, u16, u16);
};
}
#endif // CSCRIPTSPECIALFUNCTION_HPP

View File

@ -29,6 +29,8 @@
#include "CScriptCameraWaypoint.hpp" #include "CScriptCameraWaypoint.hpp"
#include "CScriptCoverPoint.hpp" #include "CScriptCoverPoint.hpp"
#include "CScriptSpawnPoint.hpp" #include "CScriptSpawnPoint.hpp"
#include "CScriptActorRotate.hpp"
#include "CScriptSpecialFunction.hpp"
#include "Camera/CCinematicCamera.hpp" #include "Camera/CCinematicCamera.hpp"
#include "MP1/CNewIntroBoss.hpp" #include "MP1/CNewIntroBoss.hpp"
#include "MP1/CWarWasp.hpp" #include "MP1/CWarWasp.hpp"
@ -43,7 +45,7 @@ namespace urde
static logvisor::Module Log("urde::ScriptLoader"); static logvisor::Module Log("urde::ScriptLoader");
static SObjectTag MorphballDoorANCS = {}; static SObjectTag MorphballDoorANCS = {};
static const SObjectTag& GetMorphballDoorANCS() static const SObjectTag& GetMorphballDoorACS()
{ {
if (!MorphballDoorANCS) if (!MorphballDoorANCS)
MorphballDoorANCS = static_cast<ProjectResourceFactoryBase*>(g_ResFactory)-> MorphballDoorANCS = static_cast<ProjectResourceFactoryBase*>(g_ResFactory)->
@ -360,7 +362,7 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in,
bool b8 = in.readBool(); bool b8 = in.readBool();
bool b9 = in.readBool(); bool b9 = in.readBool();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.x0_ancs); FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
if (!g_ResFactory->GetResourceTypeById(staticId) && !animType) if (!g_ResFactory->GetResourceTypeById(staticId) && !animType)
return nullptr; return nullptr;
@ -382,22 +384,9 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in,
CModelData data; CModelData data;
if (animType == SBIG('ANCS')) if (animType == SBIG('ANCS'))
{ data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
CAnimRes aRes;
aRes.x0_ancsId = aParms.x0_ancs;
aRes.x4_charIdx = aParms.x4_charIdx;
aRes.x8_scale = head.x40_scale;
aRes.x14_ = true;
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
data = aRes;
}
else else
{ data = CStaticRes(staticId, head.x40_scale);
CStaticRes sRes;
sRes.x0_cmdlId = staticId;
sRes.x4_scale = head.x40_scale;
data = sRes;
}
if (generateExtent || collisionExtent.isZero()) if (generateExtent || collisionExtent.isZero())
aabb = data.GetBounds(head.x10_transform.getRotation()); aabb = data.GetBounds(head.x10_transform.getRotation());
@ -454,23 +443,17 @@ CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in,
zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), collisionExtent, offset); zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), collisionExtent, offset);
if (!g_ResFactory->GetResourceTypeById(aParms.x0_ancs)) if (!g_ResFactory->GetResourceTypeById(aParms.GetACSFile()))
return nullptr; return nullptr;
CAnimRes aRes; CModelData mData = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
aRes.x0_ancsId = aParms.x0_ancs;
aRes.x4_charIdx = aParms.x4_charIdx;
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
aRes.x8_scale = head.x40_scale;
CModelData mData = aRes;
if (collisionExtent.isZero()) if (collisionExtent.isZero())
aabb = mData.GetBounds(head.x10_transform.getRotation()); aabb = mData.GetBounds(head.x10_transform.getRotation());
bool isMorphballDoor = false; bool isMorphballDoor = false;
if (propCount == 13) if (propCount == 13)
{ {
if (aParms.x0_ancs == GetMorphballDoorANCS().id) if (aParms.GetACSFile() == GetMorphballDoorACS().id)
isMorphballDoor = true; isMorphballDoor = true;
} }
else if (propCount == 14) else if (propCount == 14)
@ -622,7 +605,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in,
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
u32 w3 = in.readUint32Big(); u32 w3 = in.readUint32Big();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.x0_ancs); FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
if (!g_ResFactory->GetResourceTypeById(staticId) && !animType) if (!g_ResFactory->GetResourceTypeById(staticId) && !animType)
return nullptr; return nullptr;
@ -638,22 +621,9 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in,
CModelData data; CModelData data;
if (animType == SBIG('ANCS')) if (animType == SBIG('ANCS'))
{ data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
CAnimRes aRes;
aRes.x0_ancsId = aParms.x0_ancs;
aRes.x4_charIdx = aParms.x4_charIdx;
aRes.x8_scale = head.x40_scale;
aRes.x14_ = true;
aRes.x18_defaultAnim = aParms.x8_defaultAnim;
data = aRes;
}
else else
{ data = CStaticRes(staticId, head.x40_scale);
CStaticRes sRes;
sRes.x0_cmdlId = staticId;
sRes.x4_scale = head.x40_scale;
data = sRes;
}
if (extent.isZero()) if (extent.isZero())
aabb = data.GetBounds(head.x10_transform.getRotation()); aabb = data.GetBounds(head.x10_transform.getRotation());
@ -723,7 +693,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 7, "Dock")) if (!EnsurePropertyCount(propCount, 7, "Dock"))
return nullptr; return nullptr;
std::string name = *mgr.HashInstanceName(in); const std::string* name = mgr.HashInstanceName(in);
bool active = in.readBool(); bool active = in.readBool();
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
@ -732,7 +702,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in,
u32 dock = in.readUint32Big(); u32 dock = in.readUint32Big();
TAreaId area = in.readUint32Big(); TAreaId area = in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
return new CScriptDock(mgr.AllocateUniqueId(), name, info, position, scale, dock, area, active, 0, b1); return new CScriptDock(mgr.AllocateUniqueId(), *name, info, position, scale, dock, area, active, 0, b1);
} }
CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in,
@ -809,16 +779,13 @@ CEntity* ScriptLoader::LoadNewIntroBoss(CStateManager& mgr, CInputStream& in,
u32 w4 = in.readUint32Big(); u32 w4 = in.readUint32Big();
u32 w5 = in.readUint32Big(); u32 w5 = in.readUint32Big();
const CAnimationParameters& animParms = pInfo.GetAnimationParameters(); const CAnimationParameters& aParms = pInfo.GetAnimationParameters();
if (animParms.x0_ancs < 0) FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
if (animType != SBIG('ANCS'))
return nullptr; return nullptr;
CAnimRes res; CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation());
res.x0_ancsId = animParms.x0_ancs;
res.x4_charIdx = animParms.x4_charIdx;
res.x8_scale = head.x40_scale;
res.x14_ = true;
res.x18_defaultAnim = animParms.x8_defaultAnim;
return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info, return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info,
head.x10_transform, res, pInfo, actParms, f1, w1, head.x10_transform, res, pInfo, actParms, f1, w1,
@ -926,7 +893,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 63, "Water")) if (!EnsurePropertyCount(propCount, 63, "Water"))
return nullptr; return nullptr;
std::string name = *mgr.HashInstanceName(in); const std::string* name = mgr.HashInstanceName(in);
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
zeus::CVector3f extent; zeus::CVector3f extent;
@ -1024,7 +991,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in,
if (textureId4 == -1) if (textureId4 == -1)
realTextureId5 = textureId5; realTextureId5 = textureId5;
return new CScriptWater(mgr, mgr.AllocateUniqueId(), name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface, return new CScriptWater(mgr, mgr.AllocateUniqueId(), *name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface,
textureId1, textureId2, textureId3, textureId4, realTextureId5, realTextureId6, -1, otherV2, f1, f2, textureId1, textureId2, textureId3, textureId4, realTextureId5, realTextureId6, -1, otherV2, f1, f2,
f3, active, fluidType, b4, f4, fluidMotion, f5, f6, f7, f8, f9, f10, f11, f12, c1, c2, enterParticle, f3, active, fluidType, b4, f4, fluidMotion, f5, f6, f7, f8, f9, f10, f11, f12, c1, c2, enterParticle,
partId2, partId3, partId4, partId5, soundId1, soundId2, soundId3, soundId4, soundId5, partId2, partId3, partId4, partId5, soundId1, soundId2, soundId3, soundId4, soundId5,
@ -1038,7 +1005,7 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 13, "WarWasp")) if (!EnsurePropertyCount(propCount, 13, "WarWasp"))
return nullptr; return nullptr;
std::string name = *mgr.HashInstanceName(in); const std::string* name = mgr.HashInstanceName(in);
CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big()); CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big());
zeus::CTransform xf = LoadEditorTransformPivotOnly(in); zeus::CTransform xf = LoadEditorTransformPivotOnly(in);
zeus::CVector3f scale; zeus::CVector3f scale;
@ -1057,18 +1024,14 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in,
ResId particle = in.readUint32Big(); ResId particle = in.readUint32Big();
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
FourCC animType = g_ResFactory->GetResourceTypeById(pInfo.GetAnimationParameters().x0_ancs); const CAnimationParameters& aParms = pInfo.GetAnimationParameters();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
if (animType != SBIG('ANCS')) if (animType != SBIG('ANCS'))
return nullptr; return nullptr;
CAnimRes res; CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, true, aParms.GetInitialAnimation());
res.x0_ancsId = pInfo.GetAnimationParameters().x0_ancs;
res.x4_charIdx = pInfo.GetAnimationParameters().x4_charIdx;
res.x8_scale = scale;
res.x14_ = true;
res.x18_defaultAnim = pInfo.GetAnimationParameters().x8_defaultAnim;
CModelData mData(res); CModelData mData(res);
return new MP1::CWarWasp(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, flavor, collider, damageInfo1, actorParms, weaponDesc, return new MP1::CWarWasp(mgr.AllocateUniqueId(), *name, info, xf, std::move(mData), pInfo, flavor, collider, damageInfo1, actorParms, weaponDesc,
damageInfo2, particle, w1); damageInfo2, particle, w1);
} }
@ -1140,11 +1103,11 @@ CEntity* ScriptLoader::LoadGrapplePoint(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 5, "GrapplePoint")) if (!EnsurePropertyCount(propCount, 5, "GrapplePoint"))
return nullptr; return nullptr;
std::string name = *mgr.HashInstanceName(in); const std::string* name = mgr.HashInstanceName(in);
zeus::CTransform grappleXf = LoadEditorTransform(in); zeus::CTransform grappleXf = LoadEditorTransform(in);
bool active = in.readBool(); bool active = in.readBool();
CGrappleParameters parameters = LoadGrappleParameters(in); CGrappleParameters parameters = LoadGrappleParameters(in);
return new CScriptGrapplePoint(mgr.AllocateUniqueId(), name, info, grappleXf, active, parameters); return new CScriptGrapplePoint(mgr.AllocateUniqueId(), *name, info, grappleXf, active, parameters);
} }
CEntity* ScriptLoader::LoadPuddleSpore(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadPuddleSpore(CStateManager& mgr, CInputStream& in,
@ -1190,11 +1153,46 @@ CEntity* ScriptLoader::LoadDockAreaChange(CStateManager& mgr, CInputStream& in,
CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info) int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 6, "ActorRotate"))
return nullptr;
const std::string* name = mgr.HashInstanceName(in);
zeus::CVector3f rotation = zeus::CVector3f::ReadBig(in);
float scale = in.readFloatBig();
bool b1 = in.readBool();
bool b2 = in.readBool();
bool active = in.readBool();
return new CScriptActorRotate(mgr.AllocateUniqueId(), *name, info, rotation, scale, b1, b2, active);
} }
CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info) int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 15, "SpecialFunction"))
return nullptr;
SActorHead head = LoadActorHead(in, mgr);
CScriptSpecialFunction::ESpecialFunction specialFunction = CScriptSpecialFunction::ESpecialFunction(in.readUint32Big());
std::string str = in.readString();
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
float f3 = in.readFloatBig();
u32 w2 = in.readUint32Big();
u32 w3 = in.readUint32Big();
u32 w4 = in.readUint32Big();
bool active1 = in.readBool();
float f4 = in.readFloatBig();
s16 w5 = in.readUint32Big() & 0xFFFF;
s16 w6 = in.readUint32Big() & 0xFFFF;
s16 w7 = in.readUint32Big() & 0xFFFF;
if (specialFunction == CScriptSpecialFunction::ESpecialFunction::FourtySeven ||
specialFunction == CScriptSpecialFunction::ESpecialFunction::FourtySeven)
return nullptr;
return new CScriptSpecialFunction(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, specialFunction, str, f1, f2,
f3, f4, zeus::CVector3f::skZero, zeus::CColor::skBlack, active1, CDamageInfo(), w2, w3, w4,
w5, w6, w7);
} }
CEntity* ScriptLoader::LoadSpankWeed(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadSpankWeed(CStateManager& mgr, CInputStream& in,