Skip to content

Commit

Permalink
Entity list system for "Spawn random entity" effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Mar 17, 2024
1 parent 7176c26 commit 83b9272
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 4 deletions.
41 changes: 37 additions & 4 deletions GSChaos/CFeatureSpawnRandomEntity.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "includes.h"

std::vector<const char*> g_szEntityList =
std::vector<std::string> g_szEntityList;
std::vector<std::string> g_baseEntityList =
{
"monster_alien_controller",
"monster_alien_grunt",
Expand All @@ -17,7 +18,6 @@ std::vector<const char*> g_szEntityList =
"monster_flyer_flock",
"monster_gargantua",
"monster_gman",
"monster_grunt_repel",
"monster_handgrenade",
"monster_headcrab",
"monster_hevsuit_dead",
Expand Down Expand Up @@ -46,9 +46,42 @@ std::vector<const char*> g_szEntityList =
"xen_tree"
};

bool CFeatureSpawnRandomEntity::LoadEntityList()
{
std::string filePath = UTIL_VarArgs("chaos/entlist/%s.txt", pEngfuncs->pfnGetGameDirectory());

std::ifstream file(filePath);
if (!file.is_open())
{
DEBUG_PRINT("Failed to open file: %s\n", filePath.c_str());
return false;
}

std::string entityName;
while (std::getline(file, entityName))
{
if (!entityName.empty())
g_szEntityList.push_back(entityName);
}

file.close();

if (g_szEntityList.size() <= 1)
return false;

return true;
}

void CFeatureSpawnRandomEntity::Init()
{
CChaosFeature::Init();

if (!LoadEntityList())
{
DEBUG_PRINT("Using base entity list.\n");
g_szEntityList = g_baseEntityList;
}

m_pszEntityName = nullptr;
}

Expand All @@ -57,11 +90,11 @@ void CFeatureSpawnRandomEntity::ActivateFeature()
CChaosFeature::ActivateFeature();

int i = gChaos.GetRandomValue(0, g_szEntityList.size() - 1);
edict_t* pent = CREATE_NAMED_ENTITY(MAKE_STRING(g_szEntityList[i]));
edict_t* pent = CREATE_NAMED_ENTITY(MAKE_STRING(g_szEntityList[i].c_str()));
if (!pent)
return;

m_pszEntityName = g_szEntityList[i];
m_pszEntityName = g_szEntityList[i].c_str();

Vector origin = (*sv_player)->v.origin;
pent->v.origin = origin + gpGlobals->v_forward * 128;
Expand Down
1 change: 1 addition & 0 deletions GSChaos/CFeatureSpawnRandomEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class CFeatureSpawnRandomEntity : public CChaosFeature
{
bool LoadEntityList();
void Init() override;
void ActivateFeature() override;
void DeactivateFeature() override;
Expand Down
46 changes: 46 additions & 0 deletions gamedir/chaos/entlist/aomdc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
monster_alien_controller
monster_alien_grunt
monster_alien_slave
monster_apache
monster_babycrab
monster_barnacle
monster_barney
monster_barney_dead
monster_bigmomma
monster_bloater
monster_bullchicken
monster_bullsquid
monster_cockroach
monster_david
monster_flyer
monster_flyer_flock
monster_gargantua
monster_ghost
monster_gman
monster_headcrab
monster_hevsuit_dead
monster_hgrunt_dead
monster_houndeye
monster_human_assassin
monster_human_grunt
monster_ichthyosaur
monster_leech
monster_miniturret
monster_mortar
monster_nihilanth
monster_player
monster_rat
monster_scientist
monster_scientist_dead
monster_sentry
monster_sitting_scientist
monster_snark
monster_target
monster_tentacle
monster_turret
monster_vortigaunt
monster_wheelchair
monster_zombie
monster_zombie2
monster_zombie3
monster_zombie4
39 changes: 39 additions & 0 deletions gamedir/chaos/entlist/bshift.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
monster_alien_controller
monster_alien_grunt
monster_alien_slave
monster_apache
monster_babycrab
monster_barnacle
monster_barney
monster_barney_dead
monster_bigmomma
monster_bloater
monster_bullchicken
monster_cockroach
monster_flyer
monster_flyer_flock
monster_gargantua
monster_gman
monster_headcrab
monster_hevsuit_dead
monster_hgrunt_dead
monster_houndeye
monster_human_assassin
monster_human_grunt
monster_ichthyosaur
monster_leech
monster_miniturret
monster_mortar
monster_nihilanth
monster_rat
monster_rosenberg
monster_satchel
monster_scientist
monster_scientist_dead
monster_sentry
monster_sitting_scientist
monster_snark
monster_tentacle
monster_turret
monster_vortigaunt
monster_zombie
74 changes: 74 additions & 0 deletions gamedir/chaos/entlist/gearbox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
monster_ShockTrooper_dead
monster_alien_babyvoltigore
monster_alien_controller
monster_alien_grunt
monster_alien_slave
monster_alien_slave_dead
monster_alien_voltigore
monster_apache
monster_babycrab
monster_barnacle
monster_barney
monster_barney_dead
monster_bigmomma
monster_blkop_apache
monster_blkop_osprey
monster_bloater
monster_bullchicken
monster_cleansuit_scientist
monster_cleansuit_scientist_dead
monster_cockroach
monster_drillsergeant
monster_flyer
monster_flyer_flock
monster_gargantua
monster_geneworm
monster_gman
monster_gonome
monster_gonome_dead
monster_headcrab
monster_hevsuit_dead
monster_hfgrunt_dead
monster_hgrunt_dead
monster_houndeye
monster_houndeye_dead
monster_human_assassin
monster_human_friendly_grunt
monster_human_grunt
monster_human_grunt_ally
monster_human_grunt_ally_dead
monster_human_medic_ally
monster_human_torch_ally
monster_ichthyosaur
monster_leech
monster_male_assassin
monster_massassin_dead
monster_miniturret
monster_mortar
monster_nihilanth
monster_op4loader
monster_otis
monster_otis_dead
monster_penguin
monster_pitdrone
monster_pitworm
monster_pitworm_up
monster_rat
monster_recruit
monster_satchel
monster_scientist
monster_scientist_dead
monster_sentry
monster_shockroach
monster_shocktrooper
monster_sitting_cleansuit_scientist
monster_sitting_scientist
monster_skeleton_dead
monster_snark
monster_tentacle
monster_turret
monster_vortigaunt
monster_zombie
monster_zombie_barney
monster_zombie_soldier
monster_zombie_soldier_dead

0 comments on commit 83b9272

Please sign in to comment.