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

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (nt, FilterItem)
 MUTATOR_HOOKFUNCTION (nt, SetStartItems)
 MUTATOR_HOOKFUNCTION (nt, SetWeaponreplace)
string nt_GetFullReplacement (string w)
string nt_GetReplacement (string w, float m)
 REGISTER_MUTATOR (nt, expr_evaluate(cvar_string("g_new_toys")) &&!MUTATOR_IS_ENABLED(mutator_instagib) &&!MUTATOR_IS_ENABLED(ok))

Variables

float autocvar_g_new_toys_autoreplace
bool autocvar_g_new_toys_use_pickupsound = false
string new_toys
const float NT_AUTOREPLACE_ALWAYS = 1
const float NT_AUTOREPLACE_NEVER = 0
const float NT_AUTOREPLACE_RANDOM = 2

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/3]

MUTATOR_HOOKFUNCTION ( nt ,
FilterItem  )

Definition at line 210 of file sv_new_toys.qc.

211{
212 entity item = M_ARGV(0, entity);
213
215 item.item_pickupsound = string_null;
216 item.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;
217 }
218}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
bool nt_IsNewToy(int w)
Definition new_toys.qc:6
string string_null
Definition nil.qh:9
bool autocvar_g_new_toys_use_pickupsound

References autocvar_g_new_toys_use_pickupsound, entity(), M_ARGV, nt_IsNewToy(), and string_null.

◆ MUTATOR_HOOKFUNCTION() [2/3]

MUTATOR_HOOKFUNCTION ( nt ,
SetStartItems  )

Definition at line 141 of file sv_new_toys.qc.

142{
143 // rearrange start_weapon_default
144 // apply those bits that are set by start_weapon_defaultmask
145 // same for warmup
146
147 float j, n;
148
149 WepSet newdefault;
150 WepSet warmup_newdefault;
151
152 newdefault = '0 0 0';
153 warmup_newdefault = '0 0 0';
154
155 WepSet seti = '0 0 0';
156
157 FOREACH(Weapons, it != WEP_Null, {
158 seti = it.m_wepset;
160
161 for(j = 0; j < n; ++j)
162 FOREACH(Weapons, it != WEP_Null, {
163 if(it.netname == argv(j))
164 {
165 WepSet setk = it.m_wepset;
166 if(start_weapons & seti) newdefault |= setk;
167 if(warmup_start_weapons & seti) warmup_newdefault |= setk;
168 }
169 });
170 });
171
172 newdefault &= start_weapons_defaultmask;
174 start_weapons |= newdefault;
175
176 warmup_newdefault &= warmup_start_weapons_defaultmask;
178 warmup_start_weapons |= warmup_newdefault;
179}
#define tokenize_console
Weapons
Definition guide.qh:113
#define FOREACH(list, cond, body)
Definition iter.qh:19
string argv(float n)
float autocvar_g_new_toys_autoreplace
string nt_GetReplacement(string w, float m)
vector WepSet
Definition weapon.qh:14
WepSet start_weapons
Definition world.qh:80
WepSet start_weapons_defaultmask
Definition world.qh:82
WepSet warmup_start_weapons_defaultmask
Definition world.qh:100
WepSet warmup_start_weapons
Definition world.qh:98

References argv(), autocvar_g_new_toys_autoreplace, FOREACH, nt_GetReplacement(), start_weapons, start_weapons_defaultmask, tokenize_console, warmup_start_weapons, warmup_start_weapons_defaultmask, and Weapons.

◆ MUTATOR_HOOKFUNCTION() [3/3]

MUTATOR_HOOKFUNCTION ( nt ,
SetWeaponreplace  )

Definition at line 181 of file sv_new_toys.qc.

182{
183 if (MUTATOR_IS_ENABLED(random_items))
184 {
185 // Do not replace weapons when random items are enabled.
186 return;
187 }
188 entity wep = M_ARGV(0, entity);
189 entity wepinfo = M_ARGV(1, entity);
190 string ret_string = M_ARGV(2, string);
191
192 // otherwise, we do replace
193 if(wep.new_toys)
194 {
195 // map defined replacement:
196 ret_string = wep.new_toys;
197 }
198 else
199 {
200 // auto replacement:
201 ret_string = nt_GetReplacement(wepinfo.netname, autocvar_g_new_toys_autoreplace);
202 }
203
204 // apply regular weaponreplace
205 ret_string = W_Apply_Weaponreplace(ret_string);
206
207 M_ARGV(2, string) = ret_string;
208}
#define MUTATOR_IS_ENABLED(this)
Definition base.qh:193
string W_Apply_Weaponreplace(string in)
Definition spawning.qc:13

References autocvar_g_new_toys_autoreplace, entity(), M_ARGV, MUTATOR_IS_ENABLED, nt_GetReplacement(), and W_Apply_Weaponreplace().

◆ nt_GetFullReplacement()

string nt_GetFullReplacement ( string w)

Definition at line 117 of file sv_new_toys.qc.

118{
119 switch(w)
120 {
121 case "hagar": return "seeker";
122 case "devastator": return "minelayer";
123 case "machinegun": return "hlac";
124 case "vortex": return "rifle";
125 default: return string_null;
126 }
127}

References string_null.

Referenced by nt_GetReplacement().

◆ nt_GetReplacement()

string nt_GetReplacement ( string w,
float m )

Definition at line 129 of file sv_new_toys.qc.

130{
131 if(m == NT_AUTOREPLACE_NEVER)
132 return w;
133 string s = nt_GetFullReplacement(w);
134 if (!s)
135 return w;
136 if(m == NT_AUTOREPLACE_RANDOM)
137 s = strcat(w, " ", s);
138 return s;
139}
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
string nt_GetFullReplacement(string w)
const float NT_AUTOREPLACE_NEVER
const float NT_AUTOREPLACE_RANDOM

References NT_AUTOREPLACE_NEVER, NT_AUTOREPLACE_RANDOM, nt_GetFullReplacement(), and strcat().

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( nt ,
expr_evaluate(cvar_string("g_new_toys")) &&!MUTATOR_IS_ENABLED(mutator_instagib) &&!MUTATOR_IS_ENABLED(ok)  )

Definition at line 78 of file sv_new_toys.qc.

79{
81 {
82 if(time > 1) // game loads at time 1
83 error("This cannot be added at runtime\n");
84
85 // mark the guns as ok to use by e.g. impulse 99
86 FOREACH(Weapons, it != WEP_Null, {
87 if(nt_IsNewToy(it.m_id))
88 it.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
89 });
90 }
91
93 {
94 FOREACH(Weapons, it != WEP_Null, {
95 if(nt_IsNewToy(it.m_id))
96 it.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
97 });
98 }
99
101 {
102 LOG_INFO("This cannot be removed at runtime");
103 return -1;
104 }
105
106 return 0;
107}
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_ONROLLBACK_OR_REMOVE
Definition base.qh:311
#define MUTATOR_ONREMOVE
Definition base.qh:310
float time
#define LOG_INFO(...)
Definition log.qh:65
#define error
Definition pre.qh:6
const int WEP_FLAG_MUTATORBLOCKED
Definition weapon.qh:219

References error, FOREACH, LOG_INFO, MUTATOR_ONADD, MUTATOR_ONREMOVE, MUTATOR_ONROLLBACK_OR_REMOVE, nt_IsNewToy(), time, Weapons, and WEP_FLAG_MUTATORBLOCKED.

Variable Documentation

◆ autocvar_g_new_toys_autoreplace

float autocvar_g_new_toys_autoreplace

Definition at line 111 of file sv_new_toys.qc.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ autocvar_g_new_toys_use_pickupsound

bool autocvar_g_new_toys_use_pickupsound = false

Definition at line 112 of file sv_new_toys.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ new_toys

string new_toys

Definition at line 109 of file sv_new_toys.qc.

◆ NT_AUTOREPLACE_ALWAYS

const float NT_AUTOREPLACE_ALWAYS = 1

Definition at line 114 of file sv_new_toys.qc.

◆ NT_AUTOREPLACE_NEVER

const float NT_AUTOREPLACE_NEVER = 0

Definition at line 113 of file sv_new_toys.qc.

Referenced by nt_GetReplacement().

◆ NT_AUTOREPLACE_RANDOM

const float NT_AUTOREPLACE_RANDOM = 2

Definition at line 115 of file sv_new_toys.qc.

Referenced by nt_GetReplacement().