Skip to content

Commit

Permalink
Implement FXList nuggets
Browse files Browse the repository at this point in the history
  • Loading branch information
feliwir committed Sep 17, 2024
1 parent f18391c commit 750c4ab
Show file tree
Hide file tree
Showing 2 changed files with 327 additions and 3 deletions.
172 changes: 172 additions & 0 deletions src/game/client/fxlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ static const FieldParse s_theFXListFieldParse[] = {
{ "TerrainScorch", reinterpret_cast<inifieldparse_t>(PICK_ADDRESS(0x004CAC80, 0x00760F20)) /*&TerrainScorchFXNugget::Parse */, nullptr, 0 },
{ "ParticleSystem", reinterpret_cast<inifieldparse_t>(PICK_ADDRESS(0x004CAE10, 0x00761350)) /*&ParticleSystemFXNugget::Parse */, nullptr, 0 },
{ "FXListAtBonePos", reinterpret_cast<inifieldparse_t>(PICK_ADDRESS(0x004CB8E0, 0x00761D00)) /*&FXListAtBonePosFXNugget::Parse */, nullptr, 0 },
#else // DUMMIES
// { "RayEffect", &RayEffectFXNugget::Parse, nullptr, 0 },
{ "Tracer", &TracerFXNugget::Parse, nullptr, 0 },
{ "LightPulse", &LightPulseFXNugget::Parse, nullptr, 0 },
{ "ViewShake", &ViewShakeFXNugget::Parse, nullptr, 0 },
{ "TerrainScorch", &TerrainScorchFXNugget::Parse, nullptr, 0 },
{ "ParticleSystem", &ParticleSystemFXNugget::Parse, nullptr, 0 },
{ "FXListAtBonePos", &FXListAtBonePosFXNugget::Parse, nullptr, 0 },
#endif
{ nullptr, nullptr, nullptr, 0 },
};
Expand Down Expand Up @@ -132,3 +140,167 @@ void SoundFXNugget::Parse(INI *ini, void *formal, void *, const void *)
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void TracerFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "TracerFXNugget::Do_FX_Pos not implemented!");
}

void TracerFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "TracerFXNugget::Do_FX_Obj not implemented!");
}

void TracerFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "DecayAt", &INI::Parse_Int, nullptr, offsetof(TracerFXNugget, m_decayAt) },
{ "Length", &INI::Parse_Int, nullptr, offsetof(TracerFXNugget, m_length) },
{ "Width", &INI::Parse_Real, nullptr, offsetof(TracerFXNugget, m_width) },
{ "Color", &INI::Parse_RGB_Color, nullptr, offsetof(TracerFXNugget, m_color) },
{ "Speed", &INI::Parse_Int, nullptr, offsetof(TracerFXNugget, speed) },
{ "Probability", &INI::Parse_Real, nullptr, offsetof(TracerFXNugget, probability) },
{ nullptr, nullptr, nullptr, 0 },
};

TracerFXNugget *nugget = new TracerFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void LightPulseFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "LightPulseFXNugget::Do_FX_Pos not implemented!");
}

void LightPulseFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "LightPulseFXNugget::Do_FX_Obj not implemented!");
}

void LightPulseFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "Color", &INI::Parse_RGB_Color, nullptr, offsetof(LightPulseFXNugget, m_color) },
{ "Radius", &INI::Parse_Int, nullptr, offsetof(LightPulseFXNugget, m_radius) },
{ "RadiusAsPercentOfObjectSize",
&INI::Parse_Percent_To_Real,
nullptr,
offsetof(LightPulseFXNugget, m_radiusAsPercentOfObjectSize) },
{ "IncreaseTime", &INI::Parse_Int, nullptr, offsetof(LightPulseFXNugget, m_increaseTime) },
{ "DecreaseTime", &INI::Parse_Int, nullptr, offsetof(LightPulseFXNugget, m_decreaseTime) },
{ nullptr, nullptr, nullptr, 0 },
};

LightPulseFXNugget *nugget = new LightPulseFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void ViewShakeFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "ViewShakeFXNugget::Do_FX_Pos not implemented!");
}

void ViewShakeFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "ViewShakeFXNugget::Do_FX_Obj not implemented!");
}

void ViewShakeFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "Type", &INI::Parse_Index_List, g_shakeIntensityNames, offsetof(ViewShakeFXNugget, m_type) },
{ nullptr, nullptr, nullptr, 0 },
};

ViewShakeFXNugget *nugget = new ViewShakeFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void TerrainScorchFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "TerrainScorchFXNugget::Do_FX_Pos not implemented!");
}

void TerrainScorchFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "TerrainScorchFXNugget::Do_FX_Obj not implemented!");
}

void TerrainScorchFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "Type", &INI::Parse_AsciiString, nullptr, offsetof(TerrainScorchFXNugget, m_type) },
{ "Radius", &INI::Parse_Int, nullptr, offsetof(TerrainScorchFXNugget, m_radius) },
{ nullptr, nullptr, nullptr, 0 },
};

TerrainScorchFXNugget *nugget = new TerrainScorchFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void ParticleSystemFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "ParticleSystemFXNugget::Do_FX_Pos not implemented!");
}

void ParticleSystemFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "ParticleSystemFXNugget::Do_FX_Obj not implemented!");
}

void ParticleSystemFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "Name", &INI::Parse_AsciiString, nullptr, offsetof(ParticleSystemFXNugget, m_sysName) },
{ "Count", &INI::Parse_Int, nullptr, offsetof(ParticleSystemFXNugget, m_count) },
{ "Radius", &GameClientRandomVariable::Parse, nullptr, offsetof(ParticleSystemFXNugget, m_radius) },
{ "InitialDelay", &GameClientRandomVariable::Parse, nullptr, offsetof(ParticleSystemFXNugget, m_initialDelay) },
{ "AttachToObject", &INI::Parse_Bool, nullptr, offsetof(ParticleSystemFXNugget, m_attachToObject) },
{ "Offset", &INI::Parse_Coord3D, nullptr, offsetof(ParticleSystemFXNugget, m_offset) },
{ "Height", &GameClientRandomVariable::Parse, nullptr, offsetof(ParticleSystemFXNugget, m_height) },
{ "OrientToObject", &INI::Parse_Bool, nullptr, offsetof(ParticleSystemFXNugget, m_orientToObject) },
{ "RotateY", &INI::Parse_Angle_Real, nullptr, offsetof(ParticleSystemFXNugget, m_rotateY) },
{ "Ricochet", &INI::Parse_Bool, nullptr, offsetof(ParticleSystemFXNugget, m_ricochet) },
{ "CreateAtGroundHeight", &INI::Parse_Bool, nullptr, offsetof(ParticleSystemFXNugget, m_createAtGroundHeight) },
{ "UseCallersRadius", &INI::Parse_Bool, nullptr, offsetof(ParticleSystemFXNugget, m_useCallersRadius) },
{ nullptr, nullptr, nullptr, 0 },
};

ParticleSystemFXNugget *nugget = new ParticleSystemFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}

void FXListAtBonePosFXNugget::Do_FX_Pos(
const Coord3D *primary, const Matrix3D *primary_mtx, float primary_speed, const Coord3D *secondary, float radius) const
{
captainslog_dbgassert(false, "FXListAtBonePosFXNugget::Do_FX_Pos not implemented!");
}

void FXListAtBonePosFXNugget::Do_FX_Obj(const Object *primary, const Object *secondary) const
{
captainslog_dbgassert(false, "FXListAtBonePosFXNugget::Do_FX_Obj not implemented!");
}

