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

Go to the source code of this file.

Classes

class  OffhandWeapon
class  Weapon
 fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" More...
class  WeaponPickup

Macros

#define SPAWNFUNC_WEAPON(name, weapon)

Typedefs

using WepSet = vector

Functions

void weapon_defaultspawnfunc (entity this, Weapon e)
int weaponslot (.entity weaponentity)

Variables

int autocvar_cl_tracers_teamcolor
int max_shot_distance = 32768
const int MAX_WEAPONSLOTS = 2
OffhandWeapon offhand
entity weaponentities [MAX_WEAPONSLOTS]
string weaponorder_byid
const int WEP_FLAG_BLEED = BIT(14)
const int WEP_FLAG_CANCLIMB = BIT(3)
const int WEP_FLAG_DUALWIELD = BIT(11)
const int WEP_FLAG_HIDDEN = BIT(5)
const int WEP_FLAG_MUTATORBLOCKED = BIT(8)
const int WEP_FLAG_NODUAL = BIT(12)
const int WEP_FLAG_NORMAL = BIT(4)
const int WEP_FLAG_NOTRUEAIM = BIT(15)
const int WEP_FLAG_PENETRATEWALLS = BIT(13)
const int WEP_FLAG_RELOADABLE = BIT(6)
const int WEP_FLAG_SPECIALATTACK = BIT(16)
const int WEP_FLAG_SUPERWEAPON = BIT(7)
const int WEP_TYPE_HITSCAN = BIT(2)
const int WEP_TYPE_MELEE_PRI = BIT(9)
const int WEP_TYPE_MELEE_SEC = BIT(10)
const int WEP_TYPE_OTHER = BIT(0)
const int WEP_TYPE_SPLASH = BIT(1)
const int WS_CLEAR = 0
 no weapon selected
const int WS_DROP = 2
 deselecting frame
const int WS_INUSE = 3
 fire state
const int WS_RAISE = 1
 raise frame
const int WS_READY = 4
 idle frame

Macro Definition Documentation

◆ SPAWNFUNC_WEAPON

#define SPAWNFUNC_WEAPON ( name,
weapon )
Value:
string name
Definition menu.qh:30
float weapon
Definition progsdefs.qc:139
#define spawnfunc(id)
Definition spawnfunc.qh:96
void weapon_defaultspawnfunc(entity this, Weapon e)
Definition spawning.qc:30

Definition at line 150 of file weapon.qh.

150#define SPAWNFUNC_WEAPON(name, weapon) \
151 spawnfunc(name) { weapon_defaultspawnfunc(this, weapon); }

Referenced by REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), REGISTER_WEAPON(), and REGISTER_WEAPON().

Typedef Documentation

◆ WepSet

using WepSet = vector

Definition at line 14 of file weapon.qh.

Function Documentation

◆ weapon_defaultspawnfunc()

void weapon_defaultspawnfunc ( entity this,
Weapon e )

Definition at line 30 of file spawning.qc.

31{
32 wpn = wpn.m_spawnfunc_hookreplace(wpn, this);
33 this.classname = wpn.m_canonical_spawnfunc;
34 if (!ITEM_IS_LOOT(this) && !this.m_isreplaced)
35 {
36 if (wpn.spawnflags & WEP_FLAG_MUTATORBLOCKED)
37 {
38 //LOG_WARNF("Attempted to spawn a mutator-blocked weapon rejected: prvm_edict server %i", this);
39 startitem_failed = true;
40 return;
41 }
42
43 string s = W_Apply_Weaponreplace(wpn.netname);
44 MUTATOR_CALLHOOK(SetWeaponreplace, this, wpn, s);
45 s = M_ARGV(2, string);
46 if (s == "")
47 {
48 delete(this);
49 startitem_failed = true;
50 return;
51 }
52 int t = tokenize_console(s);
53 if (t >= 2)
54 {
55 this.team = --internalteam;
56 for (int i = 1; i < t; ++i)
57 {
58 s = argv(i);
59 Weapon wep = Weapon_from_name(s);
60 if(wep != WEP_Null)
61 {
62 entity replacement = spawn();
63 Item_CopyFields(this, replacement);
64 replacement.m_isreplaced = true;
65 weapon_defaultspawnfunc(replacement, wep);
66 }
67 }
68 }
69 if (t >= 1) // always the case!
70 {
71 s = argv(0);
72 wpn = Weapon_from_name(s);
73 }
74 if (wpn == WEP_Null)
75 {
76 delete(this);
77 startitem_failed = true;
78 return;
79 }
80 }
81
82 if(!ITEM_IS_LOOT(this))
84
85 if (!Item_IsDefinitionAllowed(wpn.m_pickup))
86 {
87 delete(this);
88 startitem_failed = true;
89 return;
90 }
91
92 if (!this.respawntime)
93 {
94 if (wpn.spawnflags & WEP_FLAG_SUPERWEAPON)
95 {
98 }
99 else
100 {
103 }
104 }
105
106 if (wpn.spawnflags & WEP_FLAG_SUPERWEAPON)
107 if (!this.superweapons_finished)
109
110 // if we don't already have ammo, give us some ammo
111 // WEAPONTODO: magazines of MG, rifle and OK weapons are unaccounted for
112 if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type))
113 SetResource(this, wpn.ammo_type,
114 this.count > 0 ? rint(this.count * GetAmmoConsumption(wpn)) : WEP_CVAR(wpn, pickup_ammo));
115
116 #if 0 // WEAPONTODO
117 if (wpn.items)
118 {
119 for (int i = 0, j = 1; i < 24; ++i, j <<= 1)
120 {
121 if (wpn.items & j)
122 {
123 ammotype = Item_CounterField(j);
124 if (!this.ammotype)
125 this.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
126 }
127 }
128 }
129 #endif
130
131 // pickup anyway
133 this.pickup_anyway = true;
134
135 if(!this.owner)
136 this.glowmod = wpn.m_color;
137 else
138 this.glowmod = colormapPaletteColor(this.owner.clientcolors & 0x0F, true);
139
140 StartItem(this, wpn.m_pickup);
141
142 #if 0 // WEAPONTODO
143 if (this.modelindex) { // don't precache if this was removed
144 wpn.wr_init(wpn);
145 }
146 #endif
147}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:44
float count
Definition powerups.qc:22
entity owner
Definition main.qh:87
int team
Definition main.qh:188
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
#define M_ARGV(x, type)
Definition events.qh:17
vector weaponsInMapAll
all the weapons placed by the mapper (weaponreplace applied), ignores most filters
Definition stats.qh:55
string classname
float modelindex
#define spawn
vector glowmod
#define tokenize_console
bool Item_IsDefinitionAllowed(entity definition)
Checks whether the items with the specified definition are allowed to spawn.
Definition spawning.qc:17
#define ITEM_IS_LOOT(item)
Returns whether the item is loot.
Definition spawning.qh:39
bool startitem_failed
Definition spawning.qh:7
float cvar(string name)
float rint(float f)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void Item_CopyFields(entity this, entity to)
Definition items.qc:850
void StartItem(entity this, entity def)
Definition items.qc:1004
float autocvar_g_balance_superweapons_time
Definition items.qh:6
float respawntimejitter
Definition items.qh:31
float superweapons_finished
Definition items.qh:38
float pickup_anyway
Definition items.qh:26
float respawntime
Definition items.qh:30
int GetAmmoConsumption(entity wpn)
Returns ammo consumed per shot by the primary/default fire mode.
Weapon Weapon_from_name(string s)
Definition all.qh:144
#define WEP_CVAR(wep, name)
Definition all.qh:321
#define WepSet_FromWeapon(it)
Definition all.qh:46
bool m_isreplaced
Holds whether the weapon has been replaced.
Definition spawning.qc:11
string W_Apply_Weaponreplace(string in)
Definition spawning.qc:13
float autocvar_g_pickup_respawntimejitter_weapon
Definition spawning.qh:10
bool autocvar_g_pickup_weapons_anyway
Definition spawning.qh:6
float autocvar_g_pickup_respawntimejitter_superweapon
Definition spawning.qh:8
float autocvar_g_pickup_respawntime_weapon
Definition spawning.qh:9
float autocvar_g_pickup_respawntime_superweapon
Definition spawning.qh:7
const int WEP_FLAG_SUPERWEAPON
Definition weapon.qh:218
const int WEP_FLAG_MUTATORBLOCKED
Definition weapon.qh:219
float internalteam

