Guest User

Untitled

a guest
Feb 18th, 2020
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <WindowsConstants.au3>
  5. #include "NomadMemory2.au3";
  6. #include <Timers.au3>
  7.  
  8. #Region ### START GUI ### Form=
  9. $Form1 = GUICreate("BOT", 400, 230, -1, -1)
  10. GUICtrlSetBkColor(-1, 0x00FF00)
  11.  
  12. #Region hotkey1
  13. $hot1lab = GuiCtrlCreateLabel("Hotkey1", 90, 10, 60, 20,-1)
  14. $hot1key = GuiCtrlCreateCombo("", 60, 30, 120, 21,-1)
  15. GUICtrlSetData($hot1key, "F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12", "F11")
  16.  
  17. $hot1labhp = GuiCtrlCreateLabel("Hotkey1 HP%", 90, 60, 80, 20,-1)
  18. $hot1hp = GuiCtrlCreateInput("75", 60, 80, 120, 20,-1)
  19.  
  20. $hot1labid = GuiCtrlCreateLabel("Zalozony ring1 id", 90, 110, 80, 20,-1)
  21. $hot1id = GuiCtrlCreateInput("3088", 60, 130, 120, 20,-1)
  22. #EndRegion
  23.  
  24. #Region hotkey1
  25. $hot2lab = GuiCtrlCreateLabel("Hotkey2", 250, 10, 60, 20,-1)
  26. $hot2key = GuiCtrlCreateCombo("", 220, 30, 120, 21,-1)
  27. GUICtrlSetData($hot2key, "F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12", "F12")
  28.  
  29. $hot2labhp = GuiCtrlCreateLabel("Hotkey2 HP%", 250, 60, 80, 20,-1)
  30. $hot2hp = GuiCtrlCreateInput("100", 220, 80, 120, 20,-1)
  31.  
  32. $hot2labid = GuiCtrlCreateLabel("Zalozony ring2 id", 250, 110, 80, 20,-1)
  33. $hot2id = GuiCtrlCreateInput("3099", 220, 130, 120, 20,-1)
  34. #EndRegion
  35.  
  36. $button = GuiCtrlCreateButton("napierdalaj", 80, 160, 70, 30,-1)
  37. $info = GuiCtrlCreateLabel("", 60, 200, 200, 20,-1)
  38.  
  39. GUISetState(@SW_SHOW)
  40. #EndRegion ### END GUI section ###
  41.  
  42.  
  43. #Region offsets
  44. $hpOffset = 0x70E000
  45. $xorOffset = 0x570458
  46. $maxHpOffset = 0x70E048
  47. $ringEquipedOffset = 0x7B0190
  48. $base = null
  49. #EndRegion
  50.  
  51. $pid = null;
  52. While 1
  53. $nMsg = GUIGetMsg()
  54. Switch $nMsg
  55. Case $GUI_EVENT_CLOSE
  56. Exit
  57. Case $button
  58. If GUICtrlRead($button) = "napierdalaj" Then
  59. #Region init vars
  60. GUICtrlSetData($button, "stop")
  61. $pid = ProcessExists("Tibia.exe")
  62. GUICtrlSetData($info, "Jakub, działam na procesie " & $pid)
  63. $mem = _MemoryOpen($pid)
  64. $base = _MemoryModuleGetBaseAddress($PID, "Tibia.exe")
  65. $xor = _MemoryRead($base + $xorOffset, $mem);
  66. $hp1 = Number(GUICtrlRead($hot1hp))/100;
  67. $hp2 = Number(GUICtrlRead($hot2hp))/100;
  68. $key1 = GUICtrlRead($hot1key);
  69. $key2 = GUICtrlRead($hot2key);
  70. $id1 = Number(GUICtrlRead($hot1id));
  71. $id2 = Number(GUICtrlRead($hot2id));
  72. $ring = _MemoryRead($base + $ringEquipedOffset, $mem);
  73. #EndRegion
  74. Else
  75. GUICtrlSetData($button, "napierdalaj")
  76. GUICtrlSetData($info, "")
  77. $pid = null
  78. EndIf
  79. EndSwitch
  80.  
  81. if $pid <> null Then
  82. $hp = BitXOR(_MemoryRead($base + $hpOffset, $mem),$xor);
  83. $maxHp = BitXOR(_MemoryRead($base + $maxHpOffset, $mem), $xor);
  84. $hpPc = $hp / $maxHp;
  85. $ring = _MemoryRead($base + $ringEquipedOffset, $mem);
  86. if $hp1 > $hp2 And $hpPc < $hp2 Then
  87. if $ring <> $id2 Then
  88. $ring = $id2
  89. sendHotkey($key2)
  90. EndIf
  91. ElseIf $hp1 > $hp2 And $hpPc < $hp1 Then
  92. if $ring <> $id1 Then
  93. $ring = $id1
  94. sendHotkey($key1)
  95. EndIf
  96. ElseIf $hp1 < $hp2 And $hpPc < $hp1 Then
  97. if $ring <> $id1 Then
  98. $ring = $id1
  99. sendHotkey($key1)
  100. EndIf
  101. ElseIf $hp1 < $hp2 And $hpPc < $hp2 Then
  102. if $ring <> $id2 Then
  103. $ring = $id2
  104. sendHotkey($key2)
  105. EndIf
  106. EndIf
  107. Sleep(50)
  108. EndIf
  109. WEnd
  110.  
  111. Func sendHotkey($ks)
  112. ControlSend("Tibia","","","{"&$ks&"}")
  113. _Sleep (200)
  114. EndFunc
  115.  
  116. Func _Sleep($Time)
  117. $begin = TimerInit()
  118. While 1
  119. if TimerDiff($begin) >= $Time Then ExitLoop
  120. WEnd
  121. Return True
  122. EndFunc
  123.  
  124. Func _MemoryModuleGetBaseAddress($iPID, $sModule)
  125. If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
  126.  
  127. If Not IsString($sModule) Then Return SetError(2, 0, 0)
  128.  
  129. Local $PSAPI = DllOpen("psapi.dll")
  130.  
  131. ;Get Process Handle
  132. Local $hProcess
  133. Local $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE
  134.  
  135. If $iPID > 0 Then
  136. Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
  137. If $hProcess[0] Then
  138. $hProcess = $hProcess[0]
  139. EndIf
  140. EndIf
  141.  
  142. ;EnumProcessModules
  143. Local $Modules = DllStructCreate("ptr[1024]")
  144. Local $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
  145. If $aCall[4] > 0 Then
  146. Local $iModnum = $aCall[4] / 4
  147. Local $aTemp
  148. For $i = 1 To $iModnum
  149. $aTemp = DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
  150. If $aTemp[3] = $sModule Then
  151. DllClose($PSAPI)
  152. Return Ptr(DllStructGetData($Modules, 1, $i))
  153. EndIf
  154. Next
  155. EndIf
  156.  
  157. DllClose($PSAPI)
  158. Return SetError(-1, 0, 0)
  159.  
  160. EndFunc
RAW Paste Data