From 396fcfdfd26602d11e03464196e4c3e9cc2dad94 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 11 May 2009 18:33:07 +0000 Subject: [PATCH] hook now takes fuel git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6706 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/defaultNexuiz.cfg | 2 +- data/qcsrc/common/items.qc | 30 ++++++++++----------- data/qcsrc/server/cl_client.qc | 9 +++++-- data/qcsrc/server/cl_weapons.qc | 43 +++++++++++++++++++----------- data/qcsrc/server/constants.qh | 4 +-- data/qcsrc/server/miscfunctions.qc | 22 +++------------ data/qcsrc/server/t_items.qc | 12 ++++++--- data/qcsrc/server/w_hook.qc | 30 ++++++++++++++------- data/qcsrc/server/w_porto.qc | 2 +- data/weapons.cfg | 6 ++--- data/weaponsHavoc.cfg | 6 ++--- 11 files changed, 92 insertions(+), 74 deletions(-) diff --git a/data/defaultNexuiz.cfg b/data/defaultNexuiz.cfg index 584add934..710bc5671 100644 --- a/data/defaultNexuiz.cfg +++ b/data/defaultNexuiz.cfg @@ -24,7 +24,7 @@ alias if_dedicated "_detect_dedicated_$qport $*" seta g_configversion 0 "Configuration file version (used to upgrade settings) 0: first run, or previous start was <2.4.1 Later, it's overridden by config.cfg, version ranges are defined in config_update.cfg" // default.cfg versioning (update using update-cvarcount.sh, run that every time after adding a new cvar) -set cvar_check_default 4ca99f9a6a53e5c14b991b2424efa88f +set cvar_check_default ca174b42ef38020187602cfda6d8ef43 // Nexuiz version (formatted for machines) // used to determine if a client version is compatible diff --git a/data/qcsrc/common/items.qc b/data/qcsrc/common/items.qc index 5c96a9fb2..5be7ad5d3 100644 --- a/data/qcsrc/common/items.qc +++ b/data/qcsrc/common/items.qc @@ -98,21 +98,21 @@ string W_FixWeaponOrder(string order, float complete) void RegisterWeapons() { // %weaponaddpoint - register_weapon(WEP_LASER, w_laser, 0, 1, 1, 1, 0, "laser", "laser", "Laser"); - register_weapon(WEP_SHOTGUN, w_shotgun, IT_SHELLS, 2, 1, 0, BOT_PICKUP_RATING_LOW, "shotgun", "shotgun", "Shotgun"); - register_weapon(WEP_UZI, w_uzi, IT_NAILS, 3, 1, 0, BOT_PICKUP_RATING_MID, "uzi", "uzi", "Machine Gun"); - register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, 1, 1, BOT_PICKUP_RATING_MID, "gl", "grenadelauncher", "Mortar"); - register_weapon(WEP_ELECTRO, w_electro, IT_CELLS, 5, 1, 0, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro"); - register_weapon(WEP_CRYLINK, w_crylink, IT_CELLS, 6, 1, 0, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink"); - register_weapon(WEP_NEX, w_nex, IT_CELLS, 7, 1, 0, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex"); - register_weapon(WEP_HAGAR, w_hagar, IT_ROCKETS, 8, 1, 1, BOT_PICKUP_RATING_MID, "hagar", "hagar", "Hagar"); - register_weapon(WEP_ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, 1, 1, BOT_PICKUP_RATING_HIGH, "rl", "rocketlauncher", "Rocket Launcher"); - register_weapon(WEP_PORTO, w_porto, 0, 0, 0, 0, 0, "porto" , "porto", "Port-O-Launch"); - register_weapon(WEP_MINSTANEX, w_minstanex, IT_CELLS, 7, 0, 1, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", "MinstaNex"); - register_weapon(WEP_HOOK, w_hook, IT_CELLS, 0, 0, 1, 0, "hookgun", "hook", "Grappling Hook"); - register_weapon(WEP_SEEKER, w_seeker, IT_ROCKETS, 8, 0, 0, BOT_PICKUP_RATING_HIGH, "seeker", "seeker", "T.A.G. Seeker"); - register_weapon(WEP_HLAC, w_hlac, IT_CELLS, 6, 1, 0, BOT_PICKUP_RATING_MID, "hlac", "hlac", "Heavy Laser Assault Cannon"); - register_weapon(WEP_CAMPINGRIFLE, w_campingrifle, IT_NAILS, 3, 1, 0, BOT_PICKUP_RATING_MID, "campingrifle", "campingrifle", "Rifle"); + register_weapon(WEP_LASER, w_laser, 0, 1, 1, 1, 0, "laser", "laser", "Laser"); + register_weapon(WEP_SHOTGUN, w_shotgun, IT_SHELLS, 2, 1, 0, BOT_PICKUP_RATING_LOW, "shotgun", "shotgun", "Shotgun"); + register_weapon(WEP_UZI, w_uzi, IT_NAILS, 3, 1, 0, BOT_PICKUP_RATING_MID, "uzi", "uzi", "Machine Gun"); + register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, 1, 1, BOT_PICKUP_RATING_MID, "gl", "grenadelauncher", "Mortar"); + register_weapon(WEP_ELECTRO, w_electro, IT_CELLS, 5, 1, 0, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro"); + register_weapon(WEP_CRYLINK, w_crylink, IT_CELLS, 6, 1, 0, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink"); + register_weapon(WEP_NEX, w_nex, IT_CELLS, 7, 1, 0, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex"); + register_weapon(WEP_HAGAR, w_hagar, IT_ROCKETS, 8, 1, 1, BOT_PICKUP_RATING_MID, "hagar", "hagar", "Hagar"); + register_weapon(WEP_ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, 1, 1, BOT_PICKUP_RATING_HIGH, "rl", "rocketlauncher", "Rocket Launcher"); + register_weapon(WEP_PORTO, w_porto, 0, 0, 0, 0, 0, "porto" , "porto", "Port-O-Launch"); + register_weapon(WEP_MINSTANEX, w_minstanex, IT_CELLS, 7, 0, 1, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", "MinstaNex"); + register_weapon(WEP_HOOK, w_hook, IT_CELLS|IT_FUEL, 0, 0, 1, 0, "hookgun", "hook", "Grappling Hook"); + register_weapon(WEP_SEEKER, w_seeker, IT_ROCKETS, 8, 0, 0, BOT_PICKUP_RATING_HIGH, "seeker", "seeker", "T.A.G. Seeker"); + register_weapon(WEP_HLAC, w_hlac, IT_CELLS, 6, 1, 0, BOT_PICKUP_RATING_MID, "hlac", "hlac", "Heavy Laser Assault Cannon"); + register_weapon(WEP_CAMPINGRIFLE, w_campingrifle, IT_NAILS, 3, 1, 0, BOT_PICKUP_RATING_MID, "campingrifle", "campingrifle", "Rifle"); register_weapons_done(); } diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index a8c7bfd50..3f447a87a 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -2182,6 +2182,7 @@ Called every frame for each client before the physics are run */ void() ctf_setstatus; void() nexball_setstatus; +.float items_added; void PlayerPreThink (void) { self.stat_sys_ticrate = cvar("sys_ticrate"); @@ -2405,12 +2406,16 @@ void PlayerPreThink (void) if(frametime) { + self.items &~= self.items_added; + W_WeaponFrame(); - self.items &~= IT_FUEL; // TODO don't do this if the current weapon actually USES fuel... + self.items_added = 0; if(self.items & IT_JETPACK) if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01) - self.items |= IT_FUEL; + self.items_added |= IT_FUEL; + + self.items |= self.items_added; } player_regen(); diff --git a/data/qcsrc/server/cl_weapons.qc b/data/qcsrc/server/cl_weapons.qc index 442afd162..7747275d6 100644 --- a/data/qcsrc/server/cl_weapons.qc +++ b/data/qcsrc/server/cl_weapons.qc @@ -173,11 +173,12 @@ void thrown_wep_think() SUB_SetFade(self, time + 20, 1); } -// returns amount of ammo used, or -1 for failure, or 0 for no ammo count -float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo) +// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count +string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo) { entity oldself, wep; - float wa, thisammo; + float wa, thisammo, i, j; + string s; var .float ammofield; wep = spawn(); @@ -198,29 +199,38 @@ float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector weapon_defaultspawnfunc(wpn); self = oldself; if(startitem_failed) - return -1; + return string_null; wep.think = thrown_wep_think; wep.nextthink = time + 0.5; - return 0; + return ""; } else { - ammofield = Item_CounterField(wa); + s = ""; oldself = self; self = wep; weapon_defaultspawnfunc(wpn); self = oldself; if(startitem_failed) - return -1; + return string_null; if(doreduce) { - thisammo = min(own.ammofield, wep.ammofield); - wep.ammofield = thisammo; - own.ammofield -= thisammo; + for(i = 0, j = 1; i < 24; ++i, j *= 2) + { + if(wa & j) + { + ammofield = Item_CounterField(j); + thisammo = min(own.ammofield, wep.ammofield); + wep.ammofield = thisammo; + own.ammofield -= thisammo; + s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j)); + } + } + s = substring(s, 5, -1); } wep.think = thrown_wep_think; wep.nextthink = time + 0.5; - return wep.ammofield; + return s; } } @@ -248,7 +258,8 @@ float W_IsWeaponThrowable(float w) // toss current weapon void W_ThrowWeapon(vector velo, vector delta, float doreduce) { - local float w, a, wb; + local float w, wb; + string a; w = self.weapon; if (w == 0) @@ -273,14 +284,14 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) self.weapons &~= wb; W_SwitchWeapon_Force(self, w_getbestweapon(self)); a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo); - if(a < 0) + if not(a) return; if(self.health >= 1) { - if(a == 0) + if(a == "") sprint(self, strcat("You dropped the ^2", W_Name(w), "\n")); else - sprint(self, strcat("You dropped the ^2", W_Name(w), " with ", ftos(a), " ", Item_CounterFieldName(W_AmmoItemCode(w)), "\n")); + sprint(self, strcat("You dropped the ^2", W_Name(w), " with ", a, "\n")); } }; @@ -346,7 +357,7 @@ void W_WeaponFrame() while (c < 5) { c = c + 1; - if(wb && self.weapons & wb == 0) + if(wb && ((self.weapons & wb) == 0)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); wb = 0; diff --git a/data/qcsrc/server/constants.qh b/data/qcsrc/server/constants.qh index 7574ada6b..d0688efcb 100644 --- a/data/qcsrc/server/constants.qh +++ b/data/qcsrc/server/constants.qh @@ -1,5 +1,5 @@ -string CVAR_CHECK_DEFAULT = "4ca99f9a6a53e5c14b991b2424efa88f"; -string CVAR_CHECK_WEAPONS = "00219e78f5d78d7d8a1600c4f4c73aa5"; +string CVAR_CHECK_DEFAULT = "ca174b42ef38020187602cfda6d8ef43"; +string CVAR_CHECK_WEAPONS = "b338022e7d7e73d5dccef57bebd2c37e"; float FALSE = 0; float TRUE = 1; diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index e911dde66..0206edcae 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -943,30 +943,16 @@ void readplayerstartcvars() } } - if(start_weapons & WEPBIT_HOOK) - { - // can't have off-hand hook, if hook weapon is enabled - - // note: if g_grappling_hook is 1, also give some initial cells - if(g_grappling_hook) - { - if(!start_ammo_cells) - start_ammo_cells = g_pickup_cells; - if(!warmup_start_ammo_cells) - warmup_start_ammo_cells = g_pickup_cells; - } - - g_grappling_hook = 0; - } - - if(g_jetpack) + if(g_jetpack || (g_grappling_hook && (start_weapons & WEPBIT_HOOK))) { g_grappling_hook = 0; // these two can't coexist, as they use the same button - start_items |= IT_JETPACK; start_items |= IT_FUEL_REGEN; start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_stable")); } + if(g_jetpack) + start_items |= IT_JETPACK; + if(g_weapon_stay == 2) { if(!start_ammo_shells) start_ammo_shells = g_pickup_shells; diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index 5b0b2052a..cbb8c8d5f 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -732,9 +732,15 @@ void weapon_defaultspawnfunc(float wpn) if(e.items && e.items != IT_SUPERWEAPON) { - ammofield = Item_CounterField(e.items); - if(!self.ammofield) - self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items))); + for(i = 0, j = 1; i < 24; ++i, j *= 2) + { + if(e.items & j) + { + ammofield = Item_CounterField(j); + if(!self.ammofield) + self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(j))); + } + } } else { diff --git a/data/qcsrc/server/w_hook.qc b/data/qcsrc/server/w_hook.qc index 03f918182..09d503131 100644 --- a/data/qcsrc/server/w_hook.qc +++ b/data/qcsrc/server/w_hook.qc @@ -7,7 +7,7 @@ .float dmg_last; .float hook_refire; .float hook_time_hooked; -.float hook_time_ammodecrease; +.float hook_time_fueldecrease; void W_Hook_ExplodeThink (void) { @@ -103,7 +103,7 @@ void spawnfunc_weapon_hook (void) float w_hook(float req) { - float hooked_time_max, hooked_ammodecrease_delay; + float hooked_time_max, hooked_fuel; if (req == WR_AIM) { @@ -115,11 +115,12 @@ float w_hook(float req) { if(!self.hook) if not(self.hook_state & HOOK_WAITING_FOR_RELEASE) + if not(self.hook_state & HOOK_FIRING) if (time > self.hook_refire) if (weapon_prepareattack(0, -1)) { if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo"); + self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel"); self.hook_state |= HOOK_FIRING; weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready); } @@ -138,6 +139,10 @@ float w_hook(float req) { // if hooked, no bombs, and increase the timer self.hook_refire = max(self.hook_refire, time + cvar("g_balance_hook_primary_refire")); + + // hook also inhibits health regeneration, but only for 1 second + if not(self.items & IT_UNLIMITED_WEAPON_AMMO) + self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen")); } if(self.hook && self.hook.state == 1) @@ -149,20 +154,22 @@ float w_hook(float req) self.hook_state |= HOOK_REMOVING; } - hooked_ammodecrease_delay = cvar("g_balance_hook_primary_hooked_ammodecrease_delay"); - if (hooked_ammodecrease_delay > 0) + hooked_fuel = cvar("g_balance_hook_primary_hooked_fuel"); + if (hooked_fuel > 0) { - if ( time > self.hook_time_ammodecrease ) + if ( time > self.hook_time_fueldecrease ) { if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { - if ( self.ammo_cells >= frametime / hooked_ammodecrease_delay ) + if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel ) { - self.ammo_cells -= frametime / hooked_ammodecrease_delay; + self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel; + self.hook_time_fueldecrease = time; // decrease next frame again } else { + self.ammo_fuel = 0; self.hook_state |= HOOK_REMOVING; W_SwitchWeapon_Force(self, w_getbestweapon(self)); } @@ -173,7 +180,7 @@ float w_hook(float req) else { self.hook_time_hooked = time; - self.hook_time_ammodecrease = time + cvar("g_balance_hook_primary_hooked_time_free"); + self.hook_time_fueldecrease = time + cvar("g_balance_hook_primary_hooked_time_free"); } if (self.BUTTON_CROUCH) @@ -218,7 +225,10 @@ float w_hook(float req) } else if (req == WR_CHECKAMMO1) { - return self.ammo_cells >= cvar("g_balance_hook_primary_ammo"); + if(self.hook) + return self.ammo_fuel > 0; + else + return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel"); } else if (req == WR_CHECKAMMO2) { diff --git a/data/qcsrc/server/w_porto.qc b/data/qcsrc/server/w_porto.qc index 50e71861b..b4f57caec 100644 --- a/data/qcsrc/server/w_porto.qc +++ b/data/qcsrc/server/w_porto.qc @@ -15,7 +15,7 @@ void W_Porto_Success (void) remove(self); } -float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo); +string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo); void W_Porto_Fail (float failhard) { if(self.owner == world) diff --git a/data/weapons.cfg b/data/weapons.cfg index 072268b1b..731f0257b 100644 --- a/data/weapons.cfg +++ b/data/weapons.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit weaponsHavoc.cfg too. -set cvar_check_weapons 00219e78f5d78d7d8a1600c4f4c73aa5 +set cvar_check_weapons b338022e7d7e73d5dccef57bebd2c37e // NOTE: this only replaces weapons on the map // use g_start_weapon_* to also replace the on-startup weapons! @@ -272,12 +272,12 @@ set g_balance_porto_primary_ammo 25 set g_balance_portal_health 200 // these get recharged whenever the portal is used set g_balance_portal_lifetime 15 // these get recharged whenever the portal is used -set g_balance_hook_primary_ammo 2 // hook monkeys set 0 +set g_balance_hook_primary_fuel 10 // hook monkeys set 0 set g_balance_hook_primary_refire 0 // hook monkeys set 0 set g_balance_hook_primary_animtime 0.3 // good shoot anim set g_balance_hook_primary_hooked_time_max 0 // infinite set g_balance_hook_primary_hooked_time_free 2 // 2s being hooked are free -set g_balance_hook_primary_hooked_ammodecrease_delay 0.5 // remove one cell every 0.5 seconds +set g_balance_hook_primary_hooked_fuel 8 // fuel per second hooked set g_balance_hook_secondary_damage 25 // not much set g_balance_hook_secondary_edgedamage 5 // not much set g_balance_hook_secondary_radius 500 // LOTS diff --git a/data/weaponsHavoc.cfg b/data/weaponsHavoc.cfg index f356f695e..e453b4b62 100644 --- a/data/weaponsHavoc.cfg +++ b/data/weaponsHavoc.cfg @@ -1,4 +1,4 @@ -set cvar_check_weapons 00219e78f5d78d7d8a1600c4f4c73aa5 +set cvar_check_weapons b338022e7d7e73d5dccef57bebd2c37e // NOTE: this only replaces weapons on the map // use g_start_weapon_* to also replace the on-startup weapons! @@ -267,12 +267,12 @@ set g_balance_porto_primary_ammo 50 set g_balance_portal_health 200 // these get recharged whenever the portal is used set g_balance_portal_lifetime 15 // these get recharged whenever the portal is used -set g_balance_hook_primary_ammo 2 // hook monkeys set 0 +set g_balance_hook_primary_fuel 10 // hook monkeys set 0 set g_balance_hook_primary_refire 0 // hook monkeys set 0 set g_balance_hook_primary_animtime 0.3 // good shoot anim set g_balance_hook_primary_hooked_time_max 0 // infinite set g_balance_hook_primary_hooked_time_free 2 // 2s being hooked are free -set g_balance_hook_primary_hooked_ammodecrease_delay 0.5 // remove one cell every 0.5 seconds +set g_balance_hook_primary_hooked_fuel 8 // fuel per second hooked set g_balance_hook_secondary_damage 25 // not much set g_balance_hook_secondary_edgedamage 5 // not much set g_balance_hook_secondary_radius 500 // LOTS -- 2.39.2