Xonotic
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

entity GetAmmoItem (Resource ammotype)
 
string GetAmmoName (Resource ammotype)
 
string GetAmmoPicture (Resource ammotype)
 
string W_FixWeaponOrder (string order, float complete)
 
string W_FixWeaponOrder_AllowIncomplete (entity this, string order)
 
string W_FixWeaponOrder_BuildImpulseList (string o)
 
string W_FixWeaponOrder_ForceComplete (string order)
 
string W_Model (string w_mdl)
 
string W_NameWeaponOrder (string order)
 
string W_NumberWeaponOrder (string order)
 
WepSet W_RandomWeapons (entity e, WepSet remaining, int n)
 
string W_Sound (string w_snd)
 
string W_UndeprecateName (string s)
 
int weaponslot (.entity weaponentity)
 

Variables

const int MAX_WEAPONSLOTS = 2
 
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 More...
 
const int WS_DROP = 2
 deselecting frame More...
 
const int WS_INUSE = 3
 fire state More...
 
const int WS_RAISE = 1
 raise frame More...
 
const int WS_READY = 4
 idle frame More...
 

Macro Definition Documentation

◆ SPAWNFUNC_WEAPON

#define SPAWNFUNC_WEAPON (   name,
  weapon 
)

Definition at line 143 of file weapon.qh.

Typedef Documentation

◆ WepSet

using WepSet = vector

Definition at line 11 of file weapon.qh.

Function Documentation

◆ GetAmmoItem()

entity GetAmmoItem ( Resource  ammotype)

Definition at line 234 of file all.qc.

References LOG_WARNF, NULL, STAT_CELLS, STAT_NAILS, STAT_ROCKETS, and STAT_SHELLS.

235 {
236  switch (ammotype)
237  {
238  case RES_SHELLS: return ITEM_Shells;
239  case RES_BULLETS: return ITEM_Bullets;
240  case RES_ROCKETS: return ITEM_Rockets;
241  case RES_CELLS: return ITEM_Cells;
242  case RES_PLASMA: return ITEM_Plasma;
243  case RES_FUEL: return ITEM_JetpackFuel;
244  }
245  LOG_WARNF("Invalid ammo type %d ", ammotype.m_id);
246  return NULL;
247  // WEAPONTODO: use this generic func to reduce duplication ?
248  // GetAmmoPicture GetAmmoName notif_arg_item_wepammo ammo_pickupevalfunc ?
249 }
#define LOG_WARNF(...)
Definition: log.qh:67
#define NULL
Definition: post.qh:17

◆ GetAmmoName()

string GetAmmoName ( Resource  ammotype)

Definition at line 220 of file all.qc.

Referenced by formatmessage().

221 {
222  switch (ammotype)
223  {
224  case RES_SHELLS: return ITEM_Shells.m_name;
225  case RES_BULLETS: return ITEM_Bullets.m_name;
226  case RES_ROCKETS: return ITEM_Rockets.m_name;
227  case RES_CELLS: return ITEM_Cells.m_name;
228  case RES_PLASMA: return ITEM_Plasma.m_name;
229  case RES_FUEL: return ITEM_JetpackFuel.m_name;
230  default: return "batteries";
231  }
232 }
+ Here is the caller graph for this function:

◆ GetAmmoPicture()

string GetAmmoPicture ( Resource  ammotype)

Definition at line 206 of file all.qc.

Referenced by DrawAmmoItem(), and W_DecreaseAmmo().

207 {
208  switch (ammotype)
209  {
210  case RES_SHELLS: return ITEM_Shells.m_icon;
211  case RES_BULLETS: return ITEM_Bullets.m_icon;
212  case RES_ROCKETS: return ITEM_Rockets.m_icon;
213  case RES_CELLS: return ITEM_Cells.m_icon;
214  case RES_PLASMA: return ITEM_Plasma.m_icon;
215  case RES_FUEL: return ITEM_JetpackFuel.m_icon;
216  default: return ""; // wtf, no ammo type?
217  }
218 }
+ Here is the caller graph for this function:

