X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator_nix.qc;h=519d51daa2510edd8f23ecef335e454127bd4f9c;hb=25bec571007cb22ae00c9c45dcfd4f6cbdc01428;hp=dc1794c5cccf1697f065d366d1c6bd9a1bf86a54;hpb=cff5b8df279d8d7842dea0273ef8773825b2995e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator_nix.qc b/qcsrc/server/mutators/mutator_nix.qc index dc1794c5c..519d51daa 100644 --- a/qcsrc/server/mutators/mutator_nix.qc +++ b/qcsrc/server/mutators/mutator_nix.qc @@ -1,4 +1,4 @@ -float g_nix, g_nix_with_laser; +float g_nix_with_laser; float nix_weapon; float nix_weapon_ammo; @@ -9,6 +9,13 @@ float nix_nextweapon_ammo; .float nix_lastinfotime; .float nix_nextincr; +.float nix_save_cells; +.float nix_save_shells; +.float nix_save_nails; +.float nix_save_rockets; +.float nix_save_fuel; +.float nix_save_weapons; + float NIX_CanChooseWeapon(float wpn) { entity e; @@ -54,65 +61,84 @@ void NIX_GiveCurrentWeapon() nix_weapon = nix_nextweapon; nix_weapon_ammo = nix_nextweapon_ammo; nix_nextweapon = 0; - nix_nextchange = time + cvar("g_balance_nix_roundtime"); + if (!nix_nextchange) // no round played yet? + nix_nextchange = time; // start the first round now! + else + nix_nextchange = time + autocvar_g_balance_nix_roundtime; //weapon_action(nix_weapon, WR_PRECACHE); // forget it, too slow } - + if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round! { self.nix_lastchange_id = nix_nextchange; if (self.items & IT_UNLIMITED_WEAPON_AMMO) { self.ammo_shells = (nix_weapon_ammo & IT_SHELLS) ? - cvar("g_pickup_shells_max") : 0; + autocvar_g_pickup_shells_max : 0; self.ammo_nails = (nix_weapon_ammo & IT_NAILS) ? - cvar("g_pickup_nails_max") : 0; + autocvar_g_pickup_nails_max : 0; self.ammo_rockets = (nix_weapon_ammo & IT_ROCKETS) ? - cvar("g_pickup_rockets_max") : 0; + autocvar_g_pickup_rockets_max : 0; self.ammo_cells = (nix_weapon_ammo & IT_CELLS) ? - cvar("g_pickup_cells_max") : 0; + autocvar_g_pickup_cells_max : 0; self.ammo_fuel = (nix_weapon_ammo & IT_FUEL) ? - cvar("g_pickup_fuel_max") : 0; + autocvar_g_pickup_fuel_max : 0; } else { self.ammo_shells = (nix_weapon_ammo & IT_SHELLS) ? - cvar("g_balance_nix_ammo_shells") : 0; + autocvar_g_balance_nix_ammo_shells : 0; self.ammo_nails = (nix_weapon_ammo & IT_NAILS) ? - cvar("g_balance_nix_ammo_nails") : 0; + autocvar_g_balance_nix_ammo_nails : 0; self.ammo_rockets = (nix_weapon_ammo & IT_ROCKETS) ? - cvar("g_balance_nix_ammo_rockets") : 0; + autocvar_g_balance_nix_ammo_rockets : 0; self.ammo_cells = (nix_weapon_ammo & IT_CELLS) ? - cvar("g_balance_nix_ammo_cells") : 0; + autocvar_g_balance_nix_ammo_cells : 0; self.ammo_fuel = (nix_weapon_ammo & IT_FUEL) ? - cvar("g_balance_nix_ammo_fuel") : 0; + autocvar_g_balance_nix_ammo_fuel : 0; } - self.nix_nextincr = time + cvar("g_balance_nix_incrtime"); + self.nix_nextincr = time + autocvar_g_balance_nix_incrtime; if(dt >= 1 && dt <= 5) self.nix_lastinfotime = -42; else - centerprint(self, strcat("\n\n^2Active weapon: ^3", W_Name(nix_weapon))); + Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^2Active weapon: ^3", W_Name(nix_weapon)), 0, 0); + + weapon_action(nix_weapon, WR_RESETPLAYER); + + // all weapons must be fully loaded when we spawn + entity e; + e = get_weaponinfo(nix_weapon); + if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars + self.(weapon_load[nix_weapon]) = cvar(strcat("g_balance_", e.netname, "_reload_ammo")); + + // nex too + if(autocvar_g_balance_nex_charge) + { + if(autocvar_g_balance_nex_secondary_chargepool) + self.nex_chargepool_ammo = 1; + self.nex_charge = autocvar_g_balance_nex_charge_start; + } } if(self.nix_lastinfotime != dt) { self.nix_lastinfotime = dt; // initial value 0 should count as "not seen" if(dt >= 1 && dt <= 5) - centerprint(self, strcat("^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n")); + Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^3%d^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon)), 1, dt); } if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr) { if (nix_weapon_ammo & IT_SHELLS) - self.ammo_shells = self.ammo_shells + cvar("g_balance_nix_ammoincr_shells"); + self.ammo_shells = self.ammo_shells + autocvar_g_balance_nix_ammoincr_shells; else if (nix_weapon_ammo & IT_NAILS) - self.ammo_nails = self.ammo_nails + cvar("g_balance_nix_ammoincr_nails"); + self.ammo_nails = self.ammo_nails + autocvar_g_balance_nix_ammoincr_nails; else if (nix_weapon_ammo & IT_ROCKETS) - self.ammo_rockets = self.ammo_rockets + cvar("g_balance_nix_ammoincr_rockets"); + self.ammo_rockets = self.ammo_rockets + autocvar_g_balance_nix_ammoincr_rockets; else if (nix_weapon_ammo & IT_CELLS) - self.ammo_cells = self.ammo_cells + cvar("g_balance_nix_ammoincr_cells"); + self.ammo_cells = self.ammo_cells + autocvar_g_balance_nix_ammoincr_cells; if (nix_weapon_ammo & IT_FUEL) // hook uses cells and fuel - self.ammo_fuel = self.ammo_fuel + cvar("g_balance_nix_ammoincr_fuel"); - self.nix_nextincr = time + cvar("g_balance_nix_incrtime"); + self.ammo_fuel = self.ammo_fuel + autocvar_g_balance_nix_ammoincr_fuel; + self.nix_nextincr = time + autocvar_g_balance_nix_incrtime; } self.weapons = 0; @@ -169,12 +195,12 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem) case IT_25HP: case IT_ARMOR: case IT_ARMOR_SHARD: - if (cvar("g_nix_with_healtharmor")) + if (autocvar_g_nix_with_healtharmor) return 0; break; case IT_STRENGTH: case IT_INVINCIBLE: - if (cvar("g_nix_with_powerups")) + if (autocvar_g_nix_with_powerups) return 0; break; } @@ -184,7 +210,7 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem) MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn) { - if(self.classname == "target_items") // items triggers cannot work in nixnex (as they change weapons/ammo) + if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo) return 1; return 0; } @@ -207,6 +233,8 @@ MUTATOR_HOOKFUNCTION(nix_PlayerSpawn) MUTATOR_DEFINITION(mutator_nix) { + entity e; + MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY); MUTATOR_HOOK(SetStartItems, nix_SetStartItems, CBC_ORDER_EXCLUSIVE); MUTATOR_HOOK(BuildMutatorsString, nix_BuildMutatorsString, CBC_ORDER_ANY); @@ -218,19 +246,51 @@ MUTATOR_DEFINITION(mutator_nix) MUTATOR_ONADD { - g_nix = 1; - g_nix_with_laser = cvar("g_nix_with_laser"); + g_nix_with_laser = autocvar_g_nix_with_laser; - nix_nextchange = time; + nix_nextchange = 0; nix_nextweapon = 0; NIX_precache(); + + FOR_EACH_PLAYER(e) + { + if(e.deadflag == DEAD_NO) + { + e.nix_save_cells = e.ammo_cells; + e.nix_save_shells = e.ammo_shells; + e.nix_save_nails = e.ammo_nails; + e.nix_save_rockets = e.ammo_rockets; + e.nix_save_fuel = e.ammo_fuel; + e.nix_save_weapons = e.weapons; + } + else + { + e.nix_save_cells = 0; + e.nix_save_shells = 0; + e.nix_save_nails = 0; + e.nix_save_rockets = 0; + e.nix_save_fuel = 0; + e.nix_save_weapons = 0; + } + } } MUTATOR_ONREMOVE { - g_nix = 0; // as the PlayerSpawn hook will no longer run, NIX is turned off by this! + + FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO) + { + e.ammo_cells = max(start_ammo_cells, e.nix_save_cells); + e.ammo_shells = max(start_ammo_shells, e.nix_save_shells); + e.ammo_nails = max(start_ammo_nails, e.nix_save_nails); + e.ammo_rockets = max(start_ammo_rockets, e.nix_save_rockets); + e.ammo_fuel = max(start_ammo_fuel, e.nix_save_fuel); + e.weapons = (start_weapons | e.nix_save_weapons); + if(!client_hasweapon(e, e.weapon, TRUE, FALSE)) + e.switchweapon = w_getbestweapon(self); + } } return 0;