Xonotic
weaponsystem.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <common/weapons/all.qh>
4 
10 
11 #define INDEPENDENT_ATTACK_FINISHED 1
12 
13 // there is 2 weapon tics that can run in one server frame
14 const int W_TICSPERFRAME = 2;
15 
16 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
18 .void(Weapon thiswep, entity actor, .entity weaponentity, int fire) weapon_think;
19 
22 
23 // reset to 0 on weapon switch
24 // may be useful to all weapons
26 
28 
29 .float weapon_load[REGISTRY_MAX(Weapons)];
30 .int ammo_none; // used by the reloading system, must always be 0
31 .int clip_load;
33 .int clip_size;
34 
37 #if INDEPENDENT_ATTACK_FINISHED
38 #define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).(attack_finished_for[((w) - WEP_FIRST) * MAX_WEAPONSLOTS + (slot)]))
39 #else
40 #define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot])
41 #endif
42 #define ATTACK_FINISHED(ent, w) ATTACK_FINISHED_FOR(ent, ent.(w).m_weapon.m_id, weaponslot(w))
43 
44 void CL_SpawnWeaponentity(entity e, .entity weaponentity);
45 
46 void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
47 
48 void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
49 
50 vector CL_Weapon_GetShotOrg(float wpn);
51 
52 bool weaponUseForbidden(entity player);
53 bool weaponLocked(entity player);
54 
55 void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset);
56 
57 void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity);
58 
59 void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity);
60 
61 void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound);
62 
63 void W_ResetGunAlign(entity player, int preferred_alignment);
64 
65 void W_WeaponFrame(Player actor, .entity weaponentity);
66 
67 float W_WeaponRateFactor(entity this);
68 
69 float W_WeaponSpeedFactor(entity this);
70 
71 bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime);
72 
73 bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, float secondary, float attacktime);
74 
75 void weapon_prepareattack_do(entity actor, .entity weaponentity, float secondary, float attacktime);
76 
77 void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
78 
79 //REPLICATE_APPLYCHANGE("cl_gunalign", { W_ResetGunAlign(this, store.cvar_cl_gunalign); });
void weapon_prepareattack_do(entity actor,.entity weaponentity, float secondary, float attacktime)
void W_AttachToShotorg(entity actor,.entity weaponentity, entity flash, vector offset)
float weapon_load[REGISTRY_MAX(Weapons)]
Definition: weaponsystem.qh:29
int clip_size
Definition: weaponsystem.qh:33
float autocvar_g_weaponratefactor
Definition: weaponsystem.qh:8
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)
entity() spawn
bool weaponLocked(entity player)
void W_DropEvent(.void(Weapon, entity actor,.entity) event, entity player, float weapon_type, entity weapon_item,.entity weaponentity)
entity weaponentity_fld
Definition: weaponsystem.qh:27
void W_WeaponFrame(Player actor,.entity weaponentity)
bool weaponUseForbidden(entity player)
bool weapon_prepareattack_check(Weapon thiswep, entity actor,.entity weaponentity, float secondary, float attacktime)
float bulletcounter
Definition: weaponsystem.qh:25
void W_ResetGunAlign(entity player, int preferred_alignment)
float autocvar_g_weapondamagefactor
Definition: weaponsystem.qh:7
float weapon_nextthink
Definition: weaponsystem.qh:17
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
entity weapon_dropevent_item
Definition: weaponsystem.qh:21
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
int ammo_none
Definition: weaponsystem.qh:30
float W_WeaponSpeedFactor(entity this)
Definition: weaponsystem.qc:45
int clip_load
Definition: weaponsystem.qh:31
#define REGISTRY_MAX(id)
Definition: registry.qh:17
Definition: sound.qh:119
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
float autocvar_g_weaponforcefactor
Definition: weaponsystem.qh:6
void w_clear(Weapon thiswep, entity actor,.entity weaponentity, int fire)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_g_weaponspreadfactor
Definition: weaponsystem.qh:5
void CL_SpawnWeaponentity(entity e,.entity weaponentity)
float autocvar_g_weaponspeedfactor
Definition: weaponsystem.qh:9
float attack_finished_for[REGISTRY_MAX(Weapons) *MAX_WEAPONSLOTS]
Definition: weaponsystem.qh:35
float W_WeaponRateFactor(entity this)
Definition: weaponsystem.qc:33
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
int old_clip_load
Definition: weaponsystem.qh:32
vector CL_Weapon_GetShotOrg(float wpn)
const int W_TICSPERFRAME
Definition: weaponsystem.qh:14
float attack_finished_single[MAX_WEAPONSLOTS]
Definition: weaponsystem.qh:36
float internalteam
Definition: weaponsystem.qh:20