Implement beam subclasses

This commit is contained in:
Jack Andersen 2017-09-06 17:55:31 -10:00
parent 361aa1512b
commit 0907c52ca3
18 changed files with 1080 additions and 91 deletions

View File

@ -54,10 +54,10 @@ class CGunWeapon
public:
enum class ESecondaryFxType
{
Zero,
One,
Two,
Three
None,
Charge,
ToCombo,
CancelCharge
};
enum class EFrozenFxType
{
@ -86,7 +86,7 @@ protected:
EWeaponType x1c0_weaponType;
TUniqueId x1c4_playerId;
EMaterialTypes x1c8_playerMaterial;
ESecondaryFxType x1cc_enabledSecondaryEffect = ESecondaryFxType::Zero;
ESecondaryFxType x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
CVelocityInfo x1d0_velInfo;
CPlayerState::EBeamId x200_beamId;
EFrozenFxType x204_frozenEffect = EFrozenFxType::None;

View File

@ -12,8 +12,161 @@ CIceBeam::CIceBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
x21c_iceSmoke = g_SimplePool->GetObj("IceSmoke");
x228_ice2nd1 = g_SimplePool->GetObj("Ice2nd_1");
x234_ice2nd2 = g_SimplePool->GetObj("Ice2nd_2");
x248_24 = false;
x248_25 = false;
x248_24_loaded = false;
x248_25_inEndFx = false;
}
void CIceBeam::PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
// Empty
}
void CIceBeam::PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
bool subtractBlend = mgr.GetParticleFlags() == 0;
if (subtractBlend)
CElementGen::SetSubtractBlend(true);
if (x240_smokeGen)
x240_smokeGen->Render();
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None && x244_chargeFx)
x244_chargeFx->Render();
CGunWeapon::PostRenderGunFx(mgr, xf);
if (subtractBlend)
CElementGen::SetSubtractBlend(false);
}
void CIceBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x240_smokeGen)
{
zeus::CTransform beamLoc = x10_solidModelData->GetScaledLocatorTransform("LBEAM");
x240_smokeGen->SetTranslation(beamLoc.origin);
x240_smokeGen->SetOrientation(beamLoc.getRotation());
x240_smokeGen->Update(dt);
}
if (x244_chargeFx)
{
if (x248_25_inEndFx && x244_chargeFx->IsSystemDeletable())
{
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
x244_chargeFx.reset();
}
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None)
{
if (x248_25_inEndFx)
{
x244_chargeFx->SetTranslation(xf.origin);
x244_chargeFx->SetOrientation(xf.getRotation());
}
else
{
x244_chargeFx->SetGlobalOrientAndTrans(xf);
}
x244_chargeFx->Update(dt);
}
}
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
}
static const u16 kSoundId[] = { 1797, 1776 };
void CIceBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2)
{
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
NWeaponTypes::play_sfx(kSoundId[int(chargeState)], underwater, false, 0.165f);
}
void CIceBeam::EnableFx(bool enable)
{
if (x240_smokeGen)
x240_smokeGen->SetParticleEmission(enable);
}
void CIceBeam::EnableSecondaryFx(ESecondaryFxType type)
{
switch (type)
{
case ESecondaryFxType::CancelCharge:
case ESecondaryFxType::None:
if (x1cc_enabledSecondaryEffect == ESecondaryFxType::None)
break;
default:
switch (type)
{
case ESecondaryFxType::None:
case ESecondaryFxType::ToCombo:
case ESecondaryFxType::CancelCharge:
if (!x248_25_inEndFx)
{
x244_chargeFx = std::make_unique<CElementGen>(x234_ice2nd2, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x244_chargeFx->SetGlobalScale(x4_scale);
x248_25_inEndFx = true;
x1cc_enabledSecondaryEffect = ESecondaryFxType::CancelCharge;
}
break;
case ESecondaryFxType::Charge:
x244_chargeFx = std::make_unique<CElementGen>(x228_ice2nd1, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x244_chargeFx->SetGlobalScale(x4_scale);
x248_25_inEndFx = false;
x1cc_enabledSecondaryEffect = type;
break;
}
break;
}
}
void CIceBeam::Update(float dt, CStateManager& mgr)
{
CGunWeapon::Update(dt, mgr);
if (!x248_24_loaded)
{
x248_24_loaded = x21c_iceSmoke.IsLoaded() && x228_ice2nd1.IsLoaded() && x234_ice2nd2.IsLoaded();
if (x248_24_loaded)
{
x240_smokeGen = std::make_unique<CElementGen>(x21c_iceSmoke, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x240_smokeGen->SetGlobalScale(x4_scale);
x240_smokeGen->SetParticleEmission(false);
}
}
}
void CIceBeam::Load(CStateManager& mgr, bool subtypeBasePose)
{
CGunWeapon::Load(mgr, subtypeBasePose);
x21c_iceSmoke.Lock();
x228_ice2nd1.Lock();
x234_ice2nd2.Lock();
x248_25_inEndFx = false;
}
void CIceBeam::ReInitVariables()
{
x240_smokeGen.reset();
x244_chargeFx.reset();
x248_24_loaded = false;
x248_25_inEndFx = false;
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
}
void CIceBeam::Unload(CStateManager& mgr)
{
CGunWeapon::Unload(mgr);
x234_ice2nd2.Unlock();
x228_ice2nd1.Unlock();
x21c_iceSmoke.Unlock();
ReInitVariables();
}
bool CIceBeam::IsLoaded() const
{
return CGunWeapon::IsLoaded() && x248_24_loaded;
}
}

View File

@ -11,13 +11,26 @@ class CIceBeam : public CGunWeapon
TCachedToken<CGenDescription> x21c_iceSmoke;
TCachedToken<CGenDescription> x228_ice2nd1;
TCachedToken<CGenDescription> x234_ice2nd2;
u32 x240_ = 0;
u32 x244_ = 0;
bool x248_24 : 1;
bool x248_25 : 1;
std::unique_ptr<CElementGen> x240_smokeGen;
std::unique_ptr<CElementGen> x244_chargeFx;
bool x248_24_loaded : 1;
bool x248_25_inEndFx : 1;
void ReInitVariables();
public:
CIceBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
void PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
void EnableFx(bool enable);
void EnableSecondaryFx(ESecondaryFxType type);
void Update(float dt, CStateManager& mgr);
void Load(CStateManager& mgr, bool subtypeBasePose);
void Unload(CStateManager& mgr);
bool IsLoaded() const;
};
}

View File

