]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/lib/spawn.qc
Fix monsters sinking into the ground while spawning
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / lib / spawn.qc
1 float spawnmonster_checkinlist(string monster, string list)
2 {
3         string l = strcat(" ", list, " ");
4         
5         if(strstrofs(l, strcat(" ", monster, " "), 0) >= 0)
6                 return TRUE;
7         
8         return FALSE;
9 }
10
11 entity spawnmonster (string monster, entity spawnedby, entity own, vector orig, float respwn, float moveflag)
12 {
13         if(!spawncode_first_load)
14         {
15                 initialize_field_db();
16                 spawncode_first_load = TRUE;
17         }
18         
19         entity e = spawn();
20         
21         e.spawnflags = MONSTERFLAG_SPAWNED;
22         
23         if not(respwn)
24                 e.spawnflags |= MONSTERFLAG_NORESPAWN;
25         
26         setorigin(e, orig);
27         
28         if not(spawnmonster_checkinlist(monster, autocvar_g_monsters_spawn_list))
29                 monster = "knight";
30         
31         e.realowner = spawnedby;
32         
33         if(moveflag)
34                 e.monster_moveflags = moveflag;
35         
36         if (spawnedby.classname == "monster_swarm")
37                 e.monster_owner = own;  
38         else if(IS_PLAYER(spawnedby))
39         {
40                 if(teamplay && autocvar_g_monsters_teams)
41                         e.team = spawnedby.team; // colors handled in spawn code
42                         
43                 if(e.team)
44                         e.colormap = 1024;
45                 else
46                         e.colormap = spawnedby.colormap;
47                         
48                 if(autocvar_g_monsters_owners)
49                         e.monster_owner = own; // using .owner makes the monster non-solid for its master
50                         
51                 e.angles = spawnedby.angles;
52         }
53                 
54         monster = strcat("$ spawnfunc_monster_", monster);
55                 
56         target_spawn_edit_entity(e, monster, world, world, world, world, world);
57                 
58         return e;
59 }