Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
dynlight.qc
Go to the documentation of this file.
1#include "dynlight.qh"
2
3#ifdef SVQC
5#include <common/stats.qh>
6
7const float LOOP = 1;
8
9.float speed;
10
11//const int DNOSHADOW = 2;
12const int DFOLLOW = 4;
13.float light_lev;
14.float lefty;
15.vector color;
16.string dtagname;
17
18/*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW
19Dynamic spawnfunc_light.
20Can 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.
21It can spin around it's own axis in all the above cases.
22If targeted, it will toggle between on or off.
23keys:
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
34flags:
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"
38*/
40{
41 if(!this.owner)
42 delete(this);
43
44 this.nextthink = time + 0.1;
45}
47{
48 entity targ;
49 if (!this.target || this.target == "")
50 objerror (this, "dynlight: no target to follow");
51
52 targ = find(NULL, targetname, this.target);
54 this.aiment = targ;
55 this.owner = targ;
56 this.punchangle = targ.angles;
57 this.view_ofs = this.origin - targ.origin;
58 this.v_angle = this.angles - targ.angles;
60 this.nextthink = time + 0.1;
61}
63{
64 entity targ;
65 if (!this.target || this.target == "")
66 objerror (this, "dynlight: no target to follow");
67
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;
73}
75{
76 entity targ;
77 if (!this.target || this.target == "")
78 objerror (this, "dynlight: no target to follow");
79
80 targ = find(NULL, targetname, this.target);
81 setattachment(this, targ, this.dtagname);
82 this.owner = targ;
84 this.nextthink = time + 0.1;
85}
86void dynlight_use(entity this, entity actor, entity trigger)
87{
88 if(this.active != ACTIVE_ACTIVE)
89 return;
90 if (this.light_lev == 0)
91 this.light_lev = this.lefty;
92 else
93 this.light_lev = 0;
94}
95void dynlight_setactive(entity this, int act)
96{
97 int old_status = this.active;
98 if(act == ACTIVE_TOGGLE)
100 else
101 this.active = act;
102
103 if(this.active != old_status)
104 this.light_lev = (this.active == ACTIVE_ACTIVE) ? this.lefty : 0;
105}
107{
108 // TODO should anything else be reset here?
109 this.active = ACTIVE_ACTIVE;
110 this.light_lev = this.lefty;
111}
112spawnfunc(dynlight)
113{
114 if (!this.light_lev)
115 this.light_lev = 200;
116 if (!this.color)
117 this.color = '1 1 1';
118 this.lefty = this.light_lev;
119 this.use = dynlight_use;
120 this.active = ACTIVE_ACTIVE;
121 this.setactive = dynlight_setactive;
122 this.reset = dynlight_reset;
123 setsize (this, '0 0 0', '0 0 0');
124 setorigin(this, this.origin);
125 //this.pflags = PFLAGS_FULLDYNAMIC;
126 this.solid = SOLID_NOT;
127 //this.blocked = func_null;
128 //if (this.spawnflags & DNOSHADOW)
129 // this.pflags = this.pflags + PFLAGS_NOSHADOW;
130 //if (this.spawnflags & START_OFF)
131 // this.light_lev = 0;
132
133//tag attaching
134 if (this.dtagname)
135 {
137 return;
138 }
139
140// entity following
141 if (this.spawnflags & DFOLLOW)
142 {
144 return;
145 }
146// path following
147 if (this.target)
148// if (!(this.spawnflags & DFOLLOW))
149 {
151 if (!this.speed)
152 this.speed = 100;
154 return;
155 }
156}
157#endif
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector punchangle
entity owner
Definition main.qh:87
int spawnflags
Definition ammo.qh:15
vector v_angle
Definition player.qh:237
const int INITPRIO_FINDTARGET
Definition constants.qh:96
const float SOLID_NOT
float time
float nextthink
vector origin
#define use
const int ACTIVE_TOGGLE
Definition defs.qh:40
const int ACTIVE_NOT
Definition defs.qh:36
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float light_lev
Definition dynlight.qc:13
void dynlight_think(entity this)
Definition dynlight.qc:39
void dynlight_use(entity this, entity actor, entity trigger)
Definition dynlight.qc:86
void dynlight_find_path(entity this)
Definition dynlight.qc:62
vector color
Definition dynlight.qc:15
void dynlight_setactive(entity this, int act)
Definition dynlight.qc:95
float lefty
Definition dynlight.qc:14
float speed
Definition dynlight.qc:9
string dtagname
Definition dynlight.qc:16
const float LOOP
Definition dynlight.qc:7
void dynlight_find_aiment(entity this)
Definition dynlight.qc:46
const int DFOLLOW
Definition dynlight.qc:12
void dynlight_reset(entity this)
Definition dynlight.qc:106
void dynlight_find_target(entity this)
Definition dynlight.qc:74
ent angles
Definition ent_cs.qc:121
solid
Definition ent_cs.qc:165
entity find(entity start,.string field, string match)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
entity aiment
Definition movetypes.qh:90
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
#define NULL
Definition post.qh:14
#define objerror
Definition pre.qh:8
vector view_ofs
Definition progsdefs.qc:151
#define setthink(e, f)
#define spawnfunc(id)
Definition spawnfunc.qh:96
void train_next(entity this)
Definition train.qc:83
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209