4 CORE laser vortex lg rl cry gl elec hagar fireb hook
8 NEW rifle hlac minel seeker
9 IDEAS OPEN flak OPEN FUN FUN FUN FUN
13 How this mutator works:
14 =======================
16 When a gun tries to spawn, this mutator is called. It will provide alternate
22 "classname" "weapon_vortex"
25 -> This will spawn as Rifle in this mutator ONLY, and as Vortex otherwise.
28 "classname" "weapon_vortext"
29 "new_toys" "vortex rifle"
31 -> This will spawn as either Vortex or Rifle in this mutator ONLY, and as Vortex otherwise.
34 "classname" "weapon_vortex"
37 -> This is always a Vortex.
39 If the map specifies no "new_toys" argument
41 There will be two default replacements selectable: "replace all" and "replace random".
42 In "replace all" mode, e.g. Vortex will have the default replacement "rifle".
43 In "replace random" mode, Vortex will have the default replacement "vortex rifle".
45 This mutator's replacements run BEFORE regular weaponreplace!
47 The New Toys guns do NOT get a spawn function, so they can only ever be spawned
48 when this mutator is active.
50 Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
51 this mutator is active.
53 Outside this mutator, they still can be spawned by:
54 - setting their start weapon cvar to 1
57 - weaponarena (but all and most weapons arena again won't include them)
59 This mutator performs the default replacements on the DEFAULTS of the
60 start weapon selection.
62 These weapons appear in the menu's priority list, BUT get a suffix
65 Picking up a "new toys" weapon will not play standard weapon pickup sound, but
66 roflsound "New toys, new toys!" sound.
70 bool nt_IsNewToy(int w);
72 REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overkill"))
76 if(time > 1) // game loads at time 1
77 error("This cannot be added at runtime\n");
79 // mark the guns as ok to use by e.g. impulse 99
80 for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
82 get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
85 MUTATOR_ONROLLBACK_OR_REMOVE
87 for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
89 get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
94 LOG_INFO("This cannot be removed at runtime\n");
103 float autocvar_g_new_toys_autoreplace;
104 bool autocvar_g_new_toys_use_pickupsound = true;
105 const float NT_AUTOREPLACE_NEVER = 0;
106 const float NT_AUTOREPLACE_ALWAYS = 1;
107 const float NT_AUTOREPLACE_RANDOM = 2;
109 MUTATOR_HOOKFUNCTION(nt, SetModname)
115 bool nt_IsNewToy(int w)
119 case WEP_SEEKER.m_id:
120 case WEP_MINE_LAYER.m_id:
123 case WEP_SHOCKWAVE.m_id:
130 string nt_GetFullReplacement(string w)
134 case "hagar": return "seeker";
135 case "devastator": return "minelayer";
136 case "machinegun": return "hlac";
137 case "vortex": return "rifle";
138 //case "shotgun": return "shockwave";
139 default: return string_null;
143 string nt_GetReplacement(string w, float m)
145 if(m == NT_AUTOREPLACE_NEVER)
147 string s = nt_GetFullReplacement(w);
150 if(m == NT_AUTOREPLACE_RANDOM)
151 s = strcat(w, " ", s);
155 MUTATOR_HOOKFUNCTION(nt, SetStartItems)
157 // rearrange start_weapon_default
158 // apply those bits that are set by start_weapon_defaultmask
164 WepSet warmup_newdefault;
166 newdefault = '0 0 0';
167 warmup_newdefault = '0 0 0';
169 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
171 entity e = get_weaponinfo(i);
175 n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
177 for(j = 0; j < n; ++j)
178 for(k = WEP_FIRST; k <= WEP_LAST; ++k)
179 if(get_weaponinfo(k).netname == argv(j))
181 if(start_weapons & WepSet_FromWeapon(i))
182 newdefault |= WepSet_FromWeapon(k);
183 if(warmup_start_weapons & WepSet_FromWeapon(i))
184 warmup_newdefault |= WepSet_FromWeapon(k);
188 newdefault &= start_weapons_defaultmask;
189 start_weapons &= ~start_weapons_defaultmask;
190 start_weapons |= newdefault;
192 warmup_newdefault &= warmup_start_weapons_defaultmask;
193 warmup_start_weapons &= ~warmup_start_weapons_defaultmask;
194 warmup_start_weapons |= warmup_newdefault;
199 MUTATOR_HOOKFUNCTION(nt, SetWeaponreplace)
201 // otherwise, we do replace
204 // map defined replacement:
205 ret_string = self.new_toys;
210 ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
213 // apply regular weaponreplace
214 ret_string = W_Apply_Weaponreplace(ret_string);
219 MUTATOR_HOOKFUNCTION(nt, FilterItem)
221 if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
222 self.item_pickupsound = string_null;
223 self.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;