; v1.0.0

;

; NOTE 1: Bind Numpad * to Auto-Run. This fixes a problem with TSW registering middle double-clicks. (Try it yourself in-game without this script running. You'll see.)

; NOTE 2: F22, F23, and F24 are F-Key remaps on my keyboard. You can reassign them to any key, like F10, F11, and F12.

; F22 = Strafe Left. Press again to dodge Left.

;

; F24 = Strafe Right. Press again to dodge Right.

;

; F23 = If strafing left/right or walking backward, cancel movement. If standing still, dodge backwards and start walking backward.

;

; Mouse Button 4 = Strafe Left. Press again to change strafe direction.

;

; Middle Mouse Button = If strafing left/right or walking backward, cancel movement. If standing still, auto-run forward.

;

; Ctrl-F9 = Terminate Script

#InstallMouseHook

; Variables

vToggle := false

vLeft := false

vRight := false

vBack := false

; Ctrl-F9 = Terminate Script

^ F9:: ExitApp

; Only activate while TSW window is active

#If WinActive ( "ahk_class TSW" )

; Strafe Left + Dodge

* F22 ::

{

; Cancel existing movement

if ( vBack or vRight )

{

; Stop walking back

if ( vBack )

{

Send , { s up }

vBack := false

}

; Stop strafing right

if ( vRight )

{

Send , { e up }

vRight := false

}

}

if ( !vLeft )

{

; Start strafing left

Send , { q down }

vLeft := true

}

else

{

; Dodge left

Send , { q down }

Send , { q up }

Send , { q down }

Send , { q up }

Send , { q down }

/*

; Stop strafing left

Send, {q up}

vLeft := false

*/

}

KeyWait , F22

return

}

; Strafe Right + Dodge

* F24 ::

{

; Cancel existing movement

if ( vBack or vLeft )

{

; Stop walking back

if ( vBack )

{

Send , { s up }

vBack := false

}

; Stop strafing left

if ( vLeft )

{

Send , { q up }

vLeft := false

}

}

if ( !vRight )

{

; Start strafing right

Send , { e down }

vRight := true

}

else

{

; Dodge right

Send , { e down }

Send , { e up }

Send , { e down }

Send , { e up }

Send , { e down }

/*

; Stop strafing right

Send, {e up}

vRight := false

*/

}

KeyWait , F24

return

}

; Walk Back + Dodge + Stop

* F23 ::

{

; Cancel existing movement

if ( vLeft or vRight or vBack )

{

; Stop strafing left

if ( vLeft )

{

Send , { q up }

vLeft := false

}

; Stop strafing right

if ( vRight )

{

Send , { e up }

vRight := false

}

; Stop walking back

if ( vBack )

{

Send , { s up }

vBack := false

}

}

else ; If standing still, dodge back and walk back

{

; Dodge back

Send , { s down }

Send , { s up }

Send , { s down }

Send , { s up }

Send , { s down }

vBack := true

}

KeyWait , F23

return

}

; Strafe Left or Right - Reverse Strafe Direction

* XButton1 ::

{

; If strafing left, stop strafing left and start strafing right

if ( vLeft )

{

; Stop strafing left

Send , { q up }

vLeft := false

; Start strafing right

Send , { e down }

vRight := true

}

; If strafing right, stop strafing right and start strafing left

else if ( vRight )

{

; Stop strafing right

Send , { e up }

vRight := false

; Start strafing left

Send , { q down }

vLeft := true

}

; If walking back, stop walking back and start strafing left

else if ( vBack )

{

; Stop walking back

Send , { s up }

vBack := false

; Start strafing left

Send , { q down }

vLeft := true

}

else ; If standing still, start strafing left

{

; Start strafing left

Send , { q down }

vLeft := true

}

KeyWait , XButton1

return

}

; Cancel Movement, Allow Auto-Run

* MButton ::

{

; Cancel existing movement

if ( vLeft or vRight or vBack )

{

; Stop strafing left

if ( vLeft )

{

Send , { q up }

vLeft := false

}

; Stop strafing right

if ( vRight )

{

Send , { e up }

vRight := false

}

; Stop walking back

if ( vBack )

{

Send , { s up }

vBack := false

}

}

else

{

SendInput , { NumpadMult }

}

KeyWait , MButton

return

}

; These are used to clear variables in case the user hits the q/e/s keys (sending a key-up event).

; Clear Left on Q Keypress

~ * q::

{

vLeft := false

return

}

; Clear Right on E Keypress

~ * e::

{

vRight := false

return

}

; Clear Back on S Keypress

~ * s::

{

vBack := false

return