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

Go to the source code of this file.

Functions

void FireImoBeam (entity this, vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, int deathtype)
 Railgun-like beam, but has thickness and suppots slowing of target.
float turret_tag_fire_update (entity this)
 Update this.tur_shotorg by getting up2date bone info NOTICE this func overwrites the global v_forward, v_right and v_up vectors.

Function Documentation

◆ FireImoBeam()

void FireImoBeam ( entity this,
vector start,
vector end,
vector smin,
vector smax,
float bforce,
float f_dmg,
float f_velfactor,
int deathtype )

Railgun-like beam, but has thickness and suppots slowing of target.

Definition at line 25 of file util.qc.

27{
28 vector dir = normalize(end - start);
29 vector force = dir * bforce;
30
31 // go a little bit into the wall because we need to hit this wall later
32 end += dir;
33
34 // trace multiple times until we hit a wall, each obstacle will be made unsolid.
35 // note down which entities were hit so we can damage them later
36 entity o = this;
37 while (1)
38 {
39 WarpZone_tracebox_antilag(this, start, smin, smax, end, false, o, (CS(this).antilag_debug ? CS(this).antilag_debug : ANTILAG_LATENCY(this)));
41 {
42 o = NULL;
43 continue;
44 }
45
46 // if it is NULL we can't hurt it so stop now
47 if (trace_ent == NULL || trace_fraction == 1)
48 break;
49
50 // make the entity non-solid so we can hit the next one
52 trace_ent.railgunhit = true;
53 trace_ent.railgunhitloc = end;
54 trace_ent.railgunhitsolidbackup = trace_ent.solid;
57
58 // stop if this is a wall
59 if (trace_ent.solid == SOLID_BSP)
60 break;
61
62 // make the entity non-solid
63 trace_ent.solid = SOLID_NOT;
64 }
65
66 vector endpoint = trace_endpos;
67 entity endent = trace_ent;
68 float endq3surfaceflags = trace_dphitq3surfaceflags;
69
70 // find all the entities the railgun hit and restore their solid state
71 IL_EACH(g_railgunhit, it.railgunhit, it.solid = it.railgunhitsolidbackup);
72
73 // Unlike the railgun, this does NOT check for targets close by
74
75 // find all the entities the railgun hit and hurt them
76 IL_EACH(g_railgunhit, it.railgunhit,
77 {
78 // removal from the list is handled below
79 // no falloff applied
80
81 // apply the damage
82 if (it.takedamage)
83 {
84 Damage(it, this, this, f_dmg, deathtype, DMG_NOWEP, it.railgunhitloc, it.railgunforce);
85 // slow down the target
86 it.velocity *= f_velfactor;
87 }
88
89 it.railgunhitloc = '0 0 0';
90 it.railgunhitsolidbackup = SOLID_NOT;
91 it.railgunhit = false;
92 it.railgundistance = 0;
93 });
94
96
97 // no accuracy, as a weapon entity is not attached
98
99 trace_endpos = endpoint;
100 trace_ent = endent;
101 trace_dphitq3surfaceflags = endq3surfaceflags;
102}
float antilag_debug
Definition antilag.qc:19
void WarpZone_tracebox_antilag(entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag)
Definition antilag.qc:228
#define ANTILAG_LATENCY(e)
Definition antilag.qh:19
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity trace_ent
const float SOLID_NOT
vector trace_endpos
float trace_dphitq3surfaceflags
float trace_fraction
const float SOLID_BSP
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define IL_CLEAR(this)
Remove all elements.
vector WarpZone_TransformVelocity(entity wz, vector v)
Definition common.qc:514
vector WarpZone_UnTransformOrigin(entity wz, vector v)
Definition common.qc:544
entity WarpZone_trace_firstzone
Definition common.qh:38
entity WarpZone_trace_transform
Definition common.qh:37
float vlen(vector v)
vector normalize(vector v)
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
int dir
Definition impulse.qc:89
ClientState CS(Client this)
Definition state.qh:47
IntrusiveList g_railgunhit
Definition tracing.qh:89

References antilag_debug, ANTILAG_LATENCY, CS(), dir, entity(), g_railgunhit, IL_EACH, IL_PUSH(), normalize(), NULL, SOLID_BSP, SOLID_NOT, trace_dphitq3surfaceflags, trace_endpos, trace_ent, trace_fraction, vector, vlen(), WarpZone_trace_firstzone, WarpZone_trace_transform, WarpZone_tracebox_antilag(), WarpZone_TransformVelocity(), and WarpZone_UnTransformOrigin().

Referenced by beam_think().

◆ turret_tag_fire_update()

float turret_tag_fire_update ( entity this)

Update this.tur_shotorg by getting up2date bone info NOTICE this func overwrites the global v_forward, v_right and v_up vectors.

Definition at line 9 of file util.qc.

10{
11 if (!this.tur_head)
12 {
13 LOG_DEBUG("Call to turret_tag_fire_update with this.tur_head missing!");
14 this.tur_shotorg = '0 0 0';
15 return false;
16 }
17
18 this.tur_shotorg = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_fire"));
20
21 return true;
22}
vector v_forward
#define gettagindex
#define LOG_DEBUG(...)
Definition log.qh:80
#define gettaginfo
Definition post.qh:32
vector tur_shotorg
Definition sv_turrets.qh:30
entity tur_head
Definition sv_turrets.qh:28

References entity(), gettagindex, gettaginfo, LOG_DEBUG, normalize(), tur_head, tur_shotorg, and v_forward.

Referenced by turret_aim_generic(), turret_do_updates(), and turret_initialize().