4 float g_nix_with_blaster;
9 .float nix_lastchange_id;
10 .float nix_lastinfotime;
13 bool NIX_CanChooseWeapon(int wpn);
15 REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"))
19 g_nix_with_blaster = autocvar_g_nix_with_blaster;
24 for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
25 if (NIX_CanChooseWeapon(i)) {
26 Weapon w = get_weaponinfo(i);
31 MUTATOR_ONROLLBACK_OR_REMOVE
33 // nothing to roll back
38 // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
40 FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO)
42 e.ammo_cells = start_ammo_cells;
43 e.ammo_plasma = start_ammo_plasma;
44 e.ammo_shells = start_ammo_shells;
45 e.ammo_nails = start_ammo_nails;
46 e.ammo_rockets = start_ammo_rockets;
47 e.ammo_fuel = start_ammo_fuel;
48 e.weapons = start_weapons;
49 if(!client_hasweapon(e, e.weapon, true, false))
50 e.switchweapon = w_getbestweapon(self);
57 bool NIX_CanChooseWeapon(int wpn)
59 entity e = get_weaponinfo(wpn);
60 if(!e.weapon) // skip dummies
64 if(!(g_weaponarena_weapons & WepSet_FromWeapon(wpn)))
69 if(wpn == WEP_BLASTER.m_id && g_nix_with_blaster)
71 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
73 if (!(e.spawnflags & WEP_FLAG_NORMAL))
78 void NIX_ChooseNextWeapon()
81 RandomSelection_Init();
82 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
83 if(NIX_CanChooseWeapon(j))
84 RandomSelection_Add(world, j, string_null, 1, (j != nix_weapon));
85 nix_nextweapon = RandomSelection_chosen_float;
88 void NIX_GiveCurrentWeapon()
93 NIX_ChooseNextWeapon();
95 dt = ceil(nix_nextchange - time);
99 nix_weapon = nix_nextweapon;
101 if (!nix_nextchange) // no round played yet?
102 nix_nextchange = time; // start the first round now!
104 nix_nextchange = time + autocvar_g_balance_nix_roundtime;
105 // Weapon w = get_weaponinfo(nix_weapon);
106 // w.wr_init(w); // forget it, too slow
110 entity e = get_weaponinfo(nix_weapon);
112 if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
114 self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_plasma = self.ammo_fuel = 0;
116 if(self.items & IT_UNLIMITED_WEAPON_AMMO)
120 case ammo_shells: self.ammo_shells = autocvar_g_pickup_shells_max; break;
121 case ammo_nails: self.ammo_nails = autocvar_g_pickup_nails_max; break;
122 case ammo_rockets: self.ammo_rockets = autocvar_g_pickup_rockets_max; break;
123 case ammo_cells: self.ammo_cells = autocvar_g_pickup_cells_max; break;
124 case ammo_plasma: self.ammo_plasma = autocvar_g_pickup_plasma_max; break;
125 case ammo_fuel: self.ammo_fuel = autocvar_g_pickup_fuel_max; break;
132 case ammo_shells: self.ammo_shells = autocvar_g_balance_nix_ammo_shells; break;
133 case ammo_nails: self.ammo_nails = autocvar_g_balance_nix_ammo_nails; break;
134 case ammo_rockets: self.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break;
135 case ammo_cells: self.ammo_cells = autocvar_g_balance_nix_ammo_cells; break;
136 case ammo_plasma: self.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break;
137 case ammo_fuel: self.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break;
141 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
142 if(dt >= 1 && dt <= 5)
143 self.nix_lastinfotime = -42;
145 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
147 Weapon w = get_weaponinfo(nix_weapon);
150 // all weapons must be fully loaded when we spawn
151 if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
152 self.(weapon_load[nix_weapon]) = e.reloading_ammo;
155 if(WEP_CVAR(vortex, charge))
157 if(WEP_CVAR_SEC(vortex, chargepool))
158 self.vortex_chargepool_ammo = 1;
159 self.vortex_charge = WEP_CVAR(vortex, charge_start);
162 // set last change info
163 self.nix_lastchange_id = nix_nextchange;
165 if(self.nix_lastinfotime != dt)
167 self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
168 if(dt >= 1 && dt <= 5)
169 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt);
172 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
176 case ammo_shells: self.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break;
177 case ammo_nails: self.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break;
178 case ammo_rockets: self.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break;
179 case ammo_cells: self.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break;
180 case ammo_plasma: self.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break;
181 case ammo_fuel: self.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break;
184 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
187 self.weapons = '0 0 0';
188 if(g_nix_with_blaster)
189 self.weapons |= WEPSET(BLASTER);
190 self.weapons |= WepSet_FromWeapon(nix_weapon);
192 if(self.switchweapon != nix_weapon)
193 if(!client_hasweapon(self, self.switchweapon, true, false))
194 if(client_hasweapon(self, nix_weapon, true, false))
195 W_SwitchWeapon(nix_weapon);
198 MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon)
200 return 1; // no throwing in NIX
203 MUTATOR_HOOKFUNCTION(nix, BuildMutatorsString)
205 ret_string = strcat(ret_string, ":NIX");
209 MUTATOR_HOOKFUNCTION(nix, BuildMutatorsPrettyString)
211 ret_string = strcat(ret_string, ", NIX");
215 MUTATOR_HOOKFUNCTION(nix, FilterItem)
219 case ITEM_HealthSmall.m_itemid:
220 case ITEM_HealthMedium.m_itemid:
221 case ITEM_HealthLarge.m_itemid:
222 case ITEM_HealthMega.m_itemid:
223 case ITEM_ArmorSmall.m_itemid:
224 case ITEM_ArmorMedium.m_itemid:
225 case ITEM_ArmorLarge.m_itemid:
226 case ITEM_ArmorMega.m_itemid:
227 if (autocvar_g_nix_with_healtharmor)
230 case ITEM_Strength.m_itemid:
231 case ITEM_Shield.m_itemid:
232 if (autocvar_g_nix_with_powerups)
237 return 1; // delete all other items
240 MUTATOR_HOOKFUNCTION(nix, OnEntityPreSpawn)
242 if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
247 MUTATOR_HOOKFUNCTION(nix, PlayerPreThink)
249 if(!intermission_running)
250 if(self.deadflag == DEAD_NO)
252 NIX_GiveCurrentWeapon();
256 MUTATOR_HOOKFUNCTION(nix, PlayerSpawn)
258 self.nix_lastchange_id = -1;
259 NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
260 self.items |= IT_UNLIMITED_SUPERWEAPONS;
264 MUTATOR_HOOKFUNCTION(nix, SetModname, CBC_ORDER_LAST)