From: Mario <mario@smbclan.net>
Date: Thu, 24 Mar 2016 19:00:07 +0000 (+1000)
Subject: Hack to fix crouch prediction and hook/melee/frozen
X-Git-Tag: xonotic-v0.8.2~1024
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7da996452aef5f87c8a4a9f855cdc47a38baec0a;p=xonotic%2Fxonotic-data.pk3dir.git

Hack to fix crouch prediction and hook/melee/frozen
---

diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc
index 84768690c..1ddb70799 100644
--- a/qcsrc/common/physics/player.qc
+++ b/qcsrc/common/physics/player.qc
@@ -128,7 +128,17 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
 		PM_ClientMovement_Unstick(this);
 
 	// set crouched
-	if (PHYS_INPUT_BUTTON_CROUCH(this))
+	bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this);
+	if(this.hook && !wasfreed(this.hook))
+		do_crouch = false;
+	if(hud != HUD_NORMAL)
+		do_crouch = false;
+	if(STAT(FROZEN, this))
+		do_crouch = false;
+	if((activeweapon == WEP_SHOCKWAVE || activeweapon == WEP_SHOTGUN) && viewmodel.animstate_startframe == viewmodel.anim_fire2_x && time < viewmodel.weapon_nextthink)
+		do_crouch = false;
+
+	if (do_crouch)
 	{
 		// wants to crouch, this always works
 		if (!IS_DUCKED(this)) SET_DUCKED(this);
diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh
index bcc9f7329..fd1b610de 100644
--- a/qcsrc/common/physics/player.qh
+++ b/qcsrc/common/physics/player.qh
@@ -174,6 +174,8 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
 	.vector movement;
 	.vector v_angle;
 
+	.entity hook;
+
 // TODO
 	#define IS_CLIENT(s)                        ((s).isplayermodel)
 	#define IS_PLAYER(s)                        ((s).isplayermodel)
diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc
index c335e8c5b..13e8ac112 100644
--- a/qcsrc/common/weapons/weapon/hook.qc
+++ b/qcsrc/common/weapons/weapon/hook.qc
@@ -484,6 +484,9 @@ void Draw_GrapplingHook(entity this)
 void Remove_GrapplingHook(entity this)
 {
 	sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
+
+	if(csqcplayer && csqcplayer.hook == this)
+		csqcplayer.hook = NULL;
 }
 
 NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
@@ -502,6 +505,8 @@ NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
 		int myowner = ReadByte();
 		self.owner = playerslots[myowner - 1];
 		self.sv_entnum = myowner;
+		if(csqcplayer && myowner == player_localentnum)
+			csqcplayer.hook = self;
 		switch(self.HookType)
 		{
 			default: