]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_lights.qc
Merge branch 'master' into terencehill/hud_fixes
[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         if(!self.owner)
40                 remove(self);
41
42         self.nextthink = time + 0.1;
43 }
44 void dynlight_find_aiment()
45 {
46         entity targ;
47         if (!self.target)
48                 objerror ("dynlight: no target to follow");
49
50         targ = find(world, targetname, self.target);
51         self.movetype = MOVETYPE_FOLLOW;
52         self.aiment = targ;
53         self.owner = targ;
54         self.punchangle = targ.angles;
55         self.view_ofs = self.origin - targ.origin;
56         self.v_angle = self.angles - targ.angles;
57         self.think = dynlight_think;
58         self.nextthink = time + 0.1;
59 }
60 void dynlight_find_path()
61 {
62         entity targ;
63         if (!self.target)
64                 objerror ("dynlight: no target to follow");
65
66         targ = find(world, targetname, self.target);
67         self.target = targ.target;
68         setorigin (self, targ.origin);
69         self.think = train_next;
70         self.nextthink = time + 0.1;
71 }
72 void dynlight_find_target()
73 {
74         entity targ;
75         if (!self.target)
76                 objerror ("dynlight: no target to follow");
77
78         targ = find(world, targetname, self.target);
79         setattachment(self, targ, self.dtagname);
80         self.owner = targ;
81         self.think = dynlight_think;
82         self.nextthink = time + 0.1;
83 }
84 void dynlight_use()
85 {
86         if (self.light_lev == 0)
87                 self.light_lev = self.lefty;
88         else
89                 self.light_lev = 0;
90 }
91 spawnfunc(dynlight)
92 {
93         if (!self.light_lev)
94                 self.light_lev = 200;
95         if (!self.color)
96                 self.color = '1 1 1';
97         self.lefty = self.light_lev;
98         self.use = dynlight_use;
99         setsize (self, '0 0 0', '0 0 0');
100         setorigin (self, self.origin);
101         //self.pflags = PFLAGS_FULLDYNAMIC;
102         self.solid = SOLID_NOT;
103         //self.blocked = func_null;
104         //if (self.spawnflags & DNOSHADOW)
105         //      self.pflags = self.pflags + PFLAGS_NOSHADOW;
106         //if (self.spawnflags & START_OFF)
107         //      self.light_lev = 0;
108
109 //tag attaching
110         if (self.dtagname)
111         {
112                 InitializeEntity(self, dynlight_find_target, INITPRIO_FINDTARGET);
113                 return;
114         }
115
116 // entity following
117         if (self.spawnflags & DFOLLOW)
118         {
119                 InitializeEntity(self, dynlight_find_aiment, INITPRIO_FINDTARGET);
120                 return;
121         }
122 // path following
123         if (self.target)
124 //      if (!(self.spawnflags & DFOLLOW))
125         {
126                 self.movetype = MOVETYPE_NOCLIP;
127                 if (!self.speed)
128                         self.speed = 100;
129                 InitializeEntity(self, dynlight_find_path, INITPRIO_FINDTARGET);
130                 return;
131         }
132 }