7 #include "sv_monsters.qh"
8 #include <server/autocvars.qh>
9 #include <server/defs.qh>
11 entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
13 e.spawnflags = MONSTERFLAG_SPAWNED;
15 if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; }
16 //if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
20 if(monster == "random")
22 RandomSelection_Init();
23 FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MONSTER_TYPE_PASSIVE),
25 RandomSelection_AddEnt(it, 1, 1);
28 monster_id = RandomSelection_chosen_ent.monsterid;
30 else if(monster != "")
33 FOREACH(Monsters, it != MON_Null,
35 if(it.netname == monster)
38 monster_id = it.monsterid; // we have the monster, old monster id is no longer required
43 if(!found && !monster_id)
48 return NULL; // no good
51 monster_id = MON_FIRST;
55 e.realowner = spawnedby;
58 e.monster_moveflags = moveflag;
60 if(IS_PLAYER(spawnedby))
62 if(teamplay && autocvar_g_monsters_teams)
63 e.team = spawnedby.team; // colors handled in spawn code
65 if(autocvar_g_monsters_owners)
66 e.monster_follow = own; // using .owner makes the monster non-solid for its master
68 e.angles_y = spawnedby.angles_y;
71 // Monster_Spawn checks if monster is valid
72 Monster_Spawn(e, false, monster_id);