3 CORE laser nex lg rl cry gl elec hagar fireb hook
7 NEW rifle hlac minel seeker
8 IDEAS OPEN flak OPEN FUN FUN FUN FUN
12 How this mutator works:
13 =======================
15 When a gun tries to spawn, this mutator is called. It will provide alternate
21 "classname" "weapon_nex"
24 -> This will spawn as Rifle in this mutator ONLY, and as Nex otherwise.
27 "classname" "weapon_nex"
28 "new_toys" "nex rifle"
30 -> This will spawn as either Nex or Rifle in this mutator ONLY, and as Nex otherwise.
33 "classname" "weapon_nex"
36 -> This is always a Nex.
38 If the map specifies no "new_toys" argument
40 There will be two default replacements selectable: "replace all" and "replace random".
41 In "replace all" mode, e.g. Nex will have the default replacement "rifle".
42 In "replace random" mode, Nex will have the default replacement "nex rifle".
44 This mutator's replacements run BEFORE regular weaponreplace!
46 The New Toys guns do NOT get a spawn function, so they can only ever be spawned
47 when this mutator is active.
49 Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
50 this mutator is active.
52 Outside this mutator, they still can be spawned by:
53 - setting their start weapon cvar to 1
56 - weaponarena (but all and most weapons arena again won't include them)
58 This mutator performs the default replacements on the DEFAULTS of the
59 start weapon selection.
61 These weapons appear in the menu's priority list, BUT get a suffix
64 Picking up a "new toys" weapon will not play standard weapon pickup sound, but
65 roflsound "New toys, new toys!" sound.
71 float autocvar_g_new_toys_autoreplace;
72 #define NT_AUTOREPLACE_NEVER 0
73 #define NT_AUTOREPLACE_ALWAYS 1
74 #define NT_AUTOREPLACE_RANDOM 2
76 MUTATOR_HOOKFUNCTION(nt_SetModname)
82 float nt_IsNewToy(float w)
84 if((get_weaponinfo(w)).weapon)
113 string nt_GetFullReplacement(string w)
117 case "hagar": return "seeker";
118 case "rocketlauncher": return "minelayer";
119 case "uzi": return "hlac";
120 case "nex": return "rifle";
121 default: return string_null;
125 string nt_GetReplacement(string w, float m)
127 if(m == NT_AUTOREPLACE_NEVER)
129 string s = nt_GetFullReplacement(w);
132 if(m == NT_AUTOREPLACE_RANDOM)
133 s = strcat(w, " ", s);
137 MUTATOR_HOOKFUNCTION(nt_SetStartItems)
139 // rearrange start_weapon_default
140 // apply those bits that are set by start_weapon_defaultmask
146 WepSet warmup_newdefault;
148 newdefault = '0 0 0';
149 warmup_newdefault = '0 0 0';
151 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
153 entity e = get_weaponinfo(i);
157 n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
159 for(j = 0; j < n; ++j)
160 for(k = WEP_FIRST; k <= WEP_LAST; ++k)
161 if(get_weaponinfo(k).netname == argv(j))
163 if(start_weapons & WepSet_FromWeapon(i))
164 newdefault |= WepSet_FromWeapon(k);
165 if(warmup_start_weapons & WepSet_FromWeapon(i))
166 warmup_newdefault |= WepSet_FromWeapon(k);
170 newdefault &= start_weapons_defaultmask;
171 start_weapons &= ~start_weapons_defaultmask;
172 start_weapons |= newdefault;
174 warmup_newdefault &= warmup_start_weapons_defaultmask;
175 warmup_start_weapons &= ~warmup_start_weapons_defaultmask;
176 warmup_start_weapons |= warmup_newdefault;
181 MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
183 // otherwise, we do replace
186 // map defined replacement:
187 ret_string = self.new_toys;
192 ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
195 // apply regular weaponreplace
196 ret_string = W_Apply_Weaponreplace(ret_string);
201 MUTATOR_HOOKFUNCTION(nt_FilterItem)
203 if(nt_IsNewToy(self.weapon))
204 self.item_pickupsound = "weapons/weaponpickup_new_toys.wav";
208 MUTATOR_DEFINITION(mutator_new_toys)
210 MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
211 MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY);
212 MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST);
213 MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY);
217 if(time > 1) // game loads at time 1
218 error("This cannot be added at runtime\n");
220 precache_sound("weapons/weaponpickup_new_toys.wav");
222 // mark the guns as ok to use by e.g. impulse 99
224 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
226 get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
228 for(i = MON_FIRST; i <= MON_LAST; ++i)
230 get_monsterinfo(i).spawnflags &= ~MON_FLAG_MUTATORBLOCKED;
233 MUTATOR_ONROLLBACK_OR_REMOVE
236 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
238 get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
240 for(i = MON_FIRST; i <= MON_LAST; ++i)
242 get_monsterinfo(i).spawnflags |= MON_FLAG_MUTATORBLOCKED;
247 print("This cannot be removed at runtime\n");