7 CORE laser vortex lg rl cry gl elec hagar fireb hook
11 NEW rifle hlac minel seeker
12 IDEAS OPEN flak OPEN FUN FUN FUN FUN
16 How this mutator works:
17 =======================
19 When a gun tries to spawn, this mutator is called. It will provide alternate
25 "classname" "weapon_vortex"
28 -> This will spawn as Rifle in this mutator ONLY, and as Vortex otherwise.
31 "classname" "weapon_vortext"
32 "new_toys" "vortex rifle"
34 -> This will spawn as either Vortex or Rifle in this mutator ONLY, and as Vortex otherwise.
37 "classname" "weapon_vortex"
40 -> This is always a Vortex.
42 If the map specifies no "new_toys" argument
44 There will be two default replacements selectable: "replace all" and "replace random".
45 In "replace all" mode, e.g. Vortex will have the default replacement "rifle".
46 In "replace random" mode, Vortex will have the default replacement "vortex rifle".
48 This mutator's replacements run BEFORE regular weaponreplace!
50 The New Toys guns do NOT get a spawn function, so they can only ever be spawned
51 when this mutator is active.
53 Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
54 this mutator is active.
56 Outside this mutator, they still can be spawned by:
57 - setting their start weapon cvar to 1
60 - weaponarena (but all and most weapons arena again won't include them)
62 This mutator performs the default replacements on the DEFAULTS of the
63 start weapon selection.
65 These weapons appear in the menu's priority list, BUT get a suffix
68 Picking up a "new toys" weapon will not play standard weapon pickup sound, but
69 roflsound "New toys, new toys!" sound.
75 float autocvar_g_new_toys_autoreplace;
76 const float NT_AUTOREPLACE_NEVER = 0;
77 const float NT_AUTOREPLACE_ALWAYS = 1;
78 const float NT_AUTOREPLACE_RANDOM = 2;
80 MUTATOR_HOOKFUNCTION(nt_SetModname)
86 float nt_IsNewToy(float w)
101 string nt_GetFullReplacement(string w)
105 case "hagar": return "seeker";
106 case "devastator": return "minelayer";
107 case "machinegun": return "hlac";
108 case "vortex": return "rifle";
109 case "shotgun": return "shockwave";
110 default: return string_null;
114 string nt_GetReplacement(string w, float m)
116 if(m == NT_AUTOREPLACE_NEVER)
118 string s = nt_GetFullReplacement(w);
121 if(m == NT_AUTOREPLACE_RANDOM)
122 s = strcat(w, " ", s);
126 MUTATOR_HOOKFUNCTION(nt_SetStartItems)
128 // rearrange start_weapon_default
129 // apply those bits that are set by start_weapon_defaultmask
135 WepSet warmup_newdefault;
137 newdefault = '0 0 0';
138 warmup_newdefault = '0 0 0';
140 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
142 entity e = get_weaponinfo(i);
146 n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
148 for(j = 0; j < n; ++j)
149 for(k = WEP_FIRST; k <= WEP_LAST; ++k)
150 if(get_weaponinfo(k).netname == argv(j))
152 if(start_weapons & WepSet_FromWeapon(i))
153 newdefault |= WepSet_FromWeapon(k);
154 if(warmup_start_weapons & WepSet_FromWeapon(i))
155 warmup_newdefault |= WepSet_FromWeapon(k);
159 newdefault &= start_weapons_defaultmask;
160 start_weapons &= ~start_weapons_defaultmask;
161 start_weapons |= newdefault;
163 warmup_newdefault &= warmup_start_weapons_defaultmask;
164 warmup_start_weapons &= ~warmup_start_weapons_defaultmask;
165 warmup_start_weapons |= warmup_newdefault;
170 MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
172 // otherwise, we do replace
175 // map defined replacement:
176 ret_string = self.new_toys;
181 ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
184 // apply regular weaponreplace
185 ret_string = W_Apply_Weaponreplace(ret_string);
190 MUTATOR_HOOKFUNCTION(nt_FilterItem)
192 if(nt_IsNewToy(self.weapon))
193 self.item_pickupsound = "weapons/weaponpickup_new_toys.wav";
197 MUTATOR_DEFINITION(mutator_new_toys)
199 MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
200 MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY);
201 MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST);
202 MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY);
206 if(time > 1) // game loads at time 1
207 error("This cannot be added at runtime\n");
209 precache_sound("weapons/weaponpickup_new_toys.wav");
211 // mark the guns as ok to use by e.g. impulse 99
213 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
215 get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
218 MUTATOR_ONROLLBACK_OR_REMOVE
221 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
223 get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
228 print("This cannot be removed at runtime\n");