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