@ -1,6 +1,10 @@
#include "CPhazonBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "World/CPlayer.hpp"
#include "World/CWorld.hpp"
#include "CProjectileWeapon.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
@ -8,33 +12,255 @@ namespace urde
CPhazonBeam::CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: CGunWeapon(characterId, type, playerId, playerMaterial, scale),
x238_(zeus::CVector3f(-0.14664599f, 0.f, -0.14909725f) * scale.y,
x238_aaBoxScale(zeus::CVector3f(-0.14664599f, 0.f, -0.14909725f) * scale.y,
zeus::CVector3f(0.14664599f, 0.64619601f, 0.14909725f) * scale.y),
x250_(zeus::CVector3f(-0.0625f, 0.f, -0.09375f) * scale.y,
x250_aaBoxTranslate(zeus::CVector3f(-0.0625f, 0.f, -0.09375f) * scale.y,
zeus::CVector3f(0.0625f, -0.25f, 0.09375f) * scale.y)
{
x21c_phazonVeins = g_SimplePool->GetObj("PhazonVeins");
x228_phazon2nd1 = g_SimplePool->GetObj("Phazon2nd_1");
x274_24 = false;
x274_25 = true;
x274_26 = false;
x274_27 = false;
x274_24_loaded = false;
x274_25_clipWipeActive = true;
x274_26_veinsAlphaActive = false;
x274_27_phazonVeinsIdx = false;
m_aaboxShaderScale.setAABB(x238_aaBoxScale);
m_aaboxShaderTranslate.setAABB(x250_aaBoxTranslate);
}
void CPhazonBeam::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&)
void CPhazonBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
TAreaId aid = mgr.GetPlayer().GetAreaIdAlways();
if (msg == EScriptObjectMessage::Deleted && aid != kInvalidAreaId)
mgr.WorldNC()->GetArea(aid)->SetWeaponWorldLighting(4.f, 1.f);
}
void CPhazonBeam::StopBeam(CStateManager& mgr, bool b1)
{
if (x234_chargeFxGen)
x234_chargeFxGen->SetParticleEmission(false);
}
void CPhazonBeam::UpdateBeam(float dt, const zeus::CTransform& targetXf,
const zeus::CVector3f& localBeamPos, CStateManager& mgr)
{
if (x234_chargeFxGen)
x234_chargeFxGen->SetParticleEmission(IsFiring());
CGunWeapon::UpdateMuzzleFx(dt, x4_scale, localBeamPos, IsFiring());
}
void CPhazonBeam::CreateBeam(CStateManager& mgr)
{
x234_chargeFxGen = std::make_unique<CElementGen>(x228_phazon2nd1, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
if (x234_chargeFxGen)
{
x234_chargeFxGen->SetGlobalScale(x4_scale);
x234_chargeFxGen->SetParticleEmission(false);
}
}
void CPhazonBeam::PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
if (IsFiring())
{
zeus::CTransform backupView = CGraphics::g_ViewMatrix;
CGraphics::SetViewPointMatrix(xf.inverse() * backupView);
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
CGunWeapon::DrawMuzzleFx(mgr);
CGraphics::SetViewPointMatrix(backupView);
}
}
void CPhazonBeam::PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x234_chargeFxGen)
x234_chargeFxGen->Render();
CGunWeapon::PostRenderGunFx(mgr, xf);
}
void CPhazonBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x234_chargeFxGen)
{
x234_chargeFxGen->SetGlobalOrientAndTrans(xf);
x234_chargeFxGen->Update(dt);
}
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
}
static const u16 kSoundId[] = { 1805, 1767 };
void CPhazonBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2)
{
if (chargeState == EChargeState::Normal)
{
ActivateCharge(false, false);
int count = x278_fireTime > 1.f / 3.f ? 5 : 2;
int seedOffset = 0;
for (int i=0 ; i<count ; ++i, seedOffset += 1000)
{
CProjectileWeapon::SetGlobalSeed(u16(mgr.GetUpdateFrameIndex() + seedOffset));
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
CProjectileWeapon::SetGlobalSeed(u16(mgr.GetUpdateFrameIndex()));
}
x278_fireTime = 0.f;
}
else
{
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
}
NWeaponTypes::play_sfx(kSoundId[int(chargeState)], underwater, false, 0.165f);
}
void CPhazonBeam::Update(float dt, CStateManager& mgr)
{
CGunWeapon::Update(dt, mgr);
x278_fireTime += dt;
TAreaId aid = mgr.GetPlayer().GetAreaIdAlways();
if (aid != kInvalidAreaId)
{
CGameArea* area = mgr.WorldNC()->GetArea(aid);
if (x278_fireTime > 1.f / 6.f)
area->SetWeaponWorldLighting(4.f, 1.f);
else
area->SetWeaponWorldLighting(4.f, 0.9f);
}
if (!IsLoaded())
{
if (CGunWeapon::IsLoaded() && !x274_24_loaded)
{
x274_24_loaded = x228_phazon2nd1.IsLoaded() && x21c_phazonVeins.IsLoaded();
if (x274_24_loaded)
{
CreateBeam(mgr);
x224_phazonVeinsData = std::make_unique<CModelData>(
CStaticRes(NWeaponTypes::get_asset_id_from_name(x274_27_phazonVeinsIdx ?
"PhazonVeins_2" : "PhazonVeins"), x4_scale));
x21c_phazonVeins.Unlock();
x274_25_clipWipeActive = true;
}
}
}
if (x274_25_clipWipeActive)
{
x268_clipWipeScale += 0.75f * dt;
if (x268_clipWipeScale > 1.f)
x268_clipWipeScale = 1.f;
if (x268_clipWipeScale > 0.4f)
{
if (x26c_clipWipeTranslate < 0.5f)
x26c_clipWipeTranslate += 0.75f * dt;
else
x274_25_clipWipeActive = false;
}
}
else if (x274_26_veinsAlphaActive)
{
x270_indirectAlpha = x10_solidModelData->GetLocatorTransform("phazonScale_LCTR_SDK").origin.y;
}
}
void CPhazonBeam::Load(CStateManager& mgr, bool subtypeBasePose)
{
CGunWeapon::Load(mgr, subtypeBasePose);
x228_phazon2nd1.Lock();
x274_27_phazonVeinsIdx = (mgr.GetActiveRandom()->Next() & 0x2) != 0;
x21c_phazonVeins = g_SimplePool->GetObj(x274_27_phazonVeinsIdx ? "PhazonVeins_2" : "PhazonVeins");
x21c_phazonVeins.Lock();
}
void CPhazonBeam::ReInitVariables()
{
x268_clipWipeScale = 0.f;
x26c_clipWipeTranslate = 0.f;
x270_indirectAlpha = 1.f;
x234_chargeFxGen.reset();
x224_phazonVeinsData.reset();
x274_24_loaded = false;
x274_25_clipWipeActive = true;
x274_26_veinsAlphaActive = false;
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
}
void CPhazonBeam::Unload(CStateManager& mgr)
{
CGunWeapon::Unload(mgr);
x228_phazon2nd1.Unlock();
x21c_phazonVeins.Unlock();
ReInitVariables();
}
bool CPhazonBeam::IsLoaded() const
{
return CGunWeapon::IsLoaded() && x274_24_loaded;
}
void CPhazonBeam::DrawClipScaleCube() const
{
// Render AABB as completely transparent object, only modifying Z-buffer
m_aaboxShaderScale.draw(zeus::CColor::skClear);
}
void CPhazonBeam::DrawClipTranslateCube() const
{
// Render AABB as completely transparent object, only modifying Z-buffer
m_aaboxShaderTranslate.draw(zeus::CColor::skClear);
}
void CPhazonBeam::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf,
const CModelFlags& flags, const CActorLights* lights) const
{
CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
bool drawIndirect = visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan;
if (drawIndirect)
{
CGraphics::ResolveSpareTexture(g_Viewport);
CModelFlags tmpFlags = flags;
tmpFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
CGunWeapon::Draw(drawSuitArm, mgr, xf, tmpFlags, lights);
}
CGunWeapon::Draw(drawSuitArm, mgr, xf, flags, lights);
if (drawIndirect)
{
g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.3f * x270_indirectAlpha, 0.6f * x270_indirectAlpha,
x270_indirectAlpha, 0.5f * x270_indirectAlpha),
{}, zeus::CColor::skWhite, 1.f, 0.f, 0.f, 0.f);
}
if (x224_phazonVeinsData)
{
zeus::CTransform modelXf = xf * x10_solidModelData->GetScaledLocatorTransform("elbow");
if (x274_25_clipWipeActive)
{
CGraphics::SetModelMatrix(modelXf * zeus::CTransform::Scale(1.f - x268_clipWipeScale));
DrawClipScaleCube();
CGraphics::SetModelMatrix(modelXf * zeus::CTransform::Translate(0.f, x26c_clipWipeTranslate, 0.f));
DrawClipTranslateCube();
}
if (x274_26_veinsAlphaActive)
{
CModelFlags useFlags(5, 0, 3, zeus::CColor(1.f, 0.5f * x270_indirectAlpha));
x224_phazonVeinsData->Render(mgr, xf, lights, useFlags);
}
else
{
x224_phazonVeinsData->Render(mgr, xf, lights, flags);
}
}
}
void CPhazonBeam::DrawMuzzleFx(const CStateManager& mgr) const
{
if (IsFiring())
CGunWeapon::DrawMuzzleFx(mgr);
}
}

