X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fsv_spawn.qc;h=497dee86664b54d644f405e4be5ea47fc01969e9;hb=110554a235aafe14d1ae6dd6310a982a9af9e7fe;hp=9e87e488e624323d336ee9cfcedb36ec651b1ba9;hpb=f366b93e1d9e8ebdff81c9277f9958178dcb38d0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/sv_spawn.qc b/qcsrc/common/monsters/sv_spawn.qc index 9e87e488e..497dee866 100644 --- a/qcsrc/common/monsters/sv_spawn.qc +++ b/qcsrc/common/monsters/sv_spawn.qc @@ -8,21 +8,19 @@ #include #include #endif -entity spawnmonster (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) { - entity e = spawn(); - 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); if(monster == "random") { RandomSelection_Init(); - FOREACH(Monsters, it != MON_Null, + FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MONSTER_TYPE_PASSIVE), { RandomSelection_AddEnt(it, 1, 1); }); @@ -41,8 +39,17 @@ entity spawnmonster (string monster, int monster_id, entity spawnedby, entity ow 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; @@ -62,7 +69,11 @@ entity spawnmonster (string monster, int monster_id, entity spawnedby, entity ow } // Monster_Spawn checks if monster is valid - Monster_Spawn(e, monster_id); + if(!Monster_Spawn(e, false, monster_id)) + { + delete(e); + return NULL; // remove even if told not to, as we didn't spawn any kind of monster + } return e; }