5 float g_nix_with_blaster;
10 .float nix_lastchange_id;
11 .float nix_lastinfotime;
14 float NIX_CanChooseWeapon(float wpn)
17 e = get_weaponinfo(wpn);
18 if(!e.weapon) // skip dummies
22 if(!(g_weaponarena_weapons & WepSet_FromWeapon(wpn)))
27 if(wpn == WEP_BLASTER && g_nix_with_blaster) // WEAPONTODO: rename to g_nix_with_blaster
29 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
31 if (!(e.spawnflags & WEP_FLAG_NORMAL))
36 void NIX_ChooseNextWeapon()
39 RandomSelection_Init();
40 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
41 if(NIX_CanChooseWeapon(j))
42 RandomSelection_Add(world, j, string_null, 1, (j != nix_weapon));
43 nix_nextweapon = RandomSelection_chosen_float;
46 void NIX_GiveCurrentWeapon()
51 NIX_ChooseNextWeapon();
53 dt = ceil(nix_nextchange - time);
57 nix_weapon = nix_nextweapon;
59 if (!nix_nextchange) // no round played yet?
60 nix_nextchange = time; // start the first round now!
62 nix_nextchange = time + autocvar_g_balance_nix_roundtime;
63 //WEP_ACTION(nix_weapon, WR_INIT); // forget it, too slow
67 entity e = get_weaponinfo(nix_weapon);
69 if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
71 self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_plasma = self.ammo_fuel = 0;
73 if(self.items & IT_UNLIMITED_WEAPON_AMMO)
77 case ammo_shells: self.ammo_shells = autocvar_g_pickup_shells_max; break;
78 case ammo_nails: self.ammo_nails = autocvar_g_pickup_nails_max; break;
79 case ammo_rockets: self.ammo_rockets = autocvar_g_pickup_rockets_max; break;
80 case ammo_cells: self.ammo_cells = autocvar_g_pickup_cells_max; break;
81 case ammo_plasma: self.ammo_plasma = autocvar_g_pickup_plasma_max; break;
82 case ammo_fuel: self.ammo_fuel = autocvar_g_pickup_fuel_max; break;
89 case ammo_shells: self.ammo_shells = autocvar_g_balance_nix_ammo_shells; break;
90 case ammo_nails: self.ammo_nails = autocvar_g_balance_nix_ammo_nails; break;
91 case ammo_rockets: self.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break;
92 case ammo_cells: self.ammo_cells = autocvar_g_balance_nix_ammo_cells; break;
93 case ammo_plasma: self.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break;
94 case ammo_fuel: self.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break;
98 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
99 if(dt >= 1 && dt <= 5)
100 self.nix_lastinfotime = -42;
102 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
104 WEP_ACTION(nix_weapon, WR_RESETPLAYER);
106 // all weapons must be fully loaded when we spawn
107 if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
108 self.(weapon_load[nix_weapon]) = e.reloading_ammo;
111 if(WEP_CVAR(vortex, charge))
113 if(WEP_CVAR_SEC(vortex, chargepool))
114 self.vortex_chargepool_ammo = 1;
115 self.vortex_charge = WEP_CVAR(vortex, charge_start);
118 // set last change info
119 self.nix_lastchange_id = nix_nextchange;
121 if(self.nix_lastinfotime != dt)
123 self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
124 if(dt >= 1 && dt <= 5)
125 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt);
128 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
132 case ammo_shells: self.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break;
133 case ammo_nails: self.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break;
134 case ammo_rockets: self.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break;
135 case ammo_cells: self.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break;
136 case ammo_plasma: self.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break;
137 case ammo_fuel: self.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break;
140 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
143 self.weapons = '0 0 0';
144 if(g_nix_with_blaster)
145 self.weapons |= WEPSET_BLASTER;
146 self.weapons |= WepSet_FromWeapon(nix_weapon);
148 if(self.switchweapon != nix_weapon)
149 if(!client_hasweapon(self, self.switchweapon, true, false))
150 if(client_hasweapon(self, nix_weapon, true, false))
151 W_SwitchWeapon(nix_weapon);
157 for (i = WEP_FIRST; i <= WEP_LAST; ++i)
158 if (NIX_CanChooseWeapon(i))
159 WEP_ACTION(i, WR_INIT);
162 MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon)
164 return 1; // no throwing in NIX
167 MUTATOR_HOOKFUNCTION(nix_BuildMutatorsString)
169 ret_string = strcat(ret_string, ":NIX");
173 MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString)
175 ret_string = strcat(ret_string, ", NIX");
179 MUTATOR_HOOKFUNCTION(nix_FilterItem)
188 if (autocvar_g_nix_with_healtharmor)
193 if (autocvar_g_nix_with_powerups)
198 return 1; // delete all other items
201 MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn)
203 if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
208 MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
210 if(!intermission_running)
211 if(self.deadflag == DEAD_NO)
213 NIX_GiveCurrentWeapon();
217 MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
219 self.nix_lastchange_id = -1;
220 NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
221 self.items |= IT_UNLIMITED_SUPERWEAPONS;
225 MUTATOR_HOOKFUNCTION(nix_SetModname)
231 MUTATOR_DEFINITION(mutator_nix)
235 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
236 MUTATOR_HOOK(BuildMutatorsString, nix_BuildMutatorsString, CBC_ORDER_ANY);
237 MUTATOR_HOOK(BuildMutatorsPrettyString, nix_BuildMutatorsPrettyString, CBC_ORDER_ANY);
238 MUTATOR_HOOK(FilterItem, nix_FilterItem, CBC_ORDER_ANY);
239 MUTATOR_HOOK(OnEntityPreSpawn, nix_OnEntityPreSpawn, CBC_ORDER_ANY);
240 MUTATOR_HOOK(PlayerPreThink, nix_PlayerPreThink, CBC_ORDER_ANY);
241 MUTATOR_HOOK(PlayerSpawn, nix_PlayerSpawn, CBC_ORDER_ANY);
242 MUTATOR_HOOK(SetModname, nix_SetModname, CBC_ORDER_LAST);
246 g_nix_with_blaster = autocvar_g_nix_with_blaster;
254 MUTATOR_ONROLLBACK_OR_REMOVE
256 // nothing to roll back
261 // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
263 FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO)
265 e.ammo_cells = start_ammo_cells;
266 e.ammo_plasma = start_ammo_plasma;
267 e.ammo_shells = start_ammo_shells;
268 e.ammo_nails = start_ammo_nails;
269 e.ammo_rockets = start_ammo_rockets;
270 e.ammo_fuel = start_ammo_fuel;
271 e.weapons = start_weapons;
272 if(!client_hasweapon(e, e.weapon, true, false))
273 e.switchweapon = w_getbestweapon(self);