◆ W_FixWeaponOrder()

string W_FixWeaponOrder ( string  order,
float  complete 
)

Definition at line 95 of file all.qc.

References fixPriorityList(), WEP_FIRST, WEP_IMPULSE_BEGIN, and WEP_LAST.

Referenced by LocalCommand_sendcvar(), W_FixWeaponOrder_AllowIncomplete(), W_FixWeaponOrder_ForceComplete(), and XonoticWeaponsList_draw().

96 {
97  return fixPriorityList(order, WEP_FIRST, WEP_LAST, WEP_IMPULSE_BEGIN - WEP_FIRST, complete);
98 }
const int WEP_FIRST
Definition: all.qh:304
#define WEP_IMPULSE_BEGIN
Definition: all.qh:315
#define WEP_LAST
Definition: all.qh:305
string fixPriorityList(string order, float from, float to, float subtract, float complete)
Definition: util.qc:485
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_FixWeaponOrder_AllowIncomplete()

string W_FixWeaponOrder_AllowIncomplete ( entity  this,
string  order 
)

Definition at line 177 of file all.qc.

References W_FixWeaponOrder().

Referenced by STATIC_INIT(), and W_Model().

178 {
179  return W_FixWeaponOrder(order, 0);
180 }
string W_FixWeaponOrder(string order, float complete)
Definition: all.qc:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_FixWeaponOrder_BuildImpulseList()

string W_FixWeaponOrder_BuildImpulseList ( string  o)

Definition at line 162 of file all.qc.

References ftos(), heapsort(), NULL, strcat(), string_null, substring(), W_FixWeaponOrder_BuildImpulseList_buf, W_FixWeaponOrder_BuildImpulseList_cmp(), W_FixWeaponOrder_BuildImpulseList_order, W_FixWeaponOrder_BuildImpulseList_swap(), WEP_FIRST, and WEP_LAST.

Referenced by HUD_Weapons(), and W_Model().

163 {
164  int i;
166  for (i = WEP_FIRST; i <= WEP_LAST; ++i)
169  NULL);
170  o = "";
171  for (i = WEP_FIRST; i <= WEP_LAST; ++i)
174  return substring(o, 1, -1);
175 }
string string_null
Definition: nil.qh:9
const int WEP_FIRST
Definition: all.qh:304
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
Definition: sort.qh:9
#define WEP_LAST
Definition: all.qh:305
float W_FixWeaponOrder_BuildImpulseList_buf[REGISTRY_MAX(Weapons)]
Definition: all.qc:141
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
string W_FixWeaponOrder_BuildImpulseList_order
Definition: all.qc:142
void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
Definition: all.qc:143
float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
Definition: all.qc:150
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_FixWeaponOrder_ForceComplete()

string W_FixWeaponOrder_ForceComplete ( string  order)

Definition at line 182 of file all.qc.

References cvar_defstring(), W_FixWeaponOrder(), and W_NumberWeaponOrder().

Referenced by HUD_Weapons(), and W_Model().

183 {
184  if (order == "") order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
185  return W_FixWeaponOrder(order, 1);
186 }
string W_FixWeaponOrder(string order, float complete)
Definition: all.qc:95
string W_NumberWeaponOrder(string order)
Definition: all.qc:136
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_Model()

string W_Model ( string  w_mdl)

Definition at line 288 of file all.qc.

