]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_lights.qc
Merge branch 'master' into terencehill/dynamic_hud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_lights.qc
1 #include "g_lights.qh"
2
3 void train_next();
4
5 const float LOOP = 1;
6
7 .float speed;
8
9 const float DNOSHADOW = 2;
10 const float DFOLLOW = 4;
11 .float light_lev;
12 .float lefty;
13 .vector color;
14 .string dtagname;
15
16 /*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW
17 Dynamic spawnfunc_light.
18 Can do one of these things: sit still and be just a silly spawnfunc_light, travel along a path, follow an entity around, attach to a tag on an entity.
19 It can spin around it's own axis in all the above cases.
20 If targeted, it will toggle between on or off.
21 keys:
22 "light_lev" spawnfunc_light radius, default 200
23 "color" spawnfunc_light color in rgb and brightness, 1 1 1 produces bright white, up to 255 255 255 (nuclear blast), recommended values up to 1 1 1, default 1 1 1
24 "style" lightstyle, same as for static lights
25 "angles" initial orientation
26 "avelocity" a vector value, the direction and speed it rotates in
27 "skin" cubemap number, must be 16 or above
28 "dtagname" will attach to this tag on the entity which "targetname" matches "target". If the "target" is either not an md3 model or is missing tags, it will attach to the targets origin. Note that the "target" must be visible to the spawnfunc_light
29 "targetname" will toggle on and off when triggered
30 "target" if issued with a target, preferrably spawnfunc_path_corner, it will move along the path. If also issued with the FOLLOW spawnflag, then this is the entity it will follow. If issued with the "tagname" key it will attach it to this targets tag called "tagname", does not work together with FOLLOW or path movement
31 "speed" the speed it will travel along the path, default 100
32 flags:
33 "START_OFF" spawnfunc_light will be in off state until targeted
34 "NOSHADOW" will not cast shadows in realtime lighting mode
35 "FOLLOW" will follow the entity which "targetname" matches "target"
36 */
37 void dynlight_think()
38 {
39     SELFPARAM();
40         if(!self.owner)
41                 remove(self);
42
43         self.nextthink = time + 0.1;
44 }
45 void dynlight_find_aiment()
46 {
47     SELFPARAM();
48         entity targ;
49         if (!self.target)
50                 objerror ("dynlight: no target to follow");
51
52         targ = find(world, targetname, self.target);
53         self.movetype = MOVETYPE_FOLLOW;
54         self.aiment = targ;
55         self.owner = targ;
56         self.punchangle = targ.angles;
57         self.view_ofs = self.origin - targ.origin;
58         self.v_angle = self.angles - targ.angles;
59         self.think = dynlight_think;
60         self.nextthink = time + 0.1;
61 }
62 void dynlight_find_path()
63 {
64     SELFPARAM();
65         entity targ;
66         if (!self.target)
67                 objerror ("dynlight: no target to follow");
68
69         targ = find(world, targetname, self.target);
70         self.target = targ.target;
71         setorigin (self, targ.origin);
72         self.think = train_next;
73         self.nextthink = time + 0.1;
74 }
75 void dynlight_find_target()
76 {
77     SELFPARAM();
78         entity targ;
79         if (!self.target)
80                 objerror ("dynlight: no target to follow");
81
82         targ = find(world, targetname, self.target);
83         setattachment(self, targ, self.dtagname);
84         self.owner = targ;
85         self.think = dynlight_think;
86         self.nextthink = time + 0.1;
87 }
88 void dynlight_use()
89 {
90     SELFPARAM();
91         if (self.light_lev == 0)
92                 self.light_lev = self.lefty;
93         else
94                 self.light_lev = 0;
95 }
96 spawnfunc(dynlight)
97 {
98         if (!self.light_lev)
99                 self.light_lev = 200;
100         if (!self.color)
101                 self.color = '1 1 1';
102         self.lefty = self.light_lev;
103         self.use = dynlight_use;
104         setsize (self, '0 0 0', '0 0 0');
105         setorigin (self, self.origin);
106         //self.pflags = PFLAGS_FULLDYNAMIC;
107         self.solid = SOLID_NOT;
108         //self.blocked = func_null;
109         //if (self.spawnflags & DNOSHADOW)
110         //      self.pflags = self.pflags + PFLAGS_NOSHADOW;
111         //if (self.spawnflags & START_OFF)
112         //      self.light_lev = 0;
113
114 //tag attaching
115         if (self.dtagname)
116         {
117                 InitializeEntity(self, dynlight_find_target, INITPRIO_FINDTARGET);
118                 return;
119         }
120
121 // entity following
122         if (self.spawnflags & DFOLLOW)
123         {
124                 InitializeEntity(self, dynlight_find_aiment, INITPRIO_FINDTARGET);
125                 return;
126         }
127 // path following
128         if (self.target)
129 //      if (!(self.spawnflags & DFOLLOW))
130         {
131                 self.movetype = MOVETYPE_NOCLIP;
132                 if (!self.speed)
133                         self.speed = 100;
134                 InitializeEntity(self, dynlight_find_path, INITPRIO_FINDTARGET);
135                 return;
136         }
137 }