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.m_id && 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 // Weapon w = get_weaponinfo(nix_weapon);
64 // w.wr_init(w); // forget it, too slow
68 entity e = get_weaponinfo(nix_weapon);
70 if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
72 self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_plasma = self.ammo_fuel = 0;
74 if(self.items & IT_UNLIMITED_WEAPON_AMMO)
78 case ammo_shells: self.ammo_shells = autocvar_g_pickup_shells_max; break;
79 case ammo_nails: self.ammo_nails = autocvar_g_pickup_nails_max; break;
80 case ammo_rockets: self.ammo_rockets = autocvar_g_pickup_rockets_max; break;
81 case ammo_cells: self.ammo_cells = autocvar_g_pickup_cells_max; break;
82 case ammo_plasma: self.ammo_plasma = autocvar_g_pickup_plasma_max; break;
83 case ammo_fuel: self.ammo_fuel = autocvar_g_pickup_fuel_max; break;
90 case ammo_shells: self.ammo_shells = autocvar_g_balance_nix_ammo_shells; break;
91 case ammo_nails: self.ammo_nails = autocvar_g_balance_nix_ammo_nails; break;
92 case ammo_rockets: self.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break;
93 case ammo_cells: self.ammo_cells = autocvar_g_balance_nix_ammo_cells; break;
94 case ammo_plasma: self.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break;
95 case ammo_fuel: self.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break;
99 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
100 if(dt >= 1 && dt <= 5)
101 self.nix_lastinfotime = -42;
103 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
105 Weapon w = get_weaponinfo(nix_weapon);
108 // all weapons must be fully loaded when we spawn
109 if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
110 self.(weapon_load[nix_weapon]) = e.reloading_ammo;
113 if(WEP_CVAR(vortex, charge))
115 if(WEP_CVAR_SEC(vortex, chargepool))
116 self.vortex_chargepool_ammo = 1;
117 self.vortex_charge = WEP_CVAR(vortex, charge_start);
120 // set last change info
121 self.nix_lastchange_id = nix_nextchange;
123 if(self.nix_lastinfotime != dt)
125 self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
126 if(dt >= 1 && dt <= 5)
127 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt);
130 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
134 case ammo_shells: self.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break;
135 case ammo_nails: self.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break;
136 case ammo_rockets: self.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break;
137 case ammo_cells: self.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break;
138 case ammo_plasma: self.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break;
139 case ammo_fuel: self.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break;
142 self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
145 self.weapons = '0 0 0';
146 if(g_nix_with_blaster)
147 self.weapons |= WEPSET(BLASTER);
148 self.weapons |= WepSet_FromWeapon(nix_weapon);
150 if(self.switchweapon != nix_weapon)
151 if(!client_hasweapon(self, self.switchweapon, true, false))
152 if(client_hasweapon(self, nix_weapon, true, false))
153 W_SwitchWeapon(nix_weapon);
159 for (i = WEP_FIRST; i <= WEP_LAST; ++i)
160 if (NIX_CanChooseWeapon(i)) {
161 Weapon w = get_weaponinfo(i);
166 MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon)
168 return 1; // no throwing in NIX
171 MUTATOR_HOOKFUNCTION(nix_BuildMutatorsString)
173 ret_string = strcat(ret_string, ":NIX");
177 MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString)
179 ret_string = strcat(ret_string, ", NIX");
183 MUTATOR_HOOKFUNCTION(nix_FilterItem)
187 case ITEM_HealthSmall.m_itemid:
188 case ITEM_HealthMedium.m_itemid:
189 case ITEM_HealthLarge.m_itemid:
190 case ITEM_HealthMega.m_itemid:
191 case ITEM_ArmorSmall.m_itemid:
192 case ITEM_ArmorMedium.m_itemid:
193 case ITEM_ArmorLarge.m_itemid:
194 case ITEM_ArmorMega.m_itemid:
195 if (autocvar_g_nix_with_healtharmor)
198 case ITEM_Strength.m_itemid:
199 case ITEM_Shield.m_itemid:
200 if (autocvar_g_nix_with_powerups)
205 return 1; // delete all other items
208 MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn)
210 if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
215 MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
217 if(!intermission_running)
218 if(self.deadflag == DEAD_NO)
220 NIX_GiveCurrentWeapon();
224 MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
226 self.nix_lastchange_id = -1;
227 NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
228 self.items |= IT_UNLIMITED_SUPERWEAPONS;
232 MUTATOR_HOOKFUNCTION(nix_SetModname)
238 MUTATOR_DEFINITION(mutator_nix)
242 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
243 MUTATOR_HOOK(BuildMutatorsString, nix_BuildMutatorsString, CBC_ORDER_ANY);
244 MUTATOR_HOOK(BuildMutatorsPrettyString, nix_BuildMutatorsPrettyString, CBC_ORDER_ANY);
245 MUTATOR_HOOK(FilterItem, nix_FilterItem, CBC_ORDER_ANY);
246 MUTATOR_HOOK(OnEntityPreSpawn, nix_OnEntityPreSpawn, CBC_ORDER_ANY);
247 MUTATOR_HOOK(PlayerPreThink, nix_PlayerPreThink, CBC_ORDER_ANY);
248 MUTATOR_HOOK(PlayerSpawn, nix_PlayerSpawn, CBC_ORDER_ANY);
249 MUTATOR_HOOK(SetModname, nix_SetModname, CBC_ORDER_LAST);
253 g_nix_with_blaster = autocvar_g_nix_with_blaster;
261 MUTATOR_ONROLLBACK_OR_REMOVE
263 // nothing to roll back
268 // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
270 FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO)
272 e.ammo_cells = start_ammo_cells;
273 e.ammo_plasma = start_ammo_plasma;
274 e.ammo_shells = start_ammo_shells;
275 e.ammo_nails = start_ammo_nails;
276 e.ammo_rockets = start_ammo_rockets;
277 e.ammo_fuel = start_ammo_fuel;
278 e.weapons = start_weapons;
279 if(!client_hasweapon(e, e.weapon, true, false))
280 e.switchweapon = w_getbestweapon(self);