References alpha, angles, anim_set(), argv(), autocvar_chase_active, autocvar_r_drawviewmodel, CLIENT_COMMAND, CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, compressShotOrigin(), CS_CVAR, CSQCModel_server2csqc(), csqcplayer, decompressShotOrigin(), EF_ADDITIVE, EF_FULLBRIGHT, entity(), FOREACH, FOREACH_CLIENT, frame, gettagindex, gettaginfo, IS_REAL_CLIENT, IS_SPEC, LOG_HELP, LOG_INFOF, LOG_WARNF, M_ARGV, MASK_NORMAL, maxs, mins, model, movedir, msg_entity, MSG_ONE, MUTATOR_CALLHOOK, name, NET_HANDLE, nextthink, NULL, oldorigin, owner, player_localentnum, pointparticles, random(), ReadRegistered, realowner, REGISTER_NET_C2S, REGISTER_NET_TEMP, REGISTRY_GET, renderflags, REPLICATE(), RF_VIEWMODEL, scale, setanim, setmodel, setorigin(), setthink, shotdir, shotorg, spawn(), stov(), strcat(), strcpy, time, v, vector(), VF_CL_VIEWANGLES, view_ofs, viewmodelforclient, viewmodels, W_FixWeaponOrder_AllowIncomplete(), W_FixWeaponOrder_BuildImpulseList(), W_FixWeaponOrder_ForceComplete(), W_GunAlign(), W_Model(), Weapon_whereis(), weaponorder_byimpulse, weaponslot(), WriteByte(), WriteRegistered, WS_DROP, and WS_RAISE.

Referenced by W_Model().

289 {
290  string output = strcat("models/weapons/", w_mdl);
291  MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);
292  return M_ARGV(1, string);
293 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_NameWeaponOrder()

string W_NameWeaponOrder ( string  order)

Definition at line 125 of file all.qc.

References mapPriorityList(), and W_NameWeaponOrder_MapFunc().

Referenced by XonoticWeaponsList_draw().

126 {
128 }
string mapPriorityList(string order, string(string) mapfunc)
Definition: util.qc:527
string W_NameWeaponOrder_MapFunc(string s)
Definition: all.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_NumberWeaponOrder()

string W_NumberWeaponOrder ( string  order)

Definition at line 136 of file all.qc.

References mapPriorityList(), and W_NumberWeaponOrder_MapFunc().

Referenced by HUD_Weapons(), LocalCommand_sendcvar(), W_FixWeaponOrder_ForceComplete(), XonoticWeaponsList_draw(), and XonoticWeaponsList_toString().

137 {
139 }
string mapPriorityList(string order, string(string) mapfunc)
Definition: util.qc:527
string W_NumberWeaponOrder_MapFunc(string s)
Definition: all.qc:129
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_RandomWeapons()

WepSet W_RandomWeapons ( entity  e,
WepSet  remaining,
int  n 
)

Definition at line 188 of file all.qc.

References FOREACH, RandomSelection_AddEnt, RandomSelection_chosen_ent, RandomSelection_Init(), result, and WepSet_FromWeapon.

Referenced by MUTATOR_HOOKFUNCTION().

189 {
190  WepSet result = '0 0 0';
191  for (int j = 0; j < n; ++j)
192  {
194  FOREACH(Weapons, it != WEP_Null, {
195  if (remaining & (it.m_wepset))
196  RandomSelection_AddEnt(it, 1, 1);
197  });
199  result |= WepSet_FromWeapon(w);
200  remaining &= ~WepSet_FromWeapon(w);
201  }
202  return result;
203 }
vector WepSet
Definition: weapon.qh:11
ERASEABLE void RandomSelection_Init()
Definition: random.qc:4
entity result
Definition: promise.qc:43
#define RandomSelection_AddEnt(e, weight, priority)
Definition: random.qh:14
entity RandomSelection_chosen_ent
Definition: random.qh:5
#define WepSet_FromWeapon(it)
Definition: all.qh:38
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_Sound()

string W_Sound ( string  w_snd)

Definition at line 281 of file all.qc.

References M_ARGV, MUTATOR_CALLHOOK, and strcat().