void FXListAtBonePosFXNugget::Parse(INI *ini, void *formal, void *, const void *)
{
static const FieldParse _fieldParse[] = {
{ "FX", &FXList::Parse, nullptr, offsetof(FXListAtBonePosFXNugget, m_fx) },
{ "BoneName", &INI::Parse_AsciiString, nullptr, offsetof(FXListAtBonePosFXNugget, m_boneName) },
{ "OrientToBone", &INI::Parse_Bool, nullptr, offsetof(FXListAtBonePosFXNugget, m_orientToBone) },
{ nullptr, nullptr, nullptr, 0 },
};

FXListAtBonePosFXNugget *nugget = new FXListAtBonePosFXNugget{};
ini->Init_From_INI(nugget, _fieldParse);
reinterpret_cast<FXList *>(formal)->Add_FXNugget(nugget);
}
158 changes: 155 additions & 3 deletions src/game/client/fxlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#pragma once

#include "always.h"
#include "color.h"
#include "coord.h"
#include "namekeygenerator.h"
#include "randomvalue.h"
#include "rtsutils.h"
#include "subsysteminterface.h"
#include <list>
Expand All @@ -36,7 +39,7 @@ class FXNugget : public MemoryPoolObject
IMPLEMENT_ABSTRACT_POOL(FXNugget);

public:
virtual ~FXNugget(){};
virtual ~FXNugget() {};
virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
Expand Down Expand Up @@ -103,8 +106,8 @@ class SoundFXNugget : public FXNugget
IMPLEMENT_POOL(SoundFXNugget);

public:
SoundFXNugget(){};
virtual ~SoundFXNugget() override{};
SoundFXNugget() {};
virtual ~SoundFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
Expand All @@ -118,3 +121,152 @@ class SoundFXNugget : public FXNugget
private:
Utf8String m_soundName;
};

class TracerFXNugget : public FXNugget
{
IMPLEMENT_POOL(TracerFXNugget);

public:
TracerFXNugget() {};
virtual ~TracerFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
int m_decayAt;
int m_length;
float m_width;
RGBColor m_color;
int speed;
float probability;
};

class LightPulseFXNugget : public FXNugget
{
IMPLEMENT_POOL(LightPulseFXNugget);

public:
LightPulseFXNugget() : m_radiusAsPercentOfObjectSize(0.0f) {};
virtual ~LightPulseFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
RGBColor m_color;
int m_radius;
float m_radiusAsPercentOfObjectSize;
int m_increaseTime;
int m_decreaseTime;
};

class ViewShakeFXNugget : public FXNugget
{
IMPLEMENT_POOL(ViewShakeFXNugget);

public:
ViewShakeFXNugget() {};
virtual ~ViewShakeFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
ShakeIntensities m_type;
};

class TerrainScorchFXNugget : public FXNugget
{
IMPLEMENT_POOL(TerrainScorchFXNugget);

public:
TerrainScorchFXNugget() {};
virtual ~TerrainScorchFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
Utf8String m_type;
int m_radius;
};

class ParticleSystemFXNugget : public FXNugget
{
IMPLEMENT_POOL(ParticleSystemFXNugget);

public:
ParticleSystemFXNugget() {};
virtual ~ParticleSystemFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
Utf8String m_sysName;
int m_count;
GameClientRandomVariable m_radius;
Coord3D m_offset;
GameClientRandomVariable m_height;
bool m_attachToObject;
GameClientRandomVariable m_initialDelay;
bool m_orientToObject;
float m_rotateY;
bool m_ricochet;
bool m_createAtGroundHeight;
bool m_useCallersRadius;
};

struct FXListAtBonePosFXNugget : public FXNugget
{
IMPLEMENT_POOL(FXListAtBonePosFXNugget);

public:
FXListAtBonePosFXNugget() {};
virtual ~FXListAtBonePosFXNugget() override {};

virtual void Do_FX_Pos(const Coord3D *primary,
const Matrix3D *primary_mtx,
float primary_speed,
const Coord3D *secondary,
float radius) const override;
virtual void Do_FX_Obj(const Object *primary, const Object *secondary) const override;

static void Parse(INI *ini, void *formal, void *, const void *);

private:
FXList *m_fx;
Utf8String m_boneName;
bool m_orientToBone;
};

0 comments on commit 750c4ab

Please sign in to comment.