View File

@ -2,6 +2,7 @@
#define __URDE_CPHAZONBEAM_HPP__
#include "CGunWeapon.hpp"
#include "Graphics/Shaders/CAABoxShader.hpp"
namespace urde
{
@ -9,28 +10,48 @@ namespace urde
class CPhazonBeam : public CGunWeapon
{
TCachedToken<CModel> x21c_phazonVeins;
std::unique_ptr<CModelData> x224_phazonVeinsData;
TCachedToken<CGenDescription> x228_phazon2nd1;
u32 x234_ = 0;
zeus::CAABox x238_;
zeus::CAABox x250_;
float x268_ = 0.f;
float x26c_ = 0.f;
float x270_ = 1.f;
bool x274_24 : 1;
bool x274_25 : 1;
bool x274_26 : 1;
bool x274_27 : 1;
float x278_ = 1.f / 3.f;
std::unique_ptr<CElementGen> x234_chargeFxGen;
zeus::CAABox x238_aaBoxScale;
zeus::CAABox x250_aaBoxTranslate;
float x268_clipWipeScale = 0.f;
float x26c_clipWipeTranslate = 0.f;
float x270_indirectAlpha = 1.f;
bool x274_24_loaded : 1;
bool x274_25_clipWipeActive : 1;
bool x274_26_veinsAlphaActive : 1;
bool x274_27_phazonVeinsIdx : 1;
float x278_fireTime = 1.f / 3.f;
mutable CAABoxShader m_aaboxShaderScale = {true};
mutable CAABoxShader m_aaboxShaderTranslate = {true};
void ReInitVariables();
void DrawClipScaleCube() const;
void DrawClipTranslateCube() const;
public:
CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
bool IsFiring() const { return x278_ < 1.f / 6.f; }
void SetX274_25(bool b) { x274_25 = b; }
void SetX274_26(bool b) { x274_26 = b; }
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
bool IsFiring() const { return x278_fireTime < 1.f / 6.f; }
void SetClipWipeActive(bool b) { x274_25_clipWipeActive = b; }
void SetVeinsAlphaActive(bool b) { x274_26_veinsAlphaActive = b; }
void StopBeam(CStateManager& mgr, bool b1);
void UpdateBeam(float dt, const zeus::CTransform& targetXf,
const zeus::CVector3f& localBeamPos, CStateManager& mgr);
void CreateBeam(CStateManager& mgr);
void PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
void Update(float dt, CStateManager& mgr);
void Load(CStateManager& mgr, bool subtypeBasePose);
void Unload(CStateManager& mgr);
bool IsLoaded() const;
void Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf,
const CModelFlags& flags, const CActorLights* lights) const;
void DrawMuzzleFx(const CStateManager& mgr) const;
};
}

View File

