Implement CRainSplashGenerator and finish CPlayerGun constructor

This commit is contained in:
Jack Andersen 2017-08-21 17:20:22 -10:00
parent f3914d9662
commit e8a55d84d4
25 changed files with 633 additions and 89 deletions

View File

@ -1,7 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ClangTidyInspection" enabled="true" level="WARNING" enabled_by_default="true">
<inspection_tool class="ClangTidyInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="clangTidyChecks" value="*,-cert-env33-c,-cppcoreguidelines-no-malloc,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-union-access,-google-*,google-default-arguments,google-explicit-constructor,google-runtime-member-string-references,google-runtime-memset,google-runtime-operator,-llvm-*,-readability-simplify-boolean-expr,-readability-braces-around-statements,-readability-identifier-naming,-readability-function-size,-misc-bool-pointer-implicit-conversion,-misc-unused-parameters,-modernize-use-using,-safety-no-assembler,-clang-diagnostic-*,-clang-analyzer-*,-cert-flp30-c,-cppcoreguidelines-pro-type-vararg" />
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">

View File

@ -34,17 +34,26 @@ struct SChargedShotParam : SShotParam
struct ITweakPlayerGun : ITweak
{
DECL_YAML
virtual float GetUpLookAngle() const = 0;
virtual float GetDownLookAngle() const = 0;
virtual float GetVerticalSpread() const = 0;
virtual float GetHorizontalSpread() const = 0;
virtual float GetHighVerticalSpread() const = 0;
virtual float GetHighHorizontalSpread() const = 0;
virtual float GetLowVerticalSpread() const = 0;
virtual float GetLowHorizontalSpread() const = 0;
virtual float GetAimVerticalSpeed() const = 0; // x24
virtual float GetAimHorizontalSpeed() const = 0; // x28
virtual float GetBombFuseTime() const = 0; // x2c
virtual float GetBombDropDelayTime() const = 0; // x30
virtual float GetHoloHoldTime() const = 0; // x34
virtual float GetGunTransformTime() const = 0; // x38
virtual float GetGunHolsterTime() const=0;
virtual float GetGunNotFiringTime() const=0;
virtual float GetFixedVerticalAim() const=0;
virtual const zeus::CVector3f& GetGunPosition() const=0;
virtual const zeus::CVector3f& GetGrapplingArmPosition() const=0;
virtual float GetGunHolsterTime() const = 0;
virtual float GetGunNotFiringTime() const = 0;
virtual float GetFixedVerticalAim() const = 0;
virtual float GetGunExtendDistance() const = 0;
virtual const zeus::CVector3f& GetGunPosition() const = 0;
virtual const zeus::CVector3f& GetGrapplingArmPosition() const = 0;
virtual float GetRichochetDamage(atUint32) const = 0;
};
}

View File

@ -11,14 +11,14 @@ namespace DNAMP1
struct CTweakPlayerGun : ITweakPlayerGun
{
DECL_YAML
Value<float> x4_;
Value<float> x8_;
Value<float> xc_;
Value<float> x10_;
Value<float> x14_;
Value<float> x18_;
Value<float> x1c_;
Value<float> x20_;
Value<float> x4_upLookAngle;
Value<float> x8_downLookAngle;
Value<float> xc_verticalSpread;
Value<float> x10_horizontalSpread;
Value<float> x14_highVerticalSpread;
Value<float> x18_highHorizontalSpread;
Value<float> x1c_lowVerticalSpread;
Value<float> x20_lowHorizontalSpread;
Value<float> x24_aimVerticalSpeed;
Value<float> x28_aimHorizontalSpeed;
Value<float> x2c_bombFuseTime;
@ -28,7 +28,7 @@ struct CTweakPlayerGun : ITweakPlayerGun
Value<float> x3c_gunHolsterTime;
Value<float> x40_gunNotFiringTime;
Value<float> x44_fixedVerticalAim;
Value<float> x48_;
Value<float> x48_gunExtendDistance;
Value<zeus::CVector3f> x4c_gunPosition;
Value<zeus::CVector3f> x58_;
Value<zeus::CVector3f> x64_grapplingArmPosition;
@ -53,6 +53,14 @@ struct CTweakPlayerGun : ITweakPlayerGun
x44_fixedVerticalAim = zeus::degToRad(x44_fixedVerticalAim);
}
float GetUpLookAngle() const { return x4_upLookAngle; }
float GetDownLookAngle() const { return x8_downLookAngle; }
float GetVerticalSpread() const { return xc_verticalSpread; }
float GetHorizontalSpread() const { return x10_horizontalSpread; }
float GetHighVerticalSpread() const { return x14_highVerticalSpread; }
float GetHighHorizontalSpread() const { return x18_highHorizontalSpread; }
float GetLowVerticalSpread() const { return x1c_lowVerticalSpread; }
float GetLowHorizontalSpread() const { return x20_lowHorizontalSpread; }
float GetAimVerticalSpeed() const { return x24_aimVerticalSpeed; }
float GetAimHorizontalSpeed() const { return x28_aimHorizontalSpeed; }
float GetBombFuseTime() const { return x2c_bombFuseTime; }
@ -62,6 +70,7 @@ struct CTweakPlayerGun : ITweakPlayerGun
float GetGunHolsterTime() const { return x3c_gunHolsterTime; }
float GetGunNotFiringTime() const { return x40_gunNotFiringTime; }
float GetFixedVerticalAim() const { return x44_fixedVerticalAim; }
float GetGunExtendDistance() const { return x48_gunExtendDistance; }
const zeus::CVector3f& GetGunPosition() const { return x4c_gunPosition; }
const zeus::CVector3f& GetGrapplingArmPosition() const { return x64_grapplingArmPosition; }
float GetRichochetDamage(atUint32 type) const

