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