References Weapon::ammo_type, argv(), autocvar_g_balance_superweapons_time, autocvar_g_pickup_respawntime_superweapon, autocvar_g_pickup_respawntime_weapon, autocvar_g_pickup_respawntimejitter_superweapon, autocvar_g_pickup_respawntimejitter_weapon, autocvar_g_pickup_weapons_anyway, classname, colormapPaletteColor, count, cvar(), entity(), GetAmmoConsumption(), GetResource(), glowmod, internalteam, Item_CopyFields(), ITEM_IS_LOOT, Item_IsDefinitionAllowed(), M_ARGV, Weapon::m_color, m_isreplaced, Weapon::m_spawnfunc_hookreplace(), modelindex, MUTATOR_CALLHOOK, Weapon::netname, owner, pickup_anyway, respawntime, respawntimejitter, rint(), SetResource(), spawn, Weapon::spawnflags, StartItem(), startitem_failed, strcat(), superweapons_finished, team, tokenize_console, W_Apply_Weaponreplace(), weapon_defaultspawnfunc(), Weapon_from_name(), weaponsInMapAll, WEP_CVAR, WEP_FLAG_MUTATORBLOCKED, WEP_FLAG_SUPERWEAPON, WepSet_FromWeapon, and Weapon::wr_init().

Referenced by Item_Initialise(), W_ThrowNewWeapon(), and weapon_defaultspawnfunc().

◆ weaponslot()

int weaponslot ( .entity weaponentity)

Definition at line 19 of file weapon.qh.

20{
21 for (int i = 0; i < MAX_WEAPONSLOTS; ++i)
22 {
23 if (weaponentities[i] == weaponentity)
24 {
25 return i;
26 }
27 }
28 return 0;
29}
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

References entity(), MAX_WEAPONSLOTS, and weaponentities.

Referenced by _wepent_send(), client_hasweapon(), GrapplingHookSend(), Monster_Attack_Check(), W_Arc_Beam_Send(), W_MuzzleFlash(), W_Reload(), W_WeaponFrame(), weapon_prepareattack_do(), and wframe_send().

Variable Documentation

◆ autocvar_cl_tracers_teamcolor

int autocvar_cl_tracers_teamcolor

Definition at line 207 of file weapon.qh.

Referenced by NET_HANDLE().

◆ max_shot_distance

◆ MAX_WEAPONSLOTS

◆ offhand

OffhandWeapon offhand

Definition at line 199 of file weapon.qh.

Referenced by client_hasweapon().

◆ weaponentities

entity weaponentities[MAX_WEAPONSLOTS]

Definition at line 17 of file weapon.qh.