View File

@ -66,7 +66,7 @@ set(GRAPHICS_SOURCES
CPVSAreaSet.hpp CPVSAreaSet.cpp
CGraphics.hpp CGraphics.cpp
CSimpleShadow.hpp CSimpleShadow.cpp
CModelPointSelector.hpp CModelPointSelector.cpp
CRainSplashGenerator.hpp CRainSplashGenerator.cpp
Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp
Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp

View File

@ -1,16 +0,0 @@
#include "CModelPointSelector.hpp"
namespace urde
{
CModelPointSelector::CModelPointSelector(const zeus::CVector3f& scale, int, int, float, float)
{
}
void CModelPointSelector::GeneratePoints(const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn)
{
}
}

View File

@ -1,18 +0,0 @@
#ifndef URDE_CMODELPOINTSELECTOR_HPP
#define URDE_CMODELPOINTSELECTOR_HPP
#include "RetroTypes.hpp"
namespace urde
{
class CModelPointSelector
{
public:
CModelPointSelector(const zeus::CVector3f& scale, int, int, float, float);
void GeneratePoints(const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
};
}
#endif // URDE_CMODELPOINTSELECTOR_HPP

View File

@ -0,0 +1,237 @@
#include "CRainSplashGenerator.hpp"
#include "CStateManager.hpp"
#include "World/CWorld.hpp"
namespace urde
{
CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 maxSplashes,
u32 genRate, float minZ, float alpha)
: x14_scale(scale), x2c_minZ(minZ)
{
x30_alpha = std::min(1.f, alpha);
x44_genRate = std::min(maxSplashes, genRate);
x48_24 = false;
x48_25_raining = true;
x0_rainSplashes.reserve(maxSplashes);
m_gfxTok = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
for (int i=0 ; i<maxSplashes ; ++i)
x0_rainSplashes.emplace_back(ctx);
return true;
});
}
void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const zeus::CVector3f& pos) const
{
if (x0_t > 0.f)
{
float delta = dt * xc_speed;
float vt = std::max(0.f, x0_t - delta * x15_length);
auto vertCount = u32((x0_t - vt) / delta + 1.f);
m_renderer.Reset();
for (u32 i=0 ; i<vertCount ; ++i)
{
float vertAlpha = vt * alpha;
zeus::CVector3f vec(vt * x4_xEnd, vt * x8_yEnd, -4.f * vt * (vt - 1.f) * x10_zParabolaHeight);
vec += pos;
vt += delta;
m_renderer.AddVertex(vec, zeus::CColor(1.f, vertAlpha), 1);
}
m_renderer.Render();
}
}
void CRainSplashGenerator::SRainSplash::Draw(float alpha, float dt, const zeus::CVector3f& pos) const
{
for (const SSplashLine& line : x0_lines)
line.Draw(alpha, dt, pos);
}
void CRainSplashGenerator::DoDraw(const zeus::CTransform& xf) const
{
CGraphics::SetModelMatrix(xf);
if (x40_queueSize > 0)
{
if (x38_queueTail <= x3c_queueHead)
{
for (int i=x3c_queueHead ; i<x0_rainSplashes.size() ; ++i)
{
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
for (int i=0 ; i<x38_queueTail ; ++i)
{
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
}
else
{
for (int i=x3c_queueHead ; i<x38_queueTail ; ++i)
{
const SRainSplash& splash = x0_rainSplashes[i];
splash.Draw(x30_alpha, x28_dt, splash.x64_pos);
}
}
}
}
void CRainSplashGenerator::Draw(const zeus::CTransform& xf) const
{
if (x48_25_raining)
DoDraw(xf);
}
CRainSplashGenerator::SSplashLine::SSplashLine(boo::IGraphicsDataFactory::Context& ctx)
: m_renderer(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 3, nullptr, false)
{}
CRainSplashGenerator::SRainSplash::SRainSplash(boo::IGraphicsDataFactory::Context& ctx)
{
for (int i=0 ; i<4 ; ++i)
x0_lines.emplace_back(ctx);
}
void CRainSplashGenerator::SSplashLine::Update(float dt, CStateManager& mgr)
{
if (!x16_active)
return;
if (x0_t <= 0.8f)
{
x14_ = u8(5.f * (1.f - x0_t) + 3.f * x0_t);
x0_t += dt * xc_speed;
}
else if (x15_length != 0)
{
x15_length -= 1;
}
else
{
x16_active = false;
xc_speed = mgr.GetActiveRandom()->Range(0.015625f, 8.f);
x10_zParabolaHeight = mgr.GetActiveRandom()->Range(0.015625f, 0.03125f);
x4_xEnd = mgr.GetActiveRandom()->Range(-0.125f, 0.125f);
x8_yEnd = mgr.GetActiveRandom()->Range(-0.125f, 0.125f);
x15_length = u8(mgr.GetActiveRandom()->Range(1, 2));
}
}
void CRainSplashGenerator::SRainSplash::Update(float dt, CStateManager& mgr)
{
for (SSplashLine& point : x0_lines)
point.Update(dt, mgr);
}
bool CRainSplashGenerator::SRainSplash::IsActive() const
{
bool ret = false;
for (const SSplashLine& line : x0_lines)
ret |= line.x16_active;
return ret;
}
void CRainSplashGenerator::UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt)
{
for (int i=start ; i<end ; ++i)
{
SRainSplash& set = x0_rainSplashes[i];
set.Update(dt, mgr);
if (!set.IsActive())
{
x40_queueSize -= 1;
x3c_queueHead += 1;
if (x3c_queueHead >= x0_rainSplashes.size())
x3c_queueHead = 0;
}
}
}
void CRainSplashGenerator::UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt)
{
x20_generateTimer += dt;
x24_generateInterval = 1.f / (70.f * magnitude);
if (x40_queueSize > 0)
{
if (x38_queueTail <= x3c_queueHead)
{
UpdateRainSplashRange(mgr, x3c_queueHead, int(x0_rainSplashes.size()), dt);
UpdateRainSplashRange(mgr, 0, x38_queueTail, dt);
}
else
{
UpdateRainSplashRange(mgr, x3c_queueHead, x38_queueTail, dt);
}
}
}
void CRainSplashGenerator::Update(float dt, CStateManager& mgr)
{
EEnvFxType neededFx = mgr.GetWorld()->GetNeededEnvFx();
x28_dt = dt;
x48_25_raining = false;
if (neededFx != EEnvFxType::None && mgr.GetEnvFxManager()->GetX24() &&
mgr.GetEnvFxManager()->GetRainMagnitude() != 0.f && neededFx == EEnvFxType::Rain)
{
UpdateRainSplashes(mgr, mgr.GetEnvFxManager()->GetRainMagnitude(), dt);
x48_25_raining = true;
}
}
u32 CRainSplashGenerator::GetNextBestPt(u32 pt, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn,
CRandom16& rand, float minZ)
{
auto& refVert = vn[pt];
float maxDist = 0.f;
u32 nextPt = pt;
for (int i=0 ; i<3 ; ++i)
{
auto idx = u32(rand.Range(0, int(vn.size() - 1)));
auto& vert = vn[idx];
float distSq = (refVert.first - vert.first).magSquared();
if (distSq > maxDist &&
vert.second.dot(zeus::CVector3f::skUp) >= 0.f &&
(vert.first.z <= 0.f || vert.first.z > minZ))
{
nextPt = idx;
maxDist = distSq;
}
}
return nextPt;
}
void CRainSplashGenerator::SRainSplash::SetPoint(const zeus::CVector3f& pos)
{
for (SSplashLine& line : x0_lines)
line.SetActive();
x64_pos = pos;
}
void CRainSplashGenerator::AddPoint(const zeus::CVector3f& pos)
{
if (x38_queueTail >= x0_rainSplashes.size())
x38_queueTail = 0;
x0_rainSplashes[x38_queueTail].SetPoint(pos);
x40_queueSize += 1;
x38_queueTail += 1;
}
void CRainSplashGenerator::GeneratePoints(const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn)
{
if (!x48_25_raining)
return;
if (x20_generateTimer > x24_generateInterval)
{
for (int i=0 ; i<x44_genRate ; ++i)
{
if (x40_queueSize >= x0_rainSplashes.size())
break;
x34_curPoint = GetNextBestPt(x34_curPoint, vn, x10_random, x2c_minZ);
AddPoint(x14_scale * vn[x34_curPoint].first);
}
x20_generateTimer = 0.f;
}
}
}

