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