Referenced by AppendItemcodes(), bot_cmd_debug_assert_canfire(), bot_cmd_select_weapon(), bumblebee_gunner_enter(), bumblebee_gunner_exit(), CheatCommand(), CL_SpawnWeaponentity(), CreatureFrame_FallDamage(), Damage(), Drag_Update(), FixIntermissionClient(), for(), formatmessage(), freezetag_Freeze(), freezetag_Unfreeze(), GameCommand_animbench(), GameCommand_gettaginfo(), GiveBall(), GiveItems(), havocbot_ai(), havocbot_movetogoal(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), IMPULSE(), Item_GiveTo(), M_Wyvern_Attack_Fireball(), Monster_Remove(), Monster_Think(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nade_ammo_touch(), NIX_GiveCurrentWeapon(), ObserverOrSpectatorThink(), OffhandHook::offhand_think(), PlayerDamage(), PlayerPreThink(), PlayerThink(), PM_check_hitground(), PM_ClientMovement_UpdateStatus(), Portal_Think(), PutObserverInServer(), PutPlayerInServer(), racer_frame(), raptor_frame(), REGISTER_MUTATOR(), RemoveGrapplingHooks(), REPLICATE_APPLYCHANGE(), Reset_ArcBeam(), reset_map(), SetSpectatee(), spawn_held_nade(), spiderbot_frame(), TEST(), Turret::tr_attack(), trigger_magicear_processmessage(), turret_initialize(), vehicles_enter(), vehicles_exit(), vehicles_spawn(), W_Devastator_Unregister(), W_DualWielding(), W_GunAlign(), W_ResetGunAlign(), W_WeaponFrame(), weapon_byid_handle(), weapon_group_handle(), weapon_prepareattack_do(), weaponslot(), and X().

◆ weaponorder_byid

string weaponorder_byid

Definition at line 230 of file weapon.qh.

Referenced by STATIC_INIT(), W_NextWeapon(), and W_PreviousWeapon().

◆ WEP_FLAG_BLEED

const int WEP_FLAG_BLEED = BIT(14)

Definition at line 225 of file weapon.qh.

Referenced by DamageEffect().

◆ WEP_FLAG_CANCLIMB

const int WEP_FLAG_CANCLIMB = BIT(3)

Definition at line 214 of file weapon.qh.

Referenced by PlayerDamage().

◆ WEP_FLAG_DUALWIELD

const int WEP_FLAG_DUALWIELD = BIT(11)

Definition at line 222 of file weapon.qh.

Referenced by client_hasweapon(), and W_WeaponFrame().

◆ WEP_FLAG_HIDDEN

◆ WEP_FLAG_MUTATORBLOCKED

◆ WEP_FLAG_NODUAL

const int WEP_FLAG_NODUAL = BIT(12)

Definition at line 223 of file weapon.qh.

◆ WEP_FLAG_NORMAL

const int WEP_FLAG_NORMAL = BIT(4)

Definition at line 215 of file weapon.qh.

Referenced by NIX_CanChooseWeapon(), want_weapon(), and weapons_most().

◆ WEP_FLAG_NOTRUEAIM

const int WEP_FLAG_NOTRUEAIM = BIT(15)

Definition at line 226 of file weapon.qh.

Referenced by TrueAimCheck().

◆ WEP_FLAG_PENETRATEWALLS

const int WEP_FLAG_PENETRATEWALLS = BIT(13)

Definition at line 224 of file weapon.qh.

Referenced by W_SetupShot_Dir_ProjectileSize_Range().

◆ WEP_FLAG_RELOADABLE

const int WEP_FLAG_RELOADABLE = BIT(6)

◆ WEP_FLAG_SPECIALATTACK

const int WEP_FLAG_SPECIALATTACK = BIT(16)

Definition at line 227 of file weapon.qh.

Referenced by Dump_Weapon_Settings(), fixPriorityList(), STATIC_INIT(), and STATIC_INIT().

◆ WEP_FLAG_SUPERWEAPON

const int WEP_FLAG_SUPERWEAPON = BIT(7)

◆ WEP_TYPE_HITSCAN

const int WEP_TYPE_HITSCAN = BIT(2)

Definition at line 213 of file weapon.qh.

◆ WEP_TYPE_MELEE_PRI

const int WEP_TYPE_MELEE_PRI = BIT(9)

Definition at line 220 of file weapon.qh.

Referenced by nade_damage(), and weapon_thinkf().

◆ WEP_TYPE_MELEE_SEC

const int WEP_TYPE_MELEE_SEC = BIT(10)

Definition at line 221 of file weapon.qh.

Referenced by nade_damage(), and weapon_thinkf().

◆ WEP_TYPE_OTHER

const int WEP_TYPE_OTHER = BIT(0)

Definition at line 211 of file weapon.qh.

Referenced by Scoreboard_AccuracyStats_Draw(), and STATIC_INIT().

◆ WEP_TYPE_SPLASH

const int WEP_TYPE_SPLASH = BIT(1)

Definition at line 212 of file weapon.qh.

◆ WS_CLEAR

const int WS_CLEAR = 0

no weapon selected

Definition at line 33 of file weapon.qh.

Referenced by viewmodel_draw(), w_clear(), and W_WeaponFrame().

◆ WS_DROP

const int WS_DROP = 2

deselecting frame

Definition at line 37 of file weapon.qh.

Referenced by NET_HANDLE(), viewmodel_draw(), and W_WeaponFrame().

◆ WS_INUSE

const int WS_INUSE = 3

fire state

Definition at line 39 of file weapon.qh.

Referenced by W_Hagar_Attack2_Load(), W_WeaponFrame(), and weapon_prepareattack_do().

◆ WS_RAISE

const int WS_RAISE = 1

raise frame

Definition at line 35 of file weapon.qh.

Referenced by NET_HANDLE(), viewmodel_draw(), W_WeaponFrame(), and weapon_thinkf().

◆ WS_READY