More bug fixes

This commit is contained in:
Jack Andersen 2018-05-17 18:16:33 -10:00
parent 055c8e8a47
commit 979a54a8a8
18 changed files with 242 additions and 232 deletions

View File

@ -17,23 +17,23 @@ struct Effect : IScriptObject
Value<atVec3f> scale; Value<atVec3f> scale;
UniqueID32 part; UniqueID32 part;
UniqueID32 elsc; UniqueID32 elsc;
Value<bool> unknown1; Value<bool> hotInThermal;
Value<bool> unknown2; Value<bool> noTimerUnlessAreaOccluded;
Value<bool> unknown3; Value<bool> rebuildSystemsOnActivate;
Value<bool> unknown4; Value<bool> active;
Value<bool> unknown5; Value<bool> useRateInverseCamDist;
Value<float> unknown6; Value<float> rateInverseCamDist;
Value<float> unknown7; Value<float> rateInverseCamDistRate;
Value<float> unknown8; Value<float> duration;
Value<float> unknown9; Value<float> durationResetWhileVisible;
Value<bool> unknown10; Value<bool> useRateCamDistRange;
Value<float> unknown11; Value<float> rateCamDistRangeMin;
Value<float> unknown12; Value<float> rateCamDistRangeMax;
Value<float> unknown13; Value<float> rateCamDistRangeFarRate;
Value<bool> unknown14; Value<bool> combatVisorVisible;
Value<bool> unknown15; Value<bool> thermalVisorVisible;
Value<bool> unknown16; Value<bool> xrayVisorVisible;
Value<bool> unknown17; Value<bool> dieWhenSystemsDone;
LightParameters lightParameters; LightParameters lightParameters;
void nameIDs(PAKRouter<PAKBridge>& pakRouter) const void nameIDs(PAKRouter<PAKBridge>& pakRouter) const

View File

@ -758,7 +758,7 @@ void CStateManager::DrawWorld() const
{ {
if (TCastToPtr<CActor> actor = ent) if (TCastToPtr<CActor> actor = ent)
{ {
if (!actor->xe7_29_actorActive) if (!actor->xe7_29_drawEnabled)
continue; continue;
TUniqueId actorId = actor->GetUniqueId(); TUniqueId actorId = actor->GetUniqueId();
if (!thermal && area.LookupPVSUniqueID(actorId) == actorId) if (!thermal && area.LookupPVSUniqueID(actorId) == actorId)

View File

@ -24,7 +24,7 @@ CGameCamera::CGameCamera(TUniqueId uid, bool active, std::string_view name, cons
, x184_fov(fovy) , x184_fov(fovy)
{ {
xe7_29_actorActive = false; xe7_29_drawEnabled = false;
} }
void CGameCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) 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) void CGameCamera::SetActive(bool active)
{ {
CActor::SetActive(active); CActor::SetActive(active);
xe7_29_actorActive = false; xe7_29_drawEnabled = false;
} }
zeus::CMatrix4f CGameCamera::GetPerspectiveMatrix() const zeus::CMatrix4f CGameCamera::GetPerspectiveMatrix() const

View File

@ -571,8 +571,8 @@ CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPla
const char* texNames[3] = {}; const char* texNames[3] = {};
std::string finalVS, finalFS; std::string finalVS, finalFS;
_BuildShader(finalVS, finalFS, nextTex, texNames, info); _BuildShader(finalVS, finalFS, nextTex, texNames, info);
const char* uniNames[] = {"FluidPlaneUniform"}; const char* uniNames[] = {"FluidPlaneUniform", "FluidPlaneUniform", "LightingUniform"};
return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), size_t(nextTex), texNames, 1, uniNames, return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), size_t(nextTex), texNames, 3, uniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
boo::CullMode::None); boo::CullMode::None);

View File

@ -176,6 +176,7 @@ public:
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus; boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus;
CGenDescription* GetDesc() {return x1c_genDesc.GetObj();} CGenDescription* GetDesc() {return x1c_genDesc.GetObj();}
const SObjectTag* GetDescTag() const {return x1c_genDesc.GetObjectTag();}
static bool g_ParticleSystemInitialized; static bool g_ParticleSystemInitialized;
static int g_ParticleAliveCount; static int g_ParticleAliveCount;

View File

@ -66,12 +66,12 @@ CVECone::CVECone(CVectorElement* a, CRealElement* b)
{ {
zeus::CVector3f av; zeus::CVector3f av;
x4_direction->GetValue(0, av); x4_direction->GetValue(0, av);
av.normalize(); zeus::CVector3f avNorm = av.normalized();
if (av[0] > 0.8) if (avNorm.x > 0.8)
xc_xVec = av.cross(zeus::CVector3f(0.f, 1.f, 0.f)); xc_xVec = av.cross(zeus::CVector3f(0.f, 1.f, 0.f));
else else
xc_xVec = av.cross(zeus::CVector3f(1.f, 0.f, 0.f)); 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 bool CVECone::GetValue(int frame, zeus::CVector3f& valOut) const

View File

@ -51,7 +51,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
xe6_29_renderParticleDBInside = true; xe6_29_renderParticleDBInside = true;
xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask(); xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask();
xe7_27_enableRender = true; xe7_27_enableRender = true;
xe7_29_actorActive = active; xe7_29_drawEnabled = active;
xe7_30_doTargetDistanceTest = true; xe7_30_doTargetDistanceTest = true;
xe7_31_targetable = true; xe7_31_targetable = true;
if (x64_modelData) if (x64_modelData)
@ -77,11 +77,18 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
{ {
if (!x30_24_active) if (!x30_24_active)
xbc_time = CGraphics::GetSecondsMod900(); xbc_time = CGraphics::GetSecondsMod900();
}
break; break;
case EScriptObjectMessage::Decrement: }
case EScriptObjectMessage::Deactivate:
RemoveEmitter(); RemoveEmitter();
break; 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 case EScriptObjectMessage::Registered: // 33
{ {
if (x98_scanObjectInfo) if (x98_scanObjectInfo)
@ -94,14 +101,13 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
TAreaId aid = GetAreaId(); TAreaId aid = GetAreaId();
x64_modelData->AnimationData()->InitializeEffects(mgr, aid, x64_modelData->GetScale()); 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);
} }
case EScriptObjectMessage::UpdateSplashInhabitant: // 37
SetInFluid(true, uid);
break;
case EScriptObjectMessage::RemoveSplashInhabitant: // 39
SetInFluid(false, kInvalidUniqueId);
break; break;
case EScriptObjectMessage::InitializedInArea: // 35 case EScriptObjectMessage::InitializedInArea: // 35
{ {
@ -114,14 +120,8 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
if (act && xc6_nextDrawNode == kInvalidUniqueId) if (act && xc6_nextDrawNode == kInvalidUniqueId)
xc6_nextDrawNode = act->GetUniqueId(); xc6_nextDrawNode = act->GetUniqueId();
} }
break;
} }
break;
case EScriptObjectMessage::UpdateSplashInhabitant: // 37
SetInFluid(true, uid);
break;
case EScriptObjectMessage::RemoveSplashInhabitant: // 39
SetInFluid(false, kInvalidUniqueId);
break;
default: default:
break; break;
} }

View File

@ -74,7 +74,7 @@ protected:
u8 xe6_31_targetableVisorFlags : 4; u8 xe6_31_targetableVisorFlags : 4;
bool xe7_27_enableRender : 1; bool xe7_27_enableRender : 1;
bool xe7_28_worldLightingDirty : 1; bool xe7_28_worldLightingDirty : 1;
bool xe7_29_actorActive : 1; bool xe7_29_drawEnabled : 1;
bool xe7_30_doTargetDistanceTest : 1; bool xe7_30_doTargetDistanceTest : 1;
bool xe7_31_targetable : 1; bool xe7_31_targetable : 1;
}; };
@ -110,7 +110,7 @@ public:
xe4_27_notInSortedLists = true; xe4_27_notInSortedLists = true;
xe4_28_transformDirty = true; xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true; xe4_29_actorLightsDirty = true;
xe7_29_actorActive = active; xe7_29_drawEnabled = active;
CEntity::SetActive(active); CEntity::SetActive(active);
} }
virtual void PreRender(CStateManager&, const zeus::CFrustum&); virtual void PreRender(CStateManager&, const zeus::CFrustum&);
@ -184,7 +184,7 @@ public:
const CActorLights* GetActorLights() const { return x90_actorLights.get(); } const CActorLights* GetActorLights() const { return x90_actorLights.get(); }
CActorLights* ActorLights() { return x90_actorLights.get(); } CActorLights* ActorLights() { return x90_actorLights.get(); }
bool CanDrawStatic() const; 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; } void SetWorldLightingDirty(bool b) { xe7_28_worldLightingDirty = b; }
const CScannableObjectInfo* GetScannableObjectInfo() const; const CScannableObjectInfo* GetScannableObjectInfo() const;
const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const

