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)
#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;
#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);
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; }
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);