3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
6 void train_next(entity this);
12 const float DNOSHADOW = 2;
13 const float DFOLLOW = 4;
19 /*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW
20 Dynamic spawnfunc_light.
21 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.
22 It can spin around it's own axis in all the above cases.
23 If targeted, it will toggle between on or off.
25 "light_lev" spawnfunc_light radius, default 200
26 "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
27 "style" lightstyle, same as for static lights
28 "angles" initial orientation
29 "avelocity" a vector value, the direction and speed it rotates in
30 "skin" cubemap number, must be 16 or above
31 "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
32 "targetname" will toggle on and off when triggered
33 "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
34 "speed" the speed it will travel along the path, default 100
36 "START_OFF" spawnfunc_light will be in off state until targeted
37 "NOSHADOW" will not cast shadows in realtime lighting mode
38 "FOLLOW" will follow the entity which "targetname" matches "target"
40 void dynlight_think(entity this)
45 this.nextthink = time + 0.1;
47 void dynlight_find_aiment(entity this)
51 objerror (this, "dynlight: no target to follow");
53 targ = find(NULL, targetname, this.target);
54 set_movetype(this, MOVETYPE_FOLLOW);
57 this.punchangle = targ.angles;
58 this.view_ofs = this.origin - targ.origin;
59 this.v_angle = this.angles - targ.angles;
60 setthink(this, dynlight_think);
61 this.nextthink = time + 0.1;
63 void dynlight_find_path(entity this)
67 objerror (this, "dynlight: no target to follow");
69 targ = find(NULL, targetname, this.target);
70 this.target = targ.target;
71 setorigin(this, targ.origin);
72 setthink(this, train_next);
73 this.nextthink = time + 0.1;
75 void dynlight_find_target(entity this)
79 objerror (this, "dynlight: no target to follow");
81 targ = find(NULL, targetname, this.target);
82 setattachment(this, targ, this.dtagname);
84 setthink(this, dynlight_think);
85 this.nextthink = time + 0.1;
87 void dynlight_use(entity this, entity actor, entity trigger)
89 if (this.light_lev == 0)
90 this.light_lev = this.lefty;
100 this.lefty = this.light_lev;
101 this.use = dynlight_use;
102 setsize (this, '0 0 0', '0 0 0');
103 setorigin(this, this.origin);
104 //this.pflags = PFLAGS_FULLDYNAMIC;
105 this.solid = SOLID_NOT;
106 //this.blocked = func_null;
107 //if (this.spawnflags & DNOSHADOW)
108 // this.pflags = this.pflags + PFLAGS_NOSHADOW;
109 //if (this.spawnflags & START_OFF)
110 // this.light_lev = 0;
115 InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET);
120 if (this.spawnflags & DFOLLOW)
122 InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET);
127 // if (!(this.spawnflags & DFOLLOW))
129 set_movetype(this, MOVETYPE_NOCLIP);
132 InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET);