This mutator's replacements run BEFORE regular weaponreplace!
- The New Toys guns do NOT get a spawn function, so they can only ever be spawned
- when this mutator is active.
+The New Toys guns do NOT get a spawn function, so they can only ever be spawned
+when this mutator is active.
Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
this mutator is active.
This mutator performs the default replacements on the DEFAULTS of the
start weapon selection.
- These weapons appear in the menu's priority list, BUT get a suffix
- "(Mutator weapon)".
+These weapons appear in the menu's priority list, BUT get a suffix
+"(Mutator weapon)".
- Picking up a "new toys" weapon will not play standard weapon pickup sound, but
- roflsound "New toys, new toys!" sound.
+Picking up a "new toys" weapon will not play standard weapon pickup sound, but
+roflsound "New toys, new toys!" sound.
*/
-float autocvar_g_new_toys_autoreplace = 2; // 0 = never, 1 = always, 2 = random
+.string new_toys;
+
+float autocvar_g_new_toys_autoreplace;
+#define NT_AUTOREPLACE_NEVER 0
+#define NT_AUTOREPLACE_ALWAYS 1
+#define NT_AUTOREPLACE_RANDOM 2
MUTATOR_HOOKFUNCTION(nt_SetModname)
{
return 0;
}
+float nt_IsNewToy(float w)
+{
+ switch(w)
+ {
+ case WEP_SEEKER:
+ case WEP_MINE_LAYER:
+ case WEP_HLAC:
+ case WEP_RIFLE:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
string nt_GetFullReplacement(string w)
{
switch(w)
string nt_GetReplacement(string w, float m)
{
- if(m == 0)
+ if(m == NT_AUTOREPLACE_NEVER)
return w;
string s = nt_GetFullReplacement(w);
if not(s)
return w;
- if(m == 2)
+ if(m == NT_AUTOREPLACE_RANDOM)
s = strcat(w, " ", s);
return s;
}
// map defined replacement:
ret_string = self.new_toys;
}
- else if(autocvar_g_new_toys_autoreplace)
+ else
{
// auto replacement:
ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
}
- else
- {
- ret_string = other.netname;
- }
// apply regular weaponreplace
ret_string = W_Apply_Weaponreplace(ret_string);
return 0;
}
+MUTATOR_HOOKFUNCTION(nt_FilterItem)
+{
+ if(nt_IsNewToy(self.weapon))
+ self.item_pickupsound = "weapons/weaponpickup_new_toys.wav";
+ return 0;
+}
+
MUTATOR_DEFINITION(mutator_new_toys)
{
MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY);
MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST);
+ MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY);
MUTATOR_ONADD
{
if(time > 1) // game loads at time 1
error("This cannot be added at runtime\n");
- // mark all guns as ok to use by e.g. impulse 99
+ precache_sound("weapons/weaponpickup_new_toys.wav");
+
+ // mark the guns as ok to use by e.g. impulse 99
float i;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- {
- entity e = get_weaponinfo(i);
- if(e.weapon)
- e.spawnflags &~= WEP_FLAG_MUTATORBLOCKED;
- }
+ if(nt_IsNewToy(i))
+ get_weaponinfo(i).spawnflags &~= WEP_FLAG_MUTATORBLOCKED;
}
+
+ MUTATOR_ONROLLBACK_OR_REMOVE
+ {
+ float i;
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+ if(nt_IsNewToy(i))
+ get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+ }
+
MUTATOR_ONREMOVE
{
- error("This cannot be removed at runtime\n");
+ print("This cannot be removed at runtime\n");
+ return -1;
}
return 0;