From b8ecdf1fe54d2ce45a34eb2d8d6df5fe67967f49 Mon Sep 17 00:00:00 2001
From: Samual <samual@xonotic.org>
Date: Fri, 30 Sep 2011 16:00:18 -0400
Subject: [PATCH] Fix a bug with shotgun secondary where it would give up the
 swing before it actually finished tracing - Also start working on hook
 effects

---
 qcsrc/client/hook.qc      |  1 +
 qcsrc/server/w_shotgun.qc | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc
index 4971fa3aa1..e27dcaa67b 100644
--- a/qcsrc/client/hook.qc
+++ b/qcsrc/client/hook.qc
@@ -216,6 +216,7 @@ void Draw_GrapplingHook()
 void Remove_GrapplingHook()
 {
 	sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTN_NORM);
+	print("hook was removed at ", vtos(self.origin), "\n");
 }
 
 void Ent_ReadHook(float bIsNew, float type)
diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc
index f84f22e8b8..58ac58f080 100644
--- a/qcsrc/server/w_shotgun.qc
+++ b/qcsrc/server/w_shotgun.qc
@@ -60,11 +60,11 @@ void shotgun_meleethink (void)
 	
 	// calculate swing percentage based on time
 	meleetime = autocvar_g_balance_shotgun_secondary_melee_time * W_WeaponRateFactor();
-	swing = bound(0, (self.cnt + meleetime - time) / meleetime, 1);
+	swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
 	f = ((1 - swing) * autocvar_g_balance_shotgun_secondary_melee_traces);
 	
 	// check to see if we can still continue, otherwise give up now
-	if(time >= self.cnt + meleetime || (self.realowner.deadflag != DEAD_NO && autocvar_g_balance_shotgun_secondary_melee_no_doubleslap))
+	if((self.realowner.deadflag != DEAD_NO) && autocvar_g_balance_shotgun_secondary_melee_no_doubleslap)
 	{
 		remove(self);
 		return;
@@ -122,9 +122,18 @@ void shotgun_meleethink (void)
 		}
 	}
 	
-	// set up next frame 
-	self.swing_prev = i;
-	self.nextthink = time;
+	if(time >= self.cnt + meleetime)
+	{
+		// melee is finished
+		remove(self);
+		return;
+	}
+	else
+	{
+		// set up next frame 
+		self.swing_prev = i;
+		self.nextthink = time;
+	}
 }
 
 void W_Shotgun_Attack2 (void)
-- 
2.39.5