]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/weapons/tracing.qh
Split the W_Setup* macros
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / tracing.qh
1 #pragma once
2
3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5
6 vector w_shotorg;
7 vector w_shotdir;
8 vector w_shotend;
9
10 // this function calculates w_shotorg and w_shotdir based on the weapon model
11 // offset, trueaim and antilag, and won't put w_shotorg inside a wall.
12 // make sure you call makevectors first (FIXME?)
13 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);
14
15 #define W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
16         W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, max_shot_distance, deathtype)
17 #define W_SetupShot_ProjectileSize(ent, wepent, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype) \
18         W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype)
19 #define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype) \
20         W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
21 #define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype) \
22         W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, deathtype)
23 #define W_SetupShot_Range(ent, wepent, antilag, recoil, snd, chan, maxdamage, range, deathtype) \
24         W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range, deathtype)
25
26 vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute);
27
28 #if 0
29 float mspercallsum;
30 float mspercallsstyle;
31 float mspercallcount;
32 #endif
33
34 void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute);
35
36 #define W_SetupProjVelocity_Basic(ent,pspeed,pspread) \
37         W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, pspeed, 0, 0, pspread, false)
38
39 #define W_SetupProjVelocity_UP_PRE(ent, wepname, prefix) \
40         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)
41 #define W_SetupProjVelocity_UP_PRI(ent, wepname) \
42         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)
43 #define W_SetupProjVelocity_UP_SEC(ent, wepname) \
44         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)
45
46 #define W_SetupProjVelocity_UP_BOTH(ent, wepname, isprimary) \
47         if(isprimary) { W_SetupProjVelocity_UP_PRI(ent, wepname); } \
48         else { W_SetupProjVelocity_UP_SEC(ent, wepname); }
49
50 #define W_SetupProjVelocity_PRE(ent, wepname, prefix) \
51         W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR(wepname, prefix##speed), 0, 0, WEP_CVAR(wepname, prefix##spread), false)
52 #define W_SetupProjVelocity_PRI(ent, wepname) \
53         W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_PRI(wepname, speed), 0, 0, WEP_CVAR_PRI(wepname, spread), false)
54 #define W_SetupProjVelocity_SEC(ent, wepname) \
55         W_SetupProjVelocity_Explicit(ent, w_shotdir, v_up, WEP_CVAR_SEC(wepname, speed), 0, 0, WEP_CVAR_SEC(wepname, spread), false)
56
57 #define W_SetupProjVelocity_BOTH(ent, wepname, isprimary) \
58         if(isprimary) { W_SetupProjVelocity_PRI(ent, wepname); } \
59         else { W_SetupProjVelocity_SEC(ent, wepname); }
60
61 // ====================
62 //  Ballistics Tracing
63 // ====================
64
65 .float railgundistance;
66 .vector railgunforce;
67 void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
68
69 entity fireBullet_trace_callback_eff;
70 entity fireBullet_last_hit;
71 void fireBullet_trace_callback(vector start, vector hit, vector end);
72 void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect, bool do_antilag);
73 void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect);