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