kyoshiharu

Improved Camera Updated AHK

Jul 5th, 2020
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. #SingleInstance force
  2. #Persistent
  3. #MaxThreadsPerHotkey 20
  4. #Include %A_ScriptDir%\lib\classMemory.ahk
  5. SetWorkingDir %A_ScriptDir%
  6. inifile = settings.txt
  7.  
  8. ;load settings
  9. IniRead, maxZoom, %inifile%, settings, maxZoom, 60
  10. IniRead, tiltCoeficient, %inifile%, settings, tiltCoeficient, 0.005
  11. IniRead, tiltInvert, %inifile%, settings, tiltInvert, 0
  12.  
  13. loaded := false
  14. prevMouseY := 0
  15. Gui Show, w295 h330, Window
  16. Gui Add, Edit, x152 y32 w120 h21 vmaxZoom, %maxZoom%
  17. Gui Add, Text, x24 y32 w120 h23 +0x200, Max Zoom
  18. Gui Add, Text, x24 y64 w120 h23 +0x200, Tilt Coefficient
  19. Gui Add, Edit, x152 y64 w120 h21 vtiltCoeficient, %tiltCoeficient%
  20. if (tiltInvert = 1)
  21. Gui Add, CheckBox, x232 y96 w38 h24 Checked vtiltInvert
  22. else
  23. Gui Add, CheckBox, x232 y96 w38 h24 vtiltInvert
  24. Gui Add, Text, x24 y96 w204 h23 +0x200, Invert Vertical Camera Movement
  25. Gui Add, GroupBox, x16 y8 w265 h173, Settings
  26. Gui Add, Button, x64 y128 w161 h35 Default, Save settings
  27. Gui Add, Text, x16 y192 w120 h23 +0x200, Loading libraries
  28.  
  29. if (_ClassMemory.__Class != "_ClassMemory"){
  30. msgbox class memory not correctly installed. Or the (global class) variable "_ClassMemory" has been overwritten
  31. ExitApp
  32. }
  33.  
  34. Gui Font, c0x008000
  35. Gui Add, Text, x160 y192 w120 h23 +0x200, Ok
  36. Gui Font
  37. Gui Add, Text, x17 y223 w120 h23 +0x200, Searching memory
  38.  
  39. dos := new _ClassMemory("ahk_exe EoCApp.exe", "", hProcessCopy)
  40.  
  41. if !isObject(dos){
  42. msgbox failed to open a handle
  43. if (hProcessCopy = 0)
  44. msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter.
  45. else if (hProcessCopy = "")
  46. msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
  47. ExitApp
  48. }
  49.  
  50. SetFormat, integerFast, Hex
  51. aob := dos.hexStringToPattern("00 00 b0 40 00 00 98 41")
  52. bAddr := dos.processPatternScan(0x10000000000,,aob*)
  53. zoomMinAddr := bAddr
  54. zoomMaxAddr := bAddr + 0x4
  55. TiltMinAddr := bAddr + 0x8c
  56. TiltMaxAddr := bAddr + 0x80
  57. TiltCombatMinAddr := bAddr + 0xa4
  58. TiltCombatMaxAddr := bAddr + 0x98
  59. if (bAddr = 0)
  60. {
  61. msgbox % "bAddr = " . bAddr . ". Could not lock onto camera controls in the game using the processPatternScan function."
  62. ExitApp
  63. }
  64.  
  65. Gui Font, c0x008000
  66. Gui Add, Text, x160 y223 w120 h23 +0x200, Ok
  67. Gui Font
  68. Gui Add, Text, x16 y256 w120 h23 +0x200, Enabling functions
  69.  
  70. dos.write(zoomMaxAddr, maxZoom, "Float")
  71.  
  72. Gui Font, c0x008000
  73. Gui Add, Text, x160 y256 w120 h23 +0x200, Ok
  74. Gui Font
  75. Gui Font, s14 c0x008000
  76. Gui Add, Text, x16 y288 w264 h45 +0x1 +0x200, READY
  77. Gui Font
  78. loaded := true
  79. return
  80.  
  81. ButtonSaveSettings:
  82. gui, submit, nohide
  83. IniWrite, %maxZoom%, %inifile%, settings, maxZoom
  84. IniWrite, %tiltCoeficient%, %inifile%, settings, tiltCoeficient
  85. IniWrite, %tiltInvert%, %inifile%, settings, tiltInvert
  86. dos.write(zoomMaxAddr, maxZoom, "Float")
  87. return
  88.  
  89. ~MButton::
  90. while (getkeystate("MButton"))
  91. {
  92. MouseGetPos, posX, posY
  93. if (prevMouseY = 0){
  94. prevMouseY := posY
  95. }else{
  96. diff := posY - prevMouseY
  97. if(diff != 0){
  98. prevMouseY := posY
  99. curTilt := dos.read(TiltMinAddr,"Float")
  100. adjust := diff * tiltCoeficient
  101. if(tiltInvert = 1)
  102. adjust := adjust * -1
  103. newTilt := adjust + curTilt
  104. if(newTilt < 3 and newTilt > 0.1){
  105. dos.write(TiltMinAddr, newTilt, "Float")
  106. dos.write(TiltMaxAddr, newTilt, "Float")
  107. dos.write(TiltCombatMinAddr, newTilt, "Float")
  108. dos.write(TiltCombatMaxAddr, newTilt, "Float")
  109. }
  110. }
  111. sleep, 25
  112. }
  113. }
  114. prevMouseY := 0
  115. return
  116.  
  117. GuiClose:
  118. dos.write(zoomMaxAddr, 19, "Float")
  119. ExitApp
Add Comment
Please, Sign In to add comment