@ -1,6 +1,8 @@
#include "CPlasmaBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "World/CPlayer.hpp"
#include "World/CWorld.hpp"
namespace urde
{
@ -10,13 +12,158 @@ CPlasmaBeam::CPlasmaBeam(CAssetId characterId, EWeaponType type, TUniqueId playe
: CGunWeapon(characterId, type, playerId, playerMaterial, scale)
{
x21c_plasma2nd1 = g_SimplePool->GetObj("Plasma2nd_1");
x22c_24 = false;
x22c_25 = false;
x22c_24_loaded = false;
x22c_25_worldLighingDim = false;
}
void CPlasmaBeam::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&)
void CPlasmaBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::Deleted)
DeleteBeam(mgr);
}
void CPlasmaBeam::SetWorldLighting(CStateManager& mgr, TAreaId aid, float speed, float target)
{
if (x22c_25_worldLighingDim && x23c_stateArea != aid && x23c_stateArea != kInvalidAreaId)
{
CGameArea* area = mgr.WorldNC()->GetArea(x23c_stateArea);
if (area->IsPostConstructed())
area->SetWeaponWorldLighting(2.f, 1.f);
}
x23c_stateArea = aid;
x22c_25_worldLighingDim = target != 1.f;
if (x23c_stateArea != kInvalidAreaId)
{
CGameArea* area = mgr.WorldNC()->GetArea(x23c_stateArea);
if (area->IsPostConstructed())
area->SetWeaponWorldLighting(speed, target);
}
}
void CPlasmaBeam::DeleteBeam(CStateManager& mgr)
{
if (x22c_25_worldLighingDim)
SetWorldLighting(mgr, mgr.GetPlayer().GetAreaIdAlways(), 2.f, 1.f);
}
void CPlasmaBeam::PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x228_chargeFx && x1cc_enabledSecondaryEffect != ESecondaryFxType::None)
x228_chargeFx->Render();
CGunWeapon::PostRenderGunFx(mgr, xf);
}
void CPlasmaBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x228_chargeFx && x1cc_enabledSecondaryEffect != ESecondaryFxType::None)
{
if (x228_chargeFx->IsSystemDeletable())
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
x228_chargeFx->SetTranslation(xf.origin);
x228_chargeFx->SetOrientation(xf.getRotation());
x228_chargeFx->Update(dt);
}
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
}
static const CCameraShakeData CameraShaker = { 0.125f, 0.25f };
static const u16 kSoundId[] = { 1803, 1840 };
void CPlasmaBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2)
{
bool fired = false;
if (chargeState == EChargeState::Normal)
{
if (x230_fireShotDelayTimer < 0.01f)
{
ActivateCharge(false, true);
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
x230_fireShotDelayTimer += 0.33f;
x234_fireShotDelay = 0.33f;
fired = true;
}
}
else
{
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, 1.f);
mgr.GetCameraManager()->AddCameraShaker(CameraShaker, false);
x238_lightingResetDelayTimer = 0.65f;
SetWorldLighting(mgr, mgr.GetPlayer().GetAreaIdAlways(), 8.f, 0.7f);
fired = true;
}
if (fired)
NWeaponTypes::play_sfx(kSoundId[int(chargeState)], underwater, false, 0.165f);
}
void CPlasmaBeam::EnableSecondaryFx(ESecondaryFxType type)
{
switch (type)
{
case ESecondaryFxType::CancelCharge:
if (x1cc_enabledSecondaryEffect == ESecondaryFxType::None || !x228_chargeFx)
return;
x228_chargeFx->SetParticleEmission(false);
break;
case ESecondaryFxType::Charge:
x228_chargeFx = std::make_unique<CElementGen>(x21c_plasma2nd1, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x228_chargeFx->SetGlobalScale(x4_scale);
default:
break;
}
x1cc_enabledSecondaryEffect = type;
}
void CPlasmaBeam::Update(float dt, CStateManager& mgr)
{
CGunWeapon::Update(dt, mgr);
x230_fireShotDelayTimer = std::max(0.f, x230_fireShotDelayTimer - dt);
x238_lightingResetDelayTimer -= dt;
if ((mgr.GetPlayer().GetPlayerGun()->IsCharging() ?
mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor() : 0.f) > 0.5f)
SetWorldLighting(mgr, mgr.GetPlayer().GetAreaIdAlways(), 0.2f, 0.8f);
else if (x238_lightingResetDelayTimer < 0.f && x22c_25_worldLighingDim)
SetWorldLighting(mgr, mgr.GetPlayer().GetAreaIdAlways(), 2.f, 1.f);
if (IsLoaded())
return;
if (CGunWeapon::IsLoaded() && !x22c_24_loaded)
{
x22c_24_loaded = x21c_plasma2nd1.IsLoaded();
if (x22c_24_loaded)
CreateBeam(mgr);
}
}
void CPlasmaBeam::Load(CStateManager& mgr, bool subtypeBasePose)
{
CGunWeapon::Load(mgr, subtypeBasePose);
x21c_plasma2nd1.Lock();
}
void CPlasmaBeam::ReInitVariables()
{
x228_chargeFx.reset();
x22c_24_loaded = false;
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
}
void CPlasmaBeam::Unload(CStateManager& mgr)
{
CGunWeapon::Unload(mgr);
x21c_plasma2nd1.Unlock();
DeleteBeam(mgr);
ReInitVariables();
}
bool CPlasmaBeam::IsLoaded() const
{
return CGunWeapon::IsLoaded() && x22c_24_loaded;
}
}

View File

@ -9,21 +9,35 @@ namespace urde
class CPlasmaBeam : public CGunWeapon
{
TCachedToken<CGenDescription> x21c_plasma2nd1;
u32 x228_ = 0;
bool x22c_24 : 1;
bool x22c_25 : 1;
float x230_ = 0.f;
float x234_ = 0.f;
float x238_ = 0.f;
TAreaId x23c_ = kInvalidAreaId;
std::unique_ptr<CElementGen> x228_chargeFx;
bool x22c_24_loaded : 1;
bool x22c_25_worldLighingDim : 1;
float x230_fireShotDelayTimer = 0.f;
float x234_fireShotDelay = 0.f;
float x238_lightingResetDelayTimer = 0.f;
TAreaId x23c_stateArea = kInvalidAreaId;
void ReInitVariables();
void SetWorldLighting(CStateManager& mgr, TAreaId aid, float speed, float target);
public:
CPlasmaBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
bool IsFiring() const { return x234_ > 0.f; }
void StopBeam(CStateManager& mgr, bool b1) {}
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
bool IsFiring() const { return x234_fireShotDelay > 0.f; }
void StopBeam(CStateManager& mgr, bool b1) { /* Empty */ }
void CreateBeam(CStateManager& mgr) { /* Empty */ }
void UpdateBeam(float dt, const zeus::CTransform& targetXf,
const zeus::CVector3f& localBeamPos, CStateManager& mgr) {}
const zeus::CVector3f& localBeamPos, CStateManager& mgr) { /* Empty */ }
void DeleteBeam(CStateManager& mgr);
void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
void EnableSecondaryFx(ESecondaryFxType type);
void Update(float dt, CStateManager& mgr);
void Load(CStateManager& mgr, bool subtypeBasePose);
void Unload(CStateManager& mgr);
bool IsLoaded() const;
};
}

View File

