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