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

Go to the source code of this file.

Functions

string W_Apply_Weaponreplace (string in)
void weapon_defaultspawnfunc (entity this, Weapon wpn)

Variables

float autocvar_g_pickup_respawntime_superweapon
float autocvar_g_pickup_respawntime_weapon
float autocvar_g_pickup_respawntimejitter_superweapon
float autocvar_g_pickup_respawntimejitter_weapon
bool autocvar_g_pickup_weapons_anyway

Function Documentation

◆ W_Apply_Weaponreplace()

string W_Apply_Weaponreplace ( string in)

Definition at line 13 of file spawning.qc.

14{
15 string out = "";
16 FOREACH_WORD(in, true,
17 {
18 string replacement = "";
20 if (w)
21 replacement = (w.weaponreplace != "") ? w.weaponreplace : it;
22 if (replacement == "0")
23 continue;
24 out = cons(out, replacement);
25 });
26 return out;
27}
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:36
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
ERASEABLE string cons(string a, string b)
Definition string.qh:277
Weapon Weapon_from_name(string s)
Definition all.qh:145

References cons(), FOREACH_WORD, and Weapon_from_name().

Referenced by MUTATOR_HOOKFUNCTION(), and weapon_defaultspawnfunc().

◆ weapon_defaultspawnfunc()

void weapon_defaultspawnfunc ( entity this,
Weapon wpn )

Definition at line 29 of file spawning.qc.

30{
31 wpn = wpn.m_spawnfunc_hookreplace(wpn, this);
32 this.classname = wpn.m_canonical_spawnfunc;
33 if (!ITEM_IS_LOOT(this) && !this.m_isreplaced)
34 {
36 {
37 //LOG_WARNF("Attempted to spawn a mutator-blocked weapon rejected: prvm_edict server %i", this);
38 delete(this);
39 return;
40 }
41
42 string s = W_Apply_Weaponreplace(wpn.netname);
43 MUTATOR_CALLHOOK(SetWeaponreplace, this, wpn, s);
44 s = M_ARGV(2, string);
45 if (s == "")
46 {
47 delete(this);
48 return;
49 }
50 int t = tokenize_console(s);
51 if (t >= 2)
52 {
53 this.team = --internalteam;
54 for (int i = 1; i < t; ++i)
55 {
56 s = argv(i);
57 Weapon wep = Weapon_from_name(s);
58 if (wep != WEP_Null)
59 {
60 entity replacement = spawn();
61 Item_CopyFields(this, replacement);
62 replacement.m_isreplaced = true;
63 weapon_defaultspawnfunc(replacement, wep);
64 }
65 }
66 }
67 if (t >= 1) // always the case!
68 {
69 s = argv(0);
70 wpn = Weapon_from_name(s);
71 }
72 if (wpn == WEP_Null)
73 {
74 delete(this);
75 return;
76 }
77 }
78
79 if (!ITEM_IS_LOOT(this))
81
82 if (!Item_IsDefinitionAllowed(wpn.m_pickup))
83 {
84 delete(this);
85 return;
86 }
87
88 if (!this.respawntime)
89 {
91 {
94 }
95 else
96 {
99 }
100 }
101
103 && !this.superweapons_finished)
105
106 // if we don't already have ammo, give us some ammo
107 // WEAPONTODO: magazines of MG, rifle and OK weapons are unaccounted for
108 if (wpn.ammo_type != RES_NONE && !GetResource(this, wpn.ammo_type))
109 SetResource(this, wpn.ammo_type,
110 this.count > 0 ? rint(this.count * GetAmmoConsumption(wpn)) : WEP_CVAR(wpn, pickup_ammo));
111
112 #if 0 // WEAPONTODO
113 if (wpn.items)
114 for (int i = 0, j = 1; i < 24; ++i, j <<= 1)
115 if (wpn.items & j)
116 {
117 ammotype = Item_CounterField(j);
118 if (!this.ammotype)
119 this.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
120 }
121 #endif
122
123 // pickup anyway
125 this.pickup_anyway = true;
126
127 this.glowmod = wpn.m_color;
128
129 this.itemdef = wpn.m_pickup;
130
131 #if 0 // WEAPONTODO
132 if (this.modelindex) // don't precache if this was removed
133 wpn.wr_init(wpn);
134 #endif
135}
#define MUTATOR_CALLHOOK(name,...)
Definition base.qh:186
#define M_ARGV(idx, type)
Definition base.qh:153
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.
virtual void m_spawnfunc_hookreplace()
control what happens when this weapon is spawned
Definition weapon.qh:42
Resource ammo_type
M: ammotype : main ammo type.
Definition weapon.qh:50
vector m_color
M: color : waypointsprite color.
Definition weapon.qh:56
string netname
M: refname : reference name name.
Definition weapon.qh:78
int spawnflags
M: flags : WEPSPAWNFLAG_... combined.
Definition weapon.qh:54
virtual void wr_init()
(BOTH) precaches models/sounds used by this weapon, also sets up weapon properties
Definition weapon.qh:108
float count
Definition powerups.qc:22
int team
Definition main.qh:188
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:37
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:852
float autocvar_g_balance_superweapons_time
Definition items.qh:7
float respawntimejitter
Definition items.qh:32
entity itemdef
Definition items.qh:92
float superweapons_finished
Definition items.qh:39
float pickup_anyway
Definition items.qh:27
float respawntime
Definition items.qh:31
int GetAmmoConsumption(entity wpn)
Returns ammo consumed per shot by the primary/default fire mode.
#define WEP_CVAR(wep, name)
Definition all.qh:339
#define WepSet_FromWeapon(it)
Definition all.qh:48
void weapon_defaultspawnfunc(entity this, Weapon wpn)
Definition spawning.qc:29
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
powerup timer
Definition weapon.qh:254
const int WEP_FLAG_MUTATORBLOCKED
hides from impulse 99 etc. (mutators are allowed to clear this flag)
Definition weapon.qh:255
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, count, cvar(), entity(), GetAmmoConsumption(), GetResource(), glowmod, internalteam, Item_CopyFields(), ITEM_IS_LOOT, Item_IsDefinitionAllowed(), itemdef, M_ARGV, Weapon::m_color, m_isreplaced, Weapon::m_spawnfunc_hookreplace(), modelindex, MUTATOR_CALLHOOK, Weapon::netname, pickup_anyway, respawntime, respawntimejitter, rint(), SetResource(), spawn, Weapon::spawnflags, 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 StartItem(), and weapon_defaultspawnfunc().

Variable Documentation

◆ autocvar_g_pickup_respawntime_superweapon

float autocvar_g_pickup_respawntime_superweapon

Definition at line 7 of file spawning.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and weapon_defaultspawnfunc().

◆ autocvar_g_pickup_respawntime_weapon

float autocvar_g_pickup_respawntime_weapon

Definition at line 9 of file spawning.qh.

Referenced by weapon_defaultspawnfunc().

◆ autocvar_g_pickup_respawntimejitter_superweapon

float autocvar_g_pickup_respawntimejitter_superweapon

Definition at line 8 of file spawning.qh.

Referenced by weapon_defaultspawnfunc().

◆ autocvar_g_pickup_respawntimejitter_weapon

float autocvar_g_pickup_respawntimejitter_weapon

Definition at line 10 of file spawning.qh.

Referenced by weapon_defaultspawnfunc().

◆ autocvar_g_pickup_weapons_anyway

bool autocvar_g_pickup_weapons_anyway

Definition at line 6 of file spawning.qh.

Referenced by weapon_defaultspawnfunc().