Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
dynlight.qc File Reference
#include "dynlight.qh"
#include <common/weapons/_all.qh>
#include <common/stats.qh>
Include dependency graph for dynlight.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void dynlight_find_aiment (entity this)
void dynlight_find_path (entity this)
void dynlight_find_target (entity this)
void dynlight_reset (entity this)
void dynlight_setactive (entity this, int act)
void dynlight_think (entity this)
void dynlight_use (entity this, entity actor, entity trigger)
 spawnfunc (dynlight)

Variables

vector color
const int DFOLLOW = 4
string dtagname
float lefty
float light_lev
const float LOOP = 1
float speed

Function Documentation

◆ dynlight_find_aiment()

void dynlight_find_aiment ( entity this)

Definition at line 46 of file dynlight.qc.

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}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector punchangle
entity owner
Definition main.qh:87
vector v_angle
Definition player.qh:237
float time
float nextthink
vector origin
void dynlight_think(entity this)
Definition dynlight.qc:39
ent angles
Definition ent_cs.qc:121
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
#define NULL
Definition post.qh:14
#define objerror
Definition pre.qh:8
vector view_ofs
Definition progsdefs.qc:151
#define setthink(e, f)
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55

References aiment, angles, dynlight_think(), entity(), find(), MOVETYPE_FOLLOW, nextthink, NULL, objerror, origin, owner, punchangle, set_movetype(), setthink, target, targetname, time, v_angle, and view_ofs.

Referenced by spawnfunc().

◆ dynlight_find_path()

void dynlight_find_path ( entity this)

Definition at line 62 of file dynlight.qc.

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}
void train_next(entity this)
Definition train.qc:83

References entity(), find(), nextthink, NULL, objerror, setthink, target, targetname, time, and train_next().

Referenced by spawnfunc().

◆ dynlight_find_target()

void dynlight_find_target ( entity this)

Definition at line 74 of file dynlight.qc.

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}
string dtagname
Definition dynlight.qc:16

References dtagname, dynlight_think(), entity(), find(), nextthink, NULL, objerror, owner, setthink, target, targetname, and time.

Referenced by spawnfunc().

◆ dynlight_reset()

void dynlight_reset ( entity this)

Definition at line 106 of file dynlight.qc.

107{
108 // TODO should anything else be reset here?
109 this.active = ACTIVE_ACTIVE;
110 this.light_lev = this.lefty;
111}
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float light_lev
Definition dynlight.qc:13
float lefty
Definition dynlight.qc:14

References active, ACTIVE_ACTIVE, entity(), lefty, and light_lev.

Referenced by spawnfunc().

◆ dynlight_setactive()

void dynlight_setactive ( entity this,
int act )

Definition at line 95 of file dynlight.qc.

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}
const int ACTIVE_TOGGLE
Definition defs.qh:40
const int ACTIVE_NOT
Definition defs.qh:36

References active, ACTIVE_ACTIVE, ACTIVE_NOT, ACTIVE_TOGGLE, entity(), lefty, and light_lev.

Referenced by spawnfunc().

◆ dynlight_think()

void dynlight_think ( entity this)

Definition at line 39 of file dynlight.qc.

40{
41 if(!this.owner)
42 delete(this);
43
44 this.nextthink = time + 0.1;
45}

References entity(), nextthink, owner, and time.

Referenced by dynlight_find_aiment(), and dynlight_find_target().

◆ dynlight_use()

void dynlight_use ( entity this,
entity actor,
entity trigger )

Definition at line 86 of file dynlight.qc.

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}

References active, ACTIVE_ACTIVE, entity(), lefty, and light_lev.

Referenced by spawnfunc().

◆ spawnfunc()

spawnfunc ( dynlight )

Definition at line 112 of file dynlight.qc.

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}
int spawnflags
Definition ammo.qh:15
const int INITPRIO_FINDTARGET
Definition constants.qh:96
const float SOLID_NOT
#define use
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 speed
Definition dynlight.qc:9
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
solid
Definition ent_cs.qc:165
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References active, ACTIVE_ACTIVE, color, DFOLLOW, dtagname, dynlight_find_aiment(), dynlight_find_path(), dynlight_find_target(), dynlight_reset(), dynlight_setactive(), dynlight_use(), InitializeEntity(), INITPRIO_FINDTARGET, lefty, light_lev, MOVETYPE_NOCLIP, origin, set_movetype(), solid, SOLID_NOT, spawnflags, speed, target, and use.

Variable Documentation

◆ color

◆ DFOLLOW

const int DFOLLOW = 4

Definition at line 12 of file dynlight.qc.

Referenced by spawnfunc().

◆ dtagname

string dtagname

Definition at line 16 of file dynlight.qc.

Referenced by dynlight_find_target(), and spawnfunc().

◆ lefty

float lefty

Definition at line 14 of file dynlight.qc.

Referenced by dynlight_reset(), dynlight_setactive(), dynlight_use(), and spawnfunc().

◆ light_lev

float light_lev

◆ LOOP

const float LOOP = 1

Definition at line 7 of file dynlight.qc.

◆ speed