Advertisement
Guest User

D3

a guest
Jun 14th, 2012
4,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 12.28 KB | None | 0 0
  1.  
  2. ;;================================================================================
  3. ;;================================================================================
  4. ;;  Diablo 3 Movement and Interaction UDF
  5. ;;  For personal study purposes only.
  6. ;;
  7. ;;  By UnknOwned 2012
  8. ;;================================================================================
  9. ;;================================================================================
  10.  
  11. ;;================================================================================
  12. ;; PRE FUNCTIONS
  13. ;;================================================================================
  14. ;;--------------------------------------------------------------------------------
  15. ;;  Make sure you are running as admin
  16. ;;--------------------------------------------------------------------------------
  17. $_debug = 1
  18. #RequireAdmin
  19. $Admin = IsAdmin()
  20. if $Admin <> 1 Then
  21.     MsgBox(0x30,"ERROR","This program require administrative rights you fool!")
  22.     Exit
  23. EndIf
  24.  
  25. ;;--------------------------------------------------------------------------------
  26. ;;  Includes
  27. ;;--------------------------------------------------------------------------------
  28. #include <NomadMemory.au3> ;THIS IS EXTERNAL, GET IT AT THE AUTOIT WEBSITE
  29. #Include <math.au3>
  30. #Include <String.au3>
  31. #Include <Array.au3>
  32.  
  33. ;;--------------------------------------------------------------------------------
  34. ;;  Open the process
  35. ;;--------------------------------------------------------------------------------
  36. Opt("WinTitleMatchMode", -1)
  37. SetPrivilege("SeDebugPrivilege", 1)
  38. Global $ProcessID = WinGetProcess("Diablo III","")
  39. Local $d3 = _MemoryOpen($ProcessID)
  40. If @Error Then
  41.     MsgBox(4096, "ERROR", "Failed to open memory for process;" & $ProcessID)
  42.     Exit
  43. EndIf
  44.  
  45. ;;--------------------------------------------------------------------------------
  46. ;;  Initialize the offsets
  47. ;;--------------------------------------------------------------------------------
  48. Offsetlist()
  49.  
  50.  
  51. ;;================================================================================
  52. ;; SAMPLE CODE
  53. ;;================================================================================
  54.  
  55.  
  56. ;//The following will display a list of all actors in the console
  57. IterateObjectList(1)
  58.  
  59. ;//The following will loot everything on the ground near you, including gold.
  60. while 1
  61.     $OBject = IterateObjectList(0)
  62.     $foundobject = 0   
  63.     for  $i = 0 to UBound ( $OBject ,1 )-1
  64.         _ArraySort($OBject, 0 , 0 , 0 ,8)
  65.         if $OBject[$i][6] = 2 and $OBject[$i][7] = -1 and $OBject[$i][1] <> 0xFFFFFFFF or StringInStr($OBject[$i][2],"GoldCoins") Then
  66.             InteractGUID($OBject[$i][1],0x7545)
  67.             ConsoleWrite("GO")
  68.             $foundobject = 1
  69.             ExitLoop
  70.         EndIf
  71.     Next
  72.     if $foundobject = 0 then ExitLoop
  73. wend
  74.  
  75. ;//The following will move your toon from where ever you are towards the priest.
  76. ;//This part will only work in tristram, if you are at the inn.
  77. ;//This won't work if you have not moved in this session (do a click anywhere in the world to fix)
  78. MoveToPos(2945,2809,24.04)
  79. MoveToPos(2904,2803,24.04)
  80.  
  81. ;//The following part will make you interact with the priest
  82. ;//Note that you can only interact with NPC's while the game window is active. (unless you spam the interact function once you are at the NPC)
  83. $OBject = IterateObjectList(0)
  84. $PriestIndex = _ArraySearch($OBject,"Priest_Male", 0 , 0 , 0 , 1 , 1 , 2)
  85. InteractGUID($OBject[$PriestIndex][1],0x7546)
  86. sleep(1000)
  87. InteractGUID($OBject[$PriestIndex][1],0x7546)
  88. Exit
  89.  
  90.  
  91. ;;================================================================================
  92. ;; FUNCTIONS
  93. ;;================================================================================
  94. ;;--------------------------------------------------------------------------------
  95. ;;  LocateMyToon()
  96. ;;--------------------------------------------------------------------------------
  97. func LocateMyToon()
  98.     if $_debug then ConsoleWrite("-----Looking for local player------" &@crlf)
  99.     $_CurOffset = $_itrObjectManagerD
  100.     $_Count = _MemoryRead($_itrObjectManagerCount, $d3, 'int')
  101.     for $i = 0 to $_Count step +1
  102.         $_GUID = _MemoryRead($_CurOffset+0x4, $d3, 'ptr')
  103.         $_NAME = _MemoryRead($_CurOffset+0x8, $d3, 'char[64]')
  104.         if $_GUID = 0x77BC0000 Then
  105.             global $_Myoffset = $_CurOffset
  106.             if $_debug then ConsoleWrite("My toon located at: " &$_Myoffset & ", GUID: " & $_GUID & ", NAME: " & $_NAME &@CRLF)
  107.             ExitLoop
  108.         EndIf
  109.         $_CurOffset = $_CurOffset + $_ObjmanagerStrucSize
  110.     Next
  111. EndFunc
  112.  
  113. ;;--------------------------------------------------------------------------------
  114. ;;  OffsetList()
  115. ;;--------------------------------------------------------------------------------
  116. func offsetlist()
  117.     global $ofs_ObjectManager =                 0x01580A2C
  118.     global $ofs__ObjmanagerActorOffsetA =       0x8b0
  119.     global $ofs__ObjmanagerActorCount =         0x108
  120.     global $ofs__ObjmanagerActorOffsetB =       0x148
  121.     global $ofs__ObjmanagerActorLinkToCTM =     0x380
  122.     global $_ObjmanagerStrucSize =  0x428  
  123.    
  124.     global $_itrObjectManagerA  = _MemoryRead($ofs_ObjectManager, $d3, 'ptr')      
  125.     global $_itrObjectManagerB  = _MemoryRead($_itrObjectManagerA+$ofs__ObjmanagerActorOffsetA, $d3, 'ptr')
  126.     global $_itrObjectManagerCount  = $_itrObjectManagerB+$ofs__ObjmanagerActorCount
  127.     global $_itrObjectManagerC  = _MemoryRead($_itrObjectManagerB+$ofs__ObjmanagerActorOffsetB, $d3, 'ptr')
  128.     global $_itrObjectManagerD  = _MemoryRead($_itrObjectManagerC, $d3, 'ptr') 
  129.     global $_itrObjectManagerE  = _MemoryRead($_itrObjectManagerD, $d3, 'ptr') 
  130.  
  131.  
  132.    
  133.     global $ofs_Interact =                  0x01580A14
  134.     global $ofs__InteractOffsetA =          0xA8
  135.     global $ofs__InteractOffsetB =          0x58
  136.     global $ofs__InteractOffsetUNK1 =           0x7F20 ;Set to 777c
  137.     global $ofs__InteractOffsetUNK2 =           0x7F44 ;Set to 1 for NPC interaction
  138.     global $ofs__InteractOffsetUNK3 =           0x7F7C ;Set to 7546 for NPC interaction, 7545 for loot interaction
  139.     global $ofs__InteractOffsetUNK4 =           0x7F80 ;Set to 7546 for NPC interaction, 7545 for loot interaction
  140.     global $ofs__InteractOffsetMousestate =     0x7F84 ;Mouse state 1 = clicked, 2 = mouse down
  141.     global $ofs__InteractOffsetGUID =           0x7F88 ;Set to the GUID of the actor you want to interact with
  142.    
  143.    
  144.     global $_itrInteractA  = _MemoryRead($ofs_Interact, $d3, 'ptr')
  145.     global $_itrInteractB  = _MemoryRead($_itrInteractA, $d3, 'ptr')   
  146.     global $_itrInteractC  = _MemoryRead($_itrInteractB, $d3, 'ptr')   
  147.     global $_itrInteractD  = _MemoryRead($_itrInteractC+$ofs__InteractOffsetA, $d3, 'ptr') 
  148.     global $_itrInteractE  = $_itrInteractD+$ofs__InteractOffsetB
  149.  
  150.     $FixSpeed = 0x20 ;69736
  151.     $ToggleMove = 0x34
  152.     $MoveToXoffset = 0x3c
  153.     $MoveToYoffset = 0x40
  154.     $MoveToZoffset = 0x44
  155.     $CurrentX = 0xA4
  156.     $CurrentY = 0xA8
  157.     $CurrentZ = 0xAc
  158.     $RotationOffset = 0x170
  159.    
  160.     LocateMyToon()
  161.     global $ClickToMoveMain = _MemoryRead($_Myoffset + $ofs__ObjmanagerActorLinkToCTM, $d3, 'ptr')
  162.     global $ClickToMoveRotation = $ClickToMoveMain + $RotationOffset
  163.     global $ClickToMoveCurX = $ClickToMoveMain + $CurrentX
  164.     global $ClickToMoveCurY = $ClickToMoveMain + $CurrentY
  165.     global $ClickToMoveCurZ = $ClickToMoveMain + $CurrentZ
  166.     global $ClickToMoveToX = $ClickToMoveMain + $MoveToXoffset
  167.     global $ClickToMoveToY = $ClickToMoveMain + $MoveToYoffset
  168.     global $ClickToMoveToZ = $ClickToMoveMain + $MoveToZoffset
  169.     global $ClickToMoveToggle = $ClickToMoveMain + $ToggleMove
  170.     global $ClickToMoveFix= $ClickToMoveMain + $FixSpeed
  171.    
  172.    
  173.    
  174. EndFunc
  175.  
  176. ;;--------------------------------------------------------------------------------
  177. ;;  GetCurrentPos()
  178. ;;--------------------------------------------------------------------------------
  179. Func GetCurrentPos()
  180.     dim $return[3]
  181.     $return[0] = _MemoryRead($ClickToMoveCurX, $d3, 'float')
  182.     $return[1] = _MemoryRead($ClickToMoveCurY, $d3, 'float')
  183.     $return[2] = _MemoryRead($ClickToMoveCurZ, $d3, 'float')
  184.     return $return
  185. EndFunc
  186.  
  187. ;;--------------------------------------------------------------------------------
  188. ;;  MoveToPos()
  189. ;;--------------------------------------------------------------------------------
  190. func MoveToPos($_x,$_y,$_z)
  191.     _MemoryWrite($ClickToMoveToX , $d3,$_x, 'float')
  192.     _MemoryWrite($ClickToMoveToY , $d3,$_y, 'float')
  193.     _MemoryWrite($ClickToMoveToZ , $d3,$_z, 'float')
  194.     _MemoryWrite($ClickToMoveToggle , $d3,1, 'int')
  195.     _MemoryWrite($ClickToMoveFix , $d3,69736, 'int')
  196.  
  197.     while 1
  198.         $CurrentLoc = GetCurrentPos()
  199.         $xd = $_x-$CurrentLoc[0]
  200.         $yd = $_y-$CurrentLoc[1]
  201.         $zd = $_z-$CurrentLoc[2]
  202.         $Distance = Sqrt($xd*$xd + $yd*$yd + $zd*$zd)  
  203.         if $Distance < 2 then ExitLoop
  204.         if _MemoryRead($ClickToMoveToggle, $d3, 'float') = 0 then ExitLoop
  205.         sleep(10)
  206.     WEnd
  207. EndFunc                    
  208.        
  209. ;;--------------------------------------------------------------------------------
  210. ;;  InteractGUID()
  211. ;;--------------------------------------------------------------------------------
  212. func InteractGUID($_guid,$_snoPower)
  213.     $FixSpeed = 0x20 ;69736
  214.     $ToggleMove = 0x34
  215.     $MoveToXoffset = 0x3c
  216.     $MoveToYoffset = 0x40
  217.     $MoveToZoffset = 0x44
  218.     $CurrentX = 0xA4
  219.     $CurrentY = 0xA8
  220.     $CurrentZ = 0xAc
  221.     $RotationOffset = 0x170
  222.     global $ClickToMoveRotation = $ClickToMoveMain + $RotationOffset
  223.     global $ClickToMoveCurX = $ClickToMoveMain + $CurrentX
  224.     global $ClickToMoveCurY = $ClickToMoveMain + $CurrentY
  225.     global $ClickToMoveCurZ = $ClickToMoveMain + $CurrentZ
  226.     global $ClickToMoveToX = $ClickToMoveMain + $MoveToXoffset
  227.     global $ClickToMoveToY = $ClickToMoveMain + $MoveToYoffset
  228.     global $ClickToMoveToZ = $ClickToMoveMain + $MoveToZoffset
  229.     global $ClickToMoveToggle = $ClickToMoveMain + $ToggleMove
  230.     global $ClickToMoveFix= $ClickToMoveMain + $FixSpeed   
  231.         $CurrentLocX = _MemoryRead($ClickToMoveCurX, $d3, 'float')
  232.         $CurrentLocY = _MemoryRead($ClickToMoveCurY, $d3, 'float')
  233.         $CurrentLocZ = _MemoryRead($ClickToMoveCurZ, $d3, 'float')
  234.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetUNK1 , $d3, 0x777C, 'ptr')
  235.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetUNK2 , $d3, 0x1, 'ptr')
  236.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetUNK3 , $d3, $_snoPower, 'ptr')
  237.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetUNK4 , $d3, $_snoPower, 'ptr')
  238.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetMousestate , $d3, 0x1, 'ptr')
  239.     _MemoryWrite($_itrInteractE+$ofs__InteractOffsetGUID , $d3, $_guid, 'ptr') 
  240.         _MemoryWrite($ClickToMoveToX , $d3,$CurrentLocX+1, 'float')
  241.         _MemoryWrite($ClickToMoveToY , $d3,$CurrentLocY, 'float')
  242.         _MemoryWrite($ClickToMoveToZ , $d3,$CurrentLocZ, 'float')
  243.         _MemoryWrite($ClickToMoveToggle , $d3,1, 'int')
  244.         _MemoryWrite($ClickToMoveFix , $d3,69736, 'int')   
  245.  
  246.     $tempvalue = _MemoryRead($_itrInteractE+$ofs__InteractOffsetUNK2, $d3, 'int')
  247.     while $tempvalue = 1
  248.         $tempvalue = _MemoryRead($_itrInteractE+$ofs__InteractOffsetUNK2, $d3, 'int')
  249.         sleep(10)
  250.     WEnd
  251. EndFunc
  252.    
  253. ;;--------------------------------------------------------------------------------
  254. ;;  IterateObjectList()
  255. ;;--------------------------------------------------------------------------------
  256. func IterateObjectList($_displayINFO)
  257.     if $_displayINFO = 1 then ConsoleWrite("-----Iterating through Actors------" &@crlf)
  258.     if $_displayINFO = 1 then ConsoleWrite("First Actor located at: "&$_itrObjectManagerD &@crlf)
  259.     $_CurOffset = $_itrObjectManagerD
  260.     $_Count = _MemoryRead($_itrObjectManagerCount, $d3, 'int')
  261.     dim $OBJ[$_Count+1][9]
  262.     if $_displayINFO = 1 then ConsoleWrite("Number of Actors : " & $_Count &@crlf)
  263.     for $i = 0 to $_Count step +1
  264.         $_GUID = _MemoryRead($_CurOffset+0x4, $d3, 'ptr')
  265.         $_NAME = _MemoryRead($_CurOffset+0x8, $d3, 'char[64]')
  266.         $_POS_X = _MemoryRead($_CurOffset+0xB0, $d3, 'float')  
  267.         $_POS_Y = _MemoryRead($_CurOffset+0xB4, $d3, 'float')  
  268.         $_POS_Z = _MemoryRead($_CurOffset+0xB8, $d3, 'float')  
  269.         $_DATA = _MemoryRead($_CurOffset+0x1FC, $d3, 'int')
  270.         $_DATA2 = _MemoryRead($_CurOffset+0x1Cc, $d3, 'int')       
  271.         $_DATA3 = _MemoryRead($_CurOffset+0x1C0, $d3, 'int')       
  272.        
  273.         $CurrentLoc = GetCurrentPos()
  274.         $xd = $_POS_X-$CurrentLoc[0]
  275.         $yd = $_POS_Y-$CurrentLoc[1]
  276.         $zd = $_POS_Z-$CurrentLoc[2]
  277.         $Distance = Sqrt($xd*$xd + $yd*$yd + $zd*$zd)
  278.             $OBJ[$i][0] = $i
  279.             $OBJ[$i][1] = $_GUID
  280.             $OBJ[$i][2] = $_NAME
  281.             $OBJ[$i][3] = $_POS_X
  282.             $OBJ[$i][4] = $_POS_Y
  283.             $OBJ[$i][5] = $_POS_Z
  284.             $OBJ[$i][6] = $_DATA
  285.             $OBJ[$i][7] = $_DATA2
  286.             $OBJ[$i][8] = $Distance
  287.        
  288.         if $_displayINFO = 1 then ConsoleWrite($i & @TAB&" : " & $_CurOffset & " " & $_GUID & " : " & $_DATA & " "& $_DATA2 & " " & @TAB& $_POS_X &" "& $_POS_Y&" "& $_POS_Z & @TAB& $_NAME &@crlf)
  289.         $_CurOffset = $_CurOffset + $_ObjmanagerStrucSize
  290.     Next
  291.     return $OBJ
  292. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement