diff --git a/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp index 392959ce6..2d7b869ab 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp @@ -6,6 +6,8 @@ namespace DataSpec { struct ITweakTargeting : public ITweak { + virtual float GetOvershootOffset() const =0; + virtual float GetXD0() const = 0; }; } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp index f157942f0..db16d6257 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp @@ -55,7 +55,7 @@ struct CTweakTargeting : public ITweakTargeting Value xdc_; Value xe0_; Value xe4_; - Value xe8_; + Value xe8_overshootOffset; Value xec_; Value xf0_; Value xf4_; @@ -147,6 +147,9 @@ struct CTweakTargeting : public ITweakTargeting x144_ = (2.f * M_PIF) * (0.003f * x144_); x208_ = (2.f * M_PIF) * (0.003f * x208_); } + + float GetOvershootOffset() const { return xe8_overshootOffset; } + float GetXD0() const { return xd0_; } }; } } diff --git a/Runtime/CObjectList.hpp b/Runtime/CObjectList.hpp index 209006254..132ba3b6c 100644 --- a/Runtime/CObjectList.hpp +++ b/Runtime/CObjectList.hpp @@ -30,7 +30,7 @@ class CObjectList TUniqueId next = kInvalidUniqueId; TUniqueId prev = kInvalidUniqueId; }; - SObjectListEntry x0_list[1024]; + SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector EGameObjectList x2004_listEnum; TUniqueId x2008_firstId = kInvalidUniqueId; u16 x200a_count = 0; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 623ec0d81..4519c06a4 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -326,7 +326,7 @@ void CStateManager::TouchPlayerActor() return; #if 0 - CScriptPlayerActor* spa = TCastToPtr(GetObjectById(xf6c_playerActor)); + TCastToPtr spa(ObjectById(xf6c_playerActor)); if (spa) spa->TouchModels(); #endif diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index e69de29bb..aaee7456c 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -0,0 +1,32 @@ +#include "CCollisionActor.hpp" +#include "World/CActorParameters.hpp" + +namespace urde +{ +static const CMaterialList gkDefaultCollisionActorMaterials = + CMaterialList(EMaterialTypes::Solid, EMaterialTypes::CollisionActor, EMaterialTypes::ScanPassthrough, + EMaterialTypes::CameraPassthrough); + +CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& vec1, + const zeus::CVector3f& vec2, bool active, float mass) +: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), + zeus::CTransform::Identity(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials, + zeus::CAABox::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) +{ +} + +CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& vec, bool active, + float mass) +: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), + zeus::CTransform::Identity(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials, + zeus::CAABox::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) +{ +} + +CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bool active, float, float mass) +: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), + zeus::CTransform::Identity(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials, + zeus::CAABox::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) +{ +} +} diff --git a/Runtime/Collision/CCollisionActor.hpp b/Runtime/Collision/CCollisionActor.hpp index e69de29bb..2bcb96640 100644 --- a/Runtime/Collision/CCollisionActor.hpp +++ b/Runtime/Collision/CCollisionActor.hpp @@ -0,0 +1,17 @@ +#ifndef __URDE_CCOLLISIONACTOR_HPP__ +#define __URDE_CCOLLISIONACTOR_HPP__ + +#include "World/CPhysicsActor.hpp" + +namespace urde +{ +class CCollisionActor : public CPhysicsActor +{ +public: + CCollisionActor(TUniqueId, TAreaId, TUniqueId, const zeus::CVector3f&, const zeus::CVector3f&, bool, float); + CCollisionActor(TUniqueId, TAreaId, TUniqueId, const zeus::CVector3f&, bool, float); + CCollisionActor(TUniqueId, TAreaId, TUniqueId, bool, float, float); +}; +} + +#endif // __URDE_CCOLLISIONACTOR_HPP__ diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index e1b6cf59c..32069a195 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -42,6 +42,7 @@ enum class EMaterialTypes Character = 33, Trigger = 34, Projectile = 35, + Bomb = 36, GroundCollider = 37, ThirtyEight = 38, Scannable = 39, @@ -50,11 +51,15 @@ enum class EMaterialTypes Occluder = 42, Immovable = 43, Debris = 44, + PowerBomb = 45, + Unknown46 = 46, + CollisionActor = 47, AIBlock = 48, Platform = 49, NonSolidDamageable = 50, + PlatformSlave = 52, Unknown54 = 54, - Unknwon55 = 55, + Unknown55 = 55, ExcludeFromLineOfSightTest = 56, SixtyThree = 63 }; diff --git a/Runtime/GuiSys/CCompoundTargetReticle.cpp b/Runtime/GuiSys/CCompoundTargetReticle.cpp index 67e7569e4..86db1c553 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.cpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.cpp @@ -1,6 +1,58 @@ #include "CCompoundTargetReticle.hpp" +#include "GameGlobalObjects.hpp" +#include "CSimplePool.hpp" +#include "Graphics/CModel.hpp" +#include "CStateManager.hpp" +#include namespace urde { +const CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, + zeus::CVector3f::skZero, 0.f, 1.f, true); +static float offshoot_func(float f1, float f2, float f3) { return (f1 * 0.5f) + zeus::fastSinF((f3 - 0.5f) * f2); } + +static float calculate_premultiplied_overshoot_offset(float f1) { return 2.f * (M_PIF - std::asin(1.f / f1)); } + +CCompoundTargetReticle::SOuterItemInfo::SOuterItemInfo(const char* res) : x0_(g_SimplePool->GetObj(res)) {} + +CTargetReticleRenderState::CTargetReticleRenderState(TUniqueId target, float f1, const zeus::CVector3f& vec, float f2, + float f3, bool b1) +: x0_target(target), x4_(f1), x8_(vec), x14_(f2), x18_(f3), x1c_(b1) +{ +} + +CCompoundTargetReticle::CCompoundTargetReticle(const CStateManager& mgr) +: x0_(static_cast(mgr.GetCameraManager()->GetCurrentCamera(mgr))->GetTransform().buildMatrix3f()) +, x10_(static_cast(mgr.GetCameraManager()->GetCurrentCamera(mgr))->GetTransform().buildMatrix3f()) +, x2c_overshootOffsetHalf(0.5f * g_tweakTargeting->GetOvershootOffset()) +, x30_premultOvershootOffset(calculate_premultiplied_overshoot_offset(g_tweakTargeting->GetOvershootOffset())) +, x34_crosshairs(g_SimplePool->GetObj(skCrosshairsReticleAssetName)) +, x40_seeker(g_SimplePool->GetObj(skSeekerAssetName)) +, x4c_lockConfirm(g_SimplePool->GetObj(skLockConfirmAssetName)) +, x58_targetFlower(g_SimplePool->GetObj(skTargetFlowerAssetName)) +, x64_missileBracket(g_SimplePool->GetObj(skMissileBracketAssetName)) +, x70_innerBeamIcon(g_SimplePool->GetObj(skInnerBeamIconName)) +, x7c_lockFire(g_SimplePool->GetObj(skLockFireAssetName)) +, x88_lockDagger(g_SimplePool->GetObj(skLockDaggerAssetName)) +, x94_grapple(g_SimplePool->GetObj(skGrappleReticleAssetName)) +, xa0_chargeTickFirst(g_SimplePool->GetObj(skChargeBeamTickAssetName)) +, xac_xrayRetRing(g_SimplePool->GetObj(skXRayRingModelName)) +, xb8_thermalReticle(g_SimplePool->GetObj(skThermalReticleAssetName)) +, xc4_chargeGauge(skChargeGaugeAssetName) +, xf4_(CalculateOrbitZoneReticlePosition(mgr)) +, x100_(CalculateOrbitZoneReticlePosition(mgr)) +, x208_(g_tweakTargeting->GetXD0()) +{ + xe0_outerBeamIconSquares.reserve(9); + for (u32 i = 0; i < 9; ++i) + { + char name[1024]; + sprintf(name, "%s%d", skOuterBeamIconSquareNameBase, i); + xe0_outerBeamIconSquares.emplace_back(name); + } + x34_crosshairs.Lock(); +} + +zeus::CVector3f CCompoundTargetReticle::CalculateOrbitZoneReticlePosition(const CStateManager&) const { return {}; } } diff --git a/Runtime/GuiSys/CCompoundTargetReticle.hpp b/Runtime/GuiSys/CCompoundTargetReticle.hpp index dbc2434bb..ff531b801 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.hpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.hpp @@ -1,13 +1,155 @@ #ifndef __CCOMPOUNDTARGETRETICLE_HPP__ #define __CCOMPOUNDTARGETRETICLE_HPP__ +#include "RetroTypes.hpp" +#include "zeus/CQuaternion.hpp" +#include "CToken.hpp" + namespace urde { +class CActor; +class CModel; class CStateManager; +class CTargetReticleRenderState +{ + TUniqueId x0_target; + float x4_; + zeus::CVector3f x8_; + float x14_; + float x18_; + bool x1c_; + +public: + + static const CTargetReticleRenderState skZeroRenderState; + + CTargetReticleRenderState(TUniqueId, float, const zeus::CVector3f&, float, float, bool); + void SetTargetId(TUniqueId); + void SetFactor(float); + void SetIsOrbitZoneIdlePosition(bool); + float GetMinViewportClampScale() const; + float GetFactor() const; + float GetRadiusWorld() const; + const zeus::CVector3f& GetTargetPositionWorld() const; + bool GetIsOrbitZoneIdlePosition() const; + void SetTargetPositionWorld(const zeus::CVector3f&); + void SetRadiusWorld(float); + TUniqueId GetTargetId() const; + static void InterpolateWithClamp(const CTargetReticleRenderState&, CTargetReticleRenderState&, + const CTargetReticleRenderState&, float); + float SetMinViewportClampScale(float); +}; + class CCompoundTargetReticle { +public: + struct SOuterItemInfo + { + TToken x0_; + float xc_ = 0.f; + float x10_ = 0.f; + float x14_ = 0.f; + float x18_ = 0.f; + SOuterItemInfo(const char*); + }; + +private: + + static constexpr const char* skCrosshairsReticleAssetName = "CMDL_Crosshairs"; + static constexpr const char* skOrbitZoneReticleAssetName = "CMDL_OrbitZone"; + static constexpr const char* skSeekerAssetName = "CMDL_Seeker"; + static constexpr const char* skLockConfirmAssetName = "CMDL_LockConfirm"; + static constexpr const char* skTargetFlowerAssetName = "CMDL_TargetFlower"; + static constexpr const char* skMissileBracketAssetName = "CMDL_MissileBracket"; + static constexpr const char* skChargeGaugeAssetName = "CMDL_ChargeGauge"; + static constexpr const char* skChargeBeamTickAssetName = "CMDL_ChargeTickFirst"; + static constexpr const char* skOuterBeamIconSquareNameBase = "CMDL_BeamSquare"; + static constexpr const char* skInnerBeamIconName = "CMDL_InnerBeamIcon"; + static constexpr const char* skLockFireAssetName = "CMDL_LockFIre"; + static constexpr const char* skLockDaggerAssetName = "CMDL_LockDagger0"; + static constexpr const char* skGrappleReticleAssetName = "CMDL_Grapple"; + static constexpr const char* skXRayRingModelName = "CMDL_XRayRetRing"; + static constexpr const char* skThermalReticleAssetName = "CMDL_ThermalRet"; + static constexpr const char* skOrbitPointAssetName = "CMDL_OrbitPoint"; + zeus::CQuaternion x0_; + zeus::CQuaternion x10_; + u32 x20_ = 5; + u32 x24_ = 5; + u32 x28_ = 0; + float x2c_overshootOffsetHalf; + float x30_premultOvershootOffset; + TToken x34_crosshairs; + TToken x40_seeker; + TToken x4c_lockConfirm; + TToken x58_targetFlower; + TToken x64_missileBracket; + TToken x70_innerBeamIcon; + TToken x7c_lockFire; + TToken x88_lockDagger; + TToken x94_grapple; + TToken xa0_chargeTickFirst; + TToken xac_xrayRetRing; + TToken xb8_thermalReticle; + SOuterItemInfo xc4_chargeGauge; + std::vector xe0_outerBeamIconSquares; + TUniqueId xf0_; + TUniqueId xf2_; + zeus::CVector3f xf4_; + zeus::CVector3f x100_; + CTargetReticleRenderState x10c_ = CTargetReticleRenderState::skZeroRenderState; + CTargetReticleRenderState x12c_ = CTargetReticleRenderState::skZeroRenderState; + CTargetReticleRenderState x14c_ = CTargetReticleRenderState::skZeroRenderState; + float x16c_ = 0.f; + float x170_ = 0.f; + CTargetReticleRenderState x174_ = CTargetReticleRenderState::skZeroRenderState; + CTargetReticleRenderState x194_ = CTargetReticleRenderState::skZeroRenderState; + CTargetReticleRenderState x1b4_ = CTargetReticleRenderState::skZeroRenderState; + float x1d4_ = 0.f; + float x1d8_ = 0.f; + TUniqueId x1dc_ = kInvalidUniqueId; + TUniqueId x1de_ = kInvalidUniqueId; + float x1e0_ = 0.f; + float x1e4_ = 0.f; + float x1e8_ = 0.f; + float x1ec_ = 0.f; + float x1f0_ = 0.f; + u8 x1f4_ = 0; + float x1f8_ = 0.f; + float x1fc_ = 0.f; + u32 x200_ = 0; + float x204_ = 0.f; + float x208_; + float x20c_ = 0.f; + float x210_ = 0.f; + float x214_ = 0.f; + u8 x218_ = 0; + u8 x219_ = 0; + u8 x21a_ = 0; + u8 x21b_ = 0; + u32 x21c_; + u32 x220_; + u32 x228_; public: CCompoundTargetReticle(const CStateManager&); + + void SetLeadingOrientation(const zeus::CQuaternion&); + bool CheckLoadComplete() { return true; } + void GetDesiredReticleState(const CStateManager&) const; + void Update(float, const CStateManager&); + void UpdateCurrLockOnGroup(float, const CStateManager&); + void UpdateUpdateNextLockOnGroup(float, const CStateManager&); + void UpdateOrbitZoneGroup(float, const CStateManager&); + void Draw(const CStateManager&) const; + void DrawCurrLockOnGroup(const CStateManager&) const; + void DrawNextLockOnGroup(const CStateManager&) const; + void DrawOrbitZoneGroup(const CStateManager&) const; + void UpdateTargetParameters(CTargetReticleRenderState&, const CStateManager&); + float CalculateRadiusWorld(const CActor&, const CStateManager&) const; + zeus::CVector3f CalculatePositionWorld(const CActor&, const CStateManager&) const; + zeus::CVector3f CalculateOrbitZoneReticlePosition(const CStateManager&) const; + bool IsGrappleTarget(TUniqueId, const CStateManager&) const; + void CalculateClampedScale(const zeus::CVector3f&, float, float, float, const CStateManager&); + void Touch() const; }; } diff --git a/Runtime/GuiSys/COrbitPointMarker.hpp b/Runtime/GuiSys/COrbitPointMarker.hpp index e69de29bb..23e4dfefc 100644 --- a/Runtime/GuiSys/COrbitPointMarker.hpp +++ b/Runtime/GuiSys/COrbitPointMarker.hpp @@ -0,0 +1,13 @@ +#ifndef __URDE_CORBITPOINTMARKER_HPP__ +#define __URDE_CORBIGPOINTMARKER_HPP__ + +namespace +{ +class CStateManager; +class COrbigPointMarker +{ +public: + +}; +} +#endif // __URDE_CORBIGPOINTMARKER_HPP__ diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 9d11ae7e6..14dca5139 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -5,6 +5,7 @@ #include "Audio/CSfxManager.hpp" #include "TCastTo.hpp" #include "Character/IAnimReader.hpp" +#include "Character/CActorLights.hpp" namespace urde { @@ -12,9 +13,9 @@ static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, co { CMaterialList ret = materialList; if (params.GetVisorParameters().x0_28_b3) - ret.Add(EMaterialTypes::Mud); + ret.Add(EMaterialTypes::Unknown46); if (params.GetVisorParameters().x0_29_b4) - ret.Add(EMaterialTypes::Glass); + ret.Add(EMaterialTypes::ScanPassthrough); return ret; } @@ -305,4 +306,10 @@ SAdvancementDeltas CActor::UpdateAnimation(float, CStateManager&, bool) { return {}; } + +void CActor::SetActorLights(std::unique_ptr lights) +{ + x90_actorLights = std::move(lights); + xe4_31_lightsDirty = true; +} } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index d1e8b937a..fbb89a1bc 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -58,6 +58,7 @@ protected: bool xe4_28_ : 1; bool xe4_29_ : 1; bool xe4_30_ : 1; + bool xe4_31_lightsDirty : 1; bool xe5_24_ : 1; bool xe5_25_ : 1; bool xe5_26_muted : 1; @@ -158,6 +159,7 @@ public: void EnsureRendered(const CStateManager&); void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&); SAdvancementDeltas UpdateAnimation(float, CStateManager&, bool); + void SetActorLights(std::unique_ptr); }; } diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index ab2874c48..300dfb919 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -11,7 +11,7 @@ namespace urde class CActorParameters { friend class ScriptLoader; - CLightParameters x4_lightParms; + CLightParameters x0_lightParms; CScannableParameters x40_scanParms; std::pair x44_xrayAssets = {}; std::pair x4c_thermalAssets = {}; @@ -23,15 +23,23 @@ class CActorParameters float x5c_; float x60_; float x64_; + public: - CActorParameters() - : b1(true), b2(false), b3(false), b4(false) {} + CActorParameters() : b1(true), b2(false), b3(false), b4(false) {} CActorParameters(const CLightParameters& lightParms, const CScannableParameters& scanParms, const std::pair& xrayAssets, const std::pair& thermalAssets, const CVisorParameters& visorParms, bool a, bool b, bool c, bool d) - : x4_lightParms(lightParms), x40_scanParms(scanParms), - x44_xrayAssets(xrayAssets), x4c_thermalAssets(thermalAssets), - x54_visorParms(visorParms), b1(a), b2(b), b3(c), b4(d) {} + : x0_lightParms(lightParms) + , x40_scanParms(scanParms) + , x44_xrayAssets(xrayAssets) + , x4c_thermalAssets(thermalAssets) + , x54_visorParms(visorParms) + , b1(a) + , b2(b) + , b3(c) + , b4(d) + { + } CActorParameters Scannable(const CScannableParameters& sParms) const { CActorParameters aParms = *this; @@ -39,12 +47,12 @@ public: return aParms; } - static CActorParameters None() {return CActorParameters();} + static CActorParameters None() { return CActorParameters(); } void SetVisorParameters(const CVisorParameters& vParams) { x54_visorParms = vParams; } - CVisorParameters GetVisorParameters() const { return x54_visorParms; } + const CVisorParameters& GetVisorParameters() const { return x54_visorParms; } + const CLightParameters& GetLightParameters() const { return x0_lightParms; } }; - } #endif // __URDE_CACTORPARAMETERS_HPP__ diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 9393296ba..69ba6a391 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -11,11 +11,11 @@ namespace urde { CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, - CModelData&& mData, const zeus::CAABox& aabb, float f1, float zMomentum, + CModelData&& mData, const zeus::CAABox& aabb, float mass, float zMomentum, const CMaterialList& matList, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, const CActorParameters& actParms, bool looping, bool active, u32 w1, float f3, bool b2, bool castsShadow, bool b4, bool b5) -: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(f1), actParms, 0.3f, 0.1f) +: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(mass), actParms, 0.3f, 0.1f) , x258_initialHealth(hInfo) , x260_currentHealth(hInfo) , x268_damageVulnerability(dVuln) diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index e69de29bb..866081ca1 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -0,0 +1,58 @@ +#include "World/CScriptPlayerActor.hpp" +#include "World/CActorParameters.hpp" +#include "World/CLightParameters.hpp" + +namespace urde +{ +CScriptPlayerActor::CScriptPlayerActor(TUniqueId uid, const std::string& name, const CEntityInfo& info, + const zeus::CTransform& xf, const CAnimRes& animRes, CModelData&& mData, + const zeus::CAABox& aabox, bool b1, const CMaterialList& list, float mass, + float zMomentum, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, + const CActorParameters& aParams, bool loop, bool active, u32 w1, u32 w2) +: CScriptActor(uid, name, info, xf, std::move(mData), aabox, mass, zMomentum, list, hInfo, dVuln, aParams, loop, active, + 0, 1.f, false, false, false, false) +, x2e8_(animRes) +, x304_(w2) +, x350_(w1) +{ + x354_24_ = b1; + x354_29_ = true; + x354_30_ = true; + CMaterialList exclude = GetMaterialFilter().GetExcludeList(); + CMaterialList include = GetMaterialFilter().GetIncludeList(); + include.Add(EMaterialTypes::Player); + SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude)); + + SetActorLights(aParams.GetLightParameters().MakeActorLights()); +} + +void CScriptPlayerActor::Think(float, CStateManager&) +{ + +} + +void CScriptPlayerActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) +{ +} + +void CScriptPlayerActor::SetActive(bool active) +{ + CActor::SetActive(active); + xe7_29_ = true; +} + +void CScriptPlayerActor::PreRender(CStateManager&, const zeus::CFrustum&) +{ + +} + +void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const +{ + +} + +void CScriptPlayerActor::Render(const CStateManager& mgr) const +{ + +} +} diff --git a/Runtime/World/CScriptPlayerActor.hpp b/Runtime/World/CScriptPlayerActor.hpp index 708b82337..797cbfa78 100644 --- a/Runtime/World/CScriptPlayerActor.hpp +++ b/Runtime/World/CScriptPlayerActor.hpp @@ -1,12 +1,55 @@ #ifndef __URDE_CSCRIPTPLAYERACTOR_HPP__ #define __URDE_CSCRIPTPLAYERACTOR_HPP__ -#include "CPhysicsActor.hpp" + +#include "CScriptActor.hpp" namespace urde { -class CScriptPlayerActor : CPhysicsActor +class CScriptPlayerActor : public CScriptActor { + CAnimRes x2e8_; + u32 x304_; + s32 x308_ = -1; + s32 x30c_ = -1; + s32 x310_ = -1; + u32 x314_ = 0; + u32 x318_ = 0; + u32 x31c_ = 0; + u32 x320_ = 0; + u32 x324_ = 0; + u8 x334_ = 0; + u8 x344_ = 0; + u32 x348_ = 0; + float x34c_ = 0.f; + u32 x350_; + union + { + struct + { + bool x354_24_ : 1; + bool x354_25_ : 1; + bool x354_26_ : 1; + bool x354_27_ : 1; + bool x354_28_ : 1; + bool x354_29_ : 1; + bool x354_30_ : 1; + bool x354_31_ : 1; + bool x355_24_ : 1; + }; + u8 x355_dummy = 0; + }; + public: + CScriptPlayerActor(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, const CAnimRes&, + CModelData&&, const zeus::CAABox&, bool, const CMaterialList&, float, float, + const CHealthInfo&, const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, u32); + + void Think(float, CStateManager &); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); + void SetActive(bool active); + void PreRender(CStateManager &, const zeus::CFrustum &); + void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const; + void Render(const CStateManager &mgr) const; }; } diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 532b48f10..e357adcd9 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -29,6 +29,7 @@ #include "CScriptGrapplePoint.hpp" #include "CScriptPickupGenerator.hpp" #include "CScriptPointOfInterest.hpp" +#include "CScriptPlayerActor.hpp" #include "CScriptAreaAttributes.hpp" #include "CScriptCameraWaypoint.hpp" #include "CScriptCoverPoint.hpp" @@ -282,7 +283,6 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in) CLightParameters::EWorldLightingOptions lightOpts = CLightParameters::EWorldLightingOptions(in.readUint32Big()); CLightParameters::ELightRecalculationOptions recalcOpts = CLightParameters::ELightRecalculationOptions(in.readUint32Big()); - ; zeus::CVector3f vec; vec.readBig(in); @@ -419,17 +419,13 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC if (cameraPassthrough) // Bool 4 list.Add(EMaterialTypes::CameraPassthrough); - bool generateExtent = false; - if (collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f) - generateExtent = true; - CModelData data; if (animType == SBIG('ANCS')) data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, true, aParms.GetInitialAnimation()); else data = CStaticRes(staticId, head.x40_scale); - if (generateExtent || collisionExtent.isZero()) + if ((collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f)|| collisionExtent.isZero()) aabb = data.GetBounds(head.x10_transform.getRotation()); return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), aabb, f1, @@ -1650,7 +1646,45 @@ CEntity* ScriptLoader::LoadIceSheegoth(CStateManager& mgr, CInputStream& in, int CEntity* ScriptLoader::LoadPlayerActor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 19, "PlayerActor")) + return nullptr; + + SScaledActorHead aHead = LoadScaledActorHead(in, mgr); + zeus::CVector3f extents = zeus::CVector3f::ReadBig(in); + zeus::CVector3f offset = zeus::CVector3f::ReadBig(in); + float mass = in.readFloatBig(); + float zMomentum = in.readFloatBig(); + CHealthInfo hInfo(in); + CDamageVulnerability dVuln(in); + in.readUint32Big(); + CAnimationParameters animParms = LoadAnimationParameters(in); + CActorParameters actParms = LoadActorParameters(in); + bool loop = in.readBool(); + bool snow = in.readBool(); + bool solid = in.readBool(); + bool active = in.readBool(); + u32 flags = LoadParameterFlags(in); + bool w1 = in.readUint32Big() - 1; + + FourCC fcc = g_ResFactory->GetResourceTypeById(animParms.GetACSFile()); + if (!fcc || fcc != SBIG('ANCS')) + return nullptr; + + zeus::CAABox aabox = GetCollisionBox(mgr, info.GetAreaId(), extents, offset); + CMaterialList list; + if (snow) + list.Add(EMaterialTypes::Snow); + + if (solid) + list.Add(EMaterialTypes::Solid); + + if ((extents.x < 0.f || extents.y < 0.f || extents.z < 0.f) || extents.isZero()) + aabox = zeus::CAABox({-.5f}, {0.5f}); + + return new CScriptPlayerActor(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, + CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), aHead.x40_scale, + animParms.GetInitialAnimation(), loop), CModelData::CModelDataNull(), + aabox, true, list, mass, zMomentum, hInfo, dVuln, actParms, loop, active, flags, w1); } CEntity* ScriptLoader::LoadFlaahgra(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)