282 {
283  string output = strcat("weapons/", w_snd);
284  MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
285  return M_ARGV(1, string);
286 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:

◆ W_UndeprecateName()

string W_UndeprecateName ( string  s)

Definition at line 110 of file all.qc.

Referenced by GiveItems(), spawnfunc(), and W_NumberWeaponOrder_MapFunc().

111 {
112  switch (s)
113  {
114  case "nex": return "vortex";
115  case "rocketlauncher": return "devastator";
116  case "laser": return "blaster";
117  case "minstanex": return "vaporizer";
118  case "grenadelauncher": return "mortar";
119  case "uzi": return "machinegun";
120  case "hmg": return "okhmg";
121  case "rpc": return "okrpc";
122  default: return s;
123  }
124 }
+ Here is the caller graph for this function:

◆ weaponslot()

int weaponslot ( .entity  weaponentity)

Definition at line 16 of file weapon.qh.

References MAX_WEAPONSLOTS, and weaponentities.

Referenced by client_hasweapon(), GrapplingHookSend(), Monster_Attack_Check(), W_Model(), W_Reload(), W_WeaponFrame(), and weapon_prepareattack_do().

17 {
18  for (int i = 0; i < MAX_WEAPONSLOTS; ++i)
19  {
20  if (weaponentities[i] == weaponentity)
21  {
22  return i;
23  }
24  }
25  return 0;
26 }
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
+ Here is the caller graph for this function:

Variable Documentation

◆ MAX_WEAPONSLOTS

◆ weaponentities

◆ weaponorder_byid

string weaponorder_byid

Definition at line 214 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 209 of file weapon.qh.

◆ WEP_FLAG_CANCLIMB

const int WEP_FLAG_CANCLIMB = BIT(3)

Definition at line 198 of file weapon.qh.

Referenced by PlayerDamage().

◆ WEP_FLAG_DUALWIELD

const int WEP_FLAG_DUALWIELD = BIT(11)

Definition at line 206 of file weapon.qh.

Referenced by client_hasweapon(), and W_WeaponFrame().

◆ WEP_FLAG_HIDDEN

const int WEP_FLAG_HIDDEN = BIT(5)

Definition at line 200 of file weapon.qh.

Referenced by HUD_Weapons(), Scoreboard_AccuracyStats_Draw(), want_weapon(), and weapons_most().

◆ WEP_FLAG_MUTATORBLOCKED

◆ WEP_FLAG_NODUAL

const int WEP_FLAG_NODUAL = BIT(12)

Definition at line 207 of file weapon.qh.

◆ WEP_FLAG_NORMAL

const int WEP_FLAG_NORMAL = BIT(4)

Definition at line 199 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 210 of file weapon.qh.

Referenced by TrueAimCheck().

◆ WEP_FLAG_PENETRATEWALLS

const int WEP_FLAG_PENETRATEWALLS = BIT(13)

Definition at line 208 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)

◆ WEP_FLAG_SUPERWEAPON

const int WEP_FLAG_SUPERWEAPON = BIT(7)

Definition at line 202 of file weapon.qh.

Referenced by STATIC_INIT(), and weapon_defaultspawnfunc().

◆ WEP_TYPE_HITSCAN

const int WEP_TYPE_HITSCAN = BIT(2)

Definition at line 197 of file weapon.qh.

◆ WEP_TYPE_MELEE_PRI

const int WEP_TYPE_MELEE_PRI = BIT(9)

Definition at line 204 of file weapon.qh.

Referenced by weapon_thinkf().

◆ WEP_TYPE_MELEE_SEC

const int WEP_TYPE_MELEE_SEC = BIT(10)

Definition at line 205 of file weapon.qh.

Referenced by weapon_thinkf().

◆ WEP_TYPE_OTHER

const int WEP_TYPE_OTHER = BIT(0)

Definition at line 195 of file weapon.qh.

Referenced by Scoreboard_AccuracyStats_Draw().

◆ WEP_TYPE_SPLASH

const int WEP_TYPE_SPLASH = BIT(1)

Definition at line 196 of file weapon.qh.

◆ WS_CLEAR

const int WS_CLEAR = 0

no weapon selected

Definition at line 30 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 34 of file weapon.qh.

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

◆ WS_INUSE

const int WS_INUSE = 3

fire state

Definition at line 36 of file weapon.qh.

Referenced by W_WeaponFrame(), and weapon_prepareattack_do().

◆ WS_RAISE

const int WS_RAISE = 1

raise frame

Definition at line 32 of file weapon.qh.

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

◆ WS_READY

const int WS_READY = 4