Advertisement
perazite

Diablo III v1

May 5th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.74 KB | None | 0 0
  1. /*
  2.  
  3. Description:
  4.  
  5. This script enables traditional WASD movements for Diablo III.
  6.  
  7. The default keys are:
  8. North - W
  9. West - A
  10. South - S
  11. East - D
  12.  
  13. The keys can be combined to produce a total of 8 directions (4 ordinal and 4 diagonal). The directions are relative to the
  14. screen, meaning north is moving towards the top of the screen, west is moving towards the left of the screen, and so on.
  15.  
  16.  
  17.  
  18. Use Instructions:
  19. 1) Run this script with AutoHotKey
  20. 2) Start Diablo III within 60 seconds of step 1
  21. 3) If this is your first time running this script remove bindings for the "W" "A" "S" and "D" keys in Diablo III. If any
  22.     action is bound to one of the keys used for movement by this script the action would be performed in addition to the
  23.     movement. Keep in mind if you edit this script to use another keyset the same rule applies to those keys
  24. 4) Bind the F12 key on your keyboard to the Move action.
  25.  
  26. NOTE:
  27. If you change the resolution of the game at any point after running the script, you must reload the script for it to function properly
  28.  
  29. */
  30.  
  31.  
  32.  
  33. #NoEnv                          ; Prevents bugs caused by environmental variables matching those in the script
  34. #Persistent                     ; Allows the script to stay active and makes it single-instance
  35. #MaxHotkeysPerInterval, 200     ; Safeguard to prevent accidental infinite-looping of events
  36. SendMode Input                  ; Avoids the possible limitations of SendMode Play, increases reliability.
  37. SetWorkingDir %A_ScriptDir%     ; Sets the script's working directory
  38. SetDefaultMouseSpeed, 0         ; For character movement without moving the cursor
  39. SetTitleMatchMode, 3            ; Window title must exactly match Winactive("Diablo III")
  40.  
  41.  
  42.  
  43. ; BEGIN config section -- you can change the variables below to your specific needs
  44.  
  45. mkey = F12          ; key bound to Move command in game
  46. y_offset = 10       ; distance from character to issue move command on the y-axis (used to calculate the x_offset to maintain aspect ratios)
  47.  
  48. ; END config section
  49.  
  50. OnExit, Agent_Kill
  51.  
  52. WinWaitActive, Diablo III, , 60     ; this command waits for Diablo III to be the active window to get window information
  53. if ErrorLevel
  54. {
  55.    MsgBox, Diablo III not started within the allotted time. Please run the script again then start Diablo III
  56.    ExitApp
  57. }
  58. else
  59. {
  60.         Sleep 500
  61.         WinGetPos, win_x, win_y, width, height, A
  62.         x_center := win_x + width / 2
  63.         compensation := (width / height) == (16 / 10) ? 1.063829 : 1.063711
  64.         y_center := win_y + height / 2 / compensation
  65.         offset_mod := y_offset / height
  66.         x_offset := width * offset_mod
  67.                
  68. }
  69.  
  70. SetTimer, WASD_Handler, 10
  71. return
  72.  
  73.  
  74.  
  75. Agent_Kill:     ; kills Agent.exe if it is still running after Diablo and the script close
  76.     if !WinExist("Diablo III")
  77.     {
  78.         Process, Close, Agent.exe
  79.     }
  80.     ExitApp
  81. return
  82.  
  83.  
  84.  
  85. WASD_Handler:
  86.     if !WinActive("Diablo III")
  87.     {
  88.         if !WinExist("Diablo III")      ; closes the script down if Diablo is no longer running
  89.         {  
  90.             ExitApp
  91.         }
  92.         return
  93.     }
  94.  
  95.  
  96.    
  97.     if GetKeyState("Shift", "P")        ; this if/loop lets Shift still function as a stand still key
  98.     {
  99.         Loop
  100.         {
  101.             GetKeyState, state, Shift, P
  102.             if state = U  
  103.             break              
  104.         }
  105.     }
  106.     else if GetKeyState("w", "P") || GetKeyState("s", "P") || GetKeyState("a", "P") || GetKeyState("d", "P")
  107.     {
  108.         if GetKeyState("w", "P")
  109.         {
  110.             y_final := y_center - y_offset
  111.         }
  112.         else if GetKeyState("s", "P")
  113.         {
  114.             y_final := y_center + y_offset
  115.         }
  116.         else
  117.         {
  118.             y_final := y_center
  119.         }
  120.                
  121.         if GetKeyState("a", "P")
  122.         {
  123.             x_final := x_center - x_offset
  124.         }
  125.         else if GetKeyState("d", "P")
  126.         {
  127.             x_final := x_center + x_offset
  128.         }
  129.         else
  130.         {
  131.             x_final := x_center
  132.         }
  133.        
  134.         MouseGetPos, x_initial, y_initial
  135.         MouseMove, %x_final%, %y_final%, 0         
  136.         Send {%mkey%}
  137.         MouseMove, %x_initial%, %y_initial%, 0
  138.     }
  139.    
  140.    
  141.    
  142. return
  143.  
  144.  
  145.  
  146.  
  147.  
  148. ;====================================================================================
  149. ; KEY SPAM
  150. ;====================================================================================
  151.  
  152. #SingleInstance, Force          ; Make sure only one copy of this is running at a time
  153. Random, 100ms, 50, 150          ; Define random function "100ms"
  154. SetKeyDelay, 30,30              ; sets up the keyhandler for key-press and key-hold times
  155.  
  156. xbutton1::                      ; a hotkey based on the left side mouse button
  157. Send, 1                         ; sends a 1 key to the active window
  158. gosub,100ms                     ; pauses the program for 100 milliseconds
  159. Send, 2                         ; sends a 2 key to the active window
  160. gosub,100ms                     ; pauses for another 100 milliseconds
  161. Send, 3                         ; and finally sends the 3 key to the active window
  162. Return
  163.  
  164. ^esc::                          ; press ctrl-Esc to exit the script entirely.
  165. ExitApp
  166. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement