Skip to content

Commit

Permalink
Add "monster_worldspawn" effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Mar 26, 2024
1 parent f4d7c2c commit 3cb9442
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 9 deletions.
1 change: 1 addition & 0 deletions GSChaos/CChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void CChaos::FeatureInit()
RegisterChaosFeature<CFeatureDeleteRandomEntity>();
RegisterChaosFeature<CFeatureNuke>();
RegisterChaosFeature<CFeaturePlusDuck>();
RegisterChaosFeature<CFeatureMonsterWorldspawn>();

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

Expand Down
42 changes: 42 additions & 0 deletions GSChaos/CFeatureMonsterWorldspawn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "includes.h"

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

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

monster_worldspawn = CREATE_NAMED_ENTITY(MAKE_STRING("func_wall"));

if (!monster_worldspawn)
{
DeactivateFeature();
return;
}

SET_MODEL(monster_worldspawn, pEngfuncs->pfnGetLevelName());

gEntityInterface->pfnSpawn(monster_worldspawn);

monster_worldspawn->v.origin = (*sv_player)->v.origin;
monster_worldspawn->v.solid = SOLID_BSP;
monster_worldspawn->v.movetype = MOVETYPE_PUSH;
}

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

const char* CFeatureMonsterWorldspawn::GetFeatureName()
{
return "monster_worldspawn";
}

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

#ifdef CFEATUREMONSTERWORLDSPAWN_H_RECURSE_GUARD
#error Recursive header files inclusion detected in CFeatureMonsterWorldspawn.h
#else //CFEATUREMONSTERWORLDSPAWN_H_RECURSE_GUARD

#define CFEATUREMONSTERWORLDSPAWN_H_RECURSE_GUARD

#ifndef CFEATUREMONSTERWORLDSPAWN_H_GUARD
#define CFEATUREMONSTERWORLDSPAWN_H_GUARD
#pragma once

#ifdef __cplusplus

class CFeatureMonsterWorldspawn : public CChaosFeature
{
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
const char* GetFeatureName() override;
virtual edict_t* GetWorldspawnEdict();
private:
edict_t* monster_worldspawn;
};

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

#endif //CFEATUREMONSTERWORLDSPAWN_H_GUARD

#undef CFEATUREMONSTERWORLDSPAWN_H_RECURSE_GUARD
#endif //CFEATUREMONSTERWORLDSPAWN_H_RECURSE_GUARD
2 changes: 2 additions & 0 deletions GSChaos/GSChaos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<ClCompile Include="CFeatureHL2Movement.cpp" />
<ClCompile Include="CFeatureInsaneStepsize.cpp" />
<ClCompile Include="CFeatureMakeItBunDem.cpp" />
<ClCompile Include="CFeatureMonsterWorldspawn.cpp" />
<ClCompile Include="CFeatureNice.cpp" />
<ClCompile Include="CFeatureNoclip.cpp" />
<ClCompile Include="CFeatureNodeGraphRebuilding.cpp" />
Expand Down Expand Up @@ -250,6 +251,7 @@
<ClInclude Include="CFeatureHL2Movement.h" />
<ClInclude Include="CFeatureInsaneStepsize.h" />
<ClInclude Include="CFeatureMakeItBunDem.h" />
<ClInclude Include="CFeatureMonsterWorldspawn.h" />
<ClInclude Include="CFeatureNice.h" />
<ClInclude Include="CFeatureNoclip.h" />
<ClInclude Include="CFeatureNodeGraphRebuilding.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 @@ -239,6 +239,9 @@
<ClCompile Include="CFeaturePlusDuck.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureMonsterWorldspawn.cpp">
<Filter>Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="includes.h" />
Expand Down Expand Up @@ -575,6 +578,9 @@
<ClInclude Include="CFeaturePlusDuck.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureMonsterWorldspawn.h">
<Filter>Effects</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Hooking">
Expand Down
9 changes: 0 additions & 9 deletions GSChaos/dynamic_precache.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#include "includes.h"

typedef sfxcache_t* (*_S_LoadSound)(sfx_t* s, channel_t* ch);
typedef sfx_t* (*_S_FindName)(char* name, int* pfInCache);
typedef model_t* (*_Mod_ForName)(const char* name, qboolean crash, qboolean trackCRC);
typedef int (*_PF_precache_model_I)(char* s);
typedef int (*_PF_precache_sound_I)(char* s);
typedef unsigned short (*_EV_Precache)(int type, const char* psz);
typedef void (*_PF_setmodel_I)(edict_t* e, const char* m);
typedef void (*_SV_AddSampleToHashedLookupTable)(const char* pszSample, int iSampleIndex);

_S_LoadSound ORIG_S_LoadSound = NULL;
_S_FindName ORIG_S_FindName = NULL;
_Mod_ForName ORIG_Mod_ForName = NULL;
Expand Down
18 changes: 18 additions & 0 deletions GSChaos/dynamic_precache.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@

#ifdef __cplusplus

typedef sfxcache_t* (*_S_LoadSound)(sfx_t* s, channel_t* ch);
typedef sfx_t* (*_S_FindName)(char* name, int* pfInCache);
typedef model_t* (*_Mod_ForName)(const char* name, qboolean crash, qboolean trackCRC);
typedef int (*_PF_precache_model_I)(char* s);
typedef int (*_PF_precache_sound_I)(char* s);
typedef unsigned short (*_EV_Precache)(int type, const char* psz);
typedef void (*_PF_setmodel_I)(edict_t* e, const char* m);
typedef void (*_SV_AddSampleToHashedLookupTable)(const char* pszSample, int iSampleIndex);

extern _S_LoadSound ORIG_S_LoadSound;
extern _S_FindName ORIG_S_FindName;
extern _Mod_ForName ORIG_Mod_ForName;
extern _PF_precache_model_I ORIG_PF_precache_model_I;
extern _PF_precache_sound_I ORIG_PF_precache_sound_I;
extern _PF_setmodel_I ORIG_PF_setmodel_I;
extern _EV_Precache ORIG_EV_Precache;
extern _SV_AddSampleToHashedLookupTable ORIG_SV_AddSampleToHashedLookupTable;

void InitDynamicPrecache();
sfx_t* S_LateLoadSound(char* name);
int GetModelByIndex(const char* name);
Expand Down
1 change: 1 addition & 0 deletions GSChaos/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ extern bool g_bEncrypted;
#include "CFeatureDeleteRandomEntity.h"
#include "CFeatureNuke.h"
#include "CFeaturePlusDuck.h"
#include "CFeatureMonsterWorldspawn.h"

#include "CFeatureCombineEffects.h"
//========================
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISA
> Delete random entity :xdd:
> Nuke player
> +duck
> monster_worldspawn
> Combine Effects ( 3 in 1 )
```

Expand Down

0 comments on commit 3cb9442

Please sign in to comment.