View File

@ -46,22 +46,9 @@ void CScriptActor::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{ {
if (msg == EScriptObjectMessage::Reset) switch (msg)
{
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)
{ {
case EScriptObjectMessage::InitializedInArea:
for (const SConnection& conn : x20_conns) for (const SConnection& conn : x20_conns)
{ {
if (conn.x0_state != EScriptObjectState::InheritBounds || conn.x4_msg != EScriptObjectMessage::Activate) 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) if (x2e2_31_materialFlag54)
CActor::AddMaterial(EMaterialTypes::Unknown54, mgr); 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); CActor::AcceptScriptMsg(msg, uid, mgr);

View File

@ -212,18 +212,17 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr)
return; 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); SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None);
RemoveMaterial(EMaterialTypes::Orbit, mgr); RemoveMaterial(EMaterialTypes::Orbit, mgr);
x300_25_alphaOut = true; x300_25_alphaOut = true;
x250_alphaTimer = 0.f; x250_alphaTimer = 0.f;
} }
if (x250_alphaTimer <= 0.75f) if (x250_alphaTimer <= 0.75f)
x250_alphaTimer += dt; x250_alphaTimer += dt;
}
float objAlpha = GetPuddleAlphaScale(); float objAlpha = GetPuddleAlphaScale();
x1e0_alpha = 0.2f * objAlpha; x1e0_alpha = 0.2f * objAlpha;
SetLinkedObjectAlpha(objAlpha, mgr); SetLinkedObjectAlpha(objAlpha, mgr);

View File

