4 #include <server/defs.qh>
5 #include <server/miscfunctions.qh>
11 //const int DNOSHADOW = 2;
12 const int DFOLLOW = 4;
18 /*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW
19 Dynamic spawnfunc_light.
20 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.
21 It can spin around it's own axis in all the above cases.
22 If targeted, it will toggle between on or off.
24 "light_lev" spawnfunc_light radius, default 200
25 "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
26 "style" lightstyle, same as for static lights
27 "angles" initial orientation
28 "avelocity" a vector value, the direction and speed it rotates in
29 "skin" cubemap number, must be 16 or above
30 "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
31 "targetname" will toggle on and off when triggered
32 "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
33 "speed" the speed it will travel along the path, default 100
35 "START_OFF" spawnfunc_light will be in off state until targeted
36 "NOSHADOW" will not cast shadows in realtime lighting mode
37 "FOLLOW" will follow the entity which "targetname" matches "target"
39 void dynlight_think(entity this)
44 this.nextthink = time + 0.1;
46 void dynlight_find_aiment(entity this)
50 objerror (this, "dynlight: no target to follow");
52 targ = find(NULL, targetname, this.target);
53 set_movetype(this, MOVETYPE_FOLLOW);
56 this.punchangle = targ.angles;
57 this.view_ofs = this.origin - targ.origin;
58 this.v_angle = this.angles - targ.angles;
59 setthink(this, dynlight_think);
60 this.nextthink = time + 0.1;
62 void dynlight_find_path(entity this)
66 objerror (this, "dynlight: no target to follow");
68 targ = find(NULL, targetname, this.target);
69 this.target = targ.target;
70 setorigin(this, targ.origin);
71 setthink(this, train_next); // TODO: reliant on the train's pathing functions
72 this.nextthink = time + 0.1;
74 void dynlight_find_target(entity this)
78 objerror (this, "dynlight: no target to follow");
80 targ = find(NULL, targetname, this.target);
81 setattachment(this, targ, this.dtagname);
83 setthink(this, dynlight_think);
84 this.nextthink = time + 0.1;
86 void dynlight_use(entity this, entity actor, entity trigger)
88 if (this.light_lev == 0)
89 this.light_lev = this.lefty;
99 this.lefty = this.light_lev;
100 this.use = dynlight_use;
101 setsize (this, '0 0 0', '0 0 0');
102 setorigin(this, this.origin);
103 //this.pflags = PFLAGS_FULLDYNAMIC;
104 this.solid = SOLID_NOT;
105 //this.blocked = func_null;
106 //if (this.spawnflags & DNOSHADOW)
107 // this.pflags = this.pflags + PFLAGS_NOSHADOW;
108 //if (this.spawnflags & START_OFF)
109 // this.light_lev = 0;
114 InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET);
119 if (this.spawnflags & DFOLLOW)
121 InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET);
126 // if (!(this.spawnflags & DFOLLOW))
128 set_movetype(this, MOVETYPE_NOCLIP);
131 InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET);