From 692fa8c81c402cb58f6a8cbf01fc2812f1a8d99d Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 24 Dec 2008 17:21:34 +0000 Subject: [PATCH] hook patch from Roffnan git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5298 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/constants.qh | 2 +- data/qcsrc/server/w_hook.qc | 42 ++++++++++++++++++++++++++++++++-- data/weapons.cfg | 6 +++-- data/weaponsPro.cfg | 6 +++-- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/data/qcsrc/server/constants.qh b/data/qcsrc/server/constants.qh index 39d0c845c..0cfde9f46 100644 --- a/data/qcsrc/server/constants.qh +++ b/data/qcsrc/server/constants.qh @@ -1,5 +1,5 @@ string CVAR_CHECK_DEFAULT = "3a4552d8adffd3ad69fec3f0c15c62d8"; -string CVAR_CHECK_WEAPONS = "7abbcf55140e618bfaa97b587fc7aef7"; +string CVAR_CHECK_WEAPONS = "0ce586134eb7097440e850031829efe6"; float FALSE = 0; float TRUE = 1; diff --git a/data/qcsrc/server/w_hook.qc b/data/qcsrc/server/w_hook.qc index 581100869..ddd5df43d 100644 --- a/data/qcsrc/server/w_hook.qc +++ b/data/qcsrc/server/w_hook.qc @@ -6,6 +6,8 @@ .float dmg_duration; .float dmg_last; .float hook_refire; +.float hook_datehooked; +.float hook_datehooked_delay; void W_Hook_ExplodeThink (void) { @@ -107,6 +109,8 @@ void spawnfunc_weapon_hook (void) float w_hook(float req) { + float hooked_time_max, hooked_ammodecrease_delay; + if (req == WR_AIM) { // ... sorry ... @@ -123,7 +127,7 @@ float w_hook(float req) if not(self.items & IT_UNLIMITED_WEAPON_AMMO) self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo"); self.hook_state |= HOOK_FIRING; - weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready); + weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready); } } @@ -142,6 +146,36 @@ float w_hook(float req) self.hook_refire = max(self.hook_refire, time + cvar("g_balance_hook_primary_refire")); } + if(self.hook && self.hook.state == 1) + { + hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max"); + if (hooked_time_max > 0) + { + if ( time > self.hook_datehooked + hooked_time_max ) + self.hook_state |= HOOK_REMOVING; + } + + hooked_ammodecrease_delay = cvar("g_balance_hook_primary_hooked_ammodecrease_delay"); + if (hooked_ammodecrease_delay > 0) + { + if ( time > self.hook_datehooked_delay + hooked_ammodecrease_delay ) + { + if ( self.ammo_cells >= 1 ) + { + self.ammo_cells -= 1; + self.hook_datehooked_delay = time; + } + else + { + self.hook_state |= HOOK_REMOVING; + W_SwitchWeapon_Force(self, w_getbestweapon(self)); + } + } + } + } + else + self.hook_datehooked = self.hook_datehooked_delay = time; + if (self.BUTTON_CROUCH) { self.hook_state &~= HOOK_PULLING; @@ -185,7 +219,11 @@ float w_hook(float req) } else if (req == WR_CHECKAMMO1) { - return self.ammo_cells >= cvar("g_balance_hook_primary_ammo"); + if ( cvar("g_balance_hook_primary_hooked_ammodecrease_delay") > 0 ) + if not(cvar("g_balance_hook_primary_ammo")) + return self.ammo_cells >= cvar("g_balance_hook_primary_ammo") + 1; + + return self.ammo_cells >= cvar("g_balance_hook_primary_ammo"); } else if (req == WR_CHECKAMMO2) { diff --git a/data/weapons.cfg b/data/weapons.cfg index 0b9d82ef1..8aff8cd06 100644 --- a/data/weapons.cfg +++ b/data/weapons.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit weaponsPro.cfg too. -set cvar_check_weapons 7abbcf55140e618bfaa97b587fc7aef7 +set cvar_check_weapons 0ce586134eb7097440e850031829efe6 set g_start_weapon_laser 1 set g_start_weapon_shotgun 1 @@ -241,9 +241,11 @@ set g_balance_portal_health 200 // these get recharged whenever the portal is us set g_balance_portal_lifetime 15 // these get recharged whenever the portal is used // TESTING: on-hand hook with bomb -set g_balance_hook_primary_ammo 0 // hook monkeys +set g_balance_hook_primary_ammo 1 // hook monkeys set g_balance_hook_primary_refire 0 // hook monkeys 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_ammodecrease_delay 2.5 // no ammo used if nagative or 0 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/weaponsPro.cfg b/data/weaponsPro.cfg index 97920ce0b..ffd76909d 100644 --- a/data/weaponsPro.cfg +++ b/data/weaponsPro.cfg @@ -1,4 +1,4 @@ -set cvar_check_weapons 7abbcf55140e618bfaa97b587fc7aef7 +set cvar_check_weapons 0ce586134eb7097440e850031829efe6 set g_start_weapon_laser 1 set g_start_weapon_shotgun 1 @@ -236,9 +236,11 @@ set g_balance_portal_health 200 // these get recharged whenever the portal is us set g_balance_portal_lifetime 15 // these get recharged whenever the portal is used // TESTING: on-hand hook with bomb -set g_balance_hook_primary_ammo 0 // hook monkeys +set g_balance_hook_primary_ammo 1 // hook monkeys set g_balance_hook_primary_refire 0 // hook monkeys 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_ammodecrease_delay 2.5 // no ammo used if nagative or 0 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