Page 1 of 1

Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

Posted: 10 Jun 2018, 15:16
by ouboss
Titanfall 2 is my gold standard for sprinting movement, and I'm trying to transfer it to other games. In Titanfall 2, one tap of sprint will keep you in a sprint state even if you are strafing directly left or right at the lesser, pure strafing speed. Once you return to any forward or diagonal forward movement, full sprint resumes. To release sprint, one has to release all movement keys or, I believe 's' cancels it as well but I don't remember 100%.

The following, based off of an evilC script, is getting me fairly close, but I'm finding that my w-aw-a-aw-w seems to reset movement to walk upon returning to w. Any ideas for improving this anyone?

Code: Select all

*$~w up::GoSub, move_up
*$~a up::GoSub, move_up
*$~s up::GoSub, move_up
*$~d up::GoSub, move_up
~w & LShift::GoSub, SprintAssist
~a & LShift::GoSub, SprintAssist
~s & LShift::GoSub, SprintAssist
~d & LShift::GoSub, SprintAssist
 
SprintAssist:
{	SendInput, {LShift Up}
	SendInput, {LShift DownTemp}
} Return
 
move_up:
keywait w
keywait a
keywait s
keywait d
SendInput, {LShift Up}
Return

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained  Topic is solved

Posted: 10 Jun 2018, 16:07
by Nextron
EvilC using KeyWait? :think: :wtf:

You could try something like this:

Code: Select all

*LShift::Send {Blind}{LShift down}
*LShift up::
*~w up::
*~a up::
*~s up::
*~d up::
	If GetKeyState("LShift") && !GetKeyState("w","p") && !GetKeyState("a","p") && !GetKeyState("s","p") && !GetKeyState("d","p") && !GetKeyState("LShift","p")
		Send {Blind}{LShift up}
Return

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

Posted: 10 Jun 2018, 16:21
by ouboss
Lol that part was me.

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

Posted: 10 Jun 2018, 18:51
by ouboss
Above code is perfection, minus the random LControl's I'm seeing whenever alt is thrown into the mix, reproducible when I press shift+alt+any of wasd.

Code: Select all

57  011	 	d	0.13	w              	
57  011	h	u	0.11	w              	
44  020	 	d	0.02	d              	
44  020	h	u	0.09	d              	
41  01E	 	d	0.00	a              	
57  011	 	d	0.05	w              	
44  020	 	d	0.08	d              	
41  01E	h	u	0.00	a              	
57  011	h	u	0.01	w              	
41  01E	 	d	0.08	a              	
44  020	h	u	0.02	d              	
57  011	 	d	0.06	w              	
44  020	 	d	0.09	d              	
41  01E	h	u	0.00	a              	
57  011	h	u	0.00	w              	
44  020	h	u	0.05	d              	
A0  02A	h	u	0.00	LShift         	
A0  02A	i	u	0.00	LShift         	
A4  038	 	u	0.05	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

Posted: 10 Jun 2018, 18:56
by gregster

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

Posted: 11 Jun 2018, 06:53
by ouboss
Interesting read. Was able to get it working perfectly afterwards. Thanks.