Skip to content

Commit

Permalink
Add "Ice Skating" effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Mar 11, 2024
1 parent 1634608 commit 6543e2b
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions GSChaos/CChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureNPCExplode>();
RegisterChaosFeature<CFeatureJeepy>();
RegisterChaosFeature<CFeatureGravityField>();
RegisterChaosFeature<CFeatureIceSkating>();

RegisterChaosFeature<CFeatureCombineEffects>(); // must be last!!!

Expand Down
46 changes: 46 additions & 0 deletions GSChaos/CFeatureIceSkating.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "includes.h"

void CFeatureIceSkating::Init()
{
CChaosFeature::Init();
}

void CFeatureIceSkating::ActivateFeature()
{
CChaosFeature::ActivateFeature();

sv_friction = g_engfuncs->pfnCVarGetPointer("sv_friction");

if (!sv_friction)
return;

m_flOldFrictionValue = sv_friction->value;
m_bActivated = true;
}

void CFeatureIceSkating::DeactivateFeature()
{
CChaosFeature::DeactivateFeature();
m_bActivated = false;

if (!sv_friction)
{
SERVER_COMMAND("sv_friction 4\n");
return;
}

sv_friction->value = m_flOldFrictionValue;
}

void CFeatureIceSkating::OnFrame(double time)
{
if (!m_bActivated || !sv_friction)
return;

sv_friction->value = 0.0f;
}

const char* CFeatureIceSkating::GetFeatureName()
{
return "Ice skating";
}
42 changes: 42 additions & 0 deletions GSChaos/CFeatureIceSkating.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright - ScriptedSnark, 2024.
* CFeatureIceSkating.h
*
* Project (GSChaos) header file
* Authors: ScriptedSnark.
* Do not delete this comment block. Respect others' work!
*/

#ifdef CFEATUREICESKATING_H_RECURSE_GUARD
#error Recursive header files inclusion detected in CFeatureIceSkating.h
#else //CFEATUREICESKATING_H_RECURSE_GUARD

#define CFEATUREICESKATING_H_RECURSE_GUARD

#ifndef CFEATUREICESKATING_H_GUARD
#define CFEATUREICESKATING_H_GUARD
#pragma once

#ifdef __cplusplus

class CFeatureIceSkating : public CChaosFeature
{
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
void OnFrame(double time) override;
const char* GetFeatureName() override;
private:
bool m_bActivated;
cvar_t* sv_friction;
float m_flOldFrictionValue;
};

#else //!__cplusplus
#error C++ compiler required to compile CFeatureIceSkating.h
#endif //__cplusplus

#endif //CFEATUREICESKATING_H_GUARD

#undef CFEATUREICESKATING_H_RECURSE_GUARD
#endif //CFEATUREICESKATING_H_RECURSE_GUARD
2 changes: 2 additions & 0 deletions GSChaos/GSChaos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<ClCompile Include="CFeatureGTA3HUD.cpp" />
<ClCompile Include="CFeatureHEVMadness.cpp" />
<ClCompile Include="CFeatureHighGravity.cpp" />
<ClCompile Include="CFeatureIceSkating.cpp" />
<ClCompile Include="CFeatureIchthyosaur.cpp" />
<ClCompile Include="CFeatureJeepy.cpp" />
<ClCompile Include="CFeatureLobotomy.cpp" />
Expand Down Expand Up @@ -207,6 +208,7 @@
<ClInclude Include="CFeatureGTA3HUD.h" />
<ClInclude Include="CFeatureHEVMadness.h" />
<ClInclude Include="CFeatureHighGravity.h" />
<ClInclude Include="CFeatureIceSkating.h" />
<ClInclude Include="CFeatureIchthyosaur.h" />
<ClInclude Include="CFeatureJeepy.h" />
<ClInclude Include="CFeatureLobotomy.h" />
Expand Down
6 changes: 6 additions & 0 deletions GSChaos/GSChaos.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
<ClCompile Include="CFeatureGravityField.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureIceSkating.cpp">
<Filter>Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="includes.h" />
Expand Down Expand Up @@ -392,6 +395,9 @@
<ClInclude Include="CFeatureGravityField.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureIceSkating.h">
<Filter>Effects</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Hooking">
Expand Down
1 change: 1 addition & 0 deletions GSChaos/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ extern bool g_bEncrypted;
#include "CFeatureNPCExplode.h"
#include "CFeatureJeepy.h"
#include "CFeatureGravityField.h"
#include "CFeatureIceSkating.h"

#include "CFeatureCombineEffects.h"
//========================
Expand Down

0 comments on commit 6543e2b

Please sign in to comment.