@ -428,7 +428,7 @@ void CPlayerGun::ResetCharge(CStateManager& mgr, bool b1)
if (x832_27_chargeAnimStarted || r30)
PlayAnim(NWeaponTypes::EGunAnimType::BasePosition, false);
if (r30)
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Zero);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None);
if ((x2f8_stateFlags & 0x2) != 0x2 || x330_chargeState != EChargeState::Normal)
{
if ((x2f8_stateFlags & 0x8) != 0x8)
@ -521,7 +521,7 @@ void CPlayerGun::HandleBeamChange(const CFinalInput& input, CStateManager& mgr)
x832_30_requestReturnToDefault = true;
x740_grappleArm->EnterIdle(mgr);
}
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Zero);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None);
x338_nextState = ENextState::ChangeWeapon;
x2e4_invalidSfx.reset();
}
@ -627,11 +627,11 @@ void CPlayerGun::CancelCharge(CStateManager& mgr, bool withEffect)
if (withEffect)
{
x32c_chargePhase = EChargePhase::ChargeCancelled;
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Three);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::CancelCharge);
}
else
{
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Zero);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None);
}
x834_24_charging = false;
@ -658,8 +658,8 @@ void CPlayerGun::HandlePhazonBeamChange(CStateManager& mgr)
inMorph = true;
if (x75c_phazonBeam)
{
x75c_phazonBeam->SetX274_25(false);
x75c_phazonBeam->SetX274_26(true);
x75c_phazonBeam->SetClipWipeActive(false);
x75c_phazonBeam->SetVeinsAlphaActive(true);
}
}
break;
@ -827,7 +827,7 @@ void CPlayerGun::StopContinuousBeam(CStateManager& mgr, bool b1)
if (x310_currentBeam != CPlayerState::EBeamId::Power || x833_28_phazonBeamActive)
{
x72c_currentBeam->EnableSecondaryFx(
b1 ? CGunWeapon::ESecondaryFxType::Zero : CGunWeapon::ESecondaryFxType::Three);
b1 ? CGunWeapon::ESecondaryFxType::None : CGunWeapon::ESecondaryFxType::CancelCharge);
}
break;
default:
@ -1223,7 +1223,7 @@ void CPlayerGun::EnableChargeFx(EChargeState state, CStateManager& mgr)
{
x72c_currentBeam->ActivateCharge(true, false);
SetGunLightActive(true, mgr);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::One);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Charge);
StopContinuousBeam(mgr, false);
switch (x310_currentBeam)
@ -1368,7 +1368,7 @@ void CPlayerGun::UpdateAuxWeapons(float dt, const zeus::CTransform& targetXf, CS
if (!done)
if (x72c_currentBeam->ComboFireOver())
done = true;
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Three);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::CancelCharge);
if (done)
{
x32c_chargePhase = EChargePhase::ChargeDone;
@ -1410,7 +1410,7 @@ void CPlayerGun::DoUserAnimEvent(float dt, CStateManager& mgr, const CInt32POINo
x2f8_stateFlags |= 0x10;
CancelCharge(mgr, true);
if (doFireSecondary)
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Two);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::ToCombo);
break;
default:
break;
@ -2076,7 +2076,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
if (becameFrozen)
{
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::Zero);
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None);
x72c_currentBeam->EnableFrozenEffect(CGunWeapon::EFrozenFxType::Frozen);
}
else if (becameThawed)

View File

@ -12,7 +12,151 @@ CPowerBeam::CPowerBeam(CAssetId characterId, EWeaponType type, TUniqueId playerI
x21c_shotSmoke = g_SimplePool->GetObj("ShotSmoke");
x228_power2nd1 = g_SimplePool->GetObj("Power2nd_1");
x244_24 = false;
x244_25 = false;
x244_25_loaded = false;
}
void CPowerBeam::PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
zeus::CTransform backupView = CGraphics::g_ViewMatrix;
CGraphics::SetViewPointMatrix(xf.inverse() * backupView);
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
if (x234_shotSmokeGen)
x234_shotSmokeGen->Render();
CGraphics::SetViewPointMatrix(backupView);
}
void CPowerBeam::PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None && x238_power2ndGen)
x238_power2ndGen->Render();
CGunWeapon::PostRenderGunFx(mgr, xf);
}
void CPowerBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf)
{
switch (x240_smokeState)
{
case ESmokeState::Inactive:
if (shotSmoke)
{
if (x234_shotSmokeGen)
x234_shotSmokeGen->SetParticleEmission(true);
x23c_smokeTimer = 2.f;
x240_smokeState = ESmokeState::Active;
}
break;
case ESmokeState::Active:
if (x23c_smokeTimer > 0.f)
{
x23c_smokeTimer -= dt;
}
else
{
if (x234_shotSmokeGen)
x234_shotSmokeGen->SetParticleEmission(false);
x240_smokeState = ESmokeState::Done;
}
case ESmokeState::Done:
if (x234_shotSmokeGen)
{
x234_shotSmokeGen->SetGlobalTranslation(x10_solidModelData->GetScaledLocatorTransform("LBEAM").origin);
x234_shotSmokeGen->Update(dt);
if (x240_smokeState == ESmokeState::Done && x234_shotSmokeGen->GetSystemCount() == 0)
x240_smokeState = ESmokeState::Inactive;
}
else
{
x240_smokeState = ESmokeState::Inactive;
}
break;
}
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None && x238_power2ndGen)
{
x238_power2ndGen->SetGlobalOrientAndTrans(xf);
x238_power2ndGen->Update(dt);
}
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
}
static const u16 skSoundId[] = { 1770, 1767 };
void CPowerBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2)
{
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
NWeaponTypes::play_sfx(skSoundId[int(chargeState)], underwater, false, 0.165f);
}
void CPowerBeam::EnableSecondaryFx(ESecondaryFxType type)
{
switch (type)
{
case ESecondaryFxType::None:
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None && x238_power2ndGen)
x238_power2ndGen->SetParticleEmission(false);
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
break;
case ESecondaryFxType::Charge:
x238_power2ndGen = std::make_unique<CElementGen>(x228_power2nd1,
CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x238_power2ndGen->SetGlobalScale(x4_scale);
x1cc_enabledSecondaryEffect = type;
break;
default:
break;
}
}
void CPowerBeam::Update(float dt, CStateManager& mgr)
{
CGunWeapon::Update(dt, mgr);
if (IsLoaded())
return;
if (CGunWeapon::IsLoaded() && !x244_25_loaded)
{
x244_25_loaded = x21c_shotSmoke.IsLoaded() && x228_power2nd1.IsLoaded();
if (x244_25_loaded)
{
x234_shotSmokeGen = std::make_unique<CElementGen>(x21c_shotSmoke,
CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x234_shotSmokeGen->SetParticleEmission(false);
}
}
}
void CPowerBeam::Load(CStateManager& mgr, bool subtypeBasePose)
{
CGunWeapon::Load(mgr, subtypeBasePose);
x21c_shotSmoke.Lock();
x228_power2nd1.Lock();
}
void CPowerBeam::ReInitVariables()
{
x234_shotSmokeGen.reset();
x238_power2ndGen.reset();
x23c_smokeTimer = 0.f;
x240_smokeState = ESmokeState::Inactive;
x244_24 = false;
x244_25_loaded = false;
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
}
void CPowerBeam::Unload(CStateManager& mgr)
{
CGunWeapon::Unload(mgr);
x228_power2nd1.Unlock();
x21c_shotSmoke.Unlock();
ReInitVariables();
}
bool CPowerBeam::IsLoaded() const
{
return CGunWeapon::IsLoaded() && x244_25_loaded;
}
}