View File

@ -0,0 +1,73 @@
#ifndef URDE_CRAINSPLASHGENERATOR_HPP
#define URDE_CRAINSPLASHGENERATOR_HPP
#include "RetroTypes.hpp"
#include "CRandom16.hpp"
#include "zeus/CVector3f.hpp"
#include "Graphics/CLineRenderer.hpp"
namespace urde
{
class CStateManager;
class CRainSplashGenerator
{
struct SSplashLine
{
float x0_t = 0.f;
float x4_xEnd = 0.f;
float x8_yEnd = 0.f;
float xc_speed = 4.f;
float x10_zParabolaHeight = 0.015625f;
u8 x14_ = 3;
u8 x15_length = 1;
bool x16_active = true; // used to be one-bit bitfield
mutable CLineRenderer m_renderer;
explicit SSplashLine(boo::IGraphicsDataFactory::Context& ctx);
void Update(float dt, CStateManager& mgr);
void Draw(float alpha, float dt, const zeus::CVector3f& pos) const;
void SetActive() { x16_active = true; }
};
struct SRainSplash
{
rstl::reserved_vector<SSplashLine, 4> x0_lines;
zeus::CVector3f x64_pos;
float x70_ = 0.f;
explicit SRainSplash(boo::IGraphicsDataFactory::Context& ctx);
void Update(float dt, CStateManager& mgr);
bool IsActive() const;
void Draw(float alpha, float dt, const zeus::CVector3f& pos) const;
void SetPoint(const zeus::CVector3f& pos);
};
std::vector<SRainSplash> x0_rainSplashes;
CRandom16 x10_random = {99};
zeus::CVector3f x14_scale;
float x20_generateTimer = 0.f;
float x24_generateInterval;
float x28_dt = 0.f;
float x2c_minZ;
float x30_alpha;
u32 x34_curPoint = 0;
u32 x38_queueTail = 0;
u32 x3c_queueHead = 0;
u32 x40_queueSize = 0;
u32 x44_genRate;
bool x48_24 : 1;
bool x48_25_raining : 1;
boo::GraphicsDataToken m_gfxTok;
void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt);
void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt);
void DoDraw(const zeus::CTransform& xf) const;
static u32 GetNextBestPt(u32 pt, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn,
CRandom16& rand, float minZ);
void AddPoint(const zeus::CVector3f& pos);
public:
CRainSplashGenerator(const zeus::CVector3f& scale, u32 maxSplashes, u32 genRate, float minZ, float alpha);
void Update(float dt, CStateManager& mgr);
void GeneratePoints(const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
void Draw(const zeus::CTransform& xf) const;
};
}
#endif // URDE_CRAINSPLASHGENERATOR_HPP

