From 4101ea78a254ff4e65525c06f89fd3a1fc55721a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 3 May 2016 01:27:28 -0700 Subject: [PATCH] Various imps --- DataSpec/DNAMP1/ANCS.hpp | 6 +- DataSpec/DNAMP1/EVNT.hpp | 8 +-- Runtime/Audio/CSfxHandle.cpp | 29 ++++++++ Runtime/Audio/CSfxHandle.hpp | 14 ++++ Runtime/Audio/CSfxManager.hpp | 1 + Runtime/Character/CAnimation.hpp | 1 + Runtime/Character/CEffectComponent.cpp | 12 +++- Runtime/Character/CEffectComponent.hpp | 5 +- Runtime/Character/CModelData.hpp | 1 + Runtime/Collision/CMaterialList.hpp | 2 + Runtime/World/CActor.cpp | 77 ++++++++++++++++++++-- Runtime/World/CActor.hpp | 69 +++++++++++-------- Runtime/World/CActorParameters.hpp | 1 + Runtime/World/CMakeLists.txt | 1 + Runtime/World/CScriptDamageableTrigger.cpp | 34 ++++++++++ Runtime/World/CScriptDamageableTrigger.hpp | 26 ++++++++ Runtime/World/CScriptGenerator.cpp | 20 +++++- Runtime/World/CScriptGenerator.hpp | 15 +++++ Runtime/World/CWorld.hpp | 52 ++++++++------- Runtime/World/ScriptLoader.cpp | 65 +++++++++++++++++- specter | 2 +- 21 files changed, 371 insertions(+), 70 deletions(-) create mode 100644 Runtime/World/CScriptDamageableTrigger.cpp create mode 100644 Runtime/World/CScriptDamageableTrigger.hpp diff --git a/DataSpec/DNAMP1/ANCS.hpp b/DataSpec/DNAMP1/ANCS.hpp index ab80a38fb..ea57edee8 100644 --- a/DataSpec/DNAMP1/ANCS.hpp +++ b/DataSpec/DNAMP1/ANCS.hpp @@ -135,9 +135,9 @@ struct ANCS : BigYAML DNAFourCC type; UniqueID32 id; String<-1> locator; - Value unk1; - Value unk2; - Value unk3; + Value scale; + Value parentMode; + Value flags; }; Vector comps; }; diff --git a/DataSpec/DNAMP1/EVNT.hpp b/DataSpec/DNAMP1/EVNT.hpp index b39300f0e..23edc4037 100644 --- a/DataSpec/DNAMP1/EVNT.hpp +++ b/DataSpec/DNAMP1/EVNT.hpp @@ -56,7 +56,7 @@ struct EVNT : BigYAML { DECL_YAML Value value; - String<-1> locatorName; + String<-1> locator; }; std::vector int32POINodes; @@ -64,9 +64,9 @@ struct EVNT : BigYAML { DECL_YAML Value duration; - DNAFourCC effectType; - UniqueID32 effectId; - String<-1> locatorName; + DNAFourCC type; + UniqueID32 id; + String<-1> locator; Value scale; Value parentMode; }; diff --git a/Runtime/Audio/CSfxHandle.cpp b/Runtime/Audio/CSfxHandle.cpp index e69de29bb..df96ea74b 100644 --- a/Runtime/Audio/CSfxHandle.cpp +++ b/Runtime/Audio/CSfxHandle.cpp @@ -0,0 +1,29 @@ +#include "CSfxHandle.hpp" + +namespace urde +{ +u32 CSfxHandle::mRefCount = 0; + +CSfxHandle::CSfxHandle(u32 idx) +{ + x0_index = (idx & 0xFFF) | ((++mRefCount) << 14); +} + +void CSfxHandle::operator =(const CSfxHandle& other) +{ + if (x0_index == other.x0_index) + return; + x0_index = other.x0_index; +} + +bool CSfxHandle::operator !=(const CSfxHandle& other) const +{ + return x0_index != other.x0_index; +} + +bool CSfxHandle::operator ==(const CSfxHandle& other) const +{ + return x0_index == other.x0_index; +} + +} diff --git a/Runtime/Audio/CSfxHandle.hpp b/Runtime/Audio/CSfxHandle.hpp index 496c4bfcb..3a76c27f1 100644 --- a/Runtime/Audio/CSfxHandle.hpp +++ b/Runtime/Audio/CSfxHandle.hpp @@ -1,11 +1,25 @@ #ifndef __URDE_CSFXHANDLE_HPP__ #define __URDE_CSFXHANDLE_HPP__ +#include "RetroTypes.hpp" + namespace urde { class CSfxHandle { + static u32 mRefCount; + u32 x0_index = 0; +public: + CSfxHandle() = default; + CSfxHandle(const CSfxHandle&) = default; + CSfxHandle(u32 idx); + + void operator =(const CSfxHandle& other); + bool operator !=(const CSfxHandle& other) const; + bool operator ==(const CSfxHandle& other) const; + u32 GetIndex() const { return x0_index; } + static CSfxHandle NullHandle() { return {}; } }; } diff --git a/Runtime/Audio/CSfxManager.hpp b/Runtime/Audio/CSfxManager.hpp index 76b59a494..ee4105e78 100644 --- a/Runtime/Audio/CSfxManager.hpp +++ b/Runtime/Audio/CSfxManager.hpp @@ -139,6 +139,7 @@ public: u8 vol); static void RemoveEmitter(const CSfxHandle&) {} + static void PitchBend(const CSfxHandle&, s32) {} static u16 TranslateSFXID(u16); }; diff --git a/Runtime/Character/CAnimation.hpp b/Runtime/Character/CAnimation.hpp index 5eda83d38..49777fb9a 100644 --- a/Runtime/Character/CAnimation.hpp +++ b/Runtime/Character/CAnimation.hpp @@ -15,6 +15,7 @@ class CAnimation public: CAnimation(CInputStream& in); const std::shared_ptr& GetMetaAnim() const {return x10_anim;} + const std::string& GetMetaAnimName() const { return x0_name; } }; } diff --git a/Runtime/Character/CEffectComponent.cpp b/Runtime/Character/CEffectComponent.cpp index dbdc9b082..4bbd397dd 100644 --- a/Runtime/Character/CEffectComponent.cpp +++ b/Runtime/Character/CEffectComponent.cpp @@ -13,9 +13,19 @@ CEffectComponent::CEffectComponent(CInputStream& in) x0_name = in.readString(); x10_tag = GetSObjectTagFromStream(in); x18_boneName = in.readString(); - x28_ = in.readFloatBig(); + x28_scale = in.readFloatBig(); x2c_ = in.readUint32Big(); x30_ = in.readUint32Big(); } +const std::string& CEffectComponent::GetComponentName() const +{ + return x0_name; +} + +const SObjectTag& CEffectComponent::GetParticleTag() const +{ + return x10_tag; +} + } diff --git a/Runtime/Character/CEffectComponent.hpp b/Runtime/Character/CEffectComponent.hpp index da8c69324..487e89c68 100644 --- a/Runtime/Character/CEffectComponent.hpp +++ b/Runtime/Character/CEffectComponent.hpp @@ -12,12 +12,15 @@ class CEffectComponent std::string x0_name; SObjectTag x10_tag; std::string x18_boneName; - float x28_; + float x28_scale; u32 x2c_; u32 x30_; static SObjectTag GetSObjectTagFromStream(CInputStream& in); public: CEffectComponent(CInputStream& in); + + const std::string& GetComponentName() const; + const SObjectTag& GetParticleTag() const; }; } diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index 35481ff13..3455dfb6f 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -130,6 +130,7 @@ public: const CActorLights* lights, const CModelFlags& drawFlags) const; CAnimData* AnimationData() { return x10_animData.get(); } + bool IsNull() { return !x10_animData && !x1c_normalModel; } }; } diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index 950bf0b95..5ad38ad38 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -29,6 +29,8 @@ enum class EMaterialTypes FourtyThree = 43, FourtyEight = 48, FourtyNine = 49, + Fifty = 50, + FiftySix = 56, SixtyThree = 63 }; diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index cb334ae44..0b50ba308 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -20,12 +20,13 @@ static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, co CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform&, CModelData&& mData, const CMaterialList& list, - const CActorParameters& params, TUniqueId) + const CActorParameters& params, TUniqueId otherUid) : CEntity(uid, info, active, name), x68_material(MakeActorMaterialList(list, params)), - x70_(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Nineteen}, {EMaterialTypes::Zero})) + x70_(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Nineteen}, {EMaterialTypes::Zero})), + xc6_(otherUid) { - if (mData.x1c_normalModel) + if (mData.x10_animData || mData.x1c_normalModel) x64_modelData = std::make_unique(std::move(mData)); } @@ -82,16 +83,21 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana } break; case EScriptObjectMessage::UNKM17: // 37 - //SetInFluid(true, uid); + SetInFluid(true, uid); break; case EScriptObjectMessage::UNKM19: // 39 - //SetInFluid(false, kInvalidUniqueId); + SetInFluid(false, kInvalidUniqueId); break; default:break; } CEntity::AcceptScriptMsg(msg, uid, mgr); } +zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&) +{ + return x34_transform.origin; +} + void CActor::RemoveEmitter() { if (x8c_sfxHandle) @@ -102,6 +108,12 @@ void CActor::RemoveEmitter() } } +EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVector3f&, + const zeus::CVector3f&, CWeaponMode&, int) +{ + return EWeaponCollisionResponseTypes::Unknown13; +} + void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr) { x68_material.Remove(t1); @@ -155,9 +167,62 @@ void CActor::AddMaterial(EMaterialTypes type, CStateManager& mgr) mgr.UpdateObjectInLists(*this); } +void CActor::SetCallTouch(bool callTouch) +{ + xe5_28_callTouch = callTouch; +} + +bool CActor::GetCallTouch() const +{ + return xe5_28_callTouch; +} + +void CActor::SetUseInSortedList(bool use) +{ + xe5_27_useInSortedLists = use; +} + +bool CActor::GetUseInSortedLists() const +{ + return xe5_27_useInSortedLists; +} + +void CActor::SetInFluid(bool in, TUniqueId uid) +{ + if (in) + { + xe6_26_inFluid = false; + xc4_fluidId = uid; + } + else + { + if (!xe6_26_inFluid) + return; + + xe6_26_inFluid = true; + if (xe6_26_inFluid == 0) + xc4_fluidId = kInvalidUniqueId; + } +} + bool CActor::HasModelData() const { - return x64_modelData.operator bool(); + return bool(x64_modelData); +} + +const CSfxHandle* CActor::GetSfxHandle() const +{ + return x8c_sfxHandle.get(); +} + +void CActor::SetSfxPitchBend(s32 val) +{ + xe6_30_enablePitchBend = true; + xc0_ = val; + if (x8c_sfxHandle == 0) + return; + + CSfxManager::PitchBend(*x8c_sfxHandle.get(), val); } } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 8ffce9bcf..df71cfb30 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -17,6 +17,8 @@ class CHealthInfo; class CDamageVulnerability; class CLightParameters; class CSfxHandle; +class CSimpleShadow; + class CActor : public CEntity { protected: @@ -31,10 +33,16 @@ protected: std::unique_ptr x64_modelData; CMaterialList x68_material; CMaterialFilter x70_; - s16 x88_sfxId; + s16 x88_sfxId = -1; std::unique_ptr x8c_sfxHandle; + //std::unique_ptr x94_simpleShadow; + zeus::CAABox x9c_aabox; + u32 xb8_ = 0; + float xbc_time = 0.f; + s32 xc0_ = 0; + TUniqueId xc4_fluidId = kInvalidUniqueId; TUniqueId xc6_ = kInvalidUniqueId; - float xbc_time; + u8 xd4_ = 0x7F; union { struct @@ -43,21 +51,37 @@ protected: bool xe4_28_ : 1; bool xe4_29_ : 1; bool xe4_30_ : 1; - bool xe5_0_opaque : 1; - bool xe5_26_muted : 1; - bool xe5_27_useInSortedLists : 1; - bool xe5_28_callTouch : 1; }; - u32 dummy1 = 0; + u8 dummy1 = 0; }; + union + { + struct + { + bool xe5_0_opaque : 1; + bool xe5_26_muted : 1; + bool xe5_27_useInSortedLists : 1; + bool xe5_28_callTouch : 1; + }; + u8 dummy2 = 0; + }; + union + { + struct + { + bool xe6_26_inFluid : 1; + bool xe6_30_enablePitchBend : 1; + }; + u8 dummy3 = 0; + }; union { struct { bool xe7_29_ : 1; }; - u32 dummy2 = 0; + u8 dummy4 = 0; }; public: CActor(TUniqueId, bool, const std::string&, const CEntityInfo&, @@ -82,14 +106,13 @@ public: virtual bool ValidAimTarget() { return true; } virtual bool ValidOrbitTarget() { return true; } virtual bool GetOrbitDistanceCheck() { return true; } - virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) - { return x34_transform.origin; } + virtual zeus::CVector3f GetOrbitPosition(const CStateManager&); void RemoveEmitter(); virtual std::experimental::optional GetTouchBounds() const { return {} ; } + virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int); - 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, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); @@ -100,29 +123,21 @@ public: void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); void AddMaterial(EMaterialTypes, CStateManager&); - void SetCallTouch(bool callTouch) - { - xe5_28_callTouch = callTouch; - } + void SetCallTouch(bool callTouch); - bool GetCallTouch() const - { - return xe5_28_callTouch; - } + bool GetCallTouch() const; - void SetUseInSortedList(bool use) - { - xe5_27_useInSortedLists = use; - } + void SetUseInSortedList(bool use); - bool GetUseInSortedLists() const - { - return xe5_27_useInSortedLists; - } + bool GetUseInSortedLists() const; const CMaterialFilter& GetMaterialFilter() const { return x70_; } + void SetInFluid(bool in, TUniqueId uid); + bool HasModelData() const; + const CSfxHandle* GetSfxHandle() const; + void SetSfxPitchBend(s32); }; } diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index bf5f23108..8f778c1e5 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -31,6 +31,7 @@ public: x54_visorParms(visorParms), b1(a), b2(b), b3(c), b4(d) {} static CActorParameters None() {return CActorParameters();} + void SetVisorParameters(const CVisorParameters& vParams) { x54_visorParms = vParams; } CVisorParameters GetVisorParameters() const { return x54_visorParms; } }; diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index b427db458..8dae106af 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -36,6 +36,7 @@ set(WORLD_SOURCES CScriptCoverPoint.hpp CScriptCoverPoint.cpp CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp CScriptCameraHint.hpp CScriptCameraHint.cpp + CScriptDamageableTrigger.hpp CScriptDamageableTrigger.cpp CScriptActorRotate.hpp CScriptActorRotate.cpp CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp CGrappleParameters.hpp diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp new file mode 100644 index 000000000..8ee582e83 --- /dev/null +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -0,0 +1,34 @@ +#include "CScriptDamageableTrigger.hpp" +#include "CActorParameters.hpp" + +namespace urde +{ +CActorParameters MakeDamageableTriggerActorParms(const CActorParameters& aParams, const CVisorParameters& vParams) +{ + CActorParameters ret = aParams; + ret.SetVisorParameters(vParams); + return ret; +} + +CMaterialList MakeDamageableTriggerMaterial(CScriptDamageableTrigger::ECanOrbit canOrbit) +{ + if (canOrbit == CScriptDamageableTrigger::ECanOrbit::Orbit) + return CMaterialList(EMaterialTypes::FourtyOne, EMaterialTypes::ThirtyFour, EMaterialTypes::FourtyThree, + EMaterialTypes::Fifty, EMaterialTypes::FiftySix); + return CMaterialList(EMaterialTypes::ThirtyFour, EMaterialTypes::FourtyThree, + EMaterialTypes::Fifty, EMaterialTypes::FiftySix); +} + + +CScriptDamageableTrigger::CScriptDamageableTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info, + const zeus::CVector3f& position, const zeus::CVector3f& extent, const CHealthInfo&, + const CDamageVulnerability&, u32, ResId, ResId, ResId, + CScriptDamageableTrigger::ECanOrbit canOrbit, bool active, const CVisorParameters& vParams) + : CActor(uid, active, name, info, zeus::CTransform::Translate(position), CModelData::CModelDataNull(), + MakeDamageableTriggerMaterial(canOrbit), MakeDamageableTriggerActorParms(CActorParameters::None(), vParams), + kInvalidUniqueId), + x14c_bounds(-extent * 0.5f, extent * 0.5f) +{ +} + +} diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp new file mode 100644 index 000000000..fa8955223 --- /dev/null +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -0,0 +1,26 @@ +#ifndef CSCRIPTDAMAGEABLETRIGGER_HPP +#define CSCRIPTDAMAGEABLETRIGGER_HPP + +#include "CActor.hpp" + +namespace urde +{ +class CVisorParameters; +class CScriptDamageableTrigger : public CActor +{ +public: + enum class ECanOrbit + { + NoOrbit, + Orbit, + }; + + zeus::CAABox x14c_bounds; +public: + CScriptDamageableTrigger(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, const zeus::CVector3f&, + const CHealthInfo&, const CDamageVulnerability&, u32, ResId, ResId, ResId, ECanOrbit, bool, + const CVisorParameters&); +}; +} + +#endif // CSCRIPTDAMAGEABLETRIGGER_HPP diff --git a/Runtime/World/CScriptGenerator.cpp b/Runtime/World/CScriptGenerator.cpp index 351b1622c..915e13c42 100644 --- a/Runtime/World/CScriptGenerator.cpp +++ b/Runtime/World/CScriptGenerator.cpp @@ -4,8 +4,24 @@ namespace urde { CScriptGenerator::CScriptGenerator(TUniqueId uid, const std::string& name, const CEntityInfo& info, - u32, bool, const zeus::CVector3f&, bool, bool active, float, float) -: CEntity(uid, info, active, name) + u32 w1, bool b1, const zeus::CVector3f& vec1, bool b2, bool active, float minScale, float maxScale) +: CEntity(uid, info, active, name), + x34_(w1), + x38_24_(b1), + x38_25_(b2), + x3c_(vec1), + x48_minScale(minScale), + x4c_maxScale(maxScale) { } + +void CScriptGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) +{ + if (msg == EScriptObjectMessage::SetToZero) + { + + } + + CEntity::AcceptScriptMsg(msg, objId, stateMgr); +} } diff --git a/Runtime/World/CScriptGenerator.hpp b/Runtime/World/CScriptGenerator.hpp index fd50d2d42..9e8f60119 100644 --- a/Runtime/World/CScriptGenerator.hpp +++ b/Runtime/World/CScriptGenerator.hpp @@ -9,9 +9,24 @@ namespace urde class CScriptGenerator : public CEntity { + u32 x34_; + union + { + struct + { + bool x38_24_ : 1; + bool x38_25_ : 1; + }; + u8 dummy1 =0; + }; + zeus::CVector3f x3c_; + float x48_minScale; + float x4c_maxScale; public: CScriptGenerator(TUniqueId uid, const std::string& name, const CEntityInfo& info, u32, bool, const zeus::CVector3f&, bool, bool, float, float); + + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); }; } diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index eaa2e1fe0..3d31ee941 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -12,29 +12,7 @@ class CResFactory; class CWorld { - ResId xc_worldId = -1; - ResId x10_ = -1; - ResId x24_ = -1; - - std::vector> x18_areas; - - std::unique_ptr x40_; - std::unique_ptr x44_; - - IObjectStore* x60_objectStore; - CResFactory* x64_resFactory; - - union - { - struct - { - bool x70_24_ : 1; - bool x70_25_ : 1; - bool x70_26_ : 1; - }; - }; public: - class CRelay { TEditorId x0_relay = kInvalidEditorId; @@ -50,6 +28,36 @@ public: s16 GetMessage() const { return x8_msg; } bool GetActive() const { return xa_active; } }; +private: + + ResId xc_worldId = -1; + ResId x10_ = -1; + std::vector> x18_areas; + ResId x24_ = -1; + std::vector x2c_relays; + + std::unique_ptr x40_; + std::unique_ptr x44_; + + IObjectStore* x60_objectStore; + CResFactory* x64_resFactory; + TAreaId x68_ = kInvalidAreaId; + u32 x6c_ = 0; + + union + { + struct + { + bool x70_24_ : 1; + bool x70_25_ : 1; + bool x70_26_ : 1; + bool x70_27_ : 1; + }; + }; + u32 x78_; + u32 x7c_; + +public: CWorld(IObjectStore& objStore, CResFactory& resFactory, ResId); bool DoesAreaExist(TAreaId area) const; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 9b9b64cd1..f60fb14ba 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -30,6 +30,7 @@ #include "CScriptCoverPoint.hpp" #include "CScriptSpawnPoint.hpp" #include "CScriptCameraHint.hpp" +#include "CScriptDamageableTrigger.hpp" #include "CScriptActorRotate.hpp" #include "CScriptSpecialFunction.hpp" #include "Camera/CCinematicCamera.hpp" @@ -909,9 +910,67 @@ CEntity* ScriptLoader::LoadCameraBlurKeyframe(CStateManager& mgr, CInputStream& { } +u32 ClassifyVector(const zeus::CVector3f& dir) +{ + zeus::CVector3f absDir(std::fabs(dir.x), std::fabs(dir.y), std::fabs(dir.z)); + u32 max = (absDir.x > absDir.y ? 0 : 1); + max = (absDir[max] > absDir.z ? max : 2); + + + bool positive = (absDir[max] == dir[max]); + if (max == 0) + return (positive ? 0x08 : 0x04); + else if (max == 1) + return (positive ? 0x01 : 0x02); + else if (max == 2) + return (positive ? 0x10 : 0x20); + + return 0; +} + +u32 TransformDamagableTriggerFlags(CStateManager& mgr, TAreaId aId, u32 flags) +{ + CGameArea* area = mgr.GetWorld()->GetGameAreas().at(aId).get(); + zeus::CTransform rotation = area->GetTransform().getRotation(); + + u32 ret = 0; + if (flags & 0x01) + ret |= ClassifyVector(rotation * zeus::kForwardVec); + if (flags & 0x02) + ret |= ClassifyVector(rotation * zeus::kBackVec); + if (flags & 0x04) + ret |= ClassifyVector(rotation * zeus::kLeftVec); + if (flags & 0x08) + ret |= ClassifyVector(rotation * zeus::kRightVec); + if (flags & 0x10) + ret |= ClassifyVector(rotation * zeus::kUpVec); + if (flags & 0x20) + ret |= ClassifyVector(rotation * zeus::kDownVec); + return ret; +} + CEntity* ScriptLoader::LoadDamageableTrigger(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 12, "DamageableTrigger")) + return nullptr; + + const std::string* name = mgr.HashInstanceName(in); + zeus::CVector3f position(zeus::CVector3f::ReadBig(in)); + zeus::CVector3f volume(zeus::CVector3f::ReadBig(in)); + + CHealthInfo hInfo(in); + CDamageVulnerability dVuln(in); + u32 triggerFlags = in.readUint32Big(); + triggerFlags = TransformDamagableTriggerFlags(mgr, info.GetAreaId(), triggerFlags); + ResId w1 = in.readUint32Big(); + ResId w2 = in.readUint32Big(); + ResId w3 = in.readUint32Big(); + CScriptDamageableTrigger::ECanOrbit canOrbit = CScriptDamageableTrigger::ECanOrbit(in.readBool()); + bool active = in.readBool(); + CVisorParameters vParms = LoadVisorParameters(in); + return new CScriptDamageableTrigger(mgr.AllocateUniqueId(), *name, info, position, volume, hInfo, dVuln, triggerFlags, w1, + w2, w3, canOrbit, active, vParms); } CEntity* ScriptLoader::LoadDebris(CStateManager& mgr, CInputStream& in, @@ -1229,12 +1288,12 @@ CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in, s16 w6 = in.readUint32Big() & 0xFFFF; s16 w7 = in.readUint32Big() & 0xFFFF; if (specialFunction == CScriptSpecialFunction::ESpecialFunction::FourtySeven || - 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); + f3, f4, zeus::CVector3f::skZero, zeus::CColor::skBlack, active1, CDamageInfo(), w2, w3, w4, + w5, w6, w7); } CEntity* ScriptLoader::LoadSpankWeed(CStateManager& mgr, CInputStream& in, diff --git a/specter b/specter index 90daa39c4..a48e2b4ec 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 90daa39c473e5821bf3a54c6c8f0a4a6cd011499 +Subproject commit a48e2b4ec5087bcb167f15763c84fbac2ca4c272