View File

@ -8,16 +8,35 @@ namespace urde
class CPowerBeam : public CGunWeapon
{
enum class ESmokeState
{
Inactive,
Active,
Done
};
TCachedToken<CGenDescription> x21c_shotSmoke;
TCachedToken<CGenDescription> x228_power2nd1;
std::unique_ptr<CElementGen> x234_shotSmokeGen;
float x23c_ = 0.f;
u32 x240_ = 0;
std::unique_ptr<CElementGen> x238_power2ndGen;
float x23c_smokeTimer = 0.f;
ESmokeState x240_smokeState = ESmokeState::Inactive;
bool x244_24 : 1;
bool x244_25 : 1;
bool x244_25_loaded : 1;
void ReInitVariables();
public:
CPowerBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
void PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
void EnableSecondaryFx(ESecondaryFxType type);
void Update(float dt, CStateManager& mgr);
void Load(CStateManager& mgr, bool subtypeBasePose);
void Unload(CStateManager& mgr);
bool IsLoaded() const;
};
}

View File

@ -1,6 +1,7 @@
#include "CWaveBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "CEnergyProjectile.hpp"
namespace urde
{
@ -13,8 +14,177 @@ CWaveBeam::CWaveBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
x228_wave2nd1 = g_SimplePool->GetObj("Wave2nd_1");
x234_wave2nd2 = g_SimplePool->GetObj("Wave2nd_2");
x240_wave2nd3 = g_SimplePool->GetObj("Wave2nd_3");
x258_24 = false;
x258_25 = false;
x258_24_loaded = false;
x258_25_effectTimerActive = false;
}
void CWaveBeam::PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None)
{
if (x254_chargeFx)
x254_chargeFx->Render();
if (x250_chargeElec)
x250_chargeElec->Render();
}
CGunWeapon::PostRenderGunFx(mgr, xf);
}
void CWaveBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf)
{
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::None)
{
if (x258_25_effectTimerActive && x24c_effectTimer < 0.f)
{
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
x24c_effectTimer = 0.f;
x258_25_effectTimerActive = false;
}
else
{
if (x254_chargeFx)
{
x254_chargeFx->SetGlobalTranslation(xf.origin);
x254_chargeFx->SetGlobalOrientation(xf.getRotation());
x254_chargeFx->Update(dt);
}
if (x250_chargeElec)
{
x250_chargeElec->SetGlobalTranslation(xf.origin);
x250_chargeElec->SetGlobalOrientation(xf.getRotation());
x250_chargeElec->Update(dt);
}
}
if (x258_25_effectTimerActive && x24c_effectTimer > 0.f)
x24c_effectTimer -= 0.f;
}
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
}
static const float skShotAnglePitch = 120.f;
static const u16 kSoundId[] = { 1801, 1845 };
void CWaveBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2)
{
if (chargeState == EChargeState::Charged)
{
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
}
else
{
float randAng = mgr.GetActiveRandom()->Float() * 360.f;
auto& weaponDesc = x144_weapons[int(chargeState)];
for (int i=0 ; i<3 ; ++i)
{
zeus::CTransform shotXf = xf * zeus::CTransform::RotateY(zeus::degToRad((randAng + i) * skShotAnglePitch));
CEnergyProjectile* proj = new CEnergyProjectile(true, weaponDesc, x1c0_weaponType, shotXf,
x1c8_playerMaterial, GetDamageInfo(mgr, chargeState, chargeFactor1),mgr.AllocateUniqueId(),
kInvalidAreaId, x1c4_playerId, homingTarget, CWeapon::EProjectileAttrib::ArmCannon, underwater,
zeus::CVector3f::skOne, {}, -1, false);
mgr.AddObject(proj);
proj->Think(dt, mgr);
}
}
if (chargeState == EChargeState::Charged)
x218_25_enableCharge = true;
NWeaponTypes::play_sfx(kSoundId[int(chargeState)], underwater, false, 0.165f);
CAnimPlaybackParms parms(skShootAnim[int(chargeState)], -1, 1.f, true);
x10_solidModelData->AnimationData()->EnableLooping(false);
x10_solidModelData->AnimationData()->SetAnimation(parms, false);
}
void CWaveBeam::EnableSecondaryFx(ESecondaryFxType type)
{
switch (type)
{
case ESecondaryFxType::None:
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
break;
case ESecondaryFxType::CancelCharge:
if (x1cc_enabledSecondaryEffect == ESecondaryFxType::None)
break;
default:
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::ToCombo)
{
auto& fx = type == ESecondaryFxType::Charge ? x228_wave2nd1 : x234_wave2nd2;
x250_chargeElec = std::make_unique<CParticleElectric>(fx);
x250_chargeElec->SetGlobalScale(x4_scale);
}
switch (type)
{
case ESecondaryFxType::Charge:
x254_chargeFx.reset();
break;
case ESecondaryFxType::CancelCharge:
if (x1cc_enabledSecondaryEffect != ESecondaryFxType::CancelCharge)
{
x258_25_effectTimerActive = true;
x24c_effectTimer = 3.f;
if (x254_chargeFx)
x254_chargeFx->SetParticleEmission(false);
}
break;
case ESecondaryFxType::ToCombo:
x254_chargeFx = std::make_unique<CElementGen>(x240_wave2nd3, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
x254_chargeFx->SetGlobalScale(x4_scale);
x24c_effectTimer = 0.f;
x258_25_effectTimerActive = true;
default:
break;
}
x1cc_enabledSecondaryEffect = type;
}
}
void CWaveBeam::Update(float dt, CStateManager& mgr)
{
CGunWeapon::Update(dt, mgr);
if (IsLoaded())
return;
if (CGunWeapon::IsLoaded() && !x258_24_loaded)
{
x258_24_loaded = x228_wave2nd1.IsLoaded() && x234_wave2nd2.IsLoaded() &&
x240_wave2nd3.IsLoaded() && x21c_waveBeam.IsLoaded();
}
}
void CWaveBeam::Load(CStateManager& mgr, bool subtypeBasePose)
{
CGunWeapon::Load(mgr, subtypeBasePose);
x228_wave2nd1.Lock();
x234_wave2nd2.Lock();
x240_wave2nd3.Lock();
x21c_waveBeam.Lock();
}
void CWaveBeam::ReInitVariables()
{
x24c_effectTimer = 0.f;
x250_chargeElec.reset();
x254_chargeFx.reset();
x258_24_loaded = false;
x258_25_effectTimerActive = false;
x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
}
void CWaveBeam::Unload(CStateManager& mgr)
{
CGunWeapon::Unload(mgr);
x21c_waveBeam.Unlock();
x240_wave2nd3.Unlock();
x234_wave2nd2.Unlock();
x228_wave2nd1.Unlock();
ReInitVariables();
}
bool CWaveBeam::IsLoaded() const
{
return CGunWeapon::IsLoaded() && x258_24_loaded;
}
}