@ -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) static zeus::CVector3f debris_cone(CStateManager& mgr, float coneAng, float minMag, float maxMag)
{ {
float mag = mgr.GetActiveRandom()->Float() * (maxMag - minMag) + minMag; 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); float hyp = std::max(0.f, 1.f - side * side);
if (hyp != 0.f) if (hyp != 0.f)
hyp = std::sqrt(hyp); hyp = std::sqrt(hyp);

View File

@ -22,38 +22,43 @@ u32 CScriptEffect::g_NumParticlesRendered = 0;
CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntityInfo& info, CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, const zeus::CVector3f& scale, const zeus::CTransform& xf, const zeus::CVector3f& scale,
CAssetId partId, CAssetId elscId, bool hotInThermal, bool b2, bool b3, bool active, CAssetId partId, CAssetId elscId, bool hotInThermal, bool noTimerUnlessAreaOccluded,
bool b4, float f1, float f2, float f3, float f4, bool b5, float f5, float f6, float f7, bool rebuildSystemsOnActivate, bool active, bool useRateInverseCamDist,
bool b6, bool b7, bool b8, const CLightParameters& lParms, bool b9) 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(), : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(),
CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId) CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId)
, x10c_partId(partId) , x10c_partId(partId)
, x110_24_(active) , x114_rateInverseCamDist(rateInverseCamDist)
, x110_25_(b2) , x118_rateInverseCamDistSq(rateInverseCamDist * rateInverseCamDist)
, x110_26_(b3) , x11c_rateInverseCamDistRate(rateInverseCamDistRate)
, x110_27_(b4) , x120_rateCamDistRangeMin(rateCamDistRangeMin)
, x110_28_(b6) , x124_rateCamDistRangeMax(rateCamDistRangeMax)
, x110_29_(b7) , x128_rateCamDistRangeFarRate(rateCamDistRangeFarRate)
, x110_30_(b8) , x12c_remTime(duration)
, x110_31_(b8 && b7 && b6) , x130_duration(duration)
, x111_24_(b5) , x134_durationResetWhileVisible(durationResetWhileVisible)
, 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)
, x138_actorLights(lParms.MakeActorLights()) , 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()) if (partId.IsValid())
{ {
xf8_particleSystemToken = g_SimplePool->GetObj({FOURCC('PART'), partId}); 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; zeus::CTransform newXf = xf;
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetOrientation(newXf);
@ -76,7 +81,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity
xf4_electric->SetLocalScale(scale); xf4_electric->SetLocalScale(scale);
xf4_electric->SetParticleEmission(active); xf4_electric->SetParticleEmission(active);
} }
xe7_29_actorActive = true; xe7_29_drawEnabled = true;
} }
void CScriptEffect::Accept(IVisitor& visitor) void CScriptEffect::Accept(IVisitor& visitor)
@ -86,10 +91,12 @@ void CScriptEffect::Accept(IVisitor& visitor)
void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{ {
bool active = GetActive(); bool oldActive = GetActive();
if (msg == EScriptObjectMessage::Activate)
switch (msg)
{ {
if (x110_26_) case EScriptObjectMessage::Activate:
if (x110_26_rebuildSystemsOnActivate)
{ {
if (x104_particleSystem) if (x104_particleSystem)
{ {
@ -101,7 +108,7 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetOrientation(newXf);
x104_particleSystem->SetTranslation(GetTranslation()); x104_particleSystem->SetTranslation(GetTranslation());
x104_particleSystem->SetLocalScale(scale); x104_particleSystem->SetLocalScale(scale);
x104_particleSystem->SetParticleEmission(active); x104_particleSystem->SetParticleEmission(oldActive);
x104_particleSystem->SetModulationColor(color); x104_particleSystem->SetModulationColor(color);
x104_particleSystem->SetModelsUseLights(x138_actorLights != nullptr); x104_particleSystem->SetModelsUseLights(x138_actorLights != nullptr);
} }
@ -116,29 +123,28 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
xf4_electric->SetOrientation(newXf); xf4_electric->SetOrientation(newXf);
xf4_electric->SetTranslation(GetTranslation()); xf4_electric->SetTranslation(GetTranslation());
xf4_electric->SetLocalScale(scale); xf4_electric->SetLocalScale(scale);
xf4_electric->SetParticleEmission(active); xf4_electric->SetParticleEmission(oldActive);
xf4_electric->SetModulationColor(color); xf4_electric->SetModulationColor(color);
} }
} }
} break;
else if (msg == EScriptObjectMessage::Registered) case EScriptObjectMessage::Registered:
{
if (x104_particleSystem && x104_particleSystem->SystemHasLight()) if (x104_particleSystem && x104_particleSystem->SystemHasLight())
{ {
x108_lightId = mgr.AllocateUniqueId(); 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));
} }
} break;
else if (msg == EScriptObjectMessage::Deleted) case EScriptObjectMessage::Deleted:
{
if (x108_lightId != kInvalidUniqueId) if (x108_lightId != kInvalidUniqueId)
{ {
mgr.FreeScriptObject(x108_lightId); mgr.FreeScriptObject(x108_lightId);
x108_lightId = kInvalidUniqueId; x108_lightId = kInvalidUniqueId;
} }
} break;
else if (msg == EScriptObjectMessage::InitializedInArea) case EScriptObjectMessage::InitializedInArea:
{
for (const SConnection& conn : x20_conns) for (const SConnection& conn : x20_conns)
{ {
if (!(conn.x0_state == EScriptObjectState::Active && conn.x4_msg == EScriptObjectMessage::Deactivate) || if (!(conn.x0_state == EScriptObjectState::Active && conn.x4_msg == EScriptObjectMessage::Deactivate) ||
@ -152,14 +158,17 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
x13c_triggerId = it->second; x13c_triggerId = it->second;
} }
} }
break;
default:
break;
} }
CActor::AcceptScriptMsg(msg, uid, mgr); CActor::AcceptScriptMsg(msg, uid, mgr);
TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId); TCastToPtr<CActor> light = mgr.ObjectById(x108_lightId);
mgr.SendScriptMsg(act, uid, msg); mgr.SendScriptMsg(light, uid, msg);
if (active != GetActive()) if (oldActive != GetActive())
{ {
std::vector<TUniqueId> playIds; std::vector<TUniqueId> playIds;
for (const SConnection& conn : x20_conns) for (const SConnection& conn : x20_conns)
@ -174,66 +183,46 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
if (playIds.size() > 0) if (playIds.size() > 0)
{ {
TCastToConstPtr<CActor> otherAct = mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]); TCastToConstPtr<CActor> otherAct =
mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]);
if (otherAct) if (otherAct)
act->SetTransform(otherAct->GetTransform()); light->SetTransform(otherAct->GetTransform());
else else
act->SetTransform(GetTransform()); light->SetTransform(GetTransform());
} }
x110_24_ = true; x110_24_enable = true;
if (x104_particleSystem) if (x104_particleSystem)
x104_particleSystem->SetParticleEmission(GetActive()); x104_particleSystem->SetParticleEmission(GetActive());
if (xf4_electric) if (xf4_electric)
xf4_electric->SetParticleEmission(GetActive()); xf4_electric->SetParticleEmission(GetActive());
if (GetActive()) if (GetActive())
x12c_ = zeus::max(x12c_, x130_); x12c_remTime = zeus::max(x12c_remTime, x130_duration);
} }
} }
void CScriptEffect::PreRender(CStateManager& mgr, const zeus::CFrustum&) 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); const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
float f6 = cam->GetTranslation().y - GetTranslation().y; float camMagSq = (cam->GetTranslation() - GetTranslation()).magSquared();
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;
if (f1 <= 0.001f) float camMag = 0.f;
f3 = 0.f; if (camMagSq > 0.001f)
else if (f1 != 0.f) camMag = std::sqrt(camMagSq);
f3 = f1 * zeus::sqrtF(f1); if (x110_27_useRateInverseCamDist && camMagSq < x118_rateInverseCamDistSq)
if (x110_27_ && x118_ < f1) genRate = (1.f - x11c_rateInverseCamDistRate) * (camMag / x114_rateInverseCamDist) +
x11c_rateInverseCamDistRate;
if (x111_24_useRateCamDistRange)
{ {
float f0 = x114_; float t = zeus::min(1.f, zeus::max(0.f, camMag - x120_rateCamDistRangeMin) /
float f2 = x11c_; (x124_rateCamDistRangeMax - x120_rateCamDistRangeMin));
f0 = f3 / f0; genRate = (1.f - t) * genRate + t * x128_rateCamDistRangeFarRate;
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;
} }
x104_particleSystem->SetGeneratorRate(f31); x104_particleSystem->SetGeneratorRate(genRate);
} }
if (!mgr.GetObjectById(x13c_triggerId)) if (!mgr.GetObjectById(x13c_triggerId))
@ -244,29 +233,30 @@ void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, const CStateMan
{ {
if (!x111_26_canRender) if (!x111_26_canRender)
{ {
const_cast<CScriptEffect&>(*this).x12c_ = zeus::max(x12c_, x134_); const_cast<CScriptEffect&>(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible);
return; return;
} }
if (!frustum.aabbFrustumTest(x9c_renderBounds)) if (!frustum.aabbFrustumTest(x9c_renderBounds))
return; return;
const_cast<CScriptEffect&>(*this).x12c_ = zeus::max(x12c_, x134_); const_cast<CScriptEffect&>(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible);
if (x110_31_) if (x110_31_anyVisorVisible)
{ {
bool visible = false; bool visible = false;
const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan) if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan)
visible = x110_28_; visible = x110_28_combatVisorVisible;
else if (visor == CPlayerState::EPlayerVisor::XRay) else if (visor == CPlayerState::EPlayerVisor::XRay)
visible = x110_30_; visible = x110_30_xrayVisorVisible;
else if (visor == CPlayerState::EPlayerVisor::Thermal) else if (visor == CPlayerState::EPlayerVisor::Thermal)
visible = x110_29_; visible = x110_29_thermalVisorVisible;
if (visible && x138_actorLights) if (visible && x138_actorLights)
{ {
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
const_cast<CScriptEffect&>(*this).x138_actorLights->BuildAreaLightList(mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()}); const_cast<CScriptEffect&>(*this).x138_actorLights->BuildAreaLightList(
mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()});
const_cast<CScriptEffect&>(*this).x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds); const_cast<CScriptEffect&>(*this).x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds);
} }
EnsureRendered(mgr); EnsureRendered(mgr);
@ -317,20 +307,21 @@ void CScriptEffect::Think(float dt, CStateManager& mgr)
xe4_28_transformDirty = false; xe4_28_transformDirty = false;
} }
if (x110_25_) if (x110_25_noTimerUnlessAreaOccluded)
{ {
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); 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; return;
} }
else if (x12c_ <= 0.f) else if (x12c_remTime <= 0.f)
return; return;
x12c_ -= dt; x12c_remTime -= dt;
if (x110_24_) if (x110_24_enable)
{ {
if (x104_particleSystem) if (x104_particleSystem)
{ {
@ -343,7 +334,6 @@ void CScriptEffect::Think(float dt, CStateManager& mgr)
xf4_electric->Update(dt); xf4_electric->Update(dt);
g_NumParticlesUpdating += xf4_electric->GetParticleCount(); g_NumParticlesUpdating += xf4_electric->GetParticleCount();
} }
}
if (x108_lightId != kInvalidUniqueId) if (x108_lightId != kInvalidUniqueId)
{ {
@ -354,15 +344,16 @@ void CScriptEffect::Think(float dt, CStateManager& mgr)
} }
} }
if (x111_25_) if (x111_25_dieWhenSystemsDone)
{ {
x140_ += dt; x140_destroyDelayTimer += dt;
if (x140_ > 15.f || AreBothSystemsDeleteable()) if (x140_destroyDelayTimer > 15.f || AreBothSystemsDeleteable())
{ {
mgr.FreeScriptObject(GetUniqueId()); mgr.FreeScriptObject(GetUniqueId());
return; return;
} }
} }
}
if (x104_particleSystem) if (x104_particleSystem)
{ {

View File

@ -17,35 +17,46 @@ class CScriptEffect : public CActor
std::unique_ptr<CElementGen> x104_particleSystem; std::unique_ptr<CElementGen> x104_particleSystem;
TUniqueId x108_lightId = kInvalidUniqueId; TUniqueId x108_lightId = kInvalidUniqueId;
CAssetId x10c_partId; CAssetId x10c_partId;
bool x110_24_ : 1; union
bool x110_25_ : 1; {
bool x110_26_ : 1; struct
bool x110_27_ : 1; {
bool x110_28_ : 1; bool x110_24_enable : 1;
bool x110_29_ : 1; bool x110_25_noTimerUnlessAreaOccluded : 1;
bool x110_30_ : 1; bool x110_26_rebuildSystemsOnActivate : 1;
bool x110_31_ : 1; bool x110_27_useRateInverseCamDist : 1;
bool x111_24_ : 1; bool x110_28_combatVisorVisible : 1;
bool x111_25_ : 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; bool x111_26_canRender : 1;
float x114_; };
float x118_; u32 _dummy = 0;
float x11c_; };
float x120_; float x114_rateInverseCamDist;
float x124_; float x118_rateInverseCamDistSq;
float x128_; float x11c_rateInverseCamDistRate;
float x12c_; float x120_rateCamDistRangeMin;
float x130_; float x124_rateCamDistRangeMax;
float x134_; float x128_rateCamDistRangeFarRate;
float x12c_remTime;
float x130_duration;
float x134_durationResetWhileVisible;
std::unique_ptr<CActorLights> x138_actorLights; std::unique_ptr<CActorLights> x138_actorLights;
TUniqueId x13c_triggerId = kInvalidUniqueId; TUniqueId x13c_triggerId = kInvalidUniqueId;
float x140_ = 0.f; float x140_destroyDelayTimer = 0.f;
public: 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, const zeus::CTransform& xf, const zeus::CVector3f& scale,
CAssetId partId, CAssetId elscId, bool, bool, bool, bool active, CAssetId partId, CAssetId elscId, bool hotInThermal, bool noTimerUnlessAreaOccluded,
bool, float, float, float, float, bool, float, float, float, bool rebuildSystemsOnActivate, bool active, bool useRateInverseCamDist,
bool, bool, bool, const CLightParameters& lParms, bool); 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 Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);

