4 #include "../../dpdefs/progsdefs.qh"
7 #include "sv_monsters.qh"
9 #include "../../server/autocvars.qh"
10 #include "../../server/defs.qh"
12 entity spawnmonster (string monster, float monster_id, entity spawnedby, entity own, vector orig, float respwn, float invincible, float moveflag)
17 e.spawnflags = MONSTERFLAG_SPAWNED;
19 if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; }
20 if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
24 if(monster == "random")
26 RandomSelection_Init();
27 for(i = MON_FIRST; i <= MON_LAST; ++i)
28 RandomSelection_Add(world, i, string_null, 1, 1);
30 monster_id = RandomSelection_chosen_float;
32 else if(monster != "")
36 for(i = MON_FIRST; i <= MON_LAST; ++i)
38 mon = get_monsterinfo(i);
39 if(mon.netname == monster)
42 monster_id = mon.monsterid; // we have the monster, old monster id is no longer required
47 monster_id = ((monster_id > 0) ? monster_id : MON_FIRST);
50 e.realowner = spawnedby;
53 e.monster_moveflags = moveflag;
55 if(IS_PLAYER(spawnedby))
57 if(teamplay && autocvar_g_monsters_teams)
58 e.team = spawnedby.team; // colors handled in spawn code
60 if(autocvar_g_monsters_owners)
61 e.monster_follow = own; // using .owner makes the monster non-solid for its master
63 e.angles_y = spawnedby.angles_y;
66 // Monster_Spawn checks if monster is valid
67 entity oldself = self;
69 Monster_Spawn(monster_id);