Last active
August 29, 2015 14:06
-
-
Save renz45/7d19427cd3e498fdcce3 to your computer and use it in GitHub Desktop.
Autohotkey script that changes wildstar controls to be like tera (asian action rpg style)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; CombatMouseLock | |
;;; v1 | |
;;; 9/6/2014 | |
;;; | |
;;; Combat mouse lock attempts to recreate a jrpg style of play | |
;;; comparable to the game Tera. This differs from combing plugins | |
;;; like steer and mousebindings in that we don't get the clunkiness | |
;;; of rebinding the mouse buttons, so objects remain selectable | |
;;; without triggering the bound abilities. The windows key is used | |
;;; to enguage the lock, while pressing left alt will temporairy | |
;;; disable the lock. | |
;;; | |
;;; Rebound buttons: | |
;;; Left Mouse Button | |
;;; Right Mouse Button | |
;;; Left Alt (retains its default functionality) | |
;;; Left Window key | |
;;; | |
;;; Keybinds are modified via the "LBF-RBR.ini" file | |
;;; which will be created on the first execution of | |
;;; LeftButtonFire.exe. Any changes made to .ini will | |
;;; take effect once the settings have been reloaded | |
;;; | |
;;; Important keys (these only work while IN Wildstar) | |
;;; F11: reload settings from LBF-RBR.ini | |
;;; F12: exit CombatMouseLock | |
;;;------------------------------------------------------------- | |
#SingleInstance force | |
#MaxThreadsPerHotkey 1 | |
Gosub, GetBindings | |
#IfWinActive, WildStar | |
Debug(str) | |
{ | |
global h_stdout | |
DebugConsoleInitialize() ; start console window if not yet started | |
str .= "`n" ; add line feed | |
DllCall("WriteFile", "uint", h_Stdout, "uint", &str, "uint", StrLen(str), "uint*", BytesWritten, "uint", NULL) ; write into the console | |
WinSet, Bottom,, ahk_id %h_stout% ; keep console on bottom | |
} | |
DebugConsoleInitialize() | |
{ | |
global h_Stdout ; Handle for console | |
static is_open = 0 ; toogle whether opened before | |
if (is_open = 1) ; yes, so don't open again | |
return | |
is_open := 1 | |
; two calls to open, no error check (it's debug, so you know what you are doing) | |
DllCall("AttachConsole", int, -1, int) | |
DllCall("AllocConsole", int) | |
dllcall("SetConsoleTitle", "str","Paddy Debug Console") ; Set the name. Example. Probably could use a_scriptname here | |
h_Stdout := DllCall("GetStdHandle", "int", -11) ; get the handle | |
WinSet, Bottom,, ahk_id %h_stout% ; make sure it's on the bottom | |
WinActivate,Lightroom ; Application specific; I need to make sure this application is running in the foreground. YMMV | |
return | |
} | |
;--------------------------------------------------------------- | |
; Functions for locking the mouse | |
;--------------------------------------------------------------- | |
locked:= false | |
temp_locked:= false | |
ToggleLock() { | |
global locked | |
if ( locked ) { | |
locked:= false | |
SendInput, {RButton UP} | |
} | |
else | |
{ | |
locked:= true | |
SendInput, {RButton DOWN} | |
} | |
return | |
} | |
TempUnlock() { | |
global locked | |
global temp_locked | |
if(locked && !temp_locked ) { | |
temp_locked:= true | |
locked:= false | |
SendInput, {RButton UP} | |
} | |
return | |
} | |
Templock() { | |
global locked | |
global temp_locked | |
if(temp_locked) { | |
temp_locked:= false | |
locked:= true | |
SendInput, {RButton DOWN} | |
} | |
return | |
} | |
;--------------------------------------------------------------- | |
; Function for keys with BOTH down and up events | |
; Left Mouse Button | |
;--------------------------------------------------------------- | |
ButtonFireDown(bind, button, fire_during_temp) { | |
global locked | |
global temp_locked | |
if ( locked ) | |
{ | |
Send, {%bind% DOWN} | |
} | |
else if((temp_locked && fire_during_temp) || !temp_locked) | |
{ | |
Send, {%button% DOWN} | |
} | |
return | |
} | |
ButtonFireUp(bind, button, respect_lock) { | |
global locked | |
if ( respect_lock ) { | |
if (locked) { | |
SendInput, {%bind% UP} | |
} | |
else | |
{ | |
SendInput, {%button% UP} | |
} | |
} | |
else | |
{ | |
SendInput, {%bind% UP} | |
SendInput, {%button% UP} | |
} | |
return | |
} | |
~F11:: Gosub, GetBindings | |
~F12:: ExitApp | |
;--------------------------------------------------------------- | |
; Button binds | |
;--------------------------------------------------------------- | |
$LButton:: ButtonFireDown(Left_Click, "LButton", true) | |
$LButton UP:: ButtonFireUp(Left_Click, "LButton", false) | |
$RButton:: ButtonFireDown(Right_Click, "RButton", true) | |
$RButton UP:: ButtonFireUp(Right_Click, "RButton", true) | |
; Toggle the mouse lock | |
LWin:: ToggleLock() | |
; Temporary unlock | |
~*LAlt:: TempUnlock() | |
~*LAlt UP:: Templock() | |
; Ensure that hitting escape removes the mouse lock | |
~Esc:: | |
locked:= false | |
temp_locked:= false | |
Send, {RButton UP} | |
return | |
; Sometimes when portaling between zones, wildstar releases the right mouse button | |
; this re-enables lock if the lock was on but the mouse button gets released for some | |
; reason within the game. | |
~a:: | |
~w:: | |
~s:: | |
~d:: | |
If (locked && !GetKeyState("RButton","P")) { | |
Send, {RButton DOWN} | |
} | |
return | |
; Ventrillo rebind | |
Capslock::RCtrl | |
;--------------------------------------------------------------- | |
; Subroutines | |
;--------------------------------------------------------------- | |
; LBF-RBR.ini is created at first run, you can change the mouse bindings here | |
; after running the script for the first time. Defaults to: | |
; Left mouse - 1 | |
; Right mouse - 2 | |
GetBindings: | |
;----READ BINDINGS FROM INI FILE---- | |
IniRead, Left_Click, LBF-RBR.ini, LBFire, Left_Click, 1 | |
IniWrite, %Left_Click%, LBF-RBR.ini, LBFire, Left_Click | |
IniRead, Right_Click, LBF-RBR.ini, LBFire, Right_Click, 2 | |
IniWrite, %Right_Click%, LBF-RBR.ini, LBFire, Right_Click | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment