Skip to content

Commit

Permalink
Add "Spawn 5 random entities" effect, fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Apr 15, 2024
1 parent 0d2f390 commit 8c52e47
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 3 deletions.
10 changes: 10 additions & 0 deletions GSChaos/CChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureReloadAutosave>();
RegisterChaosFeature<CFeatureExtremeGrieferJesus>();
RegisterChaosFeature<CFeatureMegaJump>();
RegisterChaosFeature<CFeatureSpawn5RandomEntities>();

// must be last
RegisterChaosFeature<CFeatureCombineEffects>();
Expand Down Expand Up @@ -442,6 +443,7 @@ void CChaos::Reset()
m_pCurrentFeature = nullptr;

g_bDespawnExShephard = true;
g_bDespawnJesus = true;

auto currentTime = std::chrono::high_resolution_clock::now() - m_pauseOffset;
m_startTime = currentTime;
Expand Down Expand Up @@ -658,6 +660,10 @@ void CChaos::OnFrame(double time)
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(currentTime - m_startTime);
auto globalDuration = std::chrono::duration_cast<std::chrono::duration<double>>(currentTime - m_startGlobalTime);

auto realTime = std::chrono::high_resolution_clock::now();
auto realDuration = std::chrono::duration_cast<std::chrono::duration<double>>(realTime - m_startGlobalTime);
m_flRealTime = realDuration.count();

m_flTime = duration.count();
m_flGlobalTime = globalDuration.count();

Expand Down Expand Up @@ -791,6 +797,10 @@ double CChaos::GetGlobalTime()
return m_flGlobalTime;
}

double CChaos::GetRealTime()
{
return m_flRealTime;
}

int CChaos::GetFrameCount() // did it only for GTA 3 HUD effect so flickering depends on FPS
{
Expand Down
2 changes: 2 additions & 0 deletions GSChaos/CChaos.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CChaos
double GetTime();
double GetChaosTime();
double GetGlobalTime();
double GetRealTime();
int GetFrameCount();
bool IsReady();

Expand All @@ -87,6 +88,7 @@ class CChaos
bool m_bPaused;
float m_flProgress;
double m_flChaosTime;
double m_flRealTime;
double m_flTime;
double m_flGlobalTime;
int m_iFrameCount;
Expand Down
14 changes: 12 additions & 2 deletions GSChaos/CFeatureExtremeGrieferJesus.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "includes.h"

bool g_bDespawnJesus;

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

if (m_bActivated)
return;

m_flTimeForSpawn = gChaos.GetGlobalTime() + 38.0;
m_flTimeForSpawn = gChaos.GetRealTime() + 38.0;
m_bActivated = true;
m_bSpawned = false;

Expand All @@ -16,6 +18,14 @@ void CFeatureExtremeGrieferJesus::ActivateFeature()

void CFeatureExtremeGrieferJesus::OnFrame(double time)
{
if (g_bDespawnJesus)
{
m_bSpawned = false;
g_bDespawnJesus = false;
m_flDespawnTime = 0.0;
return;
}

if (m_bSpawned)
{
CFeatureExtremeGrieferShephard::OnFrame(time);
Expand All @@ -24,7 +34,7 @@ void CFeatureExtremeGrieferJesus::OnFrame(double time)
if (!m_bActivated)
return;

if (m_flTimeForSpawn > gChaos.GetGlobalTime())
if (m_flTimeForSpawn > gChaos.GetRealTime())
{
CChaosFeature::OnFrame(time);
return;
Expand Down
2 changes: 2 additions & 0 deletions GSChaos/CFeatureExtremeGrieferJesus.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#ifdef __cplusplus

extern bool g_bDespawnJesus;

class CFeatureExtremeGrieferJesus : public CFeatureExtremeGrieferShephard
{
void ActivateFeature() override;
Expand Down
2 changes: 2 additions & 0 deletions GSChaos/CFeatureExtremeGrieferShephard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void CFeatureExtremeGrieferShephard::OnFrame(double time)
{
m_bSpawned = false;
g_bDespawnExShephard = false;
m_flDespawnTime = 0.0;
return;
}

if (gChaos.GetGlobalTime() > m_flDespawnTime)
Expand Down
22 changes: 22 additions & 0 deletions GSChaos/CFeatureSpawn5RandomEntities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "includes.h"

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

void CFeatureSpawn5RandomEntities::ActivateFeature()
{
for (int i = 0; i < 5; i++)
CFeatureSpawnRandomEntity::ActivateFeature();
}

void CFeatureSpawn5RandomEntities::DeactivateFeature()
{
CChaosFeature::DeactivateFeature();
}

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

#ifdef CFEATURESPAWN5RANDOMENTITIES_H_RECURSE_GUARD
#error Recursive header files inclusion detected in CFeatureSpawn5RandomEntities.h
#else //CFEATURESPAWN5RANDOMENTITIES_H_RECURSE_GUARD

#define CFEATURESPAWN5RANDOMENTITIES_H_RECURSE_GUARD

#ifndef CFEATURESPAWN5RANDOMENTITIES_H_GUARD
#define CFEATURESPAWN5RANDOMENTITIES_H_GUARD
#pragma once

#ifdef __cplusplus

class CFeatureSpawn5RandomEntities : public CFeatureSpawnRandomEntity
{
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
const char* GetFeatureName() override;
};

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

#endif //CFEATURESPAWN5RANDOMENTITIES_H_GUARD

#undef CFEATURESPAWN5RANDOMENTITIES_H_RECURSE_GUARD
#endif //CFEATURESPAWN5RANDOMENTITIES_H_RECURSE_GUARD
2 changes: 1 addition & 1 deletion GSChaos/CFeatureSpawnRandomEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class CFeatureSpawnRandomEntity : public CChaosFeature
{
bool LoadEntityList();
public:
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
Expand Down
2 changes: 2 additions & 0 deletions GSChaos/GSChaos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<ClCompile Include="CFeatureShuffleEntitiesPositions.cpp" />
<ClCompile Include="CFeatureSlap.cpp" />
<ClCompile Include="CFeatureSleepy.cpp" />
<ClCompile Include="CFeatureSpawn5RandomEntities.cpp" />
<ClCompile Include="CFeatureSpawnFastrun.cpp" />
<ClCompile Include="CFeatureSpawnRandomEntity.cpp" />
<ClCompile Include="CFeatureSqueakShephard.cpp" />
Expand Down Expand Up @@ -357,6 +358,7 @@
<ClInclude Include="CFeatureShuffleEntitiesPositions.h" />
<ClInclude Include="CFeatureSlap.h" />
<ClInclude Include="CFeatureSleepy.h" />
<ClInclude Include="CFeatureSpawn5RandomEntities.h" />
<ClInclude Include="CFeatureSpawnFastrun.h" />
<ClInclude Include="CFeatureSpawnRandomEntity.h" />
<ClInclude Include="CFeatureSqueakShephard.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 @@ -364,6 +364,9 @@
<ClCompile Include="CFeatureMegaJump.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureSpawn5RandomEntities.cpp">
<Filter>Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="includes.h" />
Expand Down Expand Up @@ -825,6 +828,9 @@
<ClInclude Include="CFeatureMegaJump.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureSpawn5RandomEntities.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 @@ -196,6 +196,7 @@ extern bool g_bEncrypted;
#include "CFeatureReloadAutosave.h"
#include "CFeatureExtremeGrieferJesus.h"
#include "CFeatureMegaJump.h"
#include "CFeatureSpawn5RandomEntities.h"

#include "CFeatureCombineEffects.h"
#include "CFeature10Effects.h"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA
> Reload Autosave
> He comes back.
> Mega Jump
> Spawn 5 random entities
> Combine Effects ( 3 in 1 )
> Let's make it more chaotic
```
Expand Down

0 comments on commit 8c52e47

Please sign in to comment.