From: Mario Date: Thu, 20 Oct 2016 21:30:25 +0000 (+1000) Subject: Add a basic entity that spawns monsters when triggered X-Git-Tag: xonotic-v0.8.2~490 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bb1bcf03db4f53e03874ff16697052e2a1624c45;p=xonotic%2Fxonotic-data.pk3dir.git Add a basic entity that spawns monsters when triggered --- 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);