]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a basic entity that spawns monsters when triggered
authorMario <mario@smbclan.net>
Thu, 20 Oct 2016 21:30:25 +0000 (07:30 +1000)
committerMario <mario@smbclan.net>
Thu, 20 Oct 2016 21:30:25 +0000 (07:30 +1000)
qcsrc/common/monsters/_mod.inc
qcsrc/common/monsters/spawner.qc [new file with mode: 0644]
qcsrc/lib/spawnfunc.qh
qcsrc/server/bot/default/navigation.qc

index be50e5503f70f2d660263fd15f68c98aa991bd40..e7f1e9734d4269ce360bb65ebe2271b5c4a0ae08 100644 (file)
@@ -5,6 +5,7 @@
 #endif
 #ifdef SVQC
     #include <common/monsters/sv_spawn.qc>
+       #include <common/monsters/spawner.qc>
 #endif
 
 #include <common/monsters/monster/_mod.inc>
diff --git a/qcsrc/common/monsters/spawner.qc b/qcsrc/common/monsters/spawner.qc
new file mode 100644 (file)
index 0000000..235a24b
--- /dev/null
@@ -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;
+}
index ae6db507f82b527babf8cb1bd49239b5df812a4b..4e3bc062d1bc78936bc7bb095b6e882f2a5cd380 100644 (file)
@@ -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) \
index 0c563d1ff9e2f1953775caa14b437171fe74c480..17f61af141ff7c8b08a3d736011ae9a77043c705 100644 (file)
@@ -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);