View File

@ -12,14 +12,25 @@ class CWaveBeam : public CGunWeapon
TCachedToken<CElectricDescription> x228_wave2nd1;
TCachedToken<CElectricDescription> x234_wave2nd2;
TCachedToken<CGenDescription> x240_wave2nd3;
float x24c_ = 0.f;
u32 x250_ = 0;
u32 x254_ = 0;
bool x258_24 : 1;
bool x258_25 : 1;
float x24c_effectTimer = 0.f;
std::unique_ptr<CParticleElectric> x250_chargeElec;
std::unique_ptr<CElementGen> x254_chargeFx;
bool x258_24_loaded : 1;
bool x258_25_effectTimerActive : 1;
void ReInitVariables();
public:
CWaveBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
void EnableSecondaryFx(ESecondaryFxType type);
void Update(float dt, CStateManager& mgr);
void Load(CStateManager& mgr, bool subtypeBasePose);
void Unload(CStateManager& mgr);
bool IsLoaded() const;
};
}

View File

@ -69,6 +69,7 @@ protected:
bool xe6_30_enablePitchBend : 1;
u8 xe6_31_targetableVisorFlags : 4;
bool xe7_27_ : 1;
bool xe7_28_worldLightingDirty : 1;
bool xe7_29_ : 1;
bool xe7_30_doTargetDistanceTest : 1;
bool xe7_31_targetable : 1;
@ -175,6 +176,7 @@ public:
const CActorLights* GetActorLights() const { return x90_actorLights.get(); }
bool CanDrawStatic() const;
bool GetE7_29() const { return xe7_29_; }
void SetWorldLightingDirty(bool b) { xe7_28_worldLightingDirty = b; }
const CScannableObjectInfo* GetScannableObjectInfo() const;
const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const
{ return const_cast<CActor*>(this)->HealthInfo(const_cast<CStateManager&>(mgr)); }

View File

@ -6,6 +6,7 @@
#include "World/CScriptAreaAttributes.hpp"
#include "CGameState.hpp"
#include "DataSpec/DNAMP1/MREA.hpp"
#include "TCastTo.hpp"
namespace urde
{
@ -465,6 +466,12 @@ void CGameArea::SetThermalSpeedAndTarget(float speed, float target)
x12c_postConstructed->x1124_thermalTarget = target;
}
void CGameArea::SetWeaponWorldLighting(float speed, float target)
{
x12c_postConstructed->x1134_weaponWorldLightingSpeed = speed;
x12c_postConstructed->x1138_weaponWorldLightingTarget = target;
}
float CGameArea::GetXRayFogDistance() const
{
const CScriptAreaAttributes* attrs = x12c_postConstructed->x10d8_areaAttributes;
@ -522,6 +529,63 @@ void CGameArea::UpdateThermalVisor(float dt)
x12c_postConstructed->x111c_thermalCurrent = influence;
}
void CGameArea::UpdateWeaponWorldLighting(float dt)
{
float newLightingLevel = x12c_postConstructed->x1128_worldLightingLevel;
if (x12c_postConstructed->x112c_xraySpeed != 0)
{
float speed = dt * x12c_postConstructed->x112c_xraySpeed;
if (std::fabs(x12c_postConstructed->x1130_xrayTarget - newLightingLevel) < speed)
{
newLightingLevel = x12c_postConstructed->x1130_xrayTarget;
x12c_postConstructed->x1134_weaponWorldLightingSpeed = 0.f;
}
else if (x12c_postConstructed->x1130_xrayTarget < newLightingLevel)
{
newLightingLevel -= speed;
}
else
{
newLightingLevel += speed;
}
}
if (x12c_postConstructed->x1134_weaponWorldLightingSpeed != 0.f)
{
float newWeaponWorldLightingLevel = x12c_postConstructed->x1128_worldLightingLevel;
float speed = dt * x12c_postConstructed->x1134_weaponWorldLightingSpeed;
if (std::fabs(x12c_postConstructed->x1138_weaponWorldLightingTarget - newLightingLevel) < speed)
{
newWeaponWorldLightingLevel = x12c_postConstructed->x1138_weaponWorldLightingTarget;
x12c_postConstructed->x1134_weaponWorldLightingSpeed = 0.f;
}
else if (x12c_postConstructed->x1138_weaponWorldLightingTarget < newWeaponWorldLightingLevel)
{
newWeaponWorldLightingLevel -= speed;
}
else
{
newWeaponWorldLightingLevel += speed;
}
if (x12c_postConstructed->x112c_xraySpeed != 0.f)
{
newLightingLevel = std::min(newLightingLevel, newWeaponWorldLightingLevel);
}
else
{
newLightingLevel = newWeaponWorldLightingLevel;
}
}
if (std::fabs(x12c_postConstructed->x1128_worldLightingLevel - newLightingLevel) >= 0.00001f)
{
x12c_postConstructed->x1128_worldLightingLevel = newLightingLevel;
for (CEntity* ent : *x12c_postConstructed->x10c0_areaObjs)
if (TCastToPtr<CActor> act = ent)
act->SetWorldLightingDirty(true);
}
}
void CGameArea::AliveUpdate(float dt)
{
if (x12c_postConstructed->x10dc_occlusionState == EOcclusionState::Occluded)
@ -530,7 +594,7 @@ void CGameArea::AliveUpdate(float dt)
x12c_postConstructed->x10e4_ = 0.f;
UpdateFog(dt);
UpdateThermalVisor(dt);
UpdateWeaponWorldLighting(dt);
}
void CGameArea::SetOcclusionState(EOcclusionState state)

