6 CORE laser vortex lg rl cry gl elec hagar fireb hook
10 NEW rifle hlac minel seeker
11 IDEAS OPEN flak OPEN FUN FUN FUN FUN
15 How this mutator works:
16 =======================
18 When a gun tries to spawn, this mutator is called. It will provide alternate
24 "classname" "weapon_vortex"
27 -> This will spawn as Rifle in this mutator ONLY, and as Vortex otherwise.
30 "classname" "weapon_vortext"
31 "new_toys" "vortex rifle"
33 -> This will spawn as either Vortex or Rifle in this mutator ONLY, and as Vortex otherwise.
36 "classname" "weapon_vortex"
39 -> This is always a Vortex.
41 If the map specifies no "new_toys" argument
43 There will be two default replacements selectable: "replace all" and "replace random".
44 In "replace all" mode, e.g. Vortex will have the default replacement "rifle".
45 In "replace random" mode, Vortex will have the default replacement "vortex rifle".
47 This mutator's replacements run BEFORE regular weaponreplace!
49 The New Toys guns do NOT get a spawn function, so they can only ever be spawned
50 when this mutator is active.
52 Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
53 this mutator is active.
55 Outside this mutator, they still can be spawned by:
56 - setting their start weapon cvar to 1
59 - weaponarena (but all and most weapons arena again won't include them)
61 This mutator performs the default replacements on the DEFAULTS of the
62 start weapon selection.
64 These weapons appear in the menu's priority list, BUT get a suffix
67 Picking up a "new toys" weapon will not play standard weapon pickup sound, but
68 roflsound "New toys, new toys!" sound.
72 bool nt_IsNewToy(int w);
74 REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overkill"))
78 if(time > 1) // game loads at time 1
79 error("This cannot be added at runtime\n");
81 // mark the guns as ok to use by e.g. impulse 99
82 for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
84 get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
87 MUTATOR_ONROLLBACK_OR_REMOVE
89 for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
91 get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
96 LOG_INFO("This cannot be removed at runtime\n");
105 float autocvar_g_new_toys_autoreplace;
106 bool autocvar_g_new_toys_use_pickupsound = true;
107 const float NT_AUTOREPLACE_NEVER = 0;
108 const float NT_AUTOREPLACE_ALWAYS = 1;
109 const float NT_AUTOREPLACE_RANDOM = 2;
111 MUTATOR_HOOKFUNCTION(nt, SetModname)
117 bool nt_IsNewToy(int w)
121 case WEP_SEEKER.m_id:
122 case WEP_MINE_LAYER.m_id:
125 case WEP_SHOCKWAVE.m_id:
132 string nt_GetFullReplacement(string w)
136 case "hagar": return "seeker";
137 case "devastator": return "minelayer";
138 case "machinegun": return "hlac";
139 case "vortex": return "rifle";
140 //case "shotgun": return "shockwave";
141 default: return string_null;
145 string nt_GetReplacement(string w, float m)
147 if(m == NT_AUTOREPLACE_NEVER)
149 string s = nt_GetFullReplacement(w);
152 if(m == NT_AUTOREPLACE_RANDOM)
153 s = strcat(w, " ", s);
157 MUTATOR_HOOKFUNCTION(nt, SetStartItems)
159 // rearrange start_weapon_default
160 // apply those bits that are set by start_weapon_defaultmask
166 WepSet warmup_newdefault;
168 newdefault = '0 0 0';
169 warmup_newdefault = '0 0 0';
171 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
173 entity e = get_weaponinfo(i);
177 n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
179 for(j = 0; j < n; ++j)
180 for(k = WEP_FIRST; k <= WEP_LAST; ++k)
181 if(get_weaponinfo(k).netname == argv(j))
183 if(start_weapons & WepSet_FromWeapon(i))
184 newdefault |= WepSet_FromWeapon(k);
185 if(warmup_start_weapons & WepSet_FromWeapon(i))
186 warmup_newdefault |= WepSet_FromWeapon(k);
190 newdefault &= start_weapons_defaultmask;
191 start_weapons &= ~start_weapons_defaultmask;
192 start_weapons |= newdefault;
194 warmup_newdefault &= warmup_start_weapons_defaultmask;
195 warmup_start_weapons &= ~warmup_start_weapons_defaultmask;
196 warmup_start_weapons |= warmup_newdefault;
201 MUTATOR_HOOKFUNCTION(nt, SetWeaponreplace)
203 // otherwise, we do replace
206 // map defined replacement:
207 ret_string = self.new_toys;
212 ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
215 // apply regular weaponreplace
216 ret_string = W_Apply_Weaponreplace(ret_string);
221 MUTATOR_HOOKFUNCTION(nt, FilterItem)
223 if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
224 self.item_pickupsound = string_null;
225 self.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;