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)
float turret_tag_fire_update (entity this)

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 )

Definition at line 27 of file util.qc.

30{
31 vector dir = normalize(end - start);
32 vector force = dir * bforce;
33
34 // go a little bit into the wall because we need to hit this wall later
35 end = end + dir;
36
37 // trace multiple times until we hit a wall, each obstacle will be made unsolid.
38 // note down which entities were hit so we can damage them later
39 entity o = this;
40 while (1)
41 {
42 if(CS(this).antilag_debug)
43 WarpZone_tracebox_antilag (this, start, smin, smax, end, false, o, CS(this).antilag_debug);
44 else
45 WarpZone_tracebox_antilag (this, start, smin, smax, end, false, o, ANTILAG_LATENCY(this));
47 {
48 o = NULL;
49 continue;
50 }
51
52 // if it is NULL we can't hurt it so stop now
53 if (trace_ent == NULL || trace_fraction == 1)
54 break;
55
56 // make the entity non-solid so we can hit the next one
58 trace_ent.railgunhit = true;
59 trace_ent.railgunhitloc = end;
60 trace_ent.railgunhitsolidbackup = trace_ent.solid;
63
64 // stop if this is a wall
65 if (trace_ent.solid == SOLID_BSP)
66 break;
67
68 // make the entity non-solid
69 trace_ent.solid = SOLID_NOT;
70 }
71
72 vector endpoint = trace_endpos;
73 entity endent = trace_ent;
74 float endq3surfaceflags = trace_dphitq3surfaceflags;
75
76 // find all the entities the railgun hit and restore their solid state
77 IL_EACH(g_railgunhit, it.railgunhit,
78 {
79 it.solid = it.railgunhitsolidbackup;
80 });
81
82 /*
83 Unlike the railgun, this does NOT check for targets close by
84 */
85
86 // find all the entities the railgun hit and hurt them
87 IL_EACH(g_railgunhit, it.railgunhit,
88 {
89 // removal from the list is handled below
90 /* no falloff applied */
91
92 // apply the damage
93 if (it.takedamage)
94 {
95 Damage(it, this, this, f_dmg, deathtype, DMG_NOWEP, it.railgunhitloc, it.railgunforce);
96 // slow down the target
97 it.velocity = it.velocity * f_velfactor;
98 }
99
100 it.railgunhitloc = '0 0 0';
101 it.railgunhitsolidbackup = SOLID_NOT;
102 it.railgunhit = false;
103 it.railgundistance = 0;
104 });
105
107
108 /* no accuracy, as a weapon entity is not attached */
109
110 trace_endpos = endpoint;
111 trace_ent = endent;
112 trace_dphitq3surfaceflags = endq3surfaceflags;
113}
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:545
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:85

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)

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().