-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
814df64
commit 763ed8f
Showing
16 changed files
with
455 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.