#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);
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;
}
// Monster_Spawn checks if monster is valid
- Monster_Spawn(e, false, 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;
}