Xonotic
tracing.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 
17 
21 
22 // this function calculates w_shotorg and w_shotdir based on the weapon model
23 // offset, trueaim and antilag, and won't put w_shotorg inside a wall.
24 // make sure you call makevectors first (FIXME?)
25 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range, int deathtype);
26 
27 #define W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
28  W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, max_shot_distance, deathtype)
29 #define W_SetupShot_ProjectileSize(ent, wepent, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
30  W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype)
31 #define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype) \
32  W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
33 #define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype) \
34  W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
35 #define W_SetupShot_Range(ent, wepent, antilag, recoil, snd, chan, maxdamage, range, deathtype) \
36  W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range, deathtype)
37 
38 vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute);
39 
40 #if 0
41 float mspercallsum;
42 float mspercallsstyle;
43 float mspercallcount;
44 #endif
45 
46 void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute);
47 
48 #define W_SetupProjVelocity_Basic(ent,pspeed,pspread) \
49  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, pspeed, 0, 0, pspread, false)
50 
51 #define W_SetupProjVelocity_UP_PRE(ent, wepname, prefix) \
52  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR(wepname, prefix##speed), WEP_CVAR(wepname, prefix##speed_up), WEP_CVAR(wepname, prefix##speed_z), WEP_CVAR(wepname, prefix##spread), false)
53 #define W_SetupProjVelocity_UP_PRI(ent, wepname) \
54  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_PRI(wepname, speed), WEP_CVAR_PRI(wepname, speed_up), WEP_CVAR_PRI(wepname, speed_z), WEP_CVAR_PRI(wepname, spread), false)
55 #define W_SetupProjVelocity_UP_SEC(ent, wepname) \
56  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_SEC(wepname, speed), WEP_CVAR_SEC(wepname, speed_up), WEP_CVAR_SEC(wepname, speed_z), WEP_CVAR_SEC(wepname, spread), false)
57 
58 #define W_SetupProjVelocity_UP_BOTH(ent, wepname, isprimary) \
59  if(isprimary) { W_SetupProjVelocity_UP_PRI(ent, wepname); } \
60  else { W_SetupProjVelocity_UP_SEC(ent, wepname); }
61 
62 #define W_SetupProjVelocity_PRE(ent, wepname, prefix) \
63  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR(wepname, prefix##speed), 0, 0, WEP_CVAR(wepname, prefix##spread), false)
64 #define W_SetupProjVelocity_PRI(ent, wepname) \
65  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_PRI(wepname, speed), 0, 0, WEP_CVAR_PRI(wepname, spread), false)
66 #define W_SetupProjVelocity_SEC(ent, wepname) \
67  W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_SEC(wepname, speed), 0, 0, WEP_CVAR_SEC(wepname, spread), false)
68 
69 #define W_SetupProjVelocity_BOTH(ent, wepname, isprimary) \
70  if(isprimary) { W_SetupProjVelocity_PRI(ent, wepname); } \
71  else { W_SetupProjVelocity_SEC(ent, wepname); }
72 
73 // ====================
74 // Ballistics Tracing
75 // ====================
76 
78 
79 // for railgun damage (hitting multiple enemies)
80 .bool railgunhit;
82 .vector railgunhitloc;
83 
85 STATIC_INIT(g_railgunhit) { g_railgunhit = IL_NEW(); }
86 
88 .vector railgunforce;
89 void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector end, float bdamage, bool headshot_notify, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
90 
93 void fireBullet_trace_callback(vector start, vector hit, vector end);
94 void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect, bool do_antilag);
95 void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect);
96 
97 void crosshair_trace(entity pl);
98 
102 
103 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
104 
106 
107 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
108 
110 STATIC_INIT(g_ctrace_changed) { g_ctrace_changed = IL_NEW(); }
bool railgunhit
Definition: tracing.qh:80
void WarpZone_crosshair_trace_plusvisibletriggers(entity pl)
Definition: tracing.qc:518
void fireBullet_antilag(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect, bool do_antilag)
Definition: tracing.qc:357
IntrusiveList g_ctrace_changed
Definition: tracing.qh:109
vector w_shotorg
Definition: tracing.qh:18
void fireBullet_trace_callback(vector start, vector hit, vector end)
Definition: tracing.qc:349
IntrusiveList g_railgunhit
Definition: tracing.qh:84
STATIC_INIT(g_railgunhit)
Definition: tracing.qh:85
#define IL_NEW()
entity() spawn
float autocvar_g_ballistics_mindistance
Definition: tracing.qh:8
void crosshair_trace(entity pl)
Definition: tracing.qc:508
vector w_shotdir
Definition: tracing.qh:19
void FireRailgunBullet(entity this,.entity weaponentity, vector start, vector end, float bdamage, bool headshot_notify, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
Definition: tracing.qc:231
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
Definition: tracing.qc:185
float autocvar_g_projectiles_newton_style_2_maxfactor
Definition: tracing.qh:12
void W_SetupShot_Dir_ProjectileSize_Range(entity ent,.entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range, int deathtype)
Definition: tracing.qc:24
void fireBullet(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect)
Definition: tracing.qc:503
int autocvar_g_projectiles_newton_style
Definition: tracing.qh:11
float autocvar_g_trueaim_minrange
Definition: tracing.qh:16
float railgundistance
Definition: tracing.qh:87
vector railgunhitloc
Definition: tracing.qh:82
float autocvar_g_ballistics_density_corpse
Definition: tracing.qh:6
int autocvar_g_projectiles_spread_style
Definition: tracing.qh:14
float autocvar_g_ballistics_density_player
Definition: tracing.qh:7
float ballistics_density
Definition: tracing.qh:77
vector w_shotend
Definition: tracing.qh:20
vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute)
Definition: tracing.qc:169
Definition: sound.qh:119
void WarpZone_crosshair_trace(entity pl)
Definition: tracing.qc:544
void traceline_antilag(entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
Definition: antilag.qc:203
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_g_ballistics_solidpenetration_exponent
Definition: tracing.qh:10
void crosshair_trace_plusvisibletriggers__is_wz(entity pl, bool is_wz)
Definition: tracing.qc:523
bool autocvar_g_ballistics_penetrate_clips
Definition: tracing.qh:9
void WarpZone_traceline_antilag(entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
Definition: antilag.qc:221
float autocvar_g_projectiles_newton_style_2_minfactor
Definition: tracing.qh:13
float railgunhitsolidbackup
Definition: tracing.qh:81
entity fireBullet_trace_callback_eff
Definition: tracing.qh:91
vector railgunforce
Definition: tracing.qh:88
int dir
Definition: impulse.qc:89
entity fireBullet_last_hit
Definition: tracing.qh:92
bool autocvar_g_norecoil
Definition: tracing.qh:15
void crosshair_trace_plusvisibletriggers(entity pl)
Definition: tracing.qc:513