Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
rifle.qc File Reference
#include "rifle.qh"
#include <common/items/item/ammo.qh>
#include "vortex.qh"
Include dependency graph for rifle.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 void (Weapon thiswep, entity actor,.entity weaponentity) rifle_bullethail_attackfunc
void W_Rifle_Attack (Weapon thiswep, entity actor,.entity weaponentity)
void W_Rifle_Attack2 (Weapon thiswep, entity actor,.entity weaponentity)
void W_Rifle_BulletHail (Weapon thiswep, entity actor,.entity weaponentity, float mode, void(Weapon thiswep, entity actor,.entity weaponentity) AttackFunc, WFRAME fr, float animtime, float refire)
void W_Rifle_BulletHail_Continue (Weapon thiswep, entity actor,.entity weaponentity, int fire)
void W_Rifle_FireBullet (Weapon thiswep,.entity weaponentity, int deathtype, Sound pSound, entity actor, bool is_primary)

Variables

bool bot_secondary_riflemooth
float rifle_bullethail_animtime
WFRAME rifle_bullethail_frame
float rifle_bullethail_refire

Function Documentation

◆ void()

void ( Weapon thiswep,
entity actor,
.entity weaponentity )

References entity().

◆ W_Rifle_Attack()

void W_Rifle_Attack ( Weapon thiswep,
entity actor,
.entity weaponentity )

Definition at line 45 of file rifle.qc.

46{
47 W_Rifle_FireBullet(thiswep, weaponentity, thiswep.m_id, SND_RIFLE_FIRE, actor, true);
48}
int m_id
Definition weapon.qh:43
void W_Rifle_FireBullet(Weapon thiswep,.entity weaponentity, int deathtype, Sound pSound, entity actor, bool is_primary)
Definition rifle.qc:5

References entity(), Weapon::m_id, and W_Rifle_FireBullet().

◆ W_Rifle_Attack2()

void W_Rifle_Attack2 ( Weapon thiswep,
entity actor,
.entity weaponentity )

Definition at line 50 of file rifle.qc.

51{
52 W_Rifle_FireBullet(thiswep, weaponentity, thiswep.m_id | HITTYPE_SECONDARY, SND_RIFLE_FIRE2, actor, false);
53}
const int HITTYPE_SECONDARY
Definition all.qh:29

References entity(), HITTYPE_SECONDARY, Weapon::m_id, and W_Rifle_FireBullet().

◆ W_Rifle_BulletHail()

void W_Rifle_BulletHail ( Weapon thiswep,
entity actor,
.entity weaponentity,
float mode,
void(Weapon thiswep, entity actor,.entity weaponentity) AttackFunc,
WFRAME fr,
float animtime,
float refire )

Definition at line 77 of file rifle.qc.

78{
79 // if we get here, we have at least one bullet to fire
80 AttackFunc(thiswep, actor, weaponentity);
81 if (mode)
82 {
83 // continue hail
84 actor.rifle_bullethail_attackfunc = AttackFunc;
85 actor.rifle_bullethail_frame = fr;
86 actor.rifle_bullethail_animtime = animtime;
87 actor.rifle_bullethail_refire = refire;
88 weapon_thinkf(actor, weaponentity, fr, animtime, W_Rifle_BulletHail_Continue);
89 }
90 else // just one shot
91 weapon_thinkf(actor, weaponentity, fr, animtime, w_ready);
92}
void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor,.entity weaponentity, int fire)
Definition rifle.qc:59
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)

References entity(), w_ready(), W_Rifle_BulletHail_Continue(), and weapon_thinkf().

◆ W_Rifle_BulletHail_Continue()

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

Definition at line 59 of file rifle.qc.

60{
61 Weapon sw = actor.(weaponentity).m_switchweapon; // make it not detect weapon changes as reason to abort firing
62 float af = ATTACK_FINISHED(actor, weaponentity);
63 actor.(weaponentity).m_switchweapon = actor.(weaponentity).m_weapon;
64 ATTACK_FINISHED(actor, weaponentity) = time;
65 float r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
66 if (actor.(weaponentity).m_switchweapon == actor.(weaponentity).m_weapon)
67 actor.(weaponentity).m_switchweapon = sw;
68 if (r)
69 {
70 actor.rifle_bullethail_attackfunc(thiswep, actor, weaponentity);
71 weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
72 }
73 else
74 ATTACK_FINISHED(actor, weaponentity) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
75}
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:42
float time
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
#define ATTACK_FINISHED(ent, w)
Weapon m_switchweapon
Definition wepent.qh:25

References ATTACK_FINISHED, entity(), m_switchweapon, time, W_Rifle_BulletHail_Continue(), weapon_prepareattack(), and weapon_thinkf().

Referenced by W_Rifle_BulletHail(), and W_Rifle_BulletHail_Continue().

◆ W_Rifle_FireBullet()

void W_Rifle_FireBullet ( Weapon thiswep,
.entity weaponentity,
int deathtype,
Sound pSound,
entity actor,
bool is_primary )

Definition at line 5 of file rifle.qc.

6{
7 float dmg = WEP_CVAR_BOTH(WEP_RIFLE, is_primary, damage);
8 float shots = WEP_CVAR_BOTH(WEP_RIFLE, is_primary, shots);
9
10 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_BOTH(WEP_RIFLE, is_primary, ammo), weaponentity);
11
12 W_SetupShot(actor, weaponentity, true, 2, pSound, CH_WEAPON_A, dmg * shots, deathtype);
13
14 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir * 2);
15
16 if (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) // if zoomed, shoot from the eye
17 {
19 w_shotorg = actor.origin + actor.view_ofs + ((w_shotorg - actor.origin - actor.view_ofs) * v_forward) * v_forward;
20 }
21
22 for (int i = 0; i < shots; ++i)
23 fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir,
24 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, spread),
25 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, solidpenetration),
26 dmg,
27 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, damagefalloff_halflife),
28 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, damagefalloff_mindist),
29 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, damagefalloff_maxdist),
30 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, headshot_multiplier),
31 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, force),
32 WEP_CVAR_BOTH(WEP_RIFLE, is_primary, damagefalloff_forcehalflife),
33 deathtype,
34 (WEP_CVAR_BOTH(WEP_RIFLE, is_primary, tracer) ? EFFECT_RIFLE : EFFECT_RIFLE_WEAK),
35 true
36 );
37
38 if (autocvar_g_casings >= 2)
39 {
40 makevectors(actor.v_angle); // for some reason, this is lost
41 SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity);
42 }
43}
float dmg
Definition breakable.qc:12
void SpawnCasing(vector vel, vector ang, int casingtype, entity casingowner,.entity weaponentity)
Definition casings.qc:17
int autocvar_g_casings
Definition casings.qh:17
#define PHYS_INPUT_BUTTON_ZOOMSCRIPT(s)
Definition player.qh:163
#define PHYS_INPUT_BUTTON_ZOOM(s)
Definition player.qh:155
vector v_up
vector v_right
vector v_forward
float random(void)
vector vectoangles(vector v)
#define makevectors
Definition post.qh:21
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
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_BOTH(wep, isprimary, name)
Definition all.qh:340
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)

References ammo, autocvar_g_casings, CH_WEAPON_A, dmg, entity(), fireBullet_falloff(), makevectors, PHYS_INPUT_BUTTON_ZOOM, PHYS_INPUT_BUTTON_ZOOMSCRIPT, random(), SpawnCasing(), v_forward, v_right, v_up, vectoangles(), W_DecreaseAmmo(), W_MuzzleFlash(), W_SetupShot, w_shotdir, w_shotorg, and WEP_CVAR_BOTH.

Referenced by W_Rifle_Attack(), and W_Rifle_Attack2().

Variable Documentation

◆ bot_secondary_riflemooth

bool bot_secondary_riflemooth

Definition at line 94 of file rifle.qc.

◆ rifle_bullethail_animtime

float rifle_bullethail_animtime

Definition at line 57 of file rifle.qc.

◆ rifle_bullethail_frame

WFRAME rifle_bullethail_frame

Definition at line 56 of file rifle.qc.

◆ rifle_bullethail_refire

float rifle_bullethail_refire

Definition at line 58 of file rifle.qc.