View File

@ -249,8 +249,8 @@ public:
float x1128_worldLightingLevel = 1.f;
float x112c_xraySpeed = 0.f;
float x1130_xrayTarget = 1.f;
float x1134_ = 0.f;
float x1138_ = 1.f;
float x1134_weaponWorldLightingSpeed = 0.f;
float x1138_weaponWorldLightingTarget = 1.f;
u32 x113c_ = 0;
};
private:
@ -266,6 +266,7 @@ private:
void UpdateFog(float dt);
void UpdateThermalVisor(float dt);
void UpdateWeaponWorldLighting(float dt);
struct MREAHeader
{
@ -304,6 +305,7 @@ public:
void SetXRaySpeedAndTarget(float f1, float f2);
void SetThermalSpeedAndTarget(float f1, float f2);
void SetWeaponWorldLighting(float speed, float target);
CAssetId GetAreaAssetId() const { return x84_mrea; }
const CAreaFog* GetAreaFog() const { return GetPostConstructed()->x10c4_areaFog.get(); }

View File

@ -84,7 +84,7 @@ zeus::CAABox CPhysicsActor::GetMotionVolume(float dt) const
zeus::CVector3f CPhysicsActor::CalculateNewVelocityWR_UsingImpulses() const
{
return x138_velocity + (xec_massRecip * (x168_impulse + x18c_));
return x138_velocity + (xec_massRecip * (x168_impulse + x18c_moveImpulse));
}
zeus::CAABox CPhysicsActor::GetBoundingBox() const
@ -171,10 +171,13 @@ zeus::CVector3f CPhysicsActor::GetTotalForcesWR() const { return x15c_force + x1
void CPhysicsActor::RotateInOneFrameOR(const zeus::CQuaternion& q, float d)
{
x198_ += GetRotateToORAngularMomentumWR(q, d);
x198_moveAngularImpulse += GetRotateToORAngularMomentumWR(q, d);
}
void CPhysicsActor::MoveInOneFrameOR(const zeus::CVector3f& trans, float d) { x18c_ += GetMoveToORImpulseWR(trans, d); }
void CPhysicsActor::MoveInOneFrameOR(const zeus::CVector3f& trans, float d)
{
x18c_moveImpulse += GetMoveToORImpulseWR(trans, d);
}
void CPhysicsActor::RotateToOR(const zeus::CQuaternion& q, float d)
{
@ -190,7 +193,7 @@ void CPhysicsActor::MoveToOR(const zeus::CVector3f& trans, float d)
void CPhysicsActor::sub_8011B098(const zeus::CVector3f& trans, float d)
{
x18c_ += xe8_mass * (trans - x34_transform.origin) * (1.f / d);
x18c_moveImpulse += xe8_mass * (trans - x34_transform.origin) * (1.f / d);
}
void CPhysicsActor::MoveToWR(const zeus::CVector3f& trans, float d)
@ -214,14 +217,14 @@ zeus::CVector3f CPhysicsActor::GetMoveToORImpulseWR(const zeus::CVector3f& trans
void CPhysicsActor::ClearImpulses()
{
x18c_ = x168_impulse = zeus::CVector3f::skZero;
x198_ = x180_angularImpulse = zeus::CAxisAngle::skZero;
x18c_moveImpulse = x168_impulse = zeus::CVector3f::skZero;
x198_moveAngularImpulse = x180_angularImpulse = zeus::CAxisAngle::skZero;
}
void CPhysicsActor::ClearForcesAndTorques()
{
x18c_ = x168_impulse = x15c_force = zeus::CVector3f::skZero;
x198_ = x180_angularImpulse = x174_torque = zeus::CAxisAngle::skZero;
x18c_moveImpulse = x168_impulse = x15c_force = zeus::CVector3f::skZero;
x198_moveAngularImpulse = x180_angularImpulse = x174_torque = zeus::CAxisAngle::skZero;
}
void CPhysicsActor::Stop()
@ -244,10 +247,10 @@ bool CPhysicsActor::WillMove(const CStateManager&)
if (!zeus::close_enough(zeus::CVector3f::skZero, x138_velocity) ||
!zeus::close_enough(zeus::CVector3f::skZero, x168_impulse) ||
!zeus::close_enough(zeus::CVector3f::skZero, x174_torque) ||
!zeus::close_enough(zeus::CVector3f::skZero, x18c_) ||
!zeus::close_enough(zeus::CVector3f::skZero, x18c_moveImpulse) ||
!zeus::close_enough(zeus::CVector3f::skZero, x144_angularVelocity) ||
!zeus::close_enough(zeus::CVector3f::skZero, x180_angularImpulse) ||
!zeus::close_enough(zeus::CVector3f::skZero, x198_) ||
!zeus::close_enough(zeus::CVector3f::skZero, x198_moveAngularImpulse) ||
!zeus::close_enough(zeus::CVector3f::skZero, GetTotalForcesWR()))
return true;
@ -305,7 +308,7 @@ CMotionState CPhysicsActor::PredictLinearMotion(float dt) const
CMotionState CPhysicsActor::PredictAngularMotion(float dt) const
{
const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_);
const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_moveAngularImpulse);
zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion({0.f, x144_angularVelocity + v1});
return {zeus::CVector3f::skZero, q * zeus::CNUQuaternion(x34_transform.buildMatrix3f()) * dt,
zeus::CVector3f::skZero, (x174_torque * dt) + x180_angularImpulse};

View File

@ -103,8 +103,8 @@ protected:
zeus::CVector3f x168_impulse;
zeus::CAxisAngle x174_torque;
zeus::CAxisAngle x180_angularImpulse;
zeus::CVector3f x18c_;
zeus::CAxisAngle x198_;
zeus::CVector3f x18c_moveImpulse;
zeus::CAxisAngle x198_moveAngularImpulse;
zeus::CAABox x1a4_baseBoundingBox;
CCollidableAABox x1c0_collisionPrimitive;
zeus::CVector3f x1e8_primitiveOffset;

2
hecl

@ -1 +1 @@
Subproject commit 806a802cff2bf5dc72afcc8145852e595cfdc654
Subproject commit 1fbe86aab4b5c262b55ba9bbfe33f8132c8d5113