Skip to content

Commit

Permalink
69 UPDATE MUGA
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Mar 28, 2024
1 parent 814df64 commit 763ed8f
Show file tree
Hide file tree
Showing 16 changed files with 455 additions and 8 deletions.
9 changes: 8 additions & 1 deletion GSChaos/CChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureGiveArmor>();
RegisterChaosFeature<CFeatureAmIDead>();
RegisterChaosFeature<CFeatureNodeGraphRebuilding>();
RegisterChaosFeature<CFeatureNice>();
RegisterChaosFeature<CFeatureExtremeGrieferShephard>();
RegisterChaosFeature<CFeatureInsaneStepsize>();
RegisterChaosFeature<CFeatureDeleteRandomEntity>();
RegisterChaosFeature<CFeatureNuke>();
Expand All @@ -269,6 +269,9 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureNoHUD>();
RegisterChaosFeature<CFeatureQuakePro>();
RegisterChaosFeature<CFeatureNegativeAccelerate>();
RegisterChaosFeature<CFeatureSqueakShephard>();
RegisterChaosFeature<CFeatureSqueakShephards>();
RegisterChaosFeature<CFeatureNice>();

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

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -556,6 +561,8 @@ void CChaos::ResetStates()
{
if (!i->IsActive())
i->ResetStates();

i->Restore();
}
}

Expand Down
5 changes: 5 additions & 0 deletions GSChaos/CChaosFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void CChaosFeature::ResetStates()
;
}

void CChaosFeature::Restore()
{
;
}

bool CChaosFeature::IsActive()
{
return m_bActivated;
Expand Down
1 change: 1 addition & 0 deletions GSChaos/CChaosFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
195 changes: 195 additions & 0 deletions GSChaos/CFeatureExtremeGrieferShephard.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
50 changes: 50 additions & 0 deletions GSChaos/CFeatureExtremeGrieferShephard.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions GSChaos/CFeatureGrieferShephard.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "includes.h"

#define SHEPHARD_ROCKET_TIME 1.25

void CFeatureGrieferShephard::Init()
{
CChaosFeature::Init();
Expand Down
8 changes: 5 additions & 3 deletions GSChaos/CFeatureGrieferShephard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@

#ifdef __cplusplus

#define SHEPHARD_ROCKET_TIME 1.25

class CFeatureGrieferShephard : public CChaosFeature
{
void Init() override;
void ActivateFeature() override;
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;
Expand Down
41 changes: 41 additions & 0 deletions GSChaos/CFeatureSqueakShephard.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Loading

0 comments on commit 763ed8f

Please sign in to comment.