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 if (!(fire & 1))
8 {
9 w_ready(thiswep, actor, weaponentity, fire);
10 return;
11 }
12
13 if (!thiswep.wr_checkammo1(thiswep, actor, weaponentity)
14 && !(actor.items & IT_UNLIMITED_AMMO))
15 {
16 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
17 w_ready(thiswep, actor, weaponentity, fire);
18 return;
19 }
20
21 W_DecreaseAmmo(WEP_OVERKILL_MACHINEGUN, actor, WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, ammo), weaponentity);
22
23 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);
25 {
26 actor.punchangle_x = random() - 0.5;
27 actor.punchangle_y = random() - 0.5;
28 }
29
30 float okmachinegun_spread = bound(
31 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_min),
32 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_min) + (WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_add) * actor.(weaponentity).misc_bulletcounter),
33 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, spread_max)
34 );
35
36 fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, okmachinegun_spread,
37 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, solidpenetration),
38 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, damage),
39 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_halflife),
40 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_mindist),
41 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_maxdist),
42 0,
43 WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, force),
44 WEP_CVAR(WEP_OVERKILL_MACHINEGUN, damagefalloff_forcehalflife),
45 WEP_OVERKILL_MACHINEGUN.m_id,
46 EFFECT_RIFLE,
47 true
48 );
49
50 ++actor.(weaponentity).misc_bulletcounter;
51
52 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
53
54 if (autocvar_g_casings >= 2) // casing code
55 {
56 makevectors(actor.v_angle); // for some reason, this is lost
57 SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity);
58 }
59
60 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, refire) * W_WeaponRateFactor(actor);
61 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_OVERKILL_MACHINEGUN, refire), W_OverkillMachineGun_Attack_Auto);
62}
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:100
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:237
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:356
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:715
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:338
#define WEP_CVAR(wep, name)
Definition all.qh:337
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().