View File

@ -41,13 +41,14 @@ s32 GetWeaponIndex(EWeaponType type)
return 0;
}
CGunWeapon::CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes mType, const zeus::CVector3f& vec)
: x4_(vec),
x104_gunCharacter(g_SimplePool->GetObj(SObjectTag{FOURCC('ANCS'), ancsId})),
x13c_armCharacter(g_SimplePool->GetObj(skSuitArmNames[0])),
x1c0_weaponType(type),
x1c4_uid(uid),
x1c8_matType(mType)
CGunWeapon::CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: x4_scale(scale),
x104_gunCharacter(g_SimplePool->GetObj(SObjectTag{FOURCC('ANCS'), ancsId})),
x13c_armCharacter(g_SimplePool->GetObj(skSuitArmNames[0])),
x1c0_weaponType(type),
x1c4_playerId(playerId),
x1c8_playerMaterial(playerMaterial)
{
}

View File

@ -46,7 +46,7 @@ protected:
static const char* skAnimDependencyNames[5];
static const char* skDependencyNames[5];
static const char* skSuitArmNames[8];
zeus::CVector3f x4_;
zeus::CVector3f x4_scale;
TToken<CAnimCharacterSet> x104_gunCharacter;
TToken<CAnimCharacterSet> x13c_armCharacter;
rstl::reserved_vector<TCachedToken<CWeaponDescription>, 2> x144_weapons;
@ -54,12 +54,12 @@ protected:
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x16c_muzzleEffects;
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x188_secondaryEffects;
EWeaponType x1c0_weaponType;
TUniqueId x1c4_uid;
EMaterialTypes x1c8_matType;
TUniqueId x1c4_playerId;
EMaterialTypes x1c8_playerMaterial;
CVelocityInfo x1d0_velInfo;
CPlayerState::EBeamId x200_beamId;
public:
CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes, const zeus::CVector3f& vec);
CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EMaterialTypes, const zeus::CVector3f& scale);
void AsyncLoadSuitArm(CStateManager& mgr);
void AllocResPools(CPlayerState::EBeamId);

