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 be50e5503..e7f1e9734 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 000000000..235a24b43 --- /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 ae6db507f..4e3bc062d 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 0c563d1ff..17f61af14 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