]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/sv_spawn.qc
Spawner: Spawn nothing if it's set to an invalid monster
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_spawn.qc
index 056379dbc41f0a88c9e9f7f03026f694bd511778..6d9daa2964cbb4c6c5c1d4c25561e22fcf2c2731 100644 (file)
@@ -8,12 +8,12 @@
     #include <server/autocvars.qh>
     #include <server/defs.qh>
 #endif
-entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag)
+entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
 {
        e.spawnflags = MONSTERFLAG_SPAWNED;
 
        if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; }
-       if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
+       //if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
 
        setorigin(e, orig);
 
@@ -39,8 +39,17 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby,
                                break;
                        }
                });
-               if(!found)
-                       monster_id = ((monster_id > 0) ? monster_id : MON_FIRST);
+
+               if(!found && !monster_id)
+               {
+                       if(removeifinvalid)
+                       {
+                               delete(e);
+                               return NULL; // no good
+                       }
+                       else
+                               monster_id = MON_FIRST;
+               }
        }
 
        e.realowner = spawnedby;