Skip to content

Commit

Permalink
Add "SUPERHOT" effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Nov 11, 2024
1 parent 2df0eef commit a1a411d
Show file tree
Hide file tree
Showing 7 changed files with 110 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 @@ -436,6 +436,7 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureNightvision>();
RegisterChaosFeature<CFeatureVoidclip>();
RegisterChaosFeature<CFeatureLowDrawDistance>();
RegisterChaosFeature<CFeatureSuperhot>();

// must be last
RegisterChaosFeature<CFeatureCheatCodeVoting>();
Expand Down
57 changes: 57 additions & 0 deletions GSChaos/CFeatureSuperhot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "includes.h"

extern float* sys_timescale;

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

void CFeatureSuperhot::ActivateFeature()
{
CChaosFeature::ActivateFeature();
}

void CFeatureSuperhot::DeactivateFeature()
{
CChaosFeature::DeactivateFeature();
*sys_timescale = 1.0f;
}

void CFeatureSuperhot::OnFrame(double time)
{
if (!IsActive())
return;

static cvar_t* sv_maxspeed;
if (!sv_maxspeed)
sv_maxspeed = pEngfuncs->pfnGetCvarPointer("sv_maxspeed");

float flMaxSpeed = sv_maxspeed ? sv_maxspeed->value : 320.0f;

if (flMaxSpeed == 0)
flMaxSpeed = 270.0f;

float flVelocity = (*sv_player)->v.velocity.Length() / flMaxSpeed;
*sys_timescale = std::clamp(flVelocity, 0.1f, 2.0f);
}

const char* CFeatureSuperhot::GetFeatureName()
{
return "SUPERHOT";
}

double CFeatureSuperhot::GetDuration()
{
return gChaos.GetChaosTime() * 1.06;
}

bool CFeatureSuperhot::UseCustomDuration()
{
return true;
}

bool CFeatureSuperhot::CanBeInfinite()
{
return true;
}
41 changes: 41 additions & 0 deletions GSChaos/CFeatureSuperhot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright - ScriptedSnark, 2024.
* CFeatureSuperhot.h
*
* Project (GSChaos) header file
* Authors: ScriptedSnark.
* Do not delete this comment block. Respect others' work!
*/

#ifdef CFEATURESUPERHOT_H_RECURSE_GUARD
#error Recursive header files inclusion detected in CFeatureSuperhot.h
#else //CFEATURESUPERHOT_H_RECURSE_GUARD

#define CFEATURESUPERHOT_H_RECURSE_GUARD

#ifndef CFEATURESUPERHOT_H_GUARD
#define CFEATURESUPERHOT_H_GUARD
#pragma once

#ifdef __cplusplus

class CFeatureSuperhot : public CChaosFeature
{
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
void OnFrame(double time) override;
const char* GetFeatureName() override;
double GetDuration() override;
bool UseCustomDuration() override;
bool CanBeInfinite() override;
};

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

#endif //CFEATURESUPERHOT_H_GUARD

#undef CFEATURESUPERHOT_H_RECURSE_GUARD
#endif //CFEATURESUPERHOT_H_RECURSE_GUARD
2 changes: 2 additions & 0 deletions GSChaos/GSChaos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
<ClCompile Include="CFeatureRollin.cpp" />
<ClCompile Include="CFeatureScientistMadness.cpp" />
<ClCompile Include="CFeatureScrollingHell.cpp" />
<ClCompile Include="CFeatureSuperhot.cpp" />
<ClCompile Include="CFeatureTempEntityMadness.cpp" />
<ClCompile Include="CFeatureTurbulentHell.cpp" />
<ClCompile Include="CFeatureSet1HP.cpp" />
Expand Down Expand Up @@ -481,6 +482,7 @@
<ClInclude Include="CFeatureRollin.h" />
<ClInclude Include="CFeatureScientistMadness.h" />
<ClInclude Include="CFeatureScrollingHell.h" />
<ClInclude Include="CFeatureSuperhot.h" />
<ClInclude Include="CFeatureTempEntityMadness.h" />
<ClInclude Include="CFeatureTurbulentHell.h" />
<ClInclude Include="CFeatureSet1HP.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 @@ -633,6 +633,9 @@
<ClCompile Include="CFeatureLowDrawDistance.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureSuperhot.cpp">
<Filter>Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="includes.h" />
Expand Down Expand Up @@ -1246,6 +1249,9 @@
<ClInclude Include="CFeatureLowDrawDistance.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureSuperhot.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 @@ -237,6 +237,7 @@ extern bool g_bEncrypted;
#include "CFeatureNightvision.h"
#include "CFeatureVoidclip.h"
#include "CFeatureLowDrawDistance.h"
#include "CFeatureSuperhot.h"

#include "CFeatureCheatCodeVoting.h"
#include "CFeatureCombineEffects.h"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA
> Nightvision
> Voidclip
> Low Draw Distance
> SUPERHOT
> Cheat Code Voting !!!(available with Twitch voting)!!!
> 3 Effects in 1
> Let's make it more chaotic
Expand Down Expand Up @@ -312,6 +313,7 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA
> Overthinking
> Nightvision
> Voidclip
> SUPERHOT
> Cheat Code Voting !!!(available with Twitch voting)!!!
> 3 Effects in 1
> Let's make it more chaotic
Expand Down

0 comments on commit a1a411d

Please sign in to comment.