]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Spawner: Spawn nothing if it's set to an invalid monster
authorMario <mario@smbclan.net>
Fri, 21 Oct 2016 16:15:29 +0000 (02:15 +1000)
committerMario <mario@smbclan.net>
Fri, 21 Oct 2016 16:15:29 +0000 (02:15 +1000)
qcsrc/common/monsters/spawner.qc
qcsrc/common/monsters/sv_spawn.qc
qcsrc/common/monsters/sv_spawn.qh
qcsrc/server/command/common.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc

index 235a24b43aad2d999444ee6be1395a3b55165026..0b34d13e659633a1892e10db93771a761ad4b629 100644 (file)
@@ -15,7 +15,7 @@ void spawner_use(entity this, entity actor, entity trigger)
        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);
+       e = spawnmonster(e, this.spawnmob, 0, this, this, this.origin, false, true, this.monster_moveflags);
 }
 
 spawnfunc(monster_spawner)
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;
index 8e4d480cd690ddfbab268494ee512090a74a2881..983676db87d3c4a225dd141db6017ebe173624d4 100644 (file)
@@ -1,3 +1,3 @@
 #pragma once
 
-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);
index 01997d903a5f2e371c9bc2c3e2c77eadd3ed4043..5b01f134942729fe68f746328195d4c8d70665ae 100644 (file)
@@ -381,11 +381,11 @@ void CommonCommand_editmob(int request, entity caller, int argc)
                                        if (tmp_moncount >= autocvar_g_monsters_max_perplayer) { print_to(caller, "You can't spawn any more monsters"); return; }
 
                                        bool found = false;
-                                       for (int i = MON_FIRST; i <= MON_LAST; ++i)
+                                       FOREACH(Monsters, it != MON_Null && it.netname == arg_lower,
                                        {
-                                               mon = get_monsterinfo(i);
-                                               if (mon.netname == arg_lower) { found = true; break; }
-                                       }
+                                               found = true;
+                                               break;
+                                       });
 
                                        if (!found && arg_lower != "random") { print_to(caller, "Invalid monster"); return; }
 
index 4c0976fe82a2ae58f87ee29ee324434019533cff..efed23a5df41f48dd0897ffb72c8434412f1cb47 100644 (file)
@@ -77,11 +77,8 @@ void invasion_SpawnChosenMonster(Monster mon)
                setsize(e, mon.mins, mon.maxs);
 
                if(MoveToRandomMapLocation(e, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
-                       monster = spawnmonster(spawn(), "", mon.m_id, NULL, NULL, e.origin, false, false, 2);
+                       monster = spawnmonster(e, "", mon.m_id, NULL, NULL, e.origin, false, false, 2);
                else return;
-
-               setthink(e, SUB_Remove);
-               e.nextthink = time + 0.1;
        }
        else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
                monster = spawnmonster(spawn(), spawn_point.spawnmob, mon.m_id, spawn_point, spawn_point, spawn_point.origin, false, false, 2);