Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
tracing.qh
Go to the documentation of this file.
1#pragma once
2
4#include <common/stats.qh>
5
18
22
23// this function calculates w_shotorg and w_shotdir based on the weapon model
24// offset, trueaim and antilag, and won't put w_shotorg inside a wall.
25// make sure you call makevectors first (FIXME?)
26void 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);
27
28#define W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
29 W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, max_shot_distance, deathtype)
30#define W_SetupShot_ProjectileSize(ent, wepent, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
31 W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype)
32#define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype) \
33 W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
34#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype) \
35 W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
36#define W_SetupShot_Range(ent, wepent, antilag, recoil, snd, chan, maxdamage, range, deathtype) \
37 W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range, deathtype)
38
40
41vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute);
42
43#if 0
44float mspercallsum;
45float mspercallsstyle;
46float mspercallcount;
47#endif
48
49void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute);
50
51#define W_SetupProjVelocity_Basic(ent,pspeed,pspread) \
52 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, pspeed, 0, 0, pspread, false)
53
54#define W_SetupProjVelocity_UP_PRE(ent, wep, prefix) \
55 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR(wep, prefix##speed), WEP_CVAR(wep, prefix##speed_up), WEP_CVAR(wep, prefix##speed_z), WEP_CVAR(wep, prefix##spread), false)
56#define W_SetupProjVelocity_UP_PRI(ent, wep) \
57 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_PRI(wep, speed), WEP_CVAR_PRI(wep, speed_up), WEP_CVAR_PRI(wep, speed_z), WEP_CVAR_PRI(wep, spread), false)
58#define W_SetupProjVelocity_UP_SEC(ent, wep) \
59 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_SEC(wep, speed), WEP_CVAR_SEC(wep, speed_up), WEP_CVAR_SEC(wep, speed_z), WEP_CVAR_SEC(wep, spread), false)
60
61#define W_SetupProjVelocity_UP_BOTH(ent, wep, isprimary) \
62 if (isprimary) \
63 W_SetupProjVelocity_UP_PRI(ent, wep); \
64 else \
65 W_SetupProjVelocity_UP_SEC(ent, wep);
66
67#define W_SetupProjVelocity_PRE(ent, wep, prefix) \
68 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR(wep, prefix##speed), 0, 0, WEP_CVAR(wep, prefix##spread), false)
69#define W_SetupProjVelocity_PRI(ent, wep) \
70 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_PRI(wep, speed), 0, 0, WEP_CVAR_PRI(wep, spread), false)
71#define W_SetupProjVelocity_SEC(ent, wep) \
72 W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_SEC(wep, speed), 0, 0, WEP_CVAR_SEC(wep, spread), false)
73
74#define W_SetupProjVelocity_BOTH(ent, wep, isprimary) \
75 if (isprimary) \
76 W_SetupProjVelocity_PRI(ent, wep); \
77 else \
78 W_SetupProjVelocity_SEC(ent, wep);
79
80// ====================
81// Ballistics Tracing
82// ====================
83
85
86// for railgun damage (hitting multiple enemies)
90
96
99void 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);
100
103void fireBullet_trace_callback(vector start, vector hit, vector end);
104void 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);
105void 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);
106
107void crosshair_trace(entity pl);
108
112
113void traceline_antilag(entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
114
116
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
#define IL_NEW()
vector
Definition self.qh:96
int dir
Definition impulse.qc:89
#define STATIC_INIT(func)
during worldspawn
Definition static.qh:33
vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute)
Definition tracing.qc:177
int autocvar_g_projectiles_spread_style
Definition tracing.qh:14
IntrusiveList g_railgunhit
Definition tracing.qh:91
float autocvar_g_projectiles_newton_style_2_maxfactor
Definition tracing.qh:12
float autocvar_g_trueaim_minrange
Definition tracing.qh:17
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:560
bool autocvar_g_norecoil
Definition tracing.qh:16
float autocvar_g_ballistics_mindistance
Definition tracing.qh:8
vector w_shotdir
Definition tracing.qh:20
vector railgunforce
Definition tracing.qh:98
float railgunhitsolidbackup
Definition tracing.qh:88
IntrusiveList g_ctrace_changed
Definition tracing.qh:117
float ballistics_density
Definition tracing.qh:84
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)
This function calculates w_shotorg and w_shotdir based on the weapon model offset,...
Definition tracing.qc:24
void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
Definition tracing.qc:188
float railgundistance
Definition tracing.qh:97
vector railgunhitloc
Definition tracing.qh:89
void traceline_antilag(entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
Definition antilag.qc:203
void fireBullet_trace_callback(vector start, vector hit, vector end)
Definition tracing.qc:371
int autocvar_g_hitscan_spread_style
Definition tracing.qh:15
void crosshair_trace(entity pl)
Definition tracing.qc:565
int autocvar_g_projectiles_newton_style
Definition tracing.qh:11
float autocvar_g_projectiles_newton_style_2_minfactor
Definition tracing.qh:13
void crosshair_trace_plusvisibletriggers(entity pl)
Definition tracing.qc:571
void WarpZone_crosshair_trace_plusvisibletriggers(entity pl)
Definition tracing.qc:576
void crosshair_trace_plusvisibletriggers__is_wz(entity pl, bool is_wz)
Definition tracing.qc:581
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:555
float autocvar_g_ballistics_solidpenetration_exponent
Definition tracing.qh:10
bool autocvar_g_ballistics_penetrate_clips
Definition tracing.qh:9
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:261
float autocvar_g_ballistics_density_corpse
Definition tracing.qh:6
vector w_shotorg
Definition tracing.qh:19
vector W_SetupShot_GetAlternatingOffset(int bullet_count)
Definition tracing.qc:166
entity fireBullet_trace_callback_eff
Definition tracing.qh:101
bool railgunhit
Definition tracing.qh:87
void WarpZone_crosshair_trace(entity pl)
Definition tracing.qc:602
float autocvar_g_ballistics_density_player
Definition tracing.qh:7
entity fireBullet_last_hit
Definition tracing.qh:102
vector w_shotend
Definition tracing.qh:21