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

Go to the source code of this file.

Functions

void W_OverkillMachineGun_Attack_Auto (Weapon thiswep, entity actor,.entity weaponentity, int fire)

Function Documentation

◆ W_OverkillMachineGun_Attack_Auto()

void W_OverkillMachineGun_Attack_Auto ( Weapon thiswep,
entity actor,
.entity weaponentity,
int fire )

Definition at line 5 of file okmachinegun.qc.

6{
7 float okmachinegun_spread;
8
9 if(!(fire & 1))
10 {
11 w_ready(thiswep, actor, weaponentity, fire);
12 return;
13 }
14
15 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
16 if(!(actor.items & IT_UNLIMITED_AMMO))
17 {
18 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
19 w_ready(thiswep, actor, weaponentity, fire);
20 return;
21 }
22
23 W_DecreaseAmmo(WEP_OVERKILL_MACHINEGUN, actor, WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, ammo), weaponentity);
24
25 W_SetupShot(actor, weaponentity, true, 0, SND_OK_MG_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, damage), WEP_OVERKILL_MACHINEGUN.m_id);
27 {
28 actor.punchangle_x = random() - 0.5;
29 actor.punchangle_y = random() - 0.5;
30 }
31
32 okmachinegun_spread = bound(WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_min), WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_min) + (WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_max));
33
34 fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, okmachinegun_spread,
35 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, solidpenetration),
36 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, damage),
37 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_halflife),
38 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_mindist),
39 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_maxdist),
40 0,
41 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, force),
42 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_forcehalflife),
43 WEP_OVERKILL_MACHINEGUN.m_id, EFFECT_RIFLE, true);
44
45 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
46
47 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
48
49 if(autocvar_g_casings >= 2) // casing code
50 {
51 makevectors(actor.v_angle); // for some reason, this is lost
52 SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity);
53 }
54
55 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, refire) * W_WeaponRateFactor(actor);
56 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, refire), W_OverkillMachineGun_Attack_Auto);
57}
void SpawnCasing(vector vel, vector ang, int casingtype, entity casingowner,.entity weaponentity)
Definition casings.qc:17
int autocvar_g_casings
Definition casings.qh:17
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
Definition weapon.qh:92
const int IT_UNLIMITED_AMMO
Definition item.qh:23
float W_WeaponRateFactor(entity this)
vector v_up
float time
vector v_right
vector v_forward
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
Definition selection.qc:246
float bound(float min, float value, float max)
float random(void)
vector vectoangles(vector v)
void W_OverkillMachineGun_Attack_Auto(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define makevectors
Definition post.qh:21
#define w_getbestweapon(ent, wepent)
Definition selection.qh:23
float misc_bulletcounter
Definition common.qh:19
const int CH_WEAPON_A
Definition sound.qh:7
float ammo
Definition sv_turrets.qh:43
void fireBullet_falloff(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float falloff_halflife, float falloff_mindist, float falloff_maxdist, float headshot_multiplier, float force, float falloff_forcehalflife, float dtype, entity tracer_effect, bool do_antilag)
Definition tracing.qc:364
bool autocvar_g_norecoil
Definition tracing.qh:16
vector w_shotdir
Definition tracing.qh:20
vector w_shotorg
Definition tracing.qh:19
#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:34
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:728
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322
#define WEP_CVAR(wep, name)
Definition all.qh:321
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define ATTACK_FINISHED(ent, w)

References ammo, ATTACK_FINISHED, autocvar_g_casings, autocvar_g_norecoil, bound(), CH_WEAPON_A, entity(), fireBullet_falloff(), IT_UNLIMITED_AMMO, makevectors, misc_bulletcounter, random(), SpawnCasing(), time, v_forward, v_right, v_up, vectoangles(), W_DecreaseAmmo(), w_getbestweapon, W_MuzzleFlash(), W_OverkillMachineGun_Attack_Auto(), w_ready(), W_SetupShot, w_shotdir, w_shotorg, W_SwitchWeapon_Force(), W_WeaponRateFactor(), weapon_thinkf(), WEP_CVAR, WEP_CVAR_PRI, and Weapon::wr_checkammo1().

Referenced by W_OverkillMachineGun_Attack_Auto().