View File

@ -0,0 +1,19 @@
#include "CIceBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
namespace urde
{
CIceBeam::CIceBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: CGunWeapon(characterId, type, playerId, playerMaterial, scale)
{
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;
}
}

View File

@ -8,6 +8,16 @@ namespace urde
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;
public:
CIceBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
};
}

View File

@ -0,0 +1,24 @@
#include "CPhazonBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
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,
zeus::CVector3f(0.14664599f, 0.64619601f, 0.14909725f) * scale.y),
x250_(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;
}
}

View File

@ -8,6 +8,22 @@ namespace urde
class CPhazonBeam : public CGunWeapon
{
TCachedToken<CModel> x21c_phazonVeins;
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;
public:
CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
};
}

View File

@ -0,0 +1,17 @@
#include "CPlasmaBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
namespace urde
{
CPlasmaBeam::CPlasmaBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: CGunWeapon(characterId, type, playerId, playerMaterial, scale)
{
x21c_plasma2nd1 = g_SimplePool->GetObj("Plasma2nd_1");
x22c_24 = false;
x22c_25 = false;
}
}

View File

@ -8,6 +8,17 @@ 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;
public:
CPlasmaBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
};
}

View File

@ -1,14 +1,21 @@
#include "CPlayerGun.hpp"
#include "Particle/CGenDescription.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "Character/CPrimitive.hpp"
namespace urde
{
static const zeus::CVector3f sGunScale(2.f);
CPlayerGun::CPlayerGun(TUniqueId id)
: x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0, 0, 0, 0.1f), x538_thisId(id),
static float kVerticalAngleTable[] = { -30.f, 0.f, 30.f };
static float kHorizontalAngleTable[] = { 30.f, 30.f, 30.f };
static float kVerticalVarianceTable[] = { 30.f, 30.f, 30.f };
float CPlayerGun::CMotionState::gGunExtendDistance = 0.125f;
CPlayerGun::CPlayerGun(TUniqueId playerId)
: x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0, 0, 0, 0.1f), x538_thisId(playerId),
x550_camBob(CPlayerCameraBob::ECameraBobType::One,
zeus::CVector2f(CPlayerCameraBob::kCameraBobExtentX, CPlayerCameraBob::kCameraBobExtentY),
CPlayerCameraBob::kCameraBobPeriod),
@ -24,15 +31,97 @@ CPlayerGun::CPlayerGun(TUniqueId id)
x73c_gunMotion = std::make_unique<CGunMotion>(g_tweakGunRes->x4_gunMotion, sGunScale);
x740_grappleArm = std::make_unique<CGrappleArm>(sGunScale);
x744_auxWeapon = std::make_unique<CAuxWeapon>(id);
x744_auxWeapon = std::make_unique<CAuxWeapon>(playerId);
x748_rainSplashGenerator = std::make_unique<CRainSplashGenerator>(sGunScale, 20, 2, 0.f, 0.125f);
x74c_powerBeam = std::make_unique<CPowerBeam>(g_tweakGunRes->x10_powerBeam, EWeaponType::Power,
playerId, EMaterialTypes::Player, sGunScale);
x750_iceBeam = std::make_unique<CIceBeam>(g_tweakGunRes->x14_iceBeam, EWeaponType::Ice,
playerId, EMaterialTypes::Player, sGunScale);
x754_waveBeam = std::make_unique<CWaveBeam>(g_tweakGunRes->x18_waveBeam, EWeaponType::Wave,
playerId, EMaterialTypes::Player, sGunScale);
x758_plasmaBeam = std::make_unique<CPlasmaBeam>(g_tweakGunRes->x1c_plasmaBeam, EWeaponType::Plasma,
playerId, EMaterialTypes::Player, sGunScale);
x75c_phazonBeam = std::make_unique<CPhazonBeam>(g_tweakGunRes->x20_phazonBeam, EWeaponType::Phazon,
playerId, EMaterialTypes::Player, sGunScale);
x774_holoTransitionGen = std::make_unique<CElementGen>(
g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->x24_holoTransition}),
CElementGen::EModelOrientationType::Normal, CElementGen::EOptionalSystemFlags::One);
x82c_shadow = std::make_unique<CWorldShadow>(32, 32, true);
x832_31_ = true;
x833_24_isFidgeting = true;
x833_30_ = true;
x6e0_rightHandModel.SetSortThermal(true);
/* TODO: Finish */
kVerticalAngleTable[2] = g_tweakPlayerGun->GetUpLookAngle();
kVerticalAngleTable[0] = g_tweakPlayerGun->GetDownLookAngle();
kHorizontalAngleTable[1] = g_tweakPlayerGun->GetHorizontalSpread();
kHorizontalAngleTable[2] = g_tweakPlayerGun->GetHighHorizontalSpread();
kHorizontalAngleTable[0] = g_tweakPlayerGun->GetLowHorizontalSpread();
kVerticalVarianceTable[1] = g_tweakPlayerGun->GetVerticalSpread();
kVerticalVarianceTable[2] = g_tweakPlayerGun->GetHighVerticalSpread();
kVerticalVarianceTable[0] = g_tweakPlayerGun->GetLowVerticalSpread();
CMotionState::SetExtendDistance(g_tweakPlayerGun->GetGunExtendDistance());
InitBeamData();
InitBombData();
InitMuzzleData();
InitCTData();
LoadHandAnimTokens();
x550_camBob.SetPlayerVelocity(zeus::CVector3f::skZero);
x550_camBob.SetBobMagnitude(0.f);
x550_camBob.SetBobTimeScale(0.f);
}
void CPlayerGun::InitBeamData()
{
x760_selectableBeams[0] = x74c_powerBeam.get();
x760_selectableBeams[0] = x750_iceBeam.get();
x760_selectableBeams[0] = x754_waveBeam.get();
x760_selectableBeams[0] = x758_plasmaBeam.get();
x72c_currentBeam = x760_selectableBeams[0];
x738_nextBeam = x72c_currentBeam;
x774_holoTransitionGen->SetParticleEmission(true);
}
void CPlayerGun::InitBombData()
{
x784_bombEffects.resize(2);
x784_bombEffects[0].push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->x28_bombSet}));
x784_bombEffects[0].push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->x2c_bombExplode}));
TLockedToken<CGenDescription> pbExplode =
g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->x30_powerBombExplode});
x784_bombEffects[1].push_back(pbExplode);
x784_bombEffects[1].push_back(pbExplode);
}
void CPlayerGun::InitMuzzleData()
{
for (int i=0 ; i<5 ; ++i)
{
x7c0_auxMuzzleEffects.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'),
g_tweakGunRes->xa4_auxMuzzle[i]}));
x800_auxMuzzleGenerators.emplace_back(new CElementGen(x7c0_auxMuzzleEffects.back(),
CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One));
x800_auxMuzzleGenerators.back()->SetParticleEmission(false);
}
}
void CPlayerGun::InitCTData()
{
x77c_.reset();
}
void CPlayerGun::LoadHandAnimTokens()
{
std::set<CPrimitive> prims;
for (int i=0 ; i<3 ; ++i)
{
CAnimPlaybackParms parms(i, -1, 1.f, true);
x6e0_rightHandModel.GetAnimationData()->GetAnimationPrimitives(parms, prims);
}
CAnimData::PrimitiveSetToTokenVector(prims, x540_handAnimTokens, true);
}
void CPlayerGun::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&)

View File

@ -19,7 +19,7 @@
#include "Character/CModelData.hpp"
#include "World/CWorldShadow.hpp"
#include "World/ScriptObjectSupport.hpp"
#include "Graphics/CModelPointSelector.hpp"
#include "Graphics/CRainSplashGenerator.hpp"
namespace urde
{
@ -68,7 +68,9 @@ private:
class CMotionState
{
static const float kGunExtendDistance;
static float gGunExtendDistance;
public:
static void SetExtendDistance(float d) { gGunExtendDistance = d; }
};
CActorLights x0_lights;
@ -133,9 +135,7 @@ private:
TUniqueId x538_thisId;
TUniqueId x53a_ = kInvalidUniqueId;
TUniqueId x53c_ = kInvalidUniqueId;
u32 x544_ = 0;
u32 x548_ = 0;
u32 x54c_ = 0;
std::vector<CToken> x540_handAnimTokens;
CPlayerCameraBob x550_camBob;
u32 x658_ = 1;
float x65c_ = 0.f;
@ -161,19 +161,24 @@ private:
CGunWeapon* x72c_currentBeam = nullptr;
u32 x730_ = 0;
u32 x734_ = 0;
u32 x738_ = 0;
CGunWeapon* x738_nextBeam = nullptr;
std::unique_ptr<CGunMotion> x73c_gunMotion;
std::unique_ptr<CGrappleArm> x740_grappleArm;
std::unique_ptr<CAuxWeapon> x744_auxWeapon;
std::unique_ptr<CModelPointSelector> x748_modelPointSelector;
std::unique_ptr<CRainSplashGenerator> x748_rainSplashGenerator;
std::unique_ptr<CPowerBeam> x74c_powerBeam;
std::unique_ptr<CIceBeam> x750_iceBeam;
std::unique_ptr<CWaveBeam> x754_waveBeam;
std::unique_ptr<CPlasmaBeam> x758_plasmaBeam;
std::unique_ptr<CPhazonBeam> x75c_phazonBeam;
CGunWeapon* x760_selectableBeams[4] = {};
std::unique_ptr<CElementGen> x774_;
CGunWeapon* x760_selectableBeams[4] = {}; // Used to be reserved_vector
std::unique_ptr<CElementGen> x774_holoTransitionGen;
std::unique_ptr<u32> x77c_;
rstl::reserved_vector<rstl::reserved_vector<TLockedToken<CGenDescription>, 2>, 2> x784_bombEffects;
rstl::reserved_vector<TLockedToken<CGenDescription>, 5> x7c0_auxMuzzleEffects;
rstl::reserved_vector<std::unique_ptr<CElementGen>, 5> x800_auxMuzzleGenerators;
std::unique_ptr<CWorldShadow> x82c_shadow;
s16 x830 = -1;
union
{
@ -218,8 +223,14 @@ private:
u32 _dummy = 0;
};
void InitBeamData();
void InitBombData();
void InitMuzzleData();
void InitCTData();
void LoadHandAnimTokens();
public:
CPlayerGun(TUniqueId id);
explicit CPlayerGun(TUniqueId playerId);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AsyncLoadSuit(CStateManager& mgr);

View File

@ -1,10 +1,18 @@
#include "CPowerBeam.hpp"
#include "Particle/CGenDescription.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
namespace urde
{
CPowerBeam::CPowerBeam(u32 w1, EWeaponType wType, TUniqueId uid, EMaterialTypes mType, const zeus::CVector3f& vec)
: CGunWeapon(w1, wType, uid, mType, vec)
CPowerBeam::CPowerBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: CGunWeapon(characterId, type, playerId, playerMaterial, scale)
{
x21c_shotSmoke = g_SimplePool->GetObj("ShotSmoke");
x228_power2nd1 = g_SimplePool->GetObj("Power2nd_1");
x244_24 = false;
x244_25 = false;
}
}

View File

@ -8,8 +8,16 @@ namespace urde
class CPowerBeam : public CGunWeapon
{
TCachedToken<CGenDescription> x21c_shotSmoke;
TCachedToken<CGenDescription> x228_power2nd1;
u32 x234_ = 0;
float x23c_ = 0.f;
u32 x240_ = 0;
bool x244_24 : 1;
bool x244_25 : 1;
public:
CPowerBeam(u32, EWeaponType, TUniqueId, EMaterialTypes, const zeus::CVector3f&);
CPowerBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
};
}

