7 #include "sv_monsters.qh"
8 #include <server/autocvars.qh>
9 #include <server/defs.qh>
11 entity spawnmonster (string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, int moveflag)
15 e.spawnflags = MONSTERFLAG_SPAWNED;
17 if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; }
18 if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
22 if(monster == "random")
24 RandomSelection_Init();
25 FOREACH(Monsters, it != MON_Null,
27 RandomSelection_AddEnt(it, 1, 1);
30 monster_id = RandomSelection_chosen_ent.monsterid;
32 else if(monster != "")
35 FOREACH(Monsters, it != MON_Null,
37 if(it.netname == monster)
40 monster_id = it.monsterid; // we have the monster, old monster id is no longer required
45 monster_id = ((monster_id > 0) ? monster_id : MON_FIRST);
48 e.realowner = spawnedby;
51 e.monster_moveflags = moveflag;
53 if(IS_PLAYER(spawnedby))
55 if(teamplay && autocvar_g_monsters_teams)
56 e.team = spawnedby.team; // colors handled in spawn code
58 if(autocvar_g_monsters_owners)
59 e.monster_follow = own; // using .owner makes the monster non-solid for its master
61 e.angles_y = spawnedby.angles_y;
64 // Monster_Spawn checks if monster is valid
65 Monster_Spawn(e, monster_id);