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 bool autocvar_g_new_toys_use_pickupsound = true;
77 const float NT_AUTOREPLACE_NEVER = 0;
78 const float NT_AUTOREPLACE_ALWAYS = 1;
79 const float NT_AUTOREPLACE_RANDOM = 2;
81 MUTATOR_HOOKFUNCTION(nt_SetModname)
87 float nt_IsNewToy(float w)
92 case WEP_MINE_LAYER.m_id:
95 case WEP_SHOCKWAVE.m_id:
102 string nt_GetFullReplacement(string w)
106 case "hagar": return "seeker";
107 case "devastator": return "minelayer";
108 case "machinegun": return "hlac";
109 case "vortex": return "rifle";
110 //case "shotgun": return "shockwave";
111 default: return string_null;
115 string nt_GetReplacement(string w, float m)
117 if(m == NT_AUTOREPLACE_NEVER)
119 string s = nt_GetFullReplacement(w);
122 if(m == NT_AUTOREPLACE_RANDOM)
123 s = strcat(w, " ", s);
127 MUTATOR_HOOKFUNCTION(nt_SetStartItems)
129 // rearrange start_weapon_default
130 // apply those bits that are set by start_weapon_defaultmask
136 WepSet warmup_newdefault;
138 newdefault = '0 0 0';
139 warmup_newdefault = '0 0 0';
141 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
143 entity e = get_weaponinfo(i);
147 n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
149 for(j = 0; j < n; ++j)
150 for(k = WEP_FIRST; k <= WEP_LAST; ++k)
151 if(get_weaponinfo(k).netname == argv(j))
153 if(start_weapons & WepSet_FromWeapon(i))
154 newdefault |= WepSet_FromWeapon(k);
155 if(warmup_start_weapons & WepSet_FromWeapon(i))
156 warmup_newdefault |= WepSet_FromWeapon(k);
160 newdefault &= start_weapons_defaultmask;
161 start_weapons &= ~start_weapons_defaultmask;
162 start_weapons |= newdefault;
164 warmup_newdefault &= warmup_start_weapons_defaultmask;
165 warmup_start_weapons &= ~warmup_start_weapons_defaultmask;
166 warmup_start_weapons |= warmup_newdefault;
171 MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
173 // otherwise, we do replace
176 // map defined replacement:
177 ret_string = self.new_toys;
182 ret_string = nt_GetReplacement(other.netname, autocvar_g_new_toys_autoreplace);
185 // apply regular weaponreplace
186 ret_string = W_Apply_Weaponreplace(ret_string);
191 MUTATOR_HOOKFUNCTION(nt_FilterItem)
193 if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
194 self.item_pickupsound = string_null;
195 self.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;
200 MUTATOR_DEFINITION(mutator_new_toys)
202 MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
203 MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY);
204 MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST);
205 MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY);
209 if(time > 1) // game loads at time 1
210 error("This cannot be added at runtime\n");
212 // mark the guns as ok to use by e.g. impulse 99
214 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
216 get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
219 MUTATOR_ONROLLBACK_OR_REMOVE
222 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
224 get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
229 LOG_INFO("This cannot be removed at runtime\n");