diff --git a/DataSpec/DNAMP1/ScriptObjects/Effect.hpp b/DataSpec/DNAMP1/ScriptObjects/Effect.hpp index 046ac064c..531e4aec1 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Effect.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/Effect.hpp @@ -17,23 +17,23 @@ struct Effect : IScriptObject Value scale; UniqueID32 part; UniqueID32 elsc; - Value unknown1; - Value unknown2; - Value unknown3; - Value unknown4; - Value unknown5; - Value unknown6; - Value unknown7; - Value unknown8; - Value unknown9; - Value unknown10; - Value unknown11; - Value unknown12; - Value unknown13; - Value unknown14; - Value unknown15; - Value unknown16; - Value unknown17; + Value hotInThermal; + Value noTimerUnlessAreaOccluded; + Value rebuildSystemsOnActivate; + Value active; + Value useRateInverseCamDist; + Value rateInverseCamDist; + Value rateInverseCamDistRate; + Value duration; + Value durationResetWhileVisible; + Value useRateCamDistRange; + Value rateCamDistRangeMin; + Value rateCamDistRangeMax; + Value rateCamDistRangeFarRate; + Value combatVisorVisible; + Value thermalVisorVisible; + Value xrayVisorVisible; + Value dieWhenSystemsDone; LightParameters lightParameters; void nameIDs(PAKRouter& pakRouter) const diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index b97fd9a9e..03b3d510c 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -758,7 +758,7 @@ void CStateManager::DrawWorld() const { if (TCastToPtr actor = ent) { - if (!actor->xe7_29_actorActive) + if (!actor->xe7_29_drawEnabled) continue; TUniqueId actorId = actor->GetUniqueId(); if (!thermal && area.LookupPVSUniqueID(actorId) == actorId) diff --git a/Runtime/Camera/CGameCamera.cpp b/Runtime/Camera/CGameCamera.cpp index a90894f1e..3ee3f733d 100644 --- a/Runtime/Camera/CGameCamera.cpp +++ b/Runtime/Camera/CGameCamera.cpp @@ -24,7 +24,7 @@ CGameCamera::CGameCamera(TUniqueId uid, bool active, std::string_view name, cons , x184_fov(fovy) { - xe7_29_actorActive = false; + xe7_29_drawEnabled = false; } void CGameCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) @@ -46,7 +46,7 @@ void CGameCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat void CGameCamera::SetActive(bool active) { CActor::SetActive(active); - xe7_29_actorActive = false; + xe7_29_drawEnabled = false; } zeus::CMatrix4f CGameCamera::GetPerspectiveMatrix() const diff --git a/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp b/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp index d35609589..f6b6d6261 100644 --- a/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp +++ b/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp @@ -571,8 +571,8 @@ CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPla const char* texNames[3] = {}; std::string finalVS, finalFS; _BuildShader(finalVS, finalFS, nextTex, texNames, info); - const char* uniNames[] = {"FluidPlaneUniform"}; - return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), size_t(nextTex), texNames, 1, uniNames, + const char* uniNames[] = {"FluidPlaneUniform", "FluidPlaneUniform", "LightingUniform"}; + return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), size_t(nextTex), texNames, 3, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None); diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index a23291ba4..b3f83fe47 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -176,6 +176,7 @@ public: boo::ObjToken m_uniformBufPmus; CGenDescription* GetDesc() {return x1c_genDesc.GetObj();} + const SObjectTag* GetDescTag() const {return x1c_genDesc.GetObjectTag();} static bool g_ParticleSystemInitialized; static int g_ParticleAliveCount; diff --git a/Runtime/Particle/CVectorElement.cpp b/Runtime/Particle/CVectorElement.cpp index 47425e709..831b33ebb 100644 --- a/Runtime/Particle/CVectorElement.cpp +++ b/Runtime/Particle/CVectorElement.cpp @@ -66,12 +66,12 @@ CVECone::CVECone(CVectorElement* a, CRealElement* b) { zeus::CVector3f av; x4_direction->GetValue(0, av); - av.normalize(); - if (av[0] > 0.8) + zeus::CVector3f avNorm = av.normalized(); + if (avNorm.x > 0.8) xc_xVec = av.cross(zeus::CVector3f(0.f, 1.f, 0.f)); else xc_xVec = av.cross(zeus::CVector3f(1.f, 0.f, 0.f)); - x18_yVec = av.cross(xc_xVec); + x18_yVec = avNorm.cross(xc_xVec); } bool CVECone::GetValue(int frame, zeus::CVector3f& valOut) const diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index d56a3e6e4..67458ac30 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -51,7 +51,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI xe6_29_renderParticleDBInside = true; xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask(); xe7_27_enableRender = true; - xe7_29_actorActive = active; + xe7_29_drawEnabled = active; xe7_30_doTargetDistanceTest = true; xe7_31_targetable = true; if (x64_modelData) @@ -77,11 +77,18 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana { if (!x30_24_active) xbc_time = CGraphics::GetSecondsMod900(); + break; } - break; - case EScriptObjectMessage::Decrement: + case EScriptObjectMessage::Deactivate: RemoveEmitter(); break; + case EScriptObjectMessage::Deleted: // 34 + { + RemoveEmitter(); + if (HasModelData() && x64_modelData->AnimationData() && x64_modelData->GetNormalModel()) + x64_modelData->AnimationData()->GetParticleDB().DeleteAllLights(mgr); + break; + } case EScriptObjectMessage::Registered: // 33 { if (x98_scanObjectInfo) @@ -94,15 +101,14 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana TAreaId aid = GetAreaId(); x64_modelData->AnimationData()->InitializeEffects(mgr, aid, x64_modelData->GetScale()); } + break; } - break; - case EScriptObjectMessage::Deleted: // 34 - { - RemoveEmitter(); - if (HasModelData() && x64_modelData->AnimationData() && x64_modelData->GetNormalModel()) - x64_modelData->AnimationData()->GetParticleDB().DeleteAllLights(mgr); - } - break; + case EScriptObjectMessage::UpdateSplashInhabitant: // 37 + SetInFluid(true, uid); + break; + case EScriptObjectMessage::RemoveSplashInhabitant: // 39 + SetInFluid(false, kInvalidUniqueId); + break; case EScriptObjectMessage::InitializedInArea: // 35 { for (const SConnection& conn : x20_conns) @@ -114,14 +120,8 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana if (act && xc6_nextDrawNode == kInvalidUniqueId) xc6_nextDrawNode = act->GetUniqueId(); } + break; } - break; - case EScriptObjectMessage::UpdateSplashInhabitant: // 37 - SetInFluid(true, uid); - break; - case EScriptObjectMessage::RemoveSplashInhabitant: // 39 - SetInFluid(false, kInvalidUniqueId); - break; default: break; } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index ccc5dd4bc..10a8c7e11 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -74,7 +74,7 @@ protected: u8 xe6_31_targetableVisorFlags : 4; bool xe7_27_enableRender : 1; bool xe7_28_worldLightingDirty : 1; - bool xe7_29_actorActive : 1; + bool xe7_29_drawEnabled : 1; bool xe7_30_doTargetDistanceTest : 1; bool xe7_31_targetable : 1; }; @@ -110,7 +110,7 @@ public: xe4_27_notInSortedLists = true; xe4_28_transformDirty = true; xe4_29_actorLightsDirty = true; - xe7_29_actorActive = active; + xe7_29_drawEnabled = active; CEntity::SetActive(active); } virtual void PreRender(CStateManager&, const zeus::CFrustum&); @@ -184,7 +184,7 @@ public: const CActorLights* GetActorLights() const { return x90_actorLights.get(); } CActorLights* ActorLights() { return x90_actorLights.get(); } bool CanDrawStatic() const; - bool IsActorActive() const { return xe7_29_actorActive; } + bool IsActorActive() const { return xe7_29_drawEnabled; } void SetWorldLightingDirty(bool b) { xe7_28_worldLightingDirty = b; } const CScannableObjectInfo* GetScannableObjectInfo() const; const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const diff --git a/Runtime/World/CFluidPlaneDoor.hpp b/Runtime/World/CFluidPlaneDoor.hpp index 19f1b70d5..b7a35245f 100644 --- a/Runtime/World/CFluidPlaneDoor.hpp +++ b/Runtime/World/CFluidPlaneDoor.hpp @@ -29,9 +29,9 @@ public: void AddRipple(const CRipple& ripple, const CScriptWater& water, CStateManager& mgr) {} void Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, - const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const std::experimental::optional& rippleManager, TUniqueId waterId, - const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const; + const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, + const std::experimental::optional& rippleManager, TUniqueId waterId, + const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const; }; } diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index f0079f61d..3c5224762 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -46,22 +46,9 @@ void CScriptActor::Accept(IVisitor& visitor) { visitor.Visit(this); } void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { - if (msg == EScriptObjectMessage::Reset) - { - x2e2_25_dead = false; - x260_currentHealth = x258_initialHealth; - } - else if (msg == EScriptObjectMessage::Increment && !GetActive()) - { - mgr.SendScriptMsg(this, x8_uid, EScriptObjectMessage::Activate); - CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_alphaMax); - } - else if (msg == EScriptObjectMessage::Decrement) - { - CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_alphaMin); - } - else if (msg == EScriptObjectMessage::InitializedInArea) + switch (msg) { + case EScriptObjectMessage::InitializedInArea: for (const SConnection& conn : x20_conns) { if (conn.x0_state != EScriptObjectState::InheritBounds || conn.x4_msg != EScriptObjectMessage::Activate) @@ -80,6 +67,23 @@ void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta if (x2e2_31_materialFlag54) CActor::AddMaterial(EMaterialTypes::Unknown54, mgr); + break; + case EScriptObjectMessage::Reset: + x2e2_25_dead = false; + x260_currentHealth = x258_initialHealth; + break; + case EScriptObjectMessage::Increment: + if (!GetActive()) + { + mgr.SendScriptMsg(this, x8_uid, EScriptObjectMessage::Activate); + CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_alphaMax); + } + break; + case EScriptObjectMessage::Decrement: + CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_alphaMin); + break; + default: + break; } CActor::AcceptScriptMsg(msg, uid, mgr); diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index 8e41e71d5..2ec7aebca 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -212,18 +212,17 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) return; } } - else + else if (x16c_hInfo.GetHP() <= 0.f && x30_24_active) { - if (x16c_hInfo.GetHP() <= 0.f && x30_24_active) - { - SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None); - RemoveMaterial(EMaterialTypes::Orbit, mgr); - x300_25_alphaOut = true; - x250_alphaTimer = 0.f; - } - if (x250_alphaTimer <= 0.75f) - x250_alphaTimer += dt; + SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None); + RemoveMaterial(EMaterialTypes::Orbit, mgr); + x300_25_alphaOut = true; + x250_alphaTimer = 0.f; } + + if (x250_alphaTimer <= 0.75f) + x250_alphaTimer += dt; + float objAlpha = GetPuddleAlphaScale(); x1e0_alpha = 0.2f * objAlpha; SetLinkedObjectAlpha(objAlpha, mgr); diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 824eda949..8fe7ac4f6 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -152,7 +152,7 @@ void CScriptDebris::AddToRenderer(const zeus::CFrustum& frustum, const CStateMan static zeus::CVector3f debris_cone(CStateManager& mgr, float coneAng, float minMag, float maxMag) { float mag = mgr.GetActiveRandom()->Float() * (maxMag - minMag) + minMag; - float side = 1.f - (1.f - std::cos(zeus::degToRad(coneAng))) * mgr.GetActiveRandom()->Float(); + float side = 1.f - (1.f - std::cos(zeus::degToRad(coneAng * 0.5f))) * mgr.GetActiveRandom()->Float(); float hyp = std::max(0.f, 1.f - side * side); if (hyp != 0.f) hyp = std::sqrt(hyp); diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index 66587ac30..f37e2ae23 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -22,38 +22,43 @@ u32 CScriptEffect::g_NumParticlesRendered = 0; CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, const zeus::CVector3f& scale, - CAssetId partId, CAssetId elscId, bool hotInThermal, bool b2, bool b3, bool active, - bool b4, float f1, float f2, float f3, float f4, bool b5, float f5, float f6, float f7, - bool b6, bool b7, bool b8, const CLightParameters& lParms, bool b9) + CAssetId partId, CAssetId elscId, bool hotInThermal, bool noTimerUnlessAreaOccluded, + bool rebuildSystemsOnActivate, bool active, bool useRateInverseCamDist, + float rateInverseCamDist, float rateInverseCamDistRate, float duration, + float durationResetWhileVisible, bool useRateCamDistRange, float rateCamDistRangeMin, + float rateCamDistRangeMax, float rateCamDistRangeFarRate, bool combatVisorVisible, + bool thermalVisorVisible, bool xrayVisorVisible, const CLightParameters& lParms, + bool dieWhenSystemsDone) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId) , x10c_partId(partId) -, x110_24_(active) -, x110_25_(b2) -, x110_26_(b3) -, x110_27_(b4) -, x110_28_(b6) -, x110_29_(b7) -, x110_30_(b8) -, x110_31_(b8 && b7 && b6) -, x111_24_(b5) -, x111_25_(b9) -, x111_26_canRender(false) -, x114_(f1) -, x118_(f1 * f1) -, x11c_(f2) -, x120_(f5) -, x124_(f6) -, x128_(f7) -, x12c_(f3) -, x130_(f3) -, x134_(f4) +, x114_rateInverseCamDist(rateInverseCamDist) +, x118_rateInverseCamDistSq(rateInverseCamDist * rateInverseCamDist) +, x11c_rateInverseCamDistRate(rateInverseCamDistRate) +, x120_rateCamDistRangeMin(rateCamDistRangeMin) +, x124_rateCamDistRangeMax(rateCamDistRangeMax) +, x128_rateCamDistRangeFarRate(rateCamDistRangeFarRate) +, x12c_remTime(duration) +, x130_duration(duration) +, x134_durationResetWhileVisible(durationResetWhileVisible) , x138_actorLights(lParms.MakeActorLights()) { + x110_24_enable = active; + x110_25_noTimerUnlessAreaOccluded = noTimerUnlessAreaOccluded; + x110_26_rebuildSystemsOnActivate = rebuildSystemsOnActivate; + x110_27_useRateInverseCamDist = useRateInverseCamDist; + x110_28_combatVisorVisible = combatVisorVisible; + x110_29_thermalVisorVisible = thermalVisorVisible; + x110_30_xrayVisorVisible = xrayVisorVisible; + x110_31_anyVisorVisible = xrayVisorVisible && thermalVisorVisible && combatVisorVisible; + x111_24_useRateCamDistRange = useRateCamDistRange; + x111_25_dieWhenSystemsDone = dieWhenSystemsDone; + x111_26_canRender = false; + if (partId.IsValid()) { xf8_particleSystemToken = g_SimplePool->GetObj({FOURCC('PART'), partId}); - x104_particleSystem.reset(new CElementGen(xf8_particleSystemToken, CElementGen::EModelOrientationType::Normal, CElementGen::EOptionalSystemFlags::One)); + x104_particleSystem.reset(new CElementGen(xf8_particleSystemToken)); zeus::CTransform newXf = xf; newXf.origin = zeus::CVector3f::skZero; x104_particleSystem->SetOrientation(newXf); @@ -76,7 +81,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity xf4_electric->SetLocalScale(scale); xf4_electric->SetParticleEmission(active); } - xe7_29_actorActive = true; + xe7_29_drawEnabled = true; } void CScriptEffect::Accept(IVisitor& visitor) @@ -86,10 +91,12 @@ void CScriptEffect::Accept(IVisitor& visitor) void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { - bool active = GetActive(); - if (msg == EScriptObjectMessage::Activate) + bool oldActive = GetActive(); + + switch (msg) { - if (x110_26_) + case EScriptObjectMessage::Activate: + if (x110_26_rebuildSystemsOnActivate) { if (x104_particleSystem) { @@ -101,7 +108,7 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetTranslation(GetTranslation()); x104_particleSystem->SetLocalScale(scale); - x104_particleSystem->SetParticleEmission(active); + x104_particleSystem->SetParticleEmission(oldActive); x104_particleSystem->SetModulationColor(color); x104_particleSystem->SetModelsUseLights(x138_actorLights != nullptr); } @@ -116,33 +123,32 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt xf4_electric->SetOrientation(newXf); xf4_electric->SetTranslation(GetTranslation()); xf4_electric->SetLocalScale(scale); - xf4_electric->SetParticleEmission(active); + xf4_electric->SetParticleEmission(oldActive); xf4_electric->SetModulationColor(color); } } - } - else if (msg == EScriptObjectMessage::Registered) - { + break; + case EScriptObjectMessage::Registered: if (x104_particleSystem && x104_particleSystem->SystemHasLight()) { x108_lightId = mgr.AllocateUniqueId(); - mgr.AddObject(new CGameLight(x108_lightId, GetAreaIdAlways(), true, std::string("EffectPLight_") + GetName().data(), x34_transform, GetUniqueId(), x104_particleSystem->GetLight(), x10c_partId.Value(), 1, 0.f)); + mgr.AddObject(new CGameLight(x108_lightId, GetAreaIdAlways(), true, + std::string("EffectPLight_") + GetName().data(), x34_transform, GetUniqueId(), + x104_particleSystem->GetLight(), x10c_partId.Value(), 1, 0.f)); } - } - else if (msg == EScriptObjectMessage::Deleted) - { + break; + case EScriptObjectMessage::Deleted: if (x108_lightId != kInvalidUniqueId) { mgr.FreeScriptObject(x108_lightId); x108_lightId = kInvalidUniqueId; } - } - else if (msg == EScriptObjectMessage::InitializedInArea) - { + break; + case EScriptObjectMessage::InitializedInArea: for (const SConnection& conn : x20_conns) { if (!(conn.x0_state == EScriptObjectState::Active && conn.x4_msg == EScriptObjectMessage::Deactivate) || - !(conn.x0_state == EScriptObjectState::Modify && conn.x4_msg == EScriptObjectMessage::Activate)) + !(conn.x0_state == EScriptObjectState::Modify && conn.x4_msg == EScriptObjectMessage::Activate)) continue; auto search = mgr.GetIdListForScript(conn.x8_objId); @@ -152,14 +158,17 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt x13c_triggerId = it->second; } } + break; + default: + break; } CActor::AcceptScriptMsg(msg, uid, mgr); - TCastToPtr act = mgr.ObjectById(x108_lightId); - mgr.SendScriptMsg(act, uid, msg); + TCastToPtr light = mgr.ObjectById(x108_lightId); + mgr.SendScriptMsg(light, uid, msg); - if (active != GetActive()) + if (oldActive != GetActive()) { std::vector playIds; for (const SConnection& conn : x20_conns) @@ -174,66 +183,46 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt if (playIds.size() > 0) { - TCastToConstPtr otherAct = mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]); + TCastToConstPtr otherAct = + mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]); if (otherAct) - act->SetTransform(otherAct->GetTransform()); + light->SetTransform(otherAct->GetTransform()); else - act->SetTransform(GetTransform()); + light->SetTransform(GetTransform()); } - x110_24_ = true; + x110_24_enable = true; if (x104_particleSystem) x104_particleSystem->SetParticleEmission(GetActive()); if (xf4_electric) xf4_electric->SetParticleEmission(GetActive()); if (GetActive()) - x12c_ = zeus::max(x12c_, x130_); + x12c_remTime = zeus::max(x12c_remTime, x130_duration); } } void CScriptEffect::PreRender(CStateManager& mgr, const zeus::CFrustum&) { - if (x110_27_ || x111_24_) + if (x110_27_useRateInverseCamDist || x111_24_useRateCamDistRange) { - float f31 = 1.f; + float genRate = 1.f; const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); - float f6 = cam->GetTranslation().y - GetTranslation().y; - float f4 = cam->GetTranslation().x - GetTranslation().x; - float f5 = cam->GetTranslation().z - GetTranslation().z; - float f1 = (f6 * f6); - float f3 = (f5 * f5); - f1 = (f4 * f4) + f1; - f1 = f3 + f1; + float camMagSq = (cam->GetTranslation() - GetTranslation()).magSquared(); - if (f1 <= 0.001f) - f3 = 0.f; - else if (f1 != 0.f) - f3 = f1 * zeus::sqrtF(f1); - if (x110_27_ && x118_ < f1) + float camMag = 0.f; + if (camMagSq > 0.001f) + camMag = std::sqrt(camMagSq); + if (x110_27_useRateInverseCamDist && camMagSq < x118_rateInverseCamDistSq) + genRate = (1.f - x11c_rateInverseCamDistRate) * (camMag / x114_rateInverseCamDist) + + x11c_rateInverseCamDistRate; + if (x111_24_useRateCamDistRange) { - float f0 = x114_; - float f2 = x11c_; - f0 = f3 / f0; - f1 = 1.f - f2; - f31 = f1 * f0 + f2; - } - if (x111_24_) - { - float f4 = x120_; - float f2 = x124_; - f1 = f3 - f4; - f2 = f2 - f4; - - f1 = zeus::max(0.f, f1); - f1 = f1 / f2; - f2 = zeus::max(0.f, f1); - f1 = 1.f - f2; - float f0 = x128_; - f0 = f2 * f0; - f31 = f1 * f31 + f0; + float t = zeus::min(1.f, zeus::max(0.f, camMag - x120_rateCamDistRangeMin) / + (x124_rateCamDistRangeMax - x120_rateCamDistRangeMin)); + genRate = (1.f - t) * genRate + t * x128_rateCamDistRangeFarRate; } - x104_particleSystem->SetGeneratorRate(f31); + x104_particleSystem->SetGeneratorRate(genRate); } if (!mgr.GetObjectById(x13c_triggerId)) @@ -244,29 +233,30 @@ void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, const CStateMan { if (!x111_26_canRender) { - const_cast(*this).x12c_ = zeus::max(x12c_, x134_); + const_cast(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); return; } if (!frustum.aabbFrustumTest(x9c_renderBounds)) return; - const_cast(*this).x12c_ = zeus::max(x12c_, x134_); + const_cast(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); - if (x110_31_) + if (x110_31_anyVisorVisible) { bool visible = false; const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan) - visible = x110_28_; + visible = x110_28_combatVisorVisible; else if (visor == CPlayerState::EPlayerVisor::XRay) - visible = x110_30_; + visible = x110_30_xrayVisorVisible; else if (visor == CPlayerState::EPlayerVisor::Thermal) - visible = x110_29_; + visible = x110_29_thermalVisorVisible; if (visible && x138_actorLights) { const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); - const_cast(*this).x138_actorLights->BuildAreaLightList(mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()}); + const_cast(*this).x138_actorLights->BuildAreaLightList( + mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()}); const_cast(*this).x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds); } EnsureRendered(mgr); @@ -317,20 +307,21 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) xe4_28_transformDirty = false; } - if (x110_25_) + if (x110_25_noTimerUnlessAreaOccluded) { const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); - bool visible = area->GetActive() ? bool(area->GetOcclusionState()) : false; + CGameArea::EOcclusionState visible = area->IsPostConstructed() ? area->GetOcclusionState() : + CGameArea::EOcclusionState::Occluded; - if (!visible || x12c_ <= 0.f) + if (visible == CGameArea::EOcclusionState::Occluded && x12c_remTime <= 0.f) return; } - else if (x12c_ <= 0.f) + else if (x12c_remTime <= 0.f) return; - x12c_ -= dt; + x12c_remTime -= dt; - if (x110_24_) + if (x110_24_enable) { if (x104_particleSystem) { @@ -343,24 +334,24 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) xf4_electric->Update(dt); g_NumParticlesUpdating += xf4_electric->GetParticleCount(); } - } - if (x108_lightId != kInvalidUniqueId) - { - if (TCastToPtr light = mgr.ObjectById(x108_lightId)) + if (x108_lightId != kInvalidUniqueId) { - if (x30_24_active) - light->SetLight(x104_particleSystem->GetLight()); + if (TCastToPtr light = mgr.ObjectById(x108_lightId)) + { + if (x30_24_active) + light->SetLight(x104_particleSystem->GetLight()); + } } - } - if (x111_25_) - { - x140_ += dt; - if (x140_ > 15.f || AreBothSystemsDeleteable()) + if (x111_25_dieWhenSystemsDone) { - mgr.FreeScriptObject(GetUniqueId()); - return; + x140_destroyDelayTimer += dt; + if (x140_destroyDelayTimer > 15.f || AreBothSystemsDeleteable()) + { + mgr.FreeScriptObject(GetUniqueId()); + return; + } } } diff --git a/Runtime/World/CScriptEffect.hpp b/Runtime/World/CScriptEffect.hpp index fc5d0bd20..910b3387b 100644 --- a/Runtime/World/CScriptEffect.hpp +++ b/Runtime/World/CScriptEffect.hpp @@ -17,35 +17,46 @@ class CScriptEffect : public CActor std::unique_ptr x104_particleSystem; TUniqueId x108_lightId = kInvalidUniqueId; CAssetId x10c_partId; - bool x110_24_ : 1; - bool x110_25_ : 1; - bool x110_26_ : 1; - bool x110_27_ : 1; - bool x110_28_ : 1; - bool x110_29_ : 1; - bool x110_30_ : 1; - bool x110_31_ : 1; - bool x111_24_ : 1; - bool x111_25_ : 1; - bool x111_26_canRender : 1; - float x114_; - float x118_; - float x11c_; - float x120_; - float x124_; - float x128_; - float x12c_; - float x130_; - float x134_; + union + { + struct + { + bool x110_24_enable : 1; + bool x110_25_noTimerUnlessAreaOccluded : 1; + bool x110_26_rebuildSystemsOnActivate : 1; + bool x110_27_useRateInverseCamDist : 1; + bool x110_28_combatVisorVisible : 1; + bool x110_29_thermalVisorVisible : 1; + bool x110_30_xrayVisorVisible : 1; + bool x110_31_anyVisorVisible : 1; + bool x111_24_useRateCamDistRange : 1; + bool x111_25_dieWhenSystemsDone : 1; + bool x111_26_canRender : 1; + }; + u32 _dummy = 0; + }; + float x114_rateInverseCamDist; + float x118_rateInverseCamDistSq; + float x11c_rateInverseCamDistRate; + float x120_rateCamDistRangeMin; + float x124_rateCamDistRangeMax; + float x128_rateCamDistRangeFarRate; + float x12c_remTime; + float x130_duration; + float x134_durationResetWhileVisible; std::unique_ptr x138_actorLights; TUniqueId x13c_triggerId = kInvalidUniqueId; - float x140_ = 0.f; + float x140_destroyDelayTimer = 0.f; public: - CScriptEffect(TUniqueId, std::string_view name, const CEntityInfo& info, + CScriptEffect(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, const zeus::CVector3f& scale, - CAssetId partId, CAssetId elscId, bool, bool, bool, bool active, - bool, float, float, float, float, bool, float, float, float, - bool, bool, bool, const CLightParameters& lParms, bool); + CAssetId partId, CAssetId elscId, bool hotInThermal, bool noTimerUnlessAreaOccluded, + bool rebuildSystemsOnActivate, bool active, bool useRateInverseCamDist, + float rateInverseCamDist, float rateInverseCamDistRate, float duration, + float durationResetWhileVisible, bool useRateCamDistRange, float rateCamDistRangeMin, + float rateCamDistRangeMax, float rateCamDistRangeFarRate, bool combatVisorVisible, + bool thermalVisorVisible, bool xrayVisorVisible, const CLightParameters& lParms, + bool dieWhenSystemsDone); void Accept(IVisitor& visitor); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index bc5ed4a1b..d09e91159 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -35,7 +35,7 @@ CScriptPlayerActor::CScriptPlayerActor(TUniqueId uid, std::string_view name, con SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude)); SetActorLights(aParams.GetLightParameters().MakeActorLights()); - xe7_29_actorActive = true; + xe7_29_drawEnabled = true; x2e3_24_isPlayerActor = true; } @@ -411,7 +411,7 @@ void CScriptPlayerActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid void CScriptPlayerActor::SetActive(bool active) { CActor::SetActive(active); - xe7_29_actorActive = true; + xe7_29_drawEnabled = true; } void CScriptPlayerActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index b10c38b23..3bbb0145c 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -576,10 +576,10 @@ CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int prop CAssetId partId(in); CAssetId elscId(in); - bool b1 = in.readBool(); - bool b2 = in.readBool(); - bool b3 = in.readBool(); - bool b4 = in.readBool(); + bool hotInThermal = in.readBool(); + bool noTimerUnlessAreaOccluded = in.readBool(); + bool rebuildSystemsOnActivate = in.readBool(); + bool active = in.readBool(); if (!partId.IsValid() && !elscId.IsValid()) return nullptr; @@ -587,24 +587,28 @@ CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int prop if (!g_ResFactory->GetResourceTypeById(partId) && !g_ResFactory->GetResourceTypeById(elscId)) return nullptr; - bool b5 = in.readBool(); - float f1 = in.readFloatBig(); - float f2 = in.readFloatBig(); - float f3 = in.readFloatBig(); - float f4 = in.readFloatBig(); - bool b6 = in.readBool(); - float f5 = in.readFloatBig(); - float f6 = in.readFloatBig(); - float f7 = in.readFloatBig(); - bool b7 = in.readBool(); - bool b8 = in.readBool(); - bool b9 = in.readBool(); - bool b10 = in.readBool(); + bool useRateInverseCamDist = in.readBool(); + float rateInverseCamDist = in.readFloatBig(); + float rateInverseCamDistRate = in.readFloatBig(); + float duration = in.readFloatBig(); + float durationResetWhileVisible = in.readFloatBig(); + bool useRateCamDistRange = in.readBool(); + float rateCamDistRangeMin = in.readFloatBig(); + float rateCamDistRangeMax = in.readFloatBig(); + float rateCamDistRangeFarRate = in.readFloatBig(); + bool combatVisorVisible = in.readBool(); + bool thermalVisorVisible = in.readBool(); + bool xrayVisorVisible = in.readBool(); + bool dieWhenSystemsDone = in.readBool(); CLightParameters lParms = LoadLightParameters(in); return new CScriptEffect(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, head.x40_scale, partId, - elscId, b1, b2, b3, b4, b5, f1, f2, f3, f4, b6, f5, f6, f7, b7, b8, b9, lParms, b10); + elscId, hotInThermal, noTimerUnlessAreaOccluded, rebuildSystemsOnActivate, active, + useRateInverseCamDist, rateInverseCamDist, rateInverseCamDistRate, duration, + durationResetWhileVisible, useRateCamDistRange, rateCamDistRangeMin, rateCamDistRangeMax, + rateCamDistRangeFarRate, combatVisorVisible, thermalVisorVisible, xrayVisorVisible, + lParms, dieWhenSystemsDone); } CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) diff --git a/hecl b/hecl index fced7add6..dc5348ad2 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit fced7add60d925bf16dfa8c2391b4a77a1e45f8e +Subproject commit dc5348ad25f5dc7264fde4319e8cd4505fe23af1 diff --git a/specter b/specter index 369cf0cdd..326b5b4d2 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 369cf0cdd900b0b5abc5957dd1f20244ae671e4a +Subproject commit 326b5b4d2ff727f4836ca0a4467ab311cd239889