Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turrets.qc
1 #include "all.qh"
2
3 // TURRET PLUGIN SYSTEM
4 entity turret_info[TUR_MAXCOUNT];
5 entity dummy_turret_info;
6
7 void turrets_common_precache()
8 {
9         precache_sound (W_Sound("rocket_impact"));
10         precache_model ("models/turrets/base-gib1.md3");
11         precache_model ("models/turrets/base-gib2.md3");
12         precache_model ("models/turrets/base-gib3.md3");
13         precache_model ("models/turrets/base-gib4.md3");
14         precache_model ("models/turrets/head-gib1.md3");
15         precache_model ("models/turrets/head-gib2.md3");
16         precache_model ("models/turrets/head-gib3.md3");
17         precache_model ("models/turrets/head-gib4.md3");
18         precache_model ("models/turrets/base.md3");
19         precache_model ("models/turrets/rocket.md3");
20
21         precache_model ("models/turrets/c512.md3");
22         precache_model ("models/marker.md3");
23
24 #ifdef SVQC
25         precache_sound(W_Sound("rocket_impact"));
26 #endif
27
28 #ifdef TURRET_DEBUG
29         precache_model ("models/turrets/c512.md3");
30         precache_model ("models/pathlib/goodsquare.md3");
31         precache_model ("models/pathlib/badsquare.md3");
32         precache_model ("models/pathlib/square.md3");
33         precache_model ("models/pathlib/edge.md3");
34 #endif
35 }
36
37 void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
38 {
39         entity e;
40         turret_info[id - 1] = e = spawn();
41         e.classname = "turret_info";
42         e.turretid = id;
43         e.netname = shortname;
44         e.turret_name = mname;
45         e.turret_func = func;
46         e.mdl = modelname;
47         e.cvar_basename = shortname;
48         e.spawnflags = turretflags;
49         e.mins = min_s;
50         e.maxs = max_s;
51         e.model = strzone(strcat("models/turrets/", modelname));
52         e.head_model = strzone(strcat("models/turrets/", headmodelname));
53
54         #ifndef MENUQC
55         turrets_common_precache();
56         #endif
57 }
58 float t_null(float dummy) { return 0; }
59 void register_turrets_done()
60 {
61         dummy_turret_info = spawn();
62         dummy_turret_info.classname = "turret_info";
63         dummy_turret_info.turretid = 0; // you can recognize dummies by this
64         dummy_turret_info.netname = "";
65         dummy_turret_info.turret_name = "Turret";
66         dummy_turret_info.turret_func = t_null;
67         dummy_turret_info.mdl = "";
68         dummy_turret_info.mins = '-0 -0 -0';
69         dummy_turret_info.maxs = '0 0 0';
70         dummy_turret_info.model = "";
71 }
72 entity get_turretinfo(float id)
73 {
74         entity m;
75         if(id < TUR_FIRST || id > TUR_LAST)
76                 return dummy_turret_info;
77         m = turret_info[id - 1];
78         if(m)
79                 return m;
80         return dummy_turret_info;
81 }