View File

@ -35,7 +35,7 @@ CScriptPlayerActor::CScriptPlayerActor(TUniqueId uid, std::string_view name, con
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude)); SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
SetActorLights(aParams.GetLightParameters().MakeActorLights()); SetActorLights(aParams.GetLightParameters().MakeActorLights());
xe7_29_actorActive = true; xe7_29_drawEnabled = true;
x2e3_24_isPlayerActor = true; x2e3_24_isPlayerActor = true;
} }
@ -411,7 +411,7 @@ void CScriptPlayerActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid
void CScriptPlayerActor::SetActive(bool active) void CScriptPlayerActor::SetActive(bool active)
{ {
CActor::SetActive(active); CActor::SetActive(active);
xe7_29_actorActive = true; xe7_29_drawEnabled = true;
} }
void CScriptPlayerActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) void CScriptPlayerActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)

View File

@ -576,10 +576,10 @@ CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int prop
CAssetId partId(in); CAssetId partId(in);
CAssetId elscId(in); CAssetId elscId(in);
bool b1 = in.readBool(); bool hotInThermal = in.readBool();
bool b2 = in.readBool(); bool noTimerUnlessAreaOccluded = in.readBool();
bool b3 = in.readBool(); bool rebuildSystemsOnActivate = in.readBool();
bool b4 = in.readBool(); bool active = in.readBool();
if (!partId.IsValid() && !elscId.IsValid()) if (!partId.IsValid() && !elscId.IsValid())
return nullptr; return nullptr;
@ -587,24 +587,28 @@ CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int prop
if (!g_ResFactory->GetResourceTypeById(partId) && !g_ResFactory->GetResourceTypeById(elscId)) if (!g_ResFactory->GetResourceTypeById(partId) && !g_ResFactory->GetResourceTypeById(elscId))
return nullptr; return nullptr;
bool b5 = in.readBool(); bool useRateInverseCamDist = in.readBool();
float f1 = in.readFloatBig(); float rateInverseCamDist = in.readFloatBig();
float f2 = in.readFloatBig(); float rateInverseCamDistRate = in.readFloatBig();
float f3 = in.readFloatBig(); float duration = in.readFloatBig();
float f4 = in.readFloatBig(); float durationResetWhileVisible = in.readFloatBig();
bool b6 = in.readBool(); bool useRateCamDistRange = in.readBool();
float f5 = in.readFloatBig(); float rateCamDistRangeMin = in.readFloatBig();
float f6 = in.readFloatBig(); float rateCamDistRangeMax = in.readFloatBig();
float f7 = in.readFloatBig(); float rateCamDistRangeFarRate = in.readFloatBig();
bool b7 = in.readBool(); bool combatVisorVisible = in.readBool();
bool b8 = in.readBool(); bool thermalVisorVisible = in.readBool();
bool b9 = in.readBool(); bool xrayVisorVisible = in.readBool();
bool b10 = in.readBool(); bool dieWhenSystemsDone = in.readBool();
CLightParameters lParms = LoadLightParameters(in); CLightParameters lParms = LoadLightParameters(in);
return new CScriptEffect(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, head.x40_scale, partId, 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) CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)

2
hecl

@ -1 +1 @@
Subproject commit fced7add60d925bf16dfa8c2391b4a77a1e45f8e Subproject commit dc5348ad25f5dc7264fde4319e8cd4505fe23af1

@ -1 +1 @@
Subproject commit 369cf0cdd900b0b5abc5957dd1f20244ae671e4a Subproject commit 326b5b4d2ff727f4836ca0a4467ab311cd239889