diff --git a/GSChaos/CChaos.cpp b/GSChaos/CChaos.cpp index e425b8b9..32437601 100644 --- a/GSChaos/CChaos.cpp +++ b/GSChaos/CChaos.cpp @@ -254,7 +254,7 @@ void CChaos::FeatureInit() RegisterChaosFeature(); RegisterChaosFeature(); RegisterChaosFeature(); - RegisterChaosFeature(); + RegisterChaosFeature(); RegisterChaosFeature(); RegisterChaosFeature(); RegisterChaosFeature(); @@ -269,6 +269,9 @@ void CChaos::FeatureInit() RegisterChaosFeature(); RegisterChaosFeature(); RegisterChaosFeature(); + RegisterChaosFeature(); + RegisterChaosFeature(); + RegisterChaosFeature(); RegisterChaosFeature(); // must be last!!! @@ -398,6 +401,8 @@ void CChaos::Reset() m_pCurrentFeature = nullptr; + g_bDespawnExShephard = true; + auto currentTime = std::chrono::high_resolution_clock::now() - m_pauseOffset; m_startTime = currentTime; @@ -556,6 +561,8 @@ void CChaos::ResetStates() { if (!i->IsActive()) i->ResetStates(); + + i->Restore(); } } diff --git a/GSChaos/CChaosFeature.cpp b/GSChaos/CChaosFeature.cpp index 0f78a85d..b4e89414 100644 --- a/GSChaos/CChaosFeature.cpp +++ b/GSChaos/CChaosFeature.cpp @@ -42,6 +42,11 @@ void CChaosFeature::ResetStates() ; } +void CChaosFeature::Restore() +{ + ; +} + bool CChaosFeature::IsActive() { return m_bActivated; diff --git a/GSChaos/CChaosFeature.h b/GSChaos/CChaosFeature.h index 515257a2..79679efb 100644 --- a/GSChaos/CChaosFeature.h +++ b/GSChaos/CChaosFeature.h @@ -29,6 +29,7 @@ class CChaosFeature virtual const char* GetFeatureName(); virtual void Draw(); virtual void ResetStates(); + virtual void Restore(); virtual bool IsActive(); private: bool m_bActivated; diff --git a/GSChaos/CFeatureExtremeGrieferShephard.cpp b/GSChaos/CFeatureExtremeGrieferShephard.cpp new file mode 100644 index 00000000..914dc2b2 --- /dev/null +++ b/GSChaos/CFeatureExtremeGrieferShephard.cpp @@ -0,0 +1,195 @@ +#include "includes.h" + +bool g_bDespawnExShephard = false; + +void CFeatureExtremeGrieferShephard::Init() +{ + CChaosFeature::Init(); + m_flRocketTime = 0.0; + m_bSpawned = false; +} + +void CFeatureExtremeGrieferShephard::ActivateFeature() +{ + CChaosFeature::ActivateFeature(); + Spawn(); + m_flDespawnTime = gChaos.GetGlobalTime() + 360.0; + ma_engine_play_sound(&miniAudio, "chaos/opfor01.mp3", NULL); +} + +void CFeatureExtremeGrieferShephard::DeactivateFeature() +{ + CChaosFeature::DeactivateFeature(); +} + +const char* CFeatureExtremeGrieferShephard::GetFeatureName() +{ + return "Spawn Extreme Griefer Shephard"; +} + +void CFeatureExtremeGrieferShephard::OnFrame(double time) +{ + static bool bPaused; + bPaused = CLWrapper::GetPausedState(); + + if (g_bDespawnExShephard) + { + m_bSpawned = false; + g_bDespawnExShephard = false; + } + + if (gChaos.GetGlobalTime() > m_flDespawnTime) + { + m_bSpawned = false; + } + + if (bPaused) + return; + + if (!m_bSpawned) + return; + + edict_t* e; + for (int i = 1; i < sv->num_edicts; i++) + { + e = ORIG_EDICT_NUM(i); + if (!e) + continue; + + edict_t* pent = e; + + if (!pent) + continue; + + if (stricmp(STRING(pent->v.classname), "rpg_rocket")) + continue; + + if (pent->v.owner != m_pShephard) + continue; + + Vector vecTarget = (*sv_player)->v.origin - pent->v.origin; + vecTarget.Normalize(); + + Vector velocity = vecTarget + gpGlobals->v_forward; + + if (pent->v.velocity.Length() > 200) + { + pent->v.nextthink = gpGlobals->time + 1.0f; + pent->v.waterlevel = 1; // I'm doing these hacks just for longer rocket life + gEntityInterface->pfnThink(pent); + pent->v.nextthink = gpGlobals->time + 1.0f; + } + + pent->v.velocity = velocity; + pent->v.angles = UTIL_VecToAngles(vecTarget); + } + + if (m_pShephard) + Think(); +} + +void CFeatureExtremeGrieferShephard::Spawn() +{ + if (m_pShephard) + { + g_engfuncs->pfnRemoveEntity(m_pShephard); + if (m_pShephard->pvPrivateData != NULL) + { + FREE_PRIVATE(m_pShephard); + } + + m_pShephard = NULL; + } + + m_pShephard = CREATE_NAMED_ENTITY(MAKE_STRING("monster_generic")); + + if (!m_pShephard) + return; + + PRECACHE_MODEL("../chaos/shephard.mdl"); + SET_MODEL(m_pShephard, "../chaos/shephard.mdl"); + + gEntityInterface->pfnSpawn(m_pShephard); + m_bSpawned = true; + Vector playerOrigin = (*sv_player)->v.origin + gpGlobals->v_forward * 96; + + SET_SIZE(m_pShephard, (*sv_player)->v.mins, (*sv_player)->v.maxs); + m_pShephard->v.health = 666; + m_pShephard->v.takedamage = DAMAGE_NO; + m_pShephard->v.origin = playerOrigin; + m_pShephard->v.angles = (*sv_player)->v.angles; + m_pShephard->v.movetype = MOVETYPE_STEP; + m_pShephard->v.solid = SOLID_BBOX; + m_pShephard->v.classname = MAKE_STRING("chaos_exgriefer"); + + m_flRocketTime = gChaos.GetGlobalTime() + (SHEPHARD_ROCKET_TIME / 2.0); +} + +void CFeatureExtremeGrieferShephard::Think() +{ + if (!m_pShephard) + return; + + if (m_pShephard->free) + return; + + if (stricmp(STRING(m_pShephard->v.classname), "chaos_exgriefer")) + return; + + m_pShephard->v.effects = 0; + Vector angle = (*sv_player)->v.v_angle; + angle.y -= 180; + m_pShephard->v.angles = angle; + + //DEBUG_PRINT("GetChaosTime(): %.01f | m_flRocketTime: %.01f\n", gChaos.GetGlobalTime(), m_flRocketTime); + if (gChaos.GetGlobalTime() > m_flRocketTime) + { + DEBUG_PRINT("CFeatureExtremeGrieferShephard::LaunchRocket\n"); + LaunchRocket(); + m_flRocketTime = gChaos.GetGlobalTime() + (SHEPHARD_ROCKET_TIME / 2.0); + } + + m_shephardLatestOrigin = m_pShephard->v.origin; +} + +void CFeatureExtremeGrieferShephard::LaunchRocket() +{ + edict_t* pent = CREATE_NAMED_ENTITY(MAKE_STRING("rpg_rocket")); + + if (!pent) + return; + + pent->v.origin = m_pShephard->v.origin + (m_pShephard->v.view_ofs * 64); + pent->v.angles = m_pShephard->v.angles; + pent->v.owner = m_pShephard; + gEntityInterface->pfnSpawn(pent); + + EMIT_SOUND_DYN2(pent, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM); + EMIT_SOUND_DYN2(pent, CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM); +} + +void CFeatureExtremeGrieferShephard::Restore() +{ + if (!m_bSpawned) + return; + + edict_t* e; + for (int i = 1; i < sv->num_edicts; i++) + { + e = ORIG_EDICT_NUM(i); + if (!e) + continue; + + if (!stricmp(STRING(e->v.classname), "chaos_exgriefer")) + { + g_engfuncs->pfnRemoveEntity(e); + if (e->pvPrivateData != NULL) + { + FREE_PRIVATE(e); + } + } + } + + Spawn(); + m_pShephard->v.origin = m_shephardLatestOrigin; +} \ No newline at end of file diff --git a/GSChaos/CFeatureExtremeGrieferShephard.h b/GSChaos/CFeatureExtremeGrieferShephard.h new file mode 100644 index 00000000..83ea2024 --- /dev/null +++ b/GSChaos/CFeatureExtremeGrieferShephard.h @@ -0,0 +1,50 @@ +/** + * Copyright - ScriptedSnark, 2024. + * CFeatureExtremeGrieferShephard.h + * + * Project (GSChaos) header file + * Authors: ScriptedSnark. + * Do not delete this comment block. Respect others' work! + */ + +#ifdef CFEATUREEXTREMEGRIEFERSHEPHARD_H_RECURSE_GUARD +#error Recursive header files inclusion detected in CFeatureExtremeGrieferShephard.h +#else //CFEATUREEXTREMEGRIEFERSHEPHARD_H_RECURSE_GUARD + +#define CFEATUREEXTREMEGRIEFERSHEPHARD_H_RECURSE_GUARD + +#ifndef CFEATUREEXTREMEGRIEFERSHEPHARD_H_GUARD +#define CFEATUREEXTREMEGRIEFERSHEPHARD_H_GUARD +#pragma once + +#ifdef __cplusplus + +extern bool g_bDespawnExShephard; + +class CFeatureExtremeGrieferShephard : public CFeatureGrieferShephard +{ + void Init() override; + void ActivateFeature() override; + void DeactivateFeature() override; + const char* GetFeatureName() override; + void OnFrame(double time) override; + void Spawn() override; + void Think() override; + void LaunchRocket() override; + void Restore() override; +private: + double m_flRocketTime; + double m_flDespawnTime; + bool m_bSpawned; + edict_t* m_pShephard; + Vector m_shephardLatestOrigin; +}; + +#else //!__cplusplus +#error C++ compiler required to compile CFeatureExtremeGrieferShephard.h +#endif //__cplusplus + +#endif //CFEATUREEXTREMEGRIEFERSHEPHARD_H_GUARD + +#undef CFEATUREEXTREMEGRIEFERSHEPHARD_H_RECURSE_GUARD +#endif //CFEATUREEXTREMEGRIEFERSHEPHARD_H_RECURSE_GUARD \ No newline at end of file diff --git a/GSChaos/CFeatureGrieferShephard.cpp b/GSChaos/CFeatureGrieferShephard.cpp index 7e26f251..d2494eb0 100644 --- a/GSChaos/CFeatureGrieferShephard.cpp +++ b/GSChaos/CFeatureGrieferShephard.cpp @@ -1,7 +1,5 @@ #include "includes.h" -#define SHEPHARD_ROCKET_TIME 1.25 - void CFeatureGrieferShephard::Init() { CChaosFeature::Init(); diff --git a/GSChaos/CFeatureGrieferShephard.h b/GSChaos/CFeatureGrieferShephard.h index c97c621c..df8285e1 100644 --- a/GSChaos/CFeatureGrieferShephard.h +++ b/GSChaos/CFeatureGrieferShephard.h @@ -19,6 +19,8 @@ #ifdef __cplusplus +#define SHEPHARD_ROCKET_TIME 1.25 + class CFeatureGrieferShephard : public CChaosFeature { void Init() override; @@ -26,9 +28,9 @@ class CFeatureGrieferShephard : public CChaosFeature void DeactivateFeature() override; const char* GetFeatureName() override; void OnFrame(double time) override; - void Spawn(); - void Think(); - void LaunchRocket(); + virtual void Spawn(); + virtual void Think(); + virtual void LaunchRocket(); private: double m_flRocketTime; edict_t* m_pShephard; diff --git a/GSChaos/CFeatureSqueakShephard.cpp b/GSChaos/CFeatureSqueakShephard.cpp new file mode 100644 index 00000000..f215639f --- /dev/null +++ b/GSChaos/CFeatureSqueakShephard.cpp @@ -0,0 +1,41 @@ +#include "includes.h" + +void CFeatureSqueakShephard::Init() +{ + CChaosFeature::Init(); +} + +void CFeatureSqueakShephard::ActivateFeature() +{ + CChaosFeature::ActivateFeature(); + SpawnSqueak(); +} + +void CFeatureSqueakShephard::DeactivateFeature() +{ + CChaosFeature::DeactivateFeature(); +} + +const char* CFeatureSqueakShephard::GetFeatureName() +{ + return "Spawn Squeak Shephard"; +} + +edict_t* CFeatureSqueakShephard::SpawnSqueak() +{ + edict_t* squeak = CREATE_NAMED_ENTITY(MAKE_STRING("monster_snark")); + if (!squeak) + return NULL; + + gEntityInterface->pfnSpawn(squeak); + + SET_MODEL(squeak, "../chaos/shephard.mdl"); + SET_SIZE(squeak, (*sv_player)->v.mins, (*sv_player)->v.maxs); + + Vector playerOrigin = (*sv_player)->v.origin + gpGlobals->v_forward * 96; + + squeak->v.health = 50; + squeak->v.origin = playerOrigin; + + return squeak; +} \ No newline at end of file diff --git a/GSChaos/CFeatureSqueakShephard.h b/GSChaos/CFeatureSqueakShephard.h new file mode 100644 index 00000000..8ef9f600 --- /dev/null +++ b/GSChaos/CFeatureSqueakShephard.h @@ -0,0 +1,39 @@ +/** + * Copyright - ScriptedSnark, 2024. + * CFeatureSqueakShephard.h + * + * Project (GSChaos) header file + * Authors: ScriptedSnark. + * Do not delete this comment block. Respect others' work! + */ + +#ifdef CFEATURESQUEAKSHEPHARD_H_RECURSE_GUARD +#error Recursive header files inclusion detected in CFeatureSqueakShephard.h +#else //CFEATURESQUEAKSHEPHARD_H_RECURSE_GUARD + +#define CFEATURESQUEAKSHEPHARD_H_RECURSE_GUARD + +#ifndef CFEATURESQUEAKSHEPHARD_H_GUARD +#define CFEATURESQUEAKSHEPHARD_H_GUARD +#pragma once + +#ifdef __cplusplus + +class CFeatureSqueakShephard : public CChaosFeature +{ + void Init() override; + void ActivateFeature() override; + void DeactivateFeature() override; + const char* GetFeatureName() override; +public: + virtual edict_t* SpawnSqueak(); +}; + +#else //!__cplusplus +#error C++ compiler required to compile CFeatureSqueakShephard.h +#endif //__cplusplus + +#endif //CFEATURESQUEAKSHEPHARD_H_GUARD + +#undef CFEATURESQUEAKSHEPHARD_H_RECURSE_GUARD +#endif //CFEATURESQUEAKSHEPHARD_H_RECURSE_GUARD \ No newline at end of file diff --git a/GSChaos/CFeatureSqueakShephards.cpp b/GSChaos/CFeatureSqueakShephards.cpp new file mode 100644 index 00000000..89933285 --- /dev/null +++ b/GSChaos/CFeatureSqueakShephards.cpp @@ -0,0 +1,43 @@ +#include "includes.h" + +void CFeatureSqueakShephards::Init() +{ + CChaosFeature::Init(); +} + +void CFeatureSqueakShephards::ActivateFeature() +{ + CChaosFeature::ActivateFeature(); + + // spawn squeaks + edict_t* pent; + for (int i = 0; i <= 5; i++) + { + pent = SpawnSqueak(); + + if (!pent) + continue; + + Vector origin = (*sv_player)->v.origin + (*sv_player)->v.view_ofs; + Vector angle = (*sv_player)->v.v_angle; + + if (i != 0) + pent->v.origin = origin + gpGlobals->v_forward * (96 * i); + else + pent->v.origin = origin + gpGlobals->v_forward * 64; + + pent->v.angles = angle; + + pent->v.effects = 0; + } +} + +void CFeatureSqueakShephards::DeactivateFeature() +{ + CChaosFeature::DeactivateFeature(); +} + +const char* CFeatureSqueakShephards::GetFeatureName() +{ + return "Squeak Shephard Ambush"; +} \ No newline at end of file diff --git a/GSChaos/CFeatureSqueakShephards.h b/GSChaos/CFeatureSqueakShephards.h new file mode 100644 index 00000000..10ac0745 --- /dev/null +++ b/GSChaos/CFeatureSqueakShephards.h @@ -0,0 +1,37 @@ +/** + * Copyright - ScriptedSnark, 2024. + * CFeatureSqueakShephards.h + * + * Project (GSChaos) header file + * Authors: ScriptedSnark. + * Do not delete this comment block. Respect others' work! + */ + +#ifdef CFEATURESQUEAKSHEPHARDS_H_RECURSE_GUARD +#error Recursive header files inclusion detected in CFeatureSqueakShephards.h +#else //CFEATURESQUEAKSHEPHARDS_H_RECURSE_GUARD + +#define CFEATURESQUEAKSHEPHARDS_H_RECURSE_GUARD + +#ifndef CFEATURESQUEAKSHEPHARDS_H_GUARD +#define CFEATURESQUEAKSHEPHARDS_H_GUARD +#pragma once + +#ifdef __cplusplus + +class CFeatureSqueakShephards : public CFeatureSqueakShephard +{ + void Init() override; + void ActivateFeature() override; + void DeactivateFeature() override; + const char* GetFeatureName() override; +}; + +#else //!__cplusplus +#error C++ compiler required to compile CFeatureSqueakShephards.h +#endif //__cplusplus + +#endif //CFEATURESQUEAKSHEPHARDS_H_GUARD + +#undef CFEATURESQUEAKSHEPHARDS_H_RECURSE_GUARD +#endif //CFEATURESQUEAKSHEPHARDS_H_RECURSE_GUARD \ No newline at end of file diff --git a/GSChaos/GSChaos.vcxproj b/GSChaos/GSChaos.vcxproj index 65f5bfb6..1c1e8f65 100644 --- a/GSChaos/GSChaos.vcxproj +++ b/GSChaos/GSChaos.vcxproj @@ -134,6 +134,7 @@ + @@ -183,6 +184,8 @@ + + @@ -254,6 +257,7 @@ + @@ -303,6 +307,8 @@ + + diff --git a/GSChaos/GSChaos.vcxproj.filters b/GSChaos/GSChaos.vcxproj.filters index 669e5473..daf081cc 100644 --- a/GSChaos/GSChaos.vcxproj.filters +++ b/GSChaos/GSChaos.vcxproj.filters @@ -269,6 +269,15 @@ Effects + + Effects + + + Effects + + + Effects + @@ -635,6 +644,15 @@ Effects + + Effects + + + Effects + + + Effects + diff --git a/GSChaos/includes.h b/GSChaos/includes.h index 463df051..fc897c6e 100644 --- a/GSChaos/includes.h +++ b/GSChaos/includes.h @@ -148,7 +148,7 @@ extern bool g_bEncrypted; #include "CFeatureGiveArmor.h" #include "CFeatureAmIDead.h" #include "CFeatureNodeGraphRebuilding.h" -#include "CFeatureNice.h" +#include "CFeatureExtremeGrieferShephard.h" #include "CFeatureInsaneStepsize.h" #include "CFeatureDeleteRandomEntity.h" #include "CFeatureNuke.h" @@ -163,6 +163,9 @@ extern bool g_bEncrypted; #include "CFeatureNoHUD.h" #include "CFeatureQuakePro.h" #include "CFeatureNegativeAccelerate.h" +#include "CFeatureNice.h" +#include "CFeatureSqueakShephard.h" +#include "CFeatureSqueakShephards.h" #include "CFeatureCombineEffects.h" //======================== diff --git a/README.md b/README.md index d7e15d50..1373b62d 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA > Give +100 armor > Am I dead? > Node Graph -> Nice +> Spawn Extreme Griefer Shephard > Insane Stepsize > Delete random entity :xdd: > Nuke player @@ -104,6 +104,8 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA > No HUD > Quake Pro > Negative Accelerate +> Spawn Squeak Shephard +> Spawn Squeak Shephards > Combine Effects ( 3 in 1 ) ``` diff --git a/gamedir/chaos/opfor01.mp3 b/gamedir/chaos/opfor01.mp3 new file mode 100644 index 00000000..1c68687b Binary files /dev/null and b/gamedir/chaos/opfor01.mp3 differ