From bb1bcf03db4f53e03874ff16697052e2a1624c45 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Oct 2016 07:30:25 +1000 Subject: [PATCH] Add a basic entity that spawns monsters when triggered --- qcsrc/common/monsters/_mod.inc | 1 + qcsrc/common/monsters/spawner.qc | 26 ++++++++++++++++++++++++++ qcsrc/lib/spawnfunc.qh | 1 + qcsrc/server/bot/default/navigation.qc | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 qcsrc/common/monsters/spawner.qc diff --git a/qcsrc/common/monsters/_mod.inc b/qcsrc/common/monsters/_mod.inc index be50e5503f..e7f1e9734d 100644 --- a/qcsrc/common/monsters/_mod.inc +++ b/qcsrc/common/monsters/_mod.inc @@ -5,6 +5,7 @@ #endif #ifdef SVQC #include + #include #endif #include diff --git a/qcsrc/common/monsters/spawner.qc b/qcsrc/common/monsters/spawner.qc new file mode 100644 index 0000000000..235a24b43a --- /dev/null +++ b/qcsrc/common/monsters/spawner.qc @@ -0,0 +1,26 @@ +#include "sv_spawn.qh" + +void spawner_use(entity this, entity actor, entity trigger) +{ + int moncount = 0; + IL_EACH(g_monsters, it.realowner == this, + { + ++moncount; + }); + + if(moncount >= this.count) + return; + + entity e = spawn(); + e.noalign = this.noalign; + e.angles = this.angles; + e.monster_skill = this.monster_skill; + e = spawnmonster(e, this.spawnmob, 0, this, this, this.origin, false, false, this.monster_moveflags); +} + +spawnfunc(monster_spawner) +{ + if(!autocvar_g_monsters || !this.spawnmob || this.spawnmob == "") { delete(this); return; } + + this.use = spawner_use; +} diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index ae6db507f8..4e3bc062d1 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -165,6 +165,7 @@ noref bool require_spawnfunc_prefix; FIELD_SCALAR(fld, sound1) \ FIELD_SCALAR(fld, sounds) \ FIELD_SCALAR(fld, spawnflags) \ + FIELD_SCALAR(fld, spawnmob) \ FIELD_SCALAR(fld, speed) \ FIELD_SCALAR(fld, strength) \ FIELD_SCALAR(fld, target2) \ diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 0c563d1ff9..17f61af141 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -908,7 +908,7 @@ void navigation_poptouchedgoals(entity this) } // HACK: remove players/bots as goals, they can lead a bot to unexpected places (cliffs, lava, etc) - // TODO: rate waypoints near the targetted player at that moment, instead of the player itthis + // TODO: rate waypoints near the targetted player at that moment, instead of the player itself if(IS_PLAYER(this.goalcurrent)) navigation_poproute(this); -- 2.39.2