View File

@ -0,0 +1,20 @@
#include "CWaveBeam.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
namespace urde
{
CWaveBeam::CWaveBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale)
: CGunWeapon(characterId, type, playerId, playerMaterial, scale)
{
x21c_waveBeam = g_SimplePool->GetObj("WaveBeam");
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;
}
}

View File

@ -8,6 +8,18 @@ namespace urde
class CWaveBeam : public CGunWeapon
{
TCachedToken<CWeaponDescription> x21c_waveBeam;
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;
public:
CWaveBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId,
EMaterialTypes playerMaterial, const zeus::CVector3f& scale);
};
}

View File

@ -7,7 +7,7 @@
#include "zeus/CTransform.hpp"
#include "Particle/CParticleElectric.hpp"
#include "Particle/CParticleSwoosh.hpp"
#include "Graphics/CModelPointSelector.hpp"
#include "Graphics/CRainSplashGenerator.hpp"
namespace urde
{
@ -42,7 +42,7 @@ public:
u32 xc8_ = 0;
u32 xcc_seed3 = 99;
zeus::CColor xd0_;
std::unique_ptr<CModelPointSelector> xd4_pointSelector;
std::unique_ptr<CRainSplashGenerator> xd4_rainSplashGenerator;
TToken<CTexture> xdc_ashy;
std::unique_ptr<CElementGen> xe4_;
zeus::CVector3f xec_ = zeus::CVector3f::skOne;

View File

@ -14,8 +14,8 @@ class CTexture;
enum class EEnvFxType
{
None,
Rain,
Snow
Snow,
Rain
};
enum class EPhazonType
@ -51,10 +51,10 @@ class CEnvFxManager
{
zeus::CAABox x0_ = zeus::CAABox(-63.5, 63.5);
zeus::CVector3f x18_ = zeus::CVector3f::skZero;
u8 x24_ = 0;
bool x24_ = false;
float x28_ = 0.f;
u32 x2c_ = -1;
float x30_ = 0.f;
float x30_rainMagnitude = 0.f;
float x34_fxDensity = 0.f;
float x38_ = 0.f;
u8 x3c = 0;
@ -78,6 +78,8 @@ public:
void GetParticleBoundsToWorldScale() const;
void AreaLoaded();
void SetXB54(float f) { xb54_ = f; }
bool GetX24() const { return x24_; }
float GetRainMagnitude() const { return x30_rainMagnitude; }
};
}

View File

@ -7,7 +7,7 @@
#include "Graphics/CModel.hpp"
#include "Audio/CSfxManager.hpp"
#include "AutoMapper/CMapWorld.hpp"
#include "CEnvFxManager.hpp"
namespace urde
{
@ -147,7 +147,8 @@ private:
TLockedToken<CModel> x94_skybox;
TLockedToken<CModel> xa4_skyboxB;
TLockedToken<CModel> xb4_skyboxC;
std::vector<CSfxHandle> xc4_sfxHandles;
EEnvFxType xc4_neededFx = EEnvFxType::None;
std::vector<CSfxHandle> xc8_sfxHandles;
void LoadSoundGroup(int groupId, CAssetId agscId, CSoundGroupData& data);
void LoadSoundGroups();
@ -200,6 +201,7 @@ public:
void TouchSky();
void DrawSky(const zeus::CTransform& xf) const;
void StopSound(s16);
EEnvFxType GetNeededEnvFx() const { return xc4_neededFx; }
};
struct CWorldLayers