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 isprimary)

Variables

float 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:45
void W_Rifle_FireBullet(Weapon thiswep,.entity weaponentity, int deathtype, Sound pSound, entity actor, bool isprimary)
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 81 of file rifle.qc.

82{
83 // if we get here, we have at least one bullet to fire
84 AttackFunc(thiswep, actor, weaponentity);
85 if(mode)
86 {
87 // continue hail
88 actor.rifle_bullethail_attackfunc = AttackFunc;
89 actor.rifle_bullethail_frame = fr;
90 actor.rifle_bullethail_animtime = animtime;
91 actor.rifle_bullethail_refire = refire;
92 weapon_thinkf(actor, weaponentity, fr, animtime, W_Rifle_BulletHail_Continue);
93 }
94 else
95 {
96 // just one shot
97 weapon_thinkf(actor, weaponentity, fr, animtime, w_ready);
98 }
99}
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 float r, af;
62
63 Weapon sw = actor.(weaponentity).m_switchweapon; // make it not detect weapon changes as reason to abort firing
64 af = ATTACK_FINISHED(actor, weaponentity);
65 actor.(weaponentity).m_switchweapon = actor.(weaponentity).m_weapon;
66 ATTACK_FINISHED(actor, weaponentity) = time;
67 r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
68 if(actor.(weaponentity).m_switchweapon == actor.(weaponentity).m_weapon)
69 actor.(weaponentity).m_switchweapon = sw;
70 if(r)
71 {
72 actor.rifle_bullethail_attackfunc(thiswep, actor, weaponentity);
73 weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
74 }
75 else
76 {
77 ATTACK_FINISHED(actor, weaponentity) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
78 }
79}
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:44
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 isprimary )

Definition at line 5 of file rifle.qc.

6{
7 float pAmmo = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, ammo);
8 float pDamage = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, damage);
9 float pDF_HalfLife = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, damagefalloff_halflife);
10 float pDF_ForceHalfLife = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, damagefalloff_forcehalflife);
11 float pDF_MaxDist = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, damagefalloff_maxdist);
12 float pDF_MinDist = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, damagefalloff_mindist);
13 float pForce = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, force);
14 float pHeadshotDamage = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, headshot_multiplier);
15 float pShots = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, shots);
16 float pSolidPenetration = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, solidpenetration);
17 float pSpread = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, spread);
18 float pTracer = WEP_CVAR_BOTH(WEP_RIFLE, isprimary, tracer);
19
20 W_DecreaseAmmo(thiswep, actor, pAmmo, weaponentity);
21
22 W_SetupShot(actor, weaponentity, true, 2, pSound, CH_WEAPON_A, pDamage * pShots, deathtype);
23
24 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir * 2);
25
26 if(PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) // if zoomed, shoot from the eye
27 {
29 w_shotorg = actor.origin + actor.view_ofs + ((w_shotorg - actor.origin - actor.view_ofs) * v_forward) * v_forward;
30 }
31
32 for(int i = 0; i < pShots; ++i)
33 fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, pSpread,
34 pSolidPenetration, pDamage, pDF_HalfLife, pDF_MinDist,
35 pDF_MaxDist, pHeadshotDamage, pForce, pDF_ForceHalfLife,
36 deathtype, (pTracer ? EFFECT_RIFLE : EFFECT_RIFLE_WEAK), true);
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}
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:161
#define PHYS_INPUT_BUTTON_ZOOM(s)
Definition player.qh:153
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:364
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_BOTH(wep, isprimary, name)
Definition all.qh:324
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)

References ammo, autocvar_g_casings, CH_WEAPON_A, 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

float bot_secondary_riflemooth

Definition at line 101 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.