0% found this document useful (0 votes)
243 views99 pages

GWA2

This document contains code for initializing and injecting a Guild Wars AutoIt bot into the game client process. It declares local variables and data structures for interacting with game memory, defines functions for opening the process, reading/writing memory, and getting addresses of important game structures. The Initialize function scans the running processes, opens memory, gets addresses of key variables, and sets up hooks to inject the bot code.

Uploaded by

Josh Mele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views99 pages

GWA2

This document contains code for initializing and injecting a Guild Wars AutoIt bot into the game client process. It declares local variables and data structures for interacting with game memory, defines functions for opening the process, reading/writing memory, and getting addresses of important game structures. The Initialize function scans the running processes, opens memory, gets addresses of key variables, and sets up hooks to inject the bot code.

Uploaded by

Josh Mele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 99

;~ Version 3.6.

9
#RequireAdmin
#include-once
If @AutoItX64 Then
MsgBox(16, "Error!", "Please run all bots in 32-bit (x86) mode.")
Exit
EndIf
#Region Declarations
Local $mKernelHandle
Local $mGWProcHandle
Local $mGWHwnd
Local $mMemory
Local $mLabels[1][2]
Local $mBase = 0x00DE0000
Local $mASMString, $mASMSize, $mASMCodeOffset
Local $mGUI = GUICreate('GWA'), $mSkillActivate, $mSkillCancel, $mSkillComplete,
$mChatReceive, $mLoadFinished
Local $mSkillLogStruct = DllStructCreate('dword;dword;dword;float')
Local $mSkillLogStructPtr = DllStructGetPtr($mSkillLogStruct)
Local $mChatLogStruct = DllStructCreate('dword;wchar[256]')
Local $mChatLogStructPtr = DllStructGetPtr($mChatLogStruct)
GUIRegisterMsg(0x501, 'Event')
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local

$mQueueCounter, $mQueueSize, $mQueueBase


$mTargetLogBase
$mStringLogBase
$mSkillBase
$mEnsureEnglish
$mMyID, $mCurrentTarget
$mAgentBase
$mBasePointer
$mRegion, $mLanguage
$mPing
$mCharname
$mMapID
$mMaxAgents
$mMapLoading
$mMapIsLoaded
$mLoggedIn
$mStringHandlerPtr
$mWriteChatSender
$mTraderQuoteID, $mTraderCostID, $mTraderCostValue
$mSkillTimer
$mBuildNumber
$mZoomStill, $mZoomMoving
$Rendering = True
$mDisableRendering
$mAgentCopyCount
$mAgentCopyBase

Local $mUseStringLog
Local $mUseEventSystem
#EndRegion Declarations
#Region CommandStructs
Local $mUseSkill = DllStructCreate('ptr;dword;dword;dword')

Local $mUseSkillPtr = DllStructGetPtr($mUseSkill)


Local $mMove = DllStructCreate('ptr;float;float;float')
Local $mMovePtr = DllStructGetPtr($mMove)
Local $mChangeTarget = DllStructCreate('ptr;dword')
Local $mChangeTargetPtr = DllStructGetPtr($mChangeTarget)
Local $mMove = DllStructCreate('ptr;float;float;float')
Local $mMovePtr = DllStructGetPtr($mMove)
Local $mPacket = DllStructCreate('ptr;dword;dword;dword;dword;dword;dword;dword;
dword;dword;dword;dword;dword')
Local $mPacketPtr = DllStructGetPtr($mPacket)
Local $mWriteChat = DllStructCreate('ptr')
Local $mWriteChatPtr = DllStructGetPtr($mWriteChat)
Local $mSellItem = DllStructCreate('ptr;dword;dword')
Local $mSellItemPtr = DllStructGetPtr($mSellItem)
Local $mAction = DllStructCreate('ptr;dword;dword')
Local $mActionPtr = DllStructGetPtr($mAction)
Local $mToggleLanguage = DllStructCreate('ptr;dword')
Local $mToggleLanguagePtr = DllStructGetPtr($mToggleLanguage)
Local $mUseHeroSkill = DllStructCreate('ptr;dword;dword;dword')
Local $mUseHeroSkillPtr = DllStructGetPtr($mUseHeroSkill)
Local $mBuyItem = DllStructCreate('ptr;dword;dword;dword')
Local $mBuyItemPtr = DllStructGetPtr($mBuyItem)
Local $mSendChat = DllStructCreate('ptr;dword')
Local $mSendChatPtr = DllStructGetPtr($mSendChat)
Local $mRequestQuote = DllStructCreate('ptr;dword')
Local $mRequestQuotePtr = DllStructGetPtr($mRequestQuote)
Local $mRequestQuoteSell = DllStructCreate('ptr;dword')
Local $mRequestQuoteSellPtr = DllStructGetPtr($mRequestQuoteSell)
Local $mTraderBuy = DllStructCreate('ptr')
Local $mTraderBuyPtr = DllStructGetPtr($mTraderBuy)
Local $mTraderSell = DllStructCreate('ptr')
Local $mTraderSellPtr = DllStructGetPtr($mTraderSell)
Local $mSalvage = DllStructCreate('ptr;dword;dword;dword')
Local $mSalvagePtr = DllStructGetPtr($mSalvage)
Local $mIncreaseAttribute = DllStructCreate('ptr;dword;dword')
Local $mIncreaseAttributePtr = DllStructGetPtr($mIncreaseAttribute)
Local $mDecreaseAttribute = DllStructCreate('ptr;dword;dword')
Local $mDecreaseAttributePtr = DllStructGetPtr($mDecreaseAttribute)
Local $mMakeAgentArray = DllStructCreate('ptr;dword')
Local $mMakeAgentArrayPtr = DllStructGetPtr($mMakeAgentArray)
#EndRegion CommandStructs

#Region Memory
;~ Description: Internal use only.
Func MemoryOpen($aPID)
$mKernelHandle = DllOpen('kernel32.dll')
Local $lOpenProcess = DllCall($mKernelHandle, 'int', 'OpenProcess', 'int
', 0x1F0FFF, 'int', 1, 'int', $aPID)
$mGWProcHandle = $lOpenProcess[0]
EndFunc ;==>MemoryOpen
;~ Description: Internal use only.
Func MemoryClose()
DllCall($mKernelHandle, 'int', 'CloseHandle', 'int', $mGWProcHandle)
DllClose($mKernelHandle)
EndFunc ;==>MemoryClose
;~ Description: Internal use only.
Func WriteBinary($aBinaryString, $aAddress)
Local $lData = DllStructCreate('byte[' & 0.5 * StringLen($aBinaryString)
& ']'), $i
For $i = 1 To DllStructGetSize($lData)
DllStructSetData($lData, 1, Dec(StringMid($aBinaryString, 2 * $i
- 1, 2)), $i)
Next
DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHand
le, 'ptr', $aAddress, 'ptr', DllStructGetPtr($lData), 'int', DllStructGetSize($l
Data), 'int', 0)
EndFunc ;==>WriteBinary
;~ Description: Internal use only.
Func MemoryWrite($aAddress, $aData, $aType = 'dword')
Local $lBuffer = DllStructCreate($aType)
DllStructSetData($lBuffer, 1, $aData)
DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHand
le, 'int', $aAddress, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize(
$lBuffer), 'int', '')
EndFunc ;==>MemoryWrite
;~ Description: Internal use only.
Func MemoryRead($aAddress, $aType = 'dword')
Local $lBuffer = DllStructCreate($aType)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $aAddress, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($
lBuffer), 'int', '')
Return DllStructGetData($lBuffer, 1)
EndFunc ;==>MemoryRead
;~ Description: Internal use only.
Func MemoryReadPtr($aAddress, $aOffset, $aType = 'dword')
Local $lPointerCount = UBound($aOffset) - 2
Local $lBuffer = DllStructCreate('dword')
For $i = 0 To $lPointerCount
$aAddress += $aOffset[$i]
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $aAddress, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructG
etSize($lBuffer), 'int', '')
$aAddress = DllStructGetData($lBuffer, 1)
If $aAddress == 0 Then
Local $lData[2] = [0, 0]

Return $lData
EndIf
Next
$aAddress += $aOffset[$lPointerCount + 1]
$lBuffer = DllStructCreate($aType)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $aAddress, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($
lBuffer), 'int', '')
Local $lData[2] = [$aAddress, DllStructGetData($lBuffer, 1)]
Return $lData
EndFunc ;==>MemoryReadPtr
;~ Description: Internal use only.
Func SwapEndian($aHex)
Return StringMid($aHex, 7, 2) & StringMid($aHex, 5, 2) & StringMid($aHex
, 3, 2) & StringMid($aHex, 1, 2)
EndFunc ;==>SwapEndian
#EndRegion Memory
#Region Initialisation
;~ Description: Returns a list of logged characters
Func GetLoggedCharNames()
Local $array = ScanGW()
If $array[0] <= 1 Then Return ''
Local $ret = $array[1]
For $i=2 To $array[0]
$ret &= "|"
$ret &= $array[$i]
Next
Return $ret
EndFunc
;~ Description: Returns an array of logged characters of gw windows (at pos 0 th
ere is the size of the array)
Func ScanGW()
Local $lWinList = WinList("Guild Wars")
Local $lReturnArray[1] = [0]
Local $lPid
For $i=1 To $lWinList[0][0]
$mGWHwnd = $lWinList[$i][1]
$lPid = WinGetProcess($mGWHwnd)
If __ProcessGetName($lPid) <> "gw.exe" Then ContinueLoop
MemoryOpen(WinGetProcess($mGWHwnd))
If $mGWProcHandle Then
$lReturnArray[0] += 1
ReDim $lReturnArray[$lReturnArray[0] + 1]
$lReturnArray[$lReturnArray[0]] = ScanForCharname()
EndIf
MemoryClose()
$mGWProcHandle = 0
Next
Return $lReturnArray
EndFunc

;~ Description: Injects GWA into the game client.


Func Initialize($aGW, $bChangeTitle = True, $aUseStringLog = False, $aUseEventSy
stem = True)
Local $lWinList
$mUseStringLog = $aUseStringLog
$mUseEventSystem = $aUseEventSystem
If IsString($aGW) Then
$lWinList = WinList('Guild Wars')
For $i = 1 To $lWinList[0][0]
$mGWHwnd = $lWinList[$i][1]
MemoryOpen(WinGetProcess($mGWHwnd))
If $mGWProcHandle Then
If StringRegExp(ScanForCharname(), $aGW) = 1 The
n ExitLoop
EndIf
MemoryClose()
$mGWProcHandle = 0
Next
Else
$lWinList = WinList()
For $i = 1 To $lWinList[0][0]
$mGWHwnd = $lWinList[$i][1]
If WinGetProcess($mGWHwnd) = $aGW Then
MemoryOpen($aGW)
ScanForCharname()
ExitLoop
EndIf
Next
EndIf
If $mGWProcHandle = 0 Then Return 0
Scan()
$mBasePointer = MemoryRead(GetScannedAddress('ScanBasePointer', -3))
SetValue('BasePointer', '0x' & Hex($mBasePointer, 8))
$mAgentBase = MemoryRead(GetScannedAddress('ScanAgentBase', 13))
SetValue('AgentBase', '0x' & Hex($mAgentBase, 8))
$mMaxAgents = $mAgentBase + 8
SetValue('MaxAgents', '0x' & Hex($mMaxAgents, 8))
$mMyID = $mAgentBase - 84
SetValue('MyID', '0x' & Hex($mMyID, 8))
$mMapLoading = $mAgentBase - 240
$mCurrentTarget = $mAgentBase - 1280
SetValue('PacketLocation', '0x' & Hex(MemoryRead(GetScannedAddress('Scan
BaseOffset', -3)), 8))
$mPing = MemoryRead(GetScannedAddress('ScanPing', -8))
$mMapID = MemoryRead(GetScannedAddress('ScanMapID', 71))
$mLoggedIn = MemoryRead(GetScannedAddress('ScanLoggedIn', -3)) + 4
$mRegion = MemoryRead(GetScannedAddress('ScanRegion', 8))
$mLanguage = MemoryRead(GetScannedAddress('ScanLanguage', 8)) + 12
$mSkillBase = MemoryRead(GetScannedAddress('ScanSkillBase', 9))
$mSkillTimer = MemoryRead(GetScannedAddress('ScanSkillTimer', -3))

$mBuildNumber = MemoryRead(GetScannedAddress('ScanBuildNumber', 0x54))


$mZoomStill = GetScannedAddress("ScanZoomStill", -1)
$mZoomMoving = GetScannedAddress("ScanZoomMoving", 5)
Local $lTemp
$lTemp = GetScannedAddress('ScanEngine', -16)
SetValue('MainStart', '0x' & Hex($lTemp, 8))
SetValue('MainReturn', '0x' & Hex($lTemp + 5, 8))
SetValue('RenderingMod', '0x' & Hex($lTemp + 116, 8))
SetValue('RenderingModReturn', '0x' & Hex($lTemp + 132 + 6, 8))
$lTemp = GetScannedAddress('ScanTargetLog', 1)
SetValue('TargetLogStart', '0x' & Hex($lTemp, 8))
SetValue('TargetLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillLog', 1)
SetValue('SkillLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillCompleteLog', -4)
SetValue('SkillCompleteLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillCompleteLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillCancelLog', 5)
SetValue('SkillCancelLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillCancelLogReturn', '0x' & Hex($lTemp + 6, 8))
$lTemp = GetScannedAddress('ScanChatLog', 18)
SetValue('ChatLogStart', '0x' & Hex($lTemp, 8))
SetValue('ChatLogReturn', '0x' & Hex($lTemp + 6, 8))
$lTemp = GetScannedAddress('ScanTraderHook', -7)
SetValue('TraderHookStart', '0x' & Hex($lTemp, 8))
SetValue('TraderHookReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanStringFilter1', -2)
SetValue('StringFilter1Start', '0x' & Hex($lTemp, 8))
SetValue('StringFilter1Return', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanStringFilter2', -2)
SetValue('StringFilter2Start', '0x' & Hex($lTemp, 8))
SetValue('StringFilter2Return', '0x' & Hex($lTemp + 5, 8))
SetValue('StringLogStart', '0x' & Hex(GetScannedAddress('ScanStringLog',
35), 8))
SetValue('LoadFinishedStart', '0x' & Hex(GetScannedAddress('ScanLoadFini
shed', 1), 8))
SetValue('LoadFinishedReturn', '0x' & Hex(GetScannedAddress('ScanLoadFin
ished', 6), 8))
SetValue('PostMessage', '0x' & Hex(MemoryRead(GetScannedAddress('ScanPos
tMessage', 11)), 8))
SetValue('Sleep', MemoryRead(MemoryRead(GetValue('ScanSleep') + 8) + 3))
SetValue('SalvageFunction', MemoryRead(GetValue('ScanSalvageFunction') +
8) - 18)
SetValue('SalvageGlobal', MemoryRead(MemoryRead(GetValue('ScanSalvageGlo
bal') + 8) + 1))
SetValue('IncreaseAttributeFunction', '0x' & Hex(GetScannedAddress('Scan
IncreaseAttributeFunction', -96), 8))
SetValue('DecreaseAttributeFunction', '0x' & Hex(GetScannedAddress('Scan
DecreaseAttributeFunction', 46), 8))
SetValue('MoveFunction', '0x' & Hex(GetScannedAddress('ScanMoveFunction'
, 1), 8))
SetValue('UseSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseSkillF
unction', 1), 8))
SetValue('ChangeTargetFunction', '0x' & Hex(GetScannedAddress('ScanChang
eTargetFunction', -119), 8))
SetValue('WriteChatFunction', '0x' & Hex(GetScannedAddress('ScanWriteCha
tFunction', 1), 8))

SetValue('SellItemFunction', '0x' & Hex(GetScannedAddress('ScanSellItemF


unction', -85), 8))
SetValue('PacketSendFunction', '0x' & Hex(GetScannedAddress('ScanPacketS
endFunction', 1), 8))
SetValue('ActionBase', '0x' & Hex(MemoryRead(GetScannedAddress('ScanActi
onBase', -9)), 8))
SetValue('ActionFunction', '0x' & Hex(GetScannedAddress('ScanActionFunct
ion', -5), 8))
SetValue('UseHeroSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseHe
roSkillFunction', -105), 8))
SetValue('BuyItemFunction', '0x' & Hex(GetScannedAddress('ScanBuyItemFun
ction', 1), 8))
SetValue('RequestQuoteFunction', '0x' & Hex(GetScannedAddress('ScanReque
stQuoteFunction', -2), 8))
SetValue('TraderFunction', '0x' & Hex(GetScannedAddress('ScanTraderFunct
ion', -71), 8))
SetValue('ClickToMoveFix', '0x' & Hex(GetScannedAddress("ScanClickToMove
Fix", 1), 8))
SetValue('QueueSize', '0x00000010')
SetValue('SkillLogSize', '0x00000010')
SetValue('ChatLogSize', '0x00000010')
SetValue('TargetLogSize', '0x00000200')
SetValue('StringLogSize', '0x00000200')
SetValue('CallbackEvent', '0x00000501')
ModifyMemory()
$mQueueCounter = MemoryRead(GetValue('QueueCounter'))
$mQueueSize = GetValue('QueueSize') - 1
$mQueueBase = GetValue('QueueBase')
$mTargetLogBase = GetValue('TargetLogBase')
$mStringLogBase = GetValue('StringLogBase')
$mMapIsLoaded = GetValue('MapIsLoaded')
$mEnsureEnglish = GetValue('EnsureEnglish')
$mTraderQuoteID = GetValue('TraderQuoteID')
$mTraderCostID = GetValue('TraderCostID')
$mTraderCostValue = GetValue('TraderCostValue')
$mDisableRendering = GetValue('DisableRendering')
$mAgentCopyCount = GetValue('AgentCopyCount')
$mAgentCopyBase = GetValue('AgentCopyBase')
If $mUseEventSystem Then MemoryWrite(GetValue('CallbackHandle'), $mGUI)
DllStructSetData($mUseSkill, 1, GetValue('CommandUseSkill'))
DllStructSetData($mMove, 1, GetValue('CommandMove'))
DllStructSetData($mChangeTarget, 1, GetValue('CommandChangeTarget'))
DllStructSetData($mPacket, 1, GetValue('CommandPacketSend'))
DllStructSetData($mSellItem, 1, GetValue('CommandSellItem'))
DllStructSetData($mAction, 1, GetValue('CommandAction'))
DllStructSetData($mToggleLanguage, 1, GetValue('CommandToggleLanguage'))
DllStructSetData($mUseHeroSkill, 1, GetValue('CommandUseHeroSkill'))
DllStructSetData($mBuyItem, 1, GetValue('CommandBuyItem'))
DllStructSetData($mSendChat, 1, GetValue('CommandSendChat'))
DllStructSetData($mSendChat, 2, 0x5E)
DllStructSetData($mWriteChat, 1, GetValue('CommandWriteChat'))
DllStructSetData($mRequestQuote, 1, GetValue('CommandRequestQuote'))
DllStructSetData($mRequestQuoteSell, 1, GetValue('CommandRequestQuoteSel
l'))
DllStructSetData($mTraderBuy, 1, GetValue('CommandTraderBuy'))

DllStructSetData($mTraderSell, 1, GetValue('CommandTraderSell'))
DllStructSetData($mSalvage, 1, GetValue('CommandSalvage'))
DllStructSetData($mIncreaseAttribute, 1, GetValue('CommandIncreaseAttrib
ute'))
DllStructSetData($mDecreaseAttribute, 1, GetValue('CommandDecreaseAttrib
ute'))
DllStructSetData($mMakeAgentArray, 1, GetValue('CommandMakeAgentArray'))
If $bChangeTitle Then WinSetTitle($mGWHwnd, '', 'Guild Wars - ' & GetCha
rname())
Return $mGWHwnd
EndFunc ;==>Initialize
;~ Description: Creates a GUI to select which client to initialize.
Func Initialize2($bChangeTitle = True, $aUseStringLog = True, $aUseEventSystem =
False)
Local $array = ScanGW()
If $array[0] = 0 Then
MsgBox(16, 'GW Client Slector', 'Guild Wars is not running.')
Exit
ElseIf $array[0] = 1 Then
Initialize(WinGetProcess("Guild Wars"), $bChangeTitle, $bChangeTitle,
$aUseEventSystem)
ElseIf $array[0] >= 2 Then
Local $hGUI = GUICreate("GW Client Slector", 274, 31, -1, -1, -1,0x000
00008)
Local $iCombo = GUICtrlCreateCombo("", 5, 5, 160, 20,
0x0003)
GUICtrlSetData($iCombo, GetLoggedCharNames())
Local $iStart = GUICtrlCreateButton("Start", 195, 4, 75, 23)
Local $iRefresh = GUICtrlCreateButton("", 169, 4, 23, 23)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $iStart
$CharName = GUICtrlRead($iCombo)
GUIDelete()
ExitLoop
Case $iRefresh
GUICtrlSetData($iCombo, GetLoggedCharNames())
EndSwitch
WEnd
If Not Initialize($CharName, $bChangeTitle, $bChangeTitle, $aUseEventS
ystem) Then
MsgBox(16, "GW Client Slector", "Something went wrong. Please
try again.")
Exit
EndIf
EndIf
EndFunc ;==>Initialize2
;~ Description: Internal use only.
Func GetValue($aKey)
For $i = 1 To $mLabels[0][0]
If $mLabels[$i][0] = $aKey Then Return Number($mLabels[$i][1])
Next
Return -1
EndFunc ;==>GetValue

;~ Description: Internal use only.


Func SetValue($aKey, $aValue)
$mLabels[0][0] += 1
ReDim $mLabels[$mLabels[0][0] + 1][2]
$mLabels[$mLabels[0][0]][0] = $aKey
$mLabels[$mLabels[0][0]][1] = $aValue
EndFunc ;==>SetValue
;~ Description: Internal use only.
Func Scan()
$mASMSize = 0
$mASMCodeOffset = 0
$mASMString = ''
_('MainModPtr/4')
_('ScanBasePointer:')
AddPattern('85C0750F8BCE')
_('ScanAgentBase:')
AddPattern('568BF13BF07204')
_('ScanEngine:')
AddPattern('5356DFE0F6C441')
_('ScanLoadFinished:')
AddPattern('8B561C8BCF52E8')
_('ScanPostMessage:')
AddPattern('6A00680080000051FF15')
_('ScanTargetLog:')
AddPattern('5356578BFA894DF4E8')
_('ScanChangeTargetFunction:')
AddPattern('33C03BDA0F95C033')
_('ScanMoveFunction:')
AddPattern('558BEC83EC2056578BF98D4DF0')
_('ScanPing:')
AddPattern('908D41248B49186A30')
_('ScanMapID:')
AddPattern('B07F8D55')
_('ScanLoggedIn:')
AddPattern('85C07411B807')
_('ScanRegion:')
AddPattern('83F9FD7406')
_('ScanLanguage:')
AddPattern('C38B75FC8B04B5')
_('ScanUseSkillFunction:')
AddPattern('558BEC83EC1053568BD9578BF2895DF0')
_('ScanChangeTargetFunction:')
AddPattern('33C03BDA0F95C033')
_('ScanPacketSendFunction:')
AddPattern('558BEC83EC2C5356578BF985')
_('ScanBaseOffset:')
AddPattern('5633F63BCE740E5633D2')
_('ScanWriteChatFunction:')
AddPattern('558BEC5153894DFC8B4D0856578B')
_('ScanSkillLog:')
AddPattern('408946105E5B5D')
_('ScanSkillCompleteLog:')
AddPattern('741D6A006A40')
_('ScanSkillCancelLog:')
AddPattern('85C0741D6A006A42')
_('ScanChatLog:')
AddPattern('8B45F48B138B4DEC50')
_('ScanSellItemFunction:')

AddPattern('8B4D2085C90F858E')
_('ScanStringLog:')
AddPattern('893E8B7D10895E04397E08')
_('ScanStringFilter1:')
AddPattern('51568B7508578BF9833E00')
_('ScanStringFilter2:')
AddPattern('515356578BF933D28B4F2C')
_('ScanActionFunction:')
AddPattern('8B7D0883FF098BF175116876010000')
_('ScanActionBase:')
AddPattern('8B4208A80175418B4A08')
_('ScanSkillBase:')
AddPattern('8D04B65EC1E00505')
_('ScanUseHeroSkillFunction:')
AddPattern('8B782C8B333BB70805000073338D4601')
_('ScanBuyItemFunction:')
AddPattern('558BEC81ECC000000053568B75085783FE108BFA8BD97614')
_('ScanRequestQuoteFunction:')
AddPattern('81EC9C00000053568B')
_('ScanTraderFunction:')
AddPattern('8B45188B551085')
_('ScanTraderHook:')
AddPattern('8955FC6A008D55F8B9BA')
_('ScanSleep:')
AddPattern('5F5E5B741A6860EA0000')
_('ScanSalvageFunction:')
AddPattern('8BFA8BD9897DF0895DF4')
_('ScanSalvageGlobal:')
AddPattern('8B018B4904A3')
_('ScanIncreaseAttributeFunction:')
AddPattern('8B702C8B3B8B86')
_('ScanDecreaseAttributeFunction:')
AddPattern('8B4B0C6A00516A016A04')
_('ScanSkillTimer:')
AddPattern('85c974158bd62bd183fa64')
_('ScanClickToMoveFix:')
AddPattern('3DD301000074')
_('ScanZoomStill:')
AddPattern('3B448BCB')
_('ScanZoomMoving:')
AddPattern('50EB116800803B448BCE')
_('ScanBuildNumber:')
AddPattern('8D8500FCFFFF8D')
_('ScanProc:')
_('pushad')
_('mov ecx,401000')
_('mov esi,ScanProc')
_('ScanLoop:')
_('inc ecx')
_('mov al,byte[ecx]')
_('mov edx,ScanBasePointer')
_('ScanInnerLoop:')
_('mov ebx,dword[edx]')
_('cmp ebx,-1')
_('jnz ScanContinue')
_('add edx,50')
_('cmp edx,esi')
_('jnz ScanInnerLoop')

_('cmp ecx,900000')
_('jnz ScanLoop')
_('jmp ScanExit')
_('ScanContinue:')
_('lea edi,dword[edx+ebx]')
_('add edi,C')
_('mov ah,byte[edi]')
_('cmp al,ah')
_('jz ScanMatched')
_('mov dword[edx],0')
_('add edx,50')
_('cmp edx,esi')
_('jnz ScanInnerLoop')
_('cmp ecx,900000')
_('jnz ScanLoop')
_('jmp ScanExit')
_('ScanMatched:')
_('inc ebx')
_('mov edi,dword[edx+4]')
_('cmp ebx,edi')
_('jz ScanFound')
_('mov dword[edx],ebx')
_('add edx,50')
_('cmp edx,esi')
_('jnz ScanInnerLoop')
_('cmp ecx,900000')
_('jnz ScanLoop')
_('jmp ScanExit')
_('ScanFound:')
_('lea edi,dword[edx+8]')
_('mov dword[edi],ecx')
_('mov dword[edx],-1')
_('add edx,50')
_('cmp edx,esi')
_('jnz ScanInnerLoop')
_('cmp ecx,900000')
_('jnz ScanLoop')
_('ScanExit:')
_('popad')
_('retn')
Local $lScanMemory = MemoryRead($mBase, 'ptr')
If $lScanMemory = 0 Then
$mMemory = DllCall($mKernelHandle, 'ptr', 'VirtualAllocEx', 'han
dle', $mGWProcHandle, 'ptr', 0, 'ulong_ptr', $mASMSize, 'dword', 0x1000, 'dword'
, 0x40)
$mMemory = $mMemory[0]
MemoryWrite($mBase, $mMemory)
Else
$mMemory = $lScanMemory
EndIf
CompleteASMCode()
If $lScanMemory = 0 Then

WriteBinary($mASMString, $mMemory + $mASMCodeOffset)


Local $lThread = DllCall($mKernelHandle, 'int', 'CreateRemoteThr
ead', 'int', $mGWProcHandle, 'ptr', 0, 'int', 0, 'int', GetLabelInfo('ScanProc')
, 'ptr', 0, 'int', 0, 'int', 0)
$lThread = $lThread[0]
Local $lResult
Do
$lResult = DllCall($mKernelHandle, 'int', 'WaitForSingle
Object', 'int', $lThread, 'int', 50)
Until $lResult[0] <> 258
DllCall($mKernelHandle, 'int', 'CloseHandle', 'int', $lThread)
EndIf
EndFunc ;==>Scan
;~ Description: Internal use only.
Func AddPattern($aPattern)
Local $lSize = Int(0.5 * StringLen($aPattern))
$mASMString &= '00000000' & SwapEndian(Hex($lSize, 8)) & '00000000' & $a
Pattern
$mASMSize += $lSize + 12
For $i = 1 To 68 - $lSize
$mASMSize += 1
$mASMString &= '00'
Next
EndFunc ;==>AddPattern
;~ Description: Internal use only.
Func GetScannedAddress($aLabel, $aOffset)
Return MemoryRead(GetLabelInfo($aLabel) + 8) - MemoryRead(GetLabelInfo($
aLabel) + 4) + $aOffset
EndFunc ;==>GetScannedAddress
;~ Description: Internal use only.
Func ScanForCharname()
Local $lCharNameCode = BinaryToString('0x90909066C705')
Local $lCurrentSearchAddress = 0x00401000
Local $lMBI[7], $lMBIBuffer = DllStructCreate('dword;dword;dword;dword;d
word;dword;dword')
Local $lSearch, $lTmpMemData, $lTmpAddress, $lTmpBuffer = DllStructCreat
e('ptr'), $i
While $lCurrentSearchAddress < 0x00900000
Local $lMBI[7]
DllCall($mKernelHandle, 'int', 'VirtualQueryEx', 'int', $mGWProc
Handle, 'int', $lCurrentSearchAddress, 'ptr', DllStructGetPtr($lMBIBuffer), 'int
', DllStructGetSize($lMBIBuffer))
For $i = 0 To 6
$lMBI[$i] = StringStripWS(DllStructGetData($lMBIBuffer,
($i + 1)), 3)
Next
If $lMBI[4] = 4096 Then
Local $lBuffer = DllStructCreate('byte[' & $lMBI[3] & ']
')
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $lCurrentSearchAddress, 'ptr', DllStructGetPtr($lBuffe
r), 'int', DllStructGetSize($lBuffer), 'int', '')
$lTmpMemData = DllStructGetData($lBuffer, 1)
$lTmpMemData = BinaryToString($lTmpMemData)

$lSearch = StringInStr($lTmpMemData, $lCharNameCode, 2)


If $lSearch > 0 Then
$lTmpAddress = $lCurrentSearchAddress + $lSearch
- 1
DllCall($mKernelHandle, 'int', 'ReadProcessMemor
y', 'int', $mGWProcHandle, 'int', $lTmpAddress + 0x6, 'ptr', DllStructGetPtr($lT
mpBuffer), 'int', DllStructGetSize($lTmpBuffer), 'int', '')
$mCharname = DllStructGetData($lTmpBuffer, 1)
Return GetCharname()
EndIf
$lCurrentSearchAddress += $lMBI[3]
EndIf
WEnd
Return ''
EndFunc ;==>ScanForCharname
#EndRegion Initialisation
#Region Commands
#Region Item
;~ Description: Starts a salvaging session of an item.
Func StartSalvage($aItem)
Local $lOffset[4] = [0, 0x18, 0x2C, 0x62C]
Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
If IsDllStruct($aItem) = 0 Then
Local $lItemID = $aItem
Else
Local $lItemID = DllStructGetData($aItem, 'ID')
EndIf
Local $lSalvageKit = FindSalvageKit()
If $lSalvageKit = 0 Then Return
DllStructSetData($mSalvage, 2, $lItemID)
DllStructSetData($mSalvage, 3, FindSalvageKit())
DllStructSetData($mSalvage, 4, $lSalvageSessionID[1])
EndFunc

Enqueue($mSalvagePtr, 16)
;==>StartSalvage

;~ Description: Salvage the materials out of an item.


Func SalvageMaterials()
Return SendPacket(0x4, 0x74)
EndFunc ;==>SalvageMaterials
;~ Description: Salvages a mod out of an item.
Func SalvageMod($aModIndex)
Return SendPacket(0x8, 0x75, $aModIndex)
EndFunc ;==>SalvageMod
;~ Description: Identifies an item.
Func IdentifyItem($aItem)
If GetIsIDed($aItem) Then Return
Local $lItemID
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem

Else
$lItemID = DllStructGetData($aItem, 'ID')
EndIf
Local $lIDKit = FindIDKit()
If $lIDKit == 0 Then Return
SendPacket(0xC, 0x66, $lIDKit, $lItemID)
Local $lDeadlock = TimerInit()
Do
Sleep(20)
Until GetIsIDed($lItemID) Or TimerDiff($lDeadlock) > 5000
If Not GetIsIDed($lItemID) Then IdentifyItem($aItem)
EndFunc ;==>IdentifyItem
;~ Description: Identifies all items in a bag.
Func IdentifyBag($aBag, $aWhites = False, $aGolds = True)
Local $lItem
If Not IsDllStruct($aBag) Then $aBag = GetBag($aBag)
For $i = 1 To DllStructGetData($aBag, 'Slots')
$lItem = GetItemBySlot($aBag, $i)
If DllStructGetData($lItem, 'ID') == 0 Then ContinueLoop
If GetRarity($lItem) == 2621 And $aWhites == False Then Continue
Loop
If GetRarity($lItem) == 2624 And $aGolds == False Then ContinueL
oop
IdentifyItem($lItem)
Sleep(GetPing())
Next
EndFunc ;==>IdentifyBag
;~ Description: Equips an item.
Func EquipItem($aItem)
Local $lItemID
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
Else
$lItemID = DllStructGetData($aItem, 'ID')
EndIf
EndFunc

Return SendPacket(0x8, 0x30, $lItemID)


;==>EquipItem

;~ Description: Uses an item.


Func UseItem($aItem)
Local $lItemID
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
Else
$lItemID = DllStructGetData($aItem, 'ID')
EndIf
EndFunc

Return SendPacket(0x8, 0x78, $lItemID)


;==>UseItem

;~ Description: Picks up an item.


Func PickUpItem($aItem)

Local $lAgentID
If IsDllStruct($aItem) = 0 Then
$lAgentID = $aItem
ElseIf DllStructGetSize($aItem) < 400 Then
$lAgentID = DllStructGetData($aItem, 'AgentID')
Else
$lAgentID = DllStructGetData($aItem, 'ID')
EndIf
EndFunc

Return SendPacket(0xC, 0x39, $lAgentID, 0)


;==>PickUpItem

;~ Description: Drops an item.


Func DropItem($aItem, $aAmount = 0)
Local $lItemID, $lAmount
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
If $aAmount > 0 Then
$lAmount = $aAmount
Else
$lAmount = DllStructGetData(GetItemByItemID($aItem), 'Qu
antity')
EndIf
Else
$lItemID = DllStructGetData($aItem, 'ID')
If $aAmount > 0 Then
$lAmount = $aAmount
Else
$lAmount = DllStructGetData($aItem, 'Quantity')
EndIf
EndIf
EndFunc

Return SendPacket(0xC, 0x26, $lItemID, $lAmount)


;==>DropItem

;~ Description: Moves an item.


Func MoveItem($aItem, $aBag, $aSlot)
Local $lItemID, $lBagID
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
Else
$lItemID = DllStructGetData($aItem, 'ID')
EndIf
If IsDllStruct($aBag) = 0 Then
$lBagID = DllStructGetData(GetBag($aBag), 'ID')
Else
$lBagID = DllStructGetData($aBag, 'ID')
EndIf
EndFunc

Return SendPacket(0x10, 0x6C, $lItemID, $lBagID, $aSlot - 1)


;==>MoveItem

;~ Description: Accepts unclaimed items after a mission.


Func AcceptAllItems()
Return SendPacket(0x8, 0x6D, DllStructGetData(GetBag(7), 'ID'))
EndFunc ;==>AcceptAllItems

;~ Description: Sells an item.


Func SellItem($aItem, $aQuantity = 0)
If IsDllStruct($aItem) = 0 Then $aItem = GetItemByItemID($aItem)
If $aQuantity = 0 Or $aQuantity > DllStructGetData($aItem, 'Quantity') T
hen $aQuantity = DllStructGetData($aItem, 'Quantity')
DllStructSetData($mSellItem, 2, $aQuantity * DllStructGetData($aItem, 'V
alue'))
DllStructSetData($mSellItem, 3, DllStructGetData($aItem, 'ID'))
Enqueue($mSellItemPtr, 12)
EndFunc ;==>SellItem
;~ Description: Buys an item.
Func BuyItem($aItem, $aQuantity, $aValue)
Local $lMerchantItemsBase = GetMerchantItemsBase()
If Not $lMerchantItemsBase Then Return
If $aItem < 1 Or $aItem > GetMerchantItemsSize() Then Return
DllStructSetData($mBuyItem, 2, $aQuantity)
DllStructSetData($mBuyItem, 3, MemoryRead($lMerchantItemsBase + 4 * ($aI
tem - 1)))
DllStructSetData($mBuyItem, 4, $aQuantity * $aValue)
Enqueue($mBuyItemPtr, 16)
EndFunc ;==>BuyItem
;~ Description: Buys an ID kit.
Func BuyIDKit()
BuyItem(5, 1, 100)
EndFunc ;==>BuyIDKit
;~ Description: Buys a superior ID kit.
Func BuySuperiorIDKit()
BuyItem(6, 1, 500)
EndFunc ;==>BuySuperiorIDKit
;~ Description: Request a quote to buy an item from a trader. Returns true if su
ccessful.
Func TraderRequest($aModelID, $aExtraID = -1)
Local $lItemStruct = DllStructCreate('long id;long agentId;byte unknown1
[4];ptr bag;ptr modstruct;long modstructsize;ptr customized;byte unknown2[4];byt
e type;byte unknown3;short extraId;short value;byte unknown4[2];short interactio
n;long modelId;ptr modString;byte unknown5[4];ptr NameString;byte unknown6[15];b
yte quantity;byte equipped;byte unknown7[1];byte slot')
Local $lOffset[4] = [0, 0x18, 0x40, 0xC0]
Local $lItemArraySize = MemoryReadPtr($mBasePointer, $lOffset)
Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0]
Local $lItemPtr, $lItemID
Local $lFound = False
Local $lQuoteID = MemoryRead($mTraderQuoteID)
For $lItemID = 1 To $lItemArraySize[1]
$lOffset[4] = 0x4 * $lItemID
$lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
If $lItemPtr[1] = 0 Then ContinueLoop
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', Dll
StructGetSize($lItemStruct), 'int', '')

If DllStructGetData($lItemStruct, 'ModelID') = $aModelID And Dll


StructGetData($lItemStruct, 'bag') = 0 And DllStructGetData($lItemStruct, 'Agent
ID') == 0 Then
If $aExtraID = -1 Or DllStructGetData($lItemStruct, 'Ext
raID') = $aExtraID Then
$lFound = True
ExitLoop
EndIf
EndIf
Next
If Not $lFound Then Return False
DllStructSetData($mRequestQuote, 2, DllStructGetData($lItemStruct, 'ID')
)
Enqueue($mRequestQuotePtr, 8)
Local $lDeadlock = TimerInit()
$lFound = False
Do
Sleep(20)
$lFound = MemoryRead($mTraderQuoteID) <> $lQuoteID
Until $lFound Or TimerDiff($lDeadlock) > GetPing() + 5000
Return $lFound
EndFunc ;==>TraderRequest
;~ Description: Buy the requested item.
Func TraderBuy()
If Not GetTraderCostID() Or Not GetTraderCostValue() Then Return False
Enqueue($mTraderBuyPtr, 4)
Return True
EndFunc ;==>TraderBuy
;~ Description: Request a quote to sell an item to the trader.
Func TraderRequestSell($aItem)
Local $lItemID
Local $lFound = False
Local $lQuoteID = MemoryRead($mTraderQuoteID)
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
Else
$lItemID = DllStructGetData($aItem, 'ID')
EndIf
DllStructSetData($mRequestQuoteSell, 2, $lItemID)
Enqueue($mRequestQuoteSellPtr, 8)
Local $lDeadlock = TimerInit()
Do
Sleep(20)
$lFound = MemoryRead($mTraderQuoteID) <> $lQuoteID
Until $lFound Or TimerDiff($lDeadlock) > GetPing() + 5000
Return $lFound
EndFunc ;==>TraderRequestSell
;~ Description: ID of the item item being sold.
Func TraderSell()
If Not GetTraderCostID() Or Not GetTraderCostValue() Then Return False
Enqueue($mTraderSellPtr, 4)
Return True

EndFunc

;==>TraderSell

;~ Description: Drop gold on the ground.


Func DropGold($aAmount = 0)
Local $lAmount
If $aAmount > 0 Then
$lAmount = $aAmount
Else
$lAmount = GetGoldCharacter()
EndIf
EndFunc

Return SendPacket(0x8, 0x29, $lAmount)


;==>DropGold

;~ Description: Deposit gold into storage.


Func DepositGold($aAmount = 0)
Local $lAmount
Local $lStorage = GetGoldStorage()
Local $lCharacter = GetGoldCharacter()
If $aAmount > 0 And $lCharacter >= $aAmount Then
$lAmount = $aAmount
Else
$lAmount = $lCharacter
EndIf
If $lStorage + $lAmount > 1000000 Then $lAmount = 1000000 - $lStorage
EndFunc

ChangeGold($lCharacter - $lAmount, $lStorage + $lAmount)


;==>DepositGold

;~ Description: Withdraw gold from storage.


Func WithdrawGold($aAmount = 0)
Local $lAmount
Local $lStorage = GetGoldStorage()
Local $lCharacter = GetGoldCharacter()
If $aAmount > 0 And $lStorage >= $aAmount Then
$lAmount = $aAmount
Else
$lAmount = $lStorage
EndIf
If $lCharacter + $lAmount > 100000 Then $lAmount = 100000 - $lCharacter
EndFunc

ChangeGold($lCharacter + $lAmount, $lStorage - $lAmount)


;==>WithdrawGold

;~ Description: Internal use for moving gold.


Func ChangeGold($aCharacter, $aStorage)
Return SendPacket(0xC, 0x76, $aCharacter, $aStorage)
EndFunc ;==>ChangeGold
#EndRegion Item
#Region H&H
;~ Description: Adds a hero to the party.
Func AddHero($aHeroId)
Return SendPacket(0x8, 0x17, $aHeroId)
EndFunc ;==>AddHero

;~ Description: Kicks a hero from the party.


Func KickHero($aHeroId)
Return SendPacket(0x8, 0x18, $aHeroId)
EndFunc ;==>KickHero
;~ Description: Kicks all heroes from the party.
Func KickAllHeroes()
Return SendPacket(0x8, 0x18, 0x26)
EndFunc ;==>KickAllHeroes
;~ Description: Add a henchman to the party.
Func AddNpc($aNpcId)
Return SendPacket(0x8, 0x99, $aNpcId)
EndFunc ;==>AddNpc
;~ Description: Kick a henchman from the party.
Func KickNpc($aNpcId)
Return SendPacket(0x8, 0xA2, $aNpcId)
EndFunc ;==>KickNpc
;~ Description: Clear the position flag from a hero.
Func CancelHero($aHeroNumber)
Local $lAgentID = GetHeroID($aHeroNumber)
Return SendPacket(0x14, 0x13, $lAgentID, 0x7F800000, 0x7F800000, 0)
EndFunc ;==>CancelHero
;~ Description: Clear the position flag from all heroes.
Func CancelAll()
Return SendPacket(0x10, 0x14, 0x7F800000, 0x7F800000, 0)
EndFunc ;==>CancelAll
;~ Description: Place a hero's position flag.
Func CommandHero($aHeroNumber, $aX, $aY)
Return SendPacket(0x14, 0x13, GetHeroID($aHeroNumber), FloatToInt($aX),
FloatToInt($aY), 0)
EndFunc ;==>CommandHero
;~ Description: Place the full-party position flag.
Func CommandAll($aX, $aY)
Return SendPacket(0x10, 0x14, FloatToInt($aX), FloatToInt($aY), 0)
EndFunc ;==>CommandAll
;~ Description: Lock a hero onto a target.
Func LockHeroTarget($aHeroNumber, $aAgentID = 0) ;$aAgentID=0 Cancels Lock
Local $lHeroID = GetHeroID($aHeroNumber)
Return SendPacket(0xC, 0xF, $lHeroID, $aAgentID)
EndFunc ;==>LockHeroTarget
;~ Description: Change a hero's aggression level.
Func SetHeroAggression($aHeroNumber, $aAggression) ;0=Fight, 1=Guard, 2=Avoid
Local $lHeroID = GetHeroID($aHeroNumber)
Return SendPacket(0xC, 0xE, $lHeroID, $aAggression)
EndFunc ;==>SetHeroAggression
;~ Description: Disable a skill on a hero's skill bar.
Func DisableHeroSkillSlot($aHeroNumber, $aSkillSlot)
If Not GetIsHeroSkillSlotDisabled($aHeroNumber, $aSkillSlot) Then Change
HeroSkillSlotState($aHeroNumber, $aSkillSlot)
EndFunc ;==>DisableHeroSkillSlot

;~ Description: Enable a skill on a hero's skill bar.


Func EnableHeroSkillSlot($aHeroNumber, $aSkillSlot)
If GetIsHeroSkillSlotDisabled($aHeroNumber, $aSkillSlot) Then ChangeHero
SkillSlotState($aHeroNumber, $aSkillSlot)
EndFunc ;==>EnableHeroSkillSlot
;~ Description: Internal use for enabling or disabling hero skills
Func ChangeHeroSkillSlotState($aHeroNumber, $aSkillSlot)
Return SendPacket(0xC, 0x12, GetHeroID($aHeroNumber), $aSkillSlot - 1)
EndFunc ;==>ChangeHeroSkillSlotState
;~ Description: Order a hero to use a skill.
Func UseHeroSkill($aHero, $aSkillSlot, $aTarget = 0)
Local $lTargetID
If IsDllStruct($aTarget) = 0 Then
$lTargetID = ConvertID($aTarget)
Else
$lTargetID = DllStructGetData($aTarget, 'ID')
EndIf
DllStructSetData($mUseHeroSkill, 2, GetHeroID($aHero))
DllStructSetData($mUseHeroSkill, 3, $lTargetID)
DllStructSetData($mUseHeroSkill, 4, $aSkillSlot - 1)
Enqueue($mUseHeroSkillPtr, 16)
EndFunc ;==>UseHeroSkill
#EndRegion H&H
#Region Movement
;~ Description: Move to a location.
Func Move($aX, $aY, $aRandom = 50)
;returns true if successful
If GetAgentExists(-2) Then
DllStructSetData($mMove, 2, $aX + Random(-$aRandom, $aRandom))
DllStructSetData($mMove, 3, $aY + Random(-$aRandom, $aRandom))
Enqueue($mMovePtr, 16)
Return True
Else
Return False
EndIf
EndFunc ;==>Move
;~ Description: Move to a location and wait until you reach it.
Func MoveTo($aX, $aY, $aRandom = 50)
If GetIsDead(-2) Then Return
Local $lBlocked = 0
Local $lMe
Local $lMapLoading = GetMapLoading(), $lMapLoadingOld
Local $lDestX = $aX + Random(-$aRandom, $aRandom)
Local $lDestY = $aY + Random(-$aRandom, $aRandom)
Move($lDestX, $lDestY, 0)
Do
Sleep(100)
$lMe = GetAgentByID(-2)
If DllStructGetData($lMe, 'HP') <= 0 Then ExitLoop

$lMapLoadingOld = $lMapLoading
$lMapLoading = GetMapLoading()
If $lMapLoading <> $lMapLoadingOld Then ExitLoop
If DllStructGetData($lMe, 'MoveX') == 0 And DllStructGetData($lM
e, 'MoveY') == 0 Then
$lBlocked += 1
$lDestX = $aX + Random(-$aRandom, $aRandom)
$lDestY = $aY + Random(-$aRandom, $aRandom)
Move($lDestX, $lDestY, 0)
EndIf
Until ComputeDistance(DllStructGetData($lMe, 'X'), DllStructGetData($lMe
, 'Y'), $lDestX, $lDestY) < 25 Or $lBlocked > 14
EndFunc ;==>MoveTo
;~ Description: Run to or follow a player.
Func GoPlayer($aAgent)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
EndFunc

Return SendPacket(0x8, 0x2D, $lAgentID)


;==>GoPlayer

;~ Description: Talk to an NPC


Func GoNPC($aAgent)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
EndFunc

Return SendPacket(0xC, 0x33, $lAgentID)


;==>GoNPC

;~ Description: Talks to NPC and waits until you reach them.


Func GoToNPC($aAgent)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lMe
Local $lBlocked = 0
Local $lMapLoading = GetMapLoading(), $lMapLoadingOld
Move(DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, 'Y'), 100
)
Sleep(100)
GoNPC($aAgent)
Do
Sleep(100)
$lMe = GetAgentByID(-2)
If DllStructGetData($lMe, 'HP') <= 0 Then ExitLoop
$lMapLoadingOld = $lMapLoading

$lMapLoading = GetMapLoading()
If $lMapLoading <> $lMapLoadingOld Then ExitLoop
If DllStructGetData($lMe, 'MoveX') == 0 And DllStructGetData($lM
e, 'MoveY') == 0 Then
$lBlocked += 1
Move(DllStructGetData($aAgent, 'X'), DllStructGetData($a
Agent, 'Y'), 100)
Sleep(100)
GoNPC($aAgent)
EndIf
Until ComputeDistance(DllStructGetData($lMe, 'X'), DllStructGetData($lMe
, 'Y'), DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, 'Y')) < 250 Or
$lBlocked > 14
Sleep(GetPing() + Random(1500, 2000, 1))
EndFunc ;==>GoToNPC
;~ Description: Run to a signpost.
Func GoSignpost($aAgent)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
EndFunc

Return SendPacket(0xC, 0x4B, $lAgentID, 0)


;==>GoSignpost

;~ Description: Go to signpost and waits until you reach it.


Func GoToSignpost($aAgent)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lMe
Local $lBlocked = 0
Local $lMapLoading = GetMapLoading(), $lMapLoadingOld
Move(DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, 'Y'), 100
)
Sleep(100)
GoSignpost($aAgent)
Do
Sleep(100)
$lMe = GetAgentByID(-2)
If DllStructGetData($lMe, 'HP') <= 0 Then ExitLoop
$lMapLoadingOld = $lMapLoading
$lMapLoading = GetMapLoading()
If $lMapLoading <> $lMapLoadingOld Then ExitLoop
If DllStructGetData($lMe, 'MoveX') == 0 And DllStructGetData($lM
e, 'MoveY') == 0 Then
$lBlocked += 1
Move(DllStructGetData($aAgent, 'X'), DllStructGetData($a
Agent, 'Y'), 100)
Sleep(100)
GoSignpost($aAgent)
EndIf

Until ComputeDistance(DllStructGetData($lMe, 'X'), DllStructGetData($lMe


, 'Y'), DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, 'Y')) < 250 Or
$lBlocked > 14
Sleep(GetPing() + Random(1500, 2000, 1))
EndFunc ;==>GoToSignpost
;~ Description: Attack an agent.
Func Attack($aAgent, $aCallTarget = False)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
EndFunc

Return SendPacket(0xC, 0x20, $lAgentID, $aCallTarget)


;==>Attack

;~ Description: Turn character to the left.


Func TurnLeft($aTurn)
If $aTurn Then
Return PerformAction(0xA2, 0x18)
Else
Return PerformAction(0xA2, 0x1A)
EndIf
EndFunc ;==>TurnLeft
;~ Description: Turn character to the right.
Func TurnRight($aTurn)
If $aTurn Then
Return PerformAction(0xA3, 0x18)
Else
Return PerformAction(0xA3, 0x1A)
EndIf
EndFunc ;==>TurnRight
;~ Description: Move backwards.
Func MoveBackward($aMove)
If $aMove Then
Return PerformAction(0xAC, 0x18)
Else
Return PerformAction(0xAC, 0x1A)
EndIf
EndFunc ;==>MoveBackward
;~ Description: Run forwards.
Func MoveForward($aMove)
If $aMove Then
Return PerformAction(0xAD, 0x18)
Else
Return PerformAction(0xAD, 0x1A)
EndIf
EndFunc ;==>MoveForward
;~ Description: Strafe to the left.
Func StrafeLeft($aStrafe)
If $aStrafe Then
Return PerformAction(0x91, 0x18)
Else

Return PerformAction(0x91, 0x1A)


EndIf
EndFunc ;==>StrafeLeft
;~ Description: Strafe to the right.
Func StrafeRight($aStrafe)
If $aStrafe Then
Return PerformAction(0x92, 0x18)
Else
Return PerformAction(0x92, 0x1A)
EndIf
EndFunc ;==>StrafeRight
;~ Description: Auto-run.
Func ToggleAutoRun()
Return PerformAction(0xB7, 0x18)
EndFunc ;==>ToggleAutoRun
;~ Description: Turn around.
Func ReverseDirection()
Return PerformAction(0xB1, 0x18)
EndFunc ;==>ReverseDirection
#EndRegion Movement
#Region Travel
;~ Description: Map travel to an outpost.
Func TravelTo($aMapID, $aDis = 0)
;returns true if successful
If GetMapID() = $aMapID And $aDis = 0 And GetMapLoading() = 0 Then Retur
n True
ZoneMap($aMapID, $aDis)
Return WaitMapLoading($aMapID)
EndFunc ;==>TravelTo
;~ Description: Internal use for map travel.
Func ZoneMap($aMapID, $aDistrict = 0)
MoveMap($aMapID, GetRegion(), $aDistrict, GetLanguage());
EndFunc ;==>ZoneMap
;~ Description: Internal use for map travel.
Func MoveMap($aMapID, $aRegion, $aDistrict, $aLanguage)
Return SendPacket(0x18, 0xAB, $aMapID, $aRegion, $aDistrict, $aLanguage,
False)
EndFunc ;==>MoveMap
;~ Description: Returns to outpost after resigning/failure.
Func ReturnToOutpost()
Return SendPacket(0x4, 0xA1)
EndFunc ;==>ReturnToOutpost
;~ Description: Enter a challenge mission/pvp.
Func EnterChallenge()
Return SendPacket(0x8, 0x9F, 1)
EndFunc ;==>EnterChallenge
;~ Description: Enter a foreign challenge mission/pvp.
Func EnterChallengeForeign()
Return SendPacket(0x8, 0x9F, 0)
EndFunc ;==>EnterChallengeForeign

;~ Description: Travel to your guild hall.


Func TravelGH()
Local $lOffset[3] = [0, 0x18, 0x3C]
Local $lGH = MemoryReadPtr($mBasePointer, $lOffset)
SendPacket(0x18, 0xAA, MemoryRead($lGH[1] + 0x64), MemoryRead($lGH[1] +
0x68), MemoryRead($lGH[1] + 0x6C), MemoryRead($lGH[1] + 0x70), 1)
Return WaitMapLoading()
EndFunc ;==>TravelGH
;~ Description: Leave your guild hall.
Func LeaveGH()
SendPacket(0x8, 0xAC, 1)
Return WaitMapLoading()
EndFunc ;==>LeaveGH
#EndRegion Travel
#Region Quest
;~ Description: Accept a quest from an NPC.
Func AcceptQuest($aQuestID)
Return SendPacket(0x8, 0x35, '0x008' & Hex($aQuestID, 3) & '01')
EndFunc ;==>AcceptQuest
;~ Description: Accept the reward for a quest.
Func QuestReward($aQuestID)
Return SendPacket(0x8, 0x35, '0x008' & Hex($aQuestID, 3) & '07')
EndFunc ;==>QuestReward
;~ Description: Abandon a quest.
Func AbandonQuest($aQuestID)
Return SendPacket(0x8, 0xA, $aQuestID)
EndFunc ;==>AbandonQuest
#EndRegion Quest
#Region Windows
;~ Description: Close all in-game windows.
Func CloseAllPanels()
Return PerformAction(0x85, 0x18)
EndFunc ;==>CloseAllPanels
;~ Description: Toggle hero window.
Func ToggleHeroWindow()
Return PerformAction(0x8A, 0x18)
EndFunc ;==>ToggleHeroWindow
;~ Description: Toggle inventory window.
Func ToggleInventory()
Return PerformAction(0x8B, 0x18)
EndFunc ;==>ToggleInventory
;~ Description: Toggle all bags window.
Func ToggleAllBags()
Return PerformAction(0xB8, 0x18)
EndFunc ;==>ToggleAllBags
;~ Description: Toggle world map.
Func ToggleWorldMap()
Return PerformAction(0x8C, 0x18)
EndFunc ;==>ToggleWorldMap
;~ Description: Toggle options window.

Func ToggleOptions()
Return PerformAction(0x8D, 0x18)
EndFunc ;==>ToggleOptions
;~ Description: Toggle quest window.
Func ToggleQuestWindow()
Return PerformAction(0x8E, 0x18)
EndFunc ;==>ToggleQuestWindow
;~ Description: Toggle skills window.
Func ToggleSkillWindow()
Return PerformAction(0x8F, 0x18)
EndFunc ;==>ToggleSkillWindow
;~ Description: Toggle mission map.
Func ToggleMissionMap()
Return PerformAction(0xB6, 0x18)
EndFunc ;==>ToggleMissionMap
;~ Description: Toggle friends list window.
Func ToggleFriendList()
Return PerformAction(0xB9, 0x18)
EndFunc ;==>ToggleFriendList
;~ Description: Toggle guild window.
Func ToggleGuildWindow()
Return PerformAction(0xBA, 0x18)
EndFunc ;==>ToggleGuildWindow
;~ Description: Toggle party window.
Func TogglePartyWindow()
Return PerformAction(0xBF, 0x18)
EndFunc ;==>TogglePartyWindow
;~ Description: Toggle score chart.
Func ToggleScoreChart()
Return PerformAction(0xBD, 0x18)
EndFunc ;==>ToggleScoreChart
;~ Description: Toggle layout window.
Func ToggleLayoutWindow()
Return PerformAction(0xC1, 0x18)
EndFunc ;==>ToggleLayoutWindow
;~ Description: Toggle minions window.
Func ToggleMinionList()
Return PerformAction(0xC2, 0x18)
EndFunc ;==>ToggleMinionList
;~ Description: Toggle a hero panel.
Func ToggleHeroPanel($aHero)
If $aHero < 4 Then
Return PerformAction(0xDB + $aHero, 0x18)
ElseIf $aHero < 8 Then
Return PerformAction(0xFE + $aHero, 0x18)
EndIf
EndFunc ;==>ToggleHeroPanel
;~ Description: Toggle hero's pet panel.
Func ToggleHeroPetPanel($aHero)

If $aHero < 4 Then


Return PerformAction(0xDF + $aHero, 0x18)
ElseIf $aHero < 8 Then
Return PerformAction(0xFA + $aHero, 0x18)
EndIf
EndFunc ;==>ToggleHeroPetPanel
;~ Description: Toggle pet panel.
Func TogglePetPanel()
Return PerformAction(0xDF, 0x18)
EndFunc ;==>TogglePetPanel
;~ Description: Toggle help window.
Func ToggleHelpWindow()
Return PerformAction(0xE4, 0x18)
EndFunc ;==>ToggleHelpWindow
#EndRegion Windows
#Region Targeting
;~ Description: Target an agent.
Func ChangeTarget($aAgent)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
DllStructSetData($mChangeTarget, 2, $lAgentID)
Enqueue($mChangeTargetPtr, 8)
EndFunc ;==>ChangeTarget
;~ Description: Call target.
Func CallTarget($aTarget)
Local $lTargetID
If IsDllStruct($aTarget) = 0 Then
$lTargetID = ConvertID($aTarget)
Else
$lTargetID = DllStructGetData($aTarget, 'ID')
EndIf
EndFunc

Return SendPacket(0xC, 0x1C, 0xA, $lTargetID)


;==>CallTarget

;~ Description: Clear current target.


Func ClearTarget()
Return PerformAction(0xE3, 0x18)
EndFunc ;==>ClearTarget
;~ Description: Target the nearest enemy.
Func TargetNearestEnemy()
Return PerformAction(0x93, 0x18)
EndFunc ;==>TargetNearestEnemy
;~ Description: Target the next enemy.
Func TargetNextEnemy()
Return PerformAction(0x95, 0x18)
EndFunc ;==>TargetNextEnemy

;~ Description: Target the next party member.


Func TargetPartyMember($aNumber)
If $aNumber > 0 And $aNumber < 13 Then Return PerformAction(0x95 + $aNum
ber, 0x18)
EndFunc ;==>TargetPartyMember
;~ Description: Target the previous enemy.
Func TargetPreviousEnemy()
Return PerformAction(0x9E, 0x18)
EndFunc ;==>TargetPreviousEnemy
;~ Description: Target the called target.
Func TargetCalledTarget()
Return PerformAction(0x9F, 0x18)
EndFunc ;==>TargetCalledTarget
;~ Description: Target yourself.
Func TargetSelf()
Return PerformAction(0xA0, 0x18)
EndFunc ;==>TargetSelf
;~ Description: Target the nearest ally.
Func TargetNearestAlly()
Return PerformAction(0xBC, 0x18)
EndFunc ;==>TargetNearestAlly
;~ Description: Target the nearest item.
Func TargetNearestItem()
Return PerformAction(0xC3, 0x18)
EndFunc ;==>TargetNearestItem
;~ Description: Target the next item.
Func TargetNextItem()
Return PerformAction(0xC4, 0x18)
EndFunc ;==>TargetNextItem
;~ Description: Target the previous item.
Func TargetPreviousItem()
Return PerformAction(0xC5, 0x18)
EndFunc ;==>TargetPreviousItem
;~ Description: Target the next party member.
Func TargetNextPartyMember()
Return PerformAction(0xCA, 0x18)
EndFunc ;==>TargetNextPartyMember
;~ Description: Target the previous party member.
Func TargetPreviousPartyMember()
Return PerformAction(0xCB, 0x18)
EndFunc ;==>TargetPreviousPartyMember
#EndRegion Targeting
#Region Display
;~ Description: Enable graphics rendering.
Func EnableRendering()
MemoryWrite($mDisableRendering, 0)
WinSetState($mGWHwnd, "", @SW_SHOW)
EndFunc ;==>EnableRendering

;~ Description: Disable graphics rendering.


Func DisableRendering()
MemoryWrite($mDisableRendering, 1)
WinSetState($mGWHwnd, "", @SW_HIDE)
EndFunc ;==>DisableRendering
Func ToggleRendering()
$Rendering = Not $Rendering
If $Rendering Then
EnableRendering()
Else
DisableRendering()
ClearMemory()
EndIf
EndFunc
Func PurgeEngineHook()
If $Rendering = False Then
EnableRendering()
Sleep(Random(2000, 2500))
DisableRendering()
ClearMemory()
EndIf
EndFunc
;~ Description: Display all names.
Func DisplayAll($aDisplay)
DisplayAllies($aDisplay)
DisplayEnemies($aDisplay)
EndFunc ;==>DisplayAll
;~ Description: Display the names of allies.
Func DisplayAllies($aDisplay)
If $aDisplay Then
Return PerformAction(0x89, 0x18)
Else
Return PerformAction(0x89, 0x1A)
EndIf
EndFunc ;==>DisplayAllies
;~ Description: Display the names of enemies.
Func DisplayEnemies($aDisplay)
If $aDisplay Then
Return PerformAction(0x94, 0x18)
Else
Return PerformAction(0x94, 0x1A)
EndIf
EndFunc ;==>DisplayEnemies
#EndRegion Display
#Region Chat
;~ Description: Write a message in chat (can only be seen by botter).
Func WriteChat($aMessage, $aSender = 'GWA')
Local $lMessage, $lSender
Local $lAddress = 256 * $mQueueCounter + $mQueueBase
If $mQueueCounter = $mQueueSize Then
$mQueueCounter = 0
Else
$mQueueCounter = $mQueueCounter + 1

EndIf
If StringLen($aSender) > 19 Then
$lSender = StringLeft($aSender, 19)
Else
$lSender = $aSender
EndIf
MemoryWrite($lAddress + 4, $lSender, 'wchar[20]')
If StringLen($aMessage) > 100 Then
$lMessage = StringLeft($aMessage, 100)
Else
$lMessage = $aMessage
EndIf
MemoryWrite($lAddress + 44, $lMessage, 'wchar[101]')
DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHand
le, 'int', $lAddress, 'ptr', $mWriteChatPtr, 'int', 4, 'int', '')
If StringLen($aMessage) > 100 Then WriteChat(StringTrimLeft($aMessage, 1
00), $aSender)
EndFunc ;==>WriteChat
;~ Description: Send a whisper to another player.
Func SendWhisper($aReceiver, $aMessage)
Local $lTotal = 'whisper ' & $aReceiver & ',' & $aMessage
Local $lMessage
If StringLen($lTotal) > 120 Then
$lMessage = StringLeft($lTotal, 120)
Else
$lMessage = $lTotal
EndIf
SendChat($lMessage, '/')
If StringLen($lTotal) > 120 Then SendWhisper($aReceiver, StringTrimLeft(
$lTotal, 120))
EndFunc ;==>SendWhisper
;~ Description: Send a message to chat.
Func SendChat($aMessage, $aChannel = '!')
Local $lMessage
Local $lAddress = 256 * $mQueueCounter + $mQueueBase
If $mQueueCounter = $mQueueSize Then
$mQueueCounter = 0
Else
$mQueueCounter = $mQueueCounter + 1
EndIf
If StringLen($aMessage) > 120 Then
$lMessage = StringLeft($aMessage, 120)
Else
$lMessage = $aMessage
EndIf
MemoryWrite($lAddress + 8, $aChannel & $lMessage, 'wchar[122]')
DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHand

le, 'int', $lAddress, 'ptr', $mSendChatPtr, 'int', 8, 'int', '')


If StringLen($aMessage) > 120 Then SendChat(StringTrimLeft($aMessage, 12
0), $aChannel)
EndFunc ;==>SendChat
#EndRegion Chat
#Region Misc
;~ Description: Change weapon sets.
Func ChangeWeaponSet($aSet)
Return PerformAction(0x80 + $aSet, 0x18)
EndFunc ;==>ChangeWeaponSet
;~ Description: Use a skill.
Func UseSkill($aSkillSlot, $aTarget, $aCallTarget = False)
Local $lTargetID
If IsDllStruct($aTarget) = 0 Then
$lTargetID = ConvertID($aTarget)
Else
$lTargetID = DllStructGetData($aTarget, 'ID')
EndIf
DllStructSetData($mUseSkill, 2, $aSkillSlot)
DllStructSetData($mUseSkill, 3, $lTargetID)
DllStructSetData($mUseSkill, 4, $aCallTarget)
Enqueue($mUseSkillPtr, 16)
EndFunc ;==>UseSkill
;~ Description: Use a skill and wait for it to be used.
Func UseSkillEx($lSkill, $lTgt = -2, $aTimeout = 3000)
If GetIsDead(-2) Then Return
If Not IsRecharged($lSkill) Then Return
Local $Skill = GetSkillByID(GetSkillBarSkillID($lSkill, 0))
Local $Energy = StringReplace(StringReplace(StringReplace(StringMid(DllStruc
tGetData($Skill, 'Unknown4'), 6, 1), 'C', '25'), 'B', '15'), 'A', '10')
If GetEnergy(-2) < $Energy Then Return
Local $lAftercast = DllStructGetData($Skill, 'Aftercast')
Local $lDeadlock = TimerInit()
UseSkill($lSkill, $lTgt)
Do
Sleep(50)
If GetIsDead(-2) = 1 Then Return
Until (Not IsRecharged($lSkill)) Or (TimerDiff($lDeadlock) > $aTimeo
ut)
Sleep($lAftercast * 1000)
EndFunc ;==>UseSkillEx
;~ Description: Returns is a skill is recharged.
Func IsRecharged($lSkill)
Return GetSkillBarSkillRecharge($lSkill) == 0
EndFunc ;==>IsRecharged
;~ Description: Cancel current action.
Func CancelAction()
Return SendPacket(0x4, 0x22)
EndFunc ;==>CancelAction
;~ Description: Same as hitting spacebar.
Func ActionInteract()

EndFunc

Return PerformAction(0x80, 0x18)


;==>ActionInteract

;~ Description: Follow a player.


Func ActionFollow()
Return PerformAction(0xCC, 0x18)
EndFunc ;==>ActionFollow
;~ Description: Drop environment object.
Func DropBundle()
Return PerformAction(0xCD, 0x18)
EndFunc ;==>DropBundle
;~ Description: Clear all hero flags.
Func ClearPartyCommands()
Return PerformAction(0xDB, 0x18)
EndFunc ;==>ClearPartyCommands
;~ Description: Suppress action.
Func SuppressAction($aSuppress)
If $aSuppress Then
Return PerformAction(0xD0, 0x18)
Else
Return PerformAction(0xD0, 0x1A)
EndIf
EndFunc ;==>SuppressAction
;~ Description: Open a chest.
Func OpenChest()
Return SendPacket(0x8, 0x4D, 2)
EndFunc ;==>OpenChest
;~ Description: Stop maintaining enchantment on target.
Func DropBuff($aSkillID, $aAgentID, $aHeroNumber = 0)
Local $lBuffStruct = DllStructCreate('long SkillId;byte unknown1[4];long
BuffId;long TargetId')
Local $lBuffCount = GetBuffCount($aHeroNumber)
Local $lBuffStructAddress
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4AC
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x4A4
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
$lOffset[4] = 0x4 + 0x24 * $i
ReDim $lOffset[6]
For $j = 0 To $lBuffCount - 1
$lOffset[5] = 0 + 0x10 * $j
$lBuffStructAddress = MemoryReadPtr($mBasePointe
r, $lOffset)
DllCall($mKernelHandle, 'int', 'ReadProcessMemor
y', 'int', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr
($lBuffStruct), 'int', DllStructGetSize($lBuffStruct), 'int', '')

If (DllStructGetData($lBuffStruct, 'SkillID') ==
$aSkillID) And (DllStructGetData($lBuffStruct, 'TargetId') == ConvertID($aAgent
ID)) Then
Return SendPacket(0x8, 0x23, DllStructGe
tData($lBuffStruct, 'BuffId'))
ExitLoop 2
EndIf
Next
EndIf
Next
EndFunc ;==>DropBuff
;~ Description: Take a screenshot.
Func MakeScreenshot()
Return PerformAction(0xAE, 0x18)
EndFunc ;==>MakeScreenshot
;~ Description: Invite a player to the party.
Func InvitePlayer($aPlayerName)
SendChat('invite ' & $aPlayerName, '/')
EndFunc ;==>InvitePlayer
;~ Description: Leave your party.
Func LeaveGroup($aKickHeroes = True)
If $aKickHeroes Then KickAllHeroes()
Return SendPacket(0x4, 0x9C)
EndFunc ;==>LeaveGroup
;~ Description: Switches to/from Hard Mode.
Func SwitchMode($aMode)
Return SendPacket(0x8, 0x95, $aMode)
EndFunc ;==>SwitchMode
;~ Description: Resign.
Func Resign()
SendChat('resign', '/')
EndFunc ;==>Resign
;~ Description: Donate Kurzick or Luxon faction.
Func DonateFaction($aFaction)
If StringLeft($aFaction, 1) = 'k' Then
Return SendPacket(0x10, 0x2F, 0, 0, 5000)
Else
Return SendPacket(0x10, 0x2F, 0, 1, 5000)
EndIf
EndFunc ;==>DonateFaction
;~ Description: Open a dialog.
Func Dialog($aDialogID)
Return SendPacket(0x8, 0x35, $aDialogID)
EndFunc ;==>Dialog
;~ Description: Skip a cinematic.
Func SkipCinematic()
Return SendPacket(0x4, 0x5D)
EndFunc ;==>SkipCinematic
;~ Description: Change a skill on the skillbar.
Func SetSkillbarSkill($aSlot, $aSkillID, $aHeroNumber = 0)
Return SendPacket(0x14, 0x56, GetHeroID($aHeroNumber), $aSlot - 1, $aSki

llID, 0)
EndFunc ;==>SetSkillbarSkill
;~ Description: Load all skills onto a skillbar simultaneously.
Func LoadSkillBar($aSkill1 = 0, $aSkill2 = 0, $aSkill3 = 0, $aSkill4 = 0, $aSkil
l5 = 0, $aSkill6 = 0, $aSkill7 = 0, $aSkill8 = 0, $aHeroNumber = 0)
SendPacket(0x2C, 0x56, GetHeroID($aHeroNumber), 8, $aSkill1, $aSkill2, $
aSkill3, $aSkill4, $aSkill5, $aSkill6, $aSkill7, $aSkill8)
EndFunc ;==>LoadSkillBar
;~ Description: Loads skill template code.
Func LoadSkillTemplate($aTemplate, $aHeroNumber = 0)
Local $lHeroID = GetHeroID($aHeroNumber)
Local $lSplitTemplate = StringSplit($aTemplate, "")
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local

$lTemplateType ; 4 Bits
$lVersionNumber ; 4 Bits
$lProfBits ; 2 Bits -> P
$lProfPrimary ; P Bits
$lProfSecondary ; P Bits
$lAttributesCount ; 4 Bits
$lAttributesBits ; 4 Bits -> A
$lAttributes[1][2] ; A Bits + 4 Bits (for each Attribute)
$lSkillsBits ; 4 Bits -> S
$lSkills[8] ; S Bits * 8
$lOpTail ; 1 Bit

$aTemplate = ""
For $i = 1 To $lSplitTemplate[0]
$aTemplate &= Base64ToBin64($lSplitTemplate[$i])
Next
$lTemplateType = Bin64ToDec(StringLeft($aTemplate, 4))
$aTemplate = StringTrimLeft($aTemplate, 4)
If $lTemplateType <> 14 Then Return False
$lVersionNumber = Bin64ToDec(StringLeft($aTemplate, 4))
$aTemplate = StringTrimLeft($aTemplate, 4)
$lProfBits = Bin64ToDec(StringLeft($aTemplate, 2)) * 2 + 4
$aTemplate = StringTrimLeft($aTemplate, 2)
$lProfPrimary = Bin64ToDec(StringLeft($aTemplate, $lProfBits))
$aTemplate = StringTrimLeft($aTemplate, $lProfBits)
If $lProfPrimary <> GetHeroProfession($aHeroNumber) Then Return False
$lProfSecondary = Bin64ToDec(StringLeft($aTemplate, $lProfBits))
$aTemplate = StringTrimLeft($aTemplate, $lProfBits)
$lAttributesCount = Bin64ToDec(StringLeft($aTemplate, 4))
$aTemplate = StringTrimLeft($aTemplate, 4)
$lAttributesBits = Bin64ToDec(StringLeft($aTemplate, 4)) + 4
$aTemplate = StringTrimLeft($aTemplate, 4)
$lAttributes[0][0] = $lAttributesCount
For $i = 1 To $lAttributesCount
If Bin64ToDec(StringLeft($aTemplate, $lAttributesBits)) == GetPr
ofPrimaryAttribute($lProfPrimary) Then
$aTemplate = StringTrimLeft($aTemplate, $lAttributesBits

)
$lAttributes[0][1] = Bin64ToDec(StringLeft($aTemplate, 4
))
$aTemplate = StringTrimLeft($aTemplate, 4)
ContinueLoop
EndIf
$lAttributes[0][0] += 1
ReDim $lAttributes[$lAttributes[0][0] + 1][2]
$lAttributes[$i][0] = Bin64ToDec(StringLeft($aTemplate, $lAttrib
utesBits))
$aTemplate = StringTrimLeft($aTemplate, $lAttributesBits)
$lAttributes[$i][1] = Bin64ToDec(StringLeft($aTemplate, 4))
$aTemplate = StringTrimLeft($aTemplate, 4)
Next
$lSkillsBits = Bin64ToDec(StringLeft($aTemplate, 4)) + 8
$aTemplate = StringTrimLeft($aTemplate, 4)
For $i = 0 To 7
$lSkills[$i] = Bin64ToDec(StringLeft($aTemplate, $lSkillsBits))
$aTemplate = StringTrimLeft($aTemplate, $lSkillsBits)
Next
$lOpTail = Bin64ToDec($aTemplate)
$lAttributes[0][0] = $lProfSecondary
LoadAttributes($lAttributes, $aHeroNumber)
LoadSkillBar($lSkills[0], $lSkills[1], $lSkills[2], $lSkills[3], $lSkill
s[4], $lSkills[5], $lSkills[6], $lSkills[7], $aHeroNumber)
EndFunc ;==>LoadSkillTemplate
;~ Description: Load attributes from a two dimensional array.
Func LoadAttributes($aAttributesArray, $aHeroNumber = 0)
Local $lPrimaryAttribute
Local $lDeadlock
Local $lHeroID = GetHeroID($aHeroNumber)
Local $lLevel
$lPrimaryAttribute = GetProfPrimaryAttribute(GetHeroProfession($aHeroNum
ber))
If $aAttributesArray[0][0] <> 0 And GetHeroProfession($aHeroNumber, True
) <> $aAttributesArray[0][0] And GetHeroProfession($aHeroNumber) <> $aAttributes
Array[0][0] Then
Do
$lDeadlock = TimerInit()
ChangeSecondProfession($aAttributesArray[0][0], $aHeroNu
mber)
Do
Sleep(20)
Until GetHeroProfession($aHeroNumber, True) == $aAttribu
tesArray[0][0] Or TimerDiff($lDeadlock) > 5000
Until GetHeroProfession($aHeroNumber, True) == $aAttributesArray
[0][0]
EndIf
$aAttributesArray[0][0] = $lPrimaryAttribute
For $i = 0 To UBound($aAttributesArray) - 1
If $aAttributesArray[$i][1] > 12 Then $aAttributesArray[$i][1] =
12

If $aAttributesArray[$i][1] < 0 Then $aAttributesArray[$i][1] =


0
Next
While GetAttributeByID($lPrimaryAttribute, False, $aHeroNumber) > $aAttr
ibutesArray[0][1]
$lLevel = GetAttributeByID($lPrimaryAttribute, False, $aHeroNumb
er)
$lDeadlock = TimerInit()
DecreaseAttribute($lPrimaryAttribute, $aHeroNumber)
Do
Sleep(20)
Until GetAttributeByID($lPrimaryAttribute, False, $aHeroNumber)
< $lLevel Or TimerDiff($lDeadlock) > 5000
TolSleep()
WEnd
For $i = 1 To UBound($aAttributesArray) - 1
While GetAttributeByID($aAttributesArray[$i][0], False, $aHeroNu
mber) > $aAttributesArray[$i][1]
$lLevel = GetAttributeByID($aAttributesArray[$i][0], Fal
se, $aHeroNumber)
$lDeadlock = TimerInit()
DecreaseAttribute($aAttributesArray[$i][0], $aHeroNumber
)
Do
Sleep(20)
Until GetAttributeByID($aAttributesArray[$i][0], False,
$aHeroNumber) < $lLevel Or TimerDiff($lDeadlock) > 5000
TolSleep()
WEnd
Next
For $i = 0 To 44
If GetAttributeByID($i, False, $aHeroNumber) > 0 Then
If $i = $lPrimaryAttribute Then ContinueLoop
For $j = 1 To UBound($aAttributesArray) - 1
If $i = $aAttributesArray[$j][0] Then ContinueLo
op 2
Local $lDummy ;AutoIt 3.8.8.0 Bug
Next
While GetAttributeByID($i, False, $aHeroNumber) > 0
$lLevel = GetAttributeByID($i, False, $aHeroNumb
er)
$lDeadlock = TimerInit()
DecreaseAttribute($i, $aHeroNumber)
Do
Sleep(20)
Until GetAttributeByID($i, False, $aHeroNumber)
< $lLevel Or TimerDiff($lDeadlock) > 5000
TolSleep()
WEnd
EndIf
Next
While GetAttributeByID($lPrimaryAttribute, False, $aHeroNumber) < $aAttr
ibutesArray[0][1]
$lLevel = GetAttributeByID($lPrimaryAttribute, False, $aHeroNumb
er)
$lDeadlock = TimerInit()
IncreaseAttribute($lPrimaryAttribute, $aHeroNumber)
Do

Sleep(20)
Until GetAttributeByID($lPrimaryAttribute, False, $aHeroNumber)
> $lLevel Or TimerDiff($lDeadlock) > 5000
TolSleep()
WEnd
For $i = 1 To UBound($aAttributesArray) - 1
While GetAttributeByID($aAttributesArray[$i][0], False, $aHeroNu
mber) < $aAttributesArray[$i][1]
$lLevel = GetAttributeByID($aAttributesArray[$i][0], Fal
se, $aHeroNumber)
$lDeadlock = TimerInit()
IncreaseAttribute($aAttributesArray[$i][0], $aHeroNumber
)
Do
Sleep(20)
Until GetAttributeByID($aAttributesArray[$i][0], False,
$aHeroNumber) > $lLevel Or TimerDiff($lDeadlock) > 5000
TolSleep()
WEnd
Next
EndFunc ;==>LoadAttributes
;~ Description: Increase attribute by 1
Func IncreaseAttribute($aAttributeID, $aHeroNumber = 0)
DllStructSetData($mIncreaseAttribute, 2, $aAttributeID)
DllStructSetData($mIncreaseAttribute, 3, GetHeroID($aHeroNumber))
Enqueue($mIncreaseAttributePtr, 12)
EndFunc ;==>IncreaseAttribute
;~ Description: Decrease attribute by 1
Func DecreaseAttribute($aAttributeID, $aHeroNumber = 0)
DllStructSetData($mDecreaseAttribute, 2, $aAttributeID)
DllStructSetData($mDecreaseAttribute, 3, GetHeroID($aHeroNumber))
Enqueue($mDecreaseAttributePtr, 12)
EndFunc ;==>DecreaseAttribute
;~ Description: Set all attributes to 0
Func ClearAttributes($aHeroNumber = 0)
Local $lLevel
If GetMapLoading() <> 0 Then Return
For $i = 0 To 44
If GetAttributeByID($i, False, $aHeroNumber) > 0 Then
Do
$lLevel = GetAttributeByID($i, False, $aHeroNumb
er)
$lDeadlock = TimerInit()
DecreaseAttribute($i, $aHeroNumber)
Do
Sleep(20)
Until $lLevel > GetAttributeByID($i, False, $aHe
roNumber) Or TimerDiff($lDeadlock) > 5000
Sleep(100)
Until GetAttributeByID($i, False, $aHeroNumber) == 0
EndIf
Next
EndFunc ;==>ClearAttributes
;~ Description: Change your secondary profession.
Func ChangeSecondProfession($aProfession, $aHeroNumber = 0)
Return SendPacket(0xC, 0x3B, GetHeroID($aHeroNumber), $aProfession)

EndFunc

;==>ChangeSecondProfession

;~ Description: Sets value of GetMapIsLoaded() to 0.


Func InitMapLoad()
MemoryWrite($mMapIsLoaded, 0)
EndFunc ;==>InitMapLoad
;~ Description: Changes game language to english.
Func EnsureEnglish($aEnsure)
If $aEnsure Then
MemoryWrite($mEnsureEnglish, 1)
Else
MemoryWrite($mEnsureEnglish, 0)
EndIf
EndFunc ;==>EnsureEnglish
;~ Description: Change game language.
Func ToggleLanguage()
DllStructSetData($mToggleLanguage, 2, 0x18)
Enqueue($mToggleLanguagePtr, 8)
EndFunc ;==>ToggleLanguage
;~ Description: Changes the maximum distance you can zoom out.
Func ChangeMaxZoom($aZoom = 750)
MemoryWrite($mZoomStill, $aZoom, "float")
MemoryWrite($mZoomMoving, $aZoom, "float")
EndFunc ;==>ChangeMaxZoom
;~ Description: Emptys Guild Wars client memory
Func ClearMemory()
DllCall($mKernelHandle, 'int', 'SetProcessWorkingSetSize', 'int', $mGWPr
ocHandle, 'int', -1, 'int', -1)
EndFunc ;==>ClearMemory
;~ Description: Changes the maximum memory Guild Wars can use.
Func SetMaxMemory($aMemory = 157286400)
DllCall($mKernelHandle, 'int', 'SetProcessWorkingSetSizeEx', 'int', $mGW
ProcHandle, 'int', 1, 'int', $aMemory, 'int', 6)
EndFunc ;==>SetMaxMemory
#EndRegion Misc
;~ Description: Internal use only.
Func Enqueue($aPtr, $aSize)
DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHand
le, 'int', 256 * $mQueueCounter + $mQueueBase, 'ptr', $aPtr, 'int', $aSize, 'int
', '')
If $mQueueCounter = $mQueueSize Then
$mQueueCounter = 0
Else
$mQueueCounter = $mQueueCounter + 1
EndIf
EndFunc ;==>Enqueue
;~ Description: Converts float to integer.
Func FloatToInt($nFloat)
Local $tFloat = DllStructCreate("float")
Local $tInt = DllStructCreate("int", DllStructGetPtr($tFloat))
DllStructSetData($tFloat, 1, $nFloat)
Return DllStructGetData($tInt, 1)
EndFunc ;==>FloatToInt

#EndRegion Commands
#Region Queries
#Region Titles
;~ Description: Returns Hero title progress.
Func GetHeroTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetHeroTitle
;~ Description: Returns Gladiator title progress.
Func GetGladiatorTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x7C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetGladiatorTitle
;~ Description: Returns Kurzick title progress.
Func GetKurzickTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0xCC]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetKurzickTitle
;~ Description: Returns Luxon title progress.
Func GetLuxonTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0xF4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetLuxonTitle
;~ Description: Returns drunkard title progress.
Func GetDrunkardTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x11C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetDrunkardTitle
;~ Description: Returns survivor title progress.
Func GetSurvivorTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x16C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetSurvivorTitle
;~ Description: Returns max titles
Func GetMaxTitles()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x194]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMaxTitles
;~ Description: Returns lucky title progress.
Func GetLuckyTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x25C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetLuckyTitle

;~ Description: Returns unlucky title progress.


Func GetUnluckyTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x284]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetUnluckyTitle
;~ Description: Returns Sunspear title progress.
Func GetSunspearTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x2AC]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetSunspearTitle
;~ Description: Returns Lightbringer title progress.
Func GetLightbringerTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x324]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetLightbringerTitle
;~ Description: Returns Commander title progress.
Func GetCommanderTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x374]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetCommanderTitle
;~ Description: Returns Gamer title progress.
Func GetGamerTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x39C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetGamerTitle
;~ Description: Returns Legendary Guardian title progress.
Func GetLegendaryGuardianTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x4DC]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetLegendaryGuardianTitle
;~ Description: Returns sweets title progress.
Func GetSweetTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x554]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetSweetTitle
;~ Description: Returns Asura title progress.
Func GetAsuraTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x5F4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetAsuraTitle
;~ Description: Returns Deldrimor title progress.
Func GetDeldrimorTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x61C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)

EndFunc

Return $lReturn[1]
;==>GetDeldrimorTitle

;~ Description: Returns Vanguard title progress.


Func GetVanguardTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x644]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetVanguardTitle
;~ Description: Returns Norn title progress.
Func GetNornTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x66C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetNornTitle
;~ Description: Returns mastery of the north title progress.
Func GetNorthMasteryTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x694]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetNorthMasteryTitle
;~ Description: Returns party title progress.
Func GetPartyTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x6BC]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetPartyTitle
;~ Description: Returns Zaishen title progress.
Func GetZaishenTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x6E4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetZaishenTitle
;~ Description: Returns treasure hunter title progress.
Func GetTreasureTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x70C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetTreasureTitle
;~ Description: Returns wisdom title progress.
Func GetWisdomTitle()
Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x734]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetWisdomTitle
#EndRegion Titles
#Region Faction
;~ Description: Returns current Kurzick faction.
Func GetKurzickFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x6E4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetKurzickFaction

;~ Description: Returns max Kurzick faction.


Func GetMaxKurzickFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x754]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMaxKurzickFaction
;~ Description: Returns current Luxon faction.
Func GetLuxonFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x6F4]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetLuxonFaction
;~ Description: Returns max Luxon faction.
Func GetMaxLuxonFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x758]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMaxLuxonFaction
;~ Description: Returns current Balthazar faction.
Func GetBalthazarFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x734]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetBalthazarFaction
;~ Description: Returns max Balthazar faction.
Func GetMaxBalthazarFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x75C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMaxBalthazarFaction
;~ Description: Returns current Imperial faction.
Func GetImperialFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x708]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetImperialFaction
;~ Description: Returns max Imperial faction.
Func GetMaxImperialFaction()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x760]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMaxImperialFaction
#EndRegion Faction
#Region Item
;~ Description: Returns rarity (name color) of an item.
Func GetRarity($aItem)
If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
Local $lPtr = DllStructGetData($aItem, 'NameString')
If $lPtr == 0 Then Return
Return MemoryRead($lPtr, 'ushort')
EndFunc ;==>GetRarity

;~ Description: Tests if an item is identified.


Func GetIsIDed($aItem)
If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
Return BitAND(DllStructGetData($aItem, 'interaction'), 1) > 0
EndFunc ;==>GetIsIDed
;~ Description: Returns a weapon or shield's minimum required attribute.
Func GetItemReq($aItem)
Local $lMod = GetModByIdentifier($aItem, "9827")
Return $lMod[0]
EndFunc ;==>GetItemReq
;~ Description: Returns a weapon or shield's required attribute.
Func GetItemAttribute($aItem)
Local $lMod = GetModByIdentifier($aItem, "9827")
Return $lMod[1]
EndFunc ;==>GetItemAttribute
;~ Description: Returns an array of a the requested mod.
Func GetModByIdentifier($aItem, $aIdentifier)
If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
Local $lReturn[2]
Local $lString = StringTrimLeft(GetModStruct($aItem), 2)
For $i = 0 To StringLen($lString) / 8 - 2
If StringMid($lString, 8 * $i + 5, 4) == $aIdentifier Then
$lReturn[0] = Int("0x" & StringMid($lString, 8 * $i + 1,
2))
$lReturn[1] = Int("0x" & StringMid($lString, 8 * $i + 3,
2))
ExitLoop
EndIf
Next
Return $lReturn
EndFunc ;==>GetModByIdentifier
;~ Description: Returns modstruct of an item.
Func GetModStruct($aItem)
If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
If DllStructGetData($aItem, 'modstruct') = 0 Then Return
Return MemoryRead(DllStructGetData($aItem, 'modstruct'), 'Byte[' & DllSt
ructGetData($aItem, 'modstructsize') * 4 & ']')
EndFunc ;==>GetModStruct
;~ Description: Tests if an item is assigned to you.
Func GetAssignedToMe($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return (DllStructGetData($aAgent, 'Owner') = GetMyID())
EndFunc ;==>GetAssignedToMe
;~ Description: Tests if you can pick up an item.
Func GetCanPickUp($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
If GetAssignedToMe($aAgent) Or DllStructGetData($aAgent, 'Owner') = 0 Th
en
Return True
Else
Return False
EndIf
EndFunc ;==>GetCanPickUp

;~ Description: Returns struct of an inventory bag.


Func GetBag($aBag)
Local $lOffset[5] = [0, 0x18, 0x40, 0xF8, 0x4 * $aBag]
Local $lBagStruct = DllStructCreate('byte unknown1[4];long
;ptr containerItem;long ItemsCount;ptr bagArray;ptr itemArray;long
g slots')
Local $lBagPtr = MemoryReadPtr($mBasePointer, $lOffset)
If $lBagPtr[1] = 0 Then Return
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int',
e, 'int', $lBagPtr[1], 'ptr', DllStructGetPtr($lBagStruct), 'int',
ize($lBagStruct), 'int', '')
Return $lBagStruct
EndFunc ;==>GetBag

index;long id
fakeSlots;lon

$mGWProcHandl
DllStructGetS

;~ Description: Returns item by slot.


Func GetItemBySlot($aBag, $aSlot)
Local $lBag
If IsDllStruct($aBag) = 0 Then
$lBag = GetBag($aBag)
Else
$lBag = $aBag
EndIf
Local $lItemPtr = DllStructGetData($lBag, 'ItemArray')
Local $lBuffer = DllStructCreate('ptr')
Local $lItemStruct = DllStructCreate('long id;long agentId;byte unknown1
[4];ptr bag;ptr modstruct;long modstructsize;ptr customized;byte unknown2[4];byt
e type;byte unknown3;short extraId;short value;byte unknown4[2];short interactio
n;long modelId;ptr modString;byte unknown5[4];ptr NameString;byte unknown6[15];b
yte quantity;byte equipped;byte unknown7[1];byte slot')
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', DllStructGetData($lBag, 'ItemArray') + 4 * ($aSlot - 1), 'ptr', DllStr
uctGetPtr($lBuffer), 'int', DllStructGetSize($lBuffer), 'int', '')
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', DllStructGetData($lBuffer, 1), 'ptr', DllStructGetPtr($lItemStruct), '
int', DllStructGetSize($lItemStruct), 'int', '')
Return $lItemStruct
EndFunc ;==>GetItemBySlot
;~ Description: Returns item struct.
Func GetItemByItemID($aItemID)
Local $lItemStruct = DllStructCreate('long id;long agentId;byte unknown1
[4];ptr bag;ptr modstruct;long modstructsize;ptr customized;byte unknown2[4];byt
e type;byte unknown3;short extraId;short value;byte unknown4[2];short interactio
n;long modelId;ptr modString;byte unknown5[4];ptr NameString;byte unknown6[15];b
yte quantity;byte equipped;byte unknown7[1];byte slot')
Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0x4 * $aItemID]
Local $lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGe
tSize($lItemStruct), 'int', '')
Return $lItemStruct
EndFunc ;==>GetItemByItemID
;~ Description: Returns item by agent ID.
Func GetItemByAgentID($aAgentID)
Local $lItemStruct = DllStructCreate('long id;long agentId;byte unknown1
[4];ptr bag;ptr modstruct;long modstructsize;ptr customized;byte unknown2[4];byt
e type;byte unknown3;short extraId;short value;byte unknown4[2];short interactio

n;long modelId;ptr modString;byte unknown5[4];ptr NameString;byte unknown6[15];b


yte quantity;byte equipped;byte unknown7[1];byte slot')
Local $lOffset[4] = [0, 0x18, 0x40, 0xC0]
Local $lItemArraySize = MemoryReadPtr($mBasePointer, $lOffset)
Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0]
Local $lItemPtr, $lItemID
Local $lAgentID = ConvertID($aAgentID)
For $lItemID = 1 To $lItemArraySize[1]
$lOffset[4] = 0x4 * $lItemID
$lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
If $lItemPtr[1] = 0 Then ContinueLoop
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', Dll
StructGetSize($lItemStruct), 'int', '')
If DllStructGetData($lItemStruct, 'AgentID') = $lAgentID Then Re
turn $lItemStruct
Next
EndFunc ;==>GetItemByAgentID
;~ Description: Returns item by model ID.
Func GetItemByModelID($aModelID)
Local $lItemStruct = DllStructCreate('long id;long agentId;byte unknown1
[4];ptr bag;ptr modstruct;long modstructsize;ptr customized;byte unknown2[4];byt
e type;byte unknown3;short extraId;short value;byte unknown4[2];short interactio
n;long modelId;ptr modString;byte unknown5[4];ptr NameString;byte unknown6[15];b
yte quantity;byte equipped;byte unknown7[1];byte slot')
Local $lOffset[4] = [0, 0x18, 0x40, 0xC0]
Local $lItemArraySize = MemoryReadPtr($mBasePointer, $lOffset)
Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0]
Local $lItemPtr, $lItemID
For $lItemID = 1 To $lItemArraySize[1]
$lOffset[4] = 0x4 * $lItemID
$lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
If $lItemPtr[1] = 0 Then ContinueLoop
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', Dll
StructGetSize($lItemStruct), 'int', '')
If DllStructGetData($lItemStruct, 'ModelID') = $aModelID Then Re
turn $lItemStruct
Next
EndFunc ;==>GetItemByModelID
;~ Description: Returns amount of gold in storage.
Func GetGoldStorage()
Local $lOffset[5] = [0, 0x18, 0x40, 0xF8, 0x80]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetGoldStorage
;~ Description: Returns amount of gold being carried.
Func GetGoldCharacter()
Local $lOffset[5] = [0, 0x18, 0x40, 0xF8, 0x7C]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetGoldCharacter

;~ Description: Returns item ID of salvage kit in inventory.


Func FindSalvageKit()
Local $lItem
Local $lKit = 0
Local $lUses = 101
For $i = 1 To 16
For $j = 1 To DllStructGetData(GetBag($i), 'Slots')
$lItem = GetItemBySlot($i, $j)
Switch DllStructGetData($lItem, 'ModelID')
Case 2991
If DllStructGetData($lItem, 'Value') / 8
< $lUses Then
$lKit = DllStructGetData($lItem,
'ID')
$lUses = DllStructGetData($lItem
, 'Value') / 8
EndIf
Case 5900
If DllStructGetData($lItem, 'Value') / 1
0 < $lUses Then
$lKit = DllStructGetData($lItem,
'ID')
$lUses = DllStructGetData($lItem
, 'Value') / 10
EndIf
Case Else
ContinueLoop
EndSwitch
Next
Next
Return $lKit
EndFunc ;==>FindSalvageKit
;~ Description: Returns item ID of ID kit in inventory.
Func FindIDKit()
Local $lItem
Local $lKit = 0
Local $lUses = 101
For $i = 1 To 16
For $j = 1 To DllStructGetData(GetBag($i), 'Slots')
$lItem = GetItemBySlot($i, $j)
Switch DllStructGetData($lItem, 'ModelID')
Case 2989
If DllStructGetData($lItem, 'Value') / 2
< $lUses Then
$lKit = DllStructGetData($lItem,
'ID')
$lUses = DllStructGetData($lItem
, 'Value') / 2
EndIf
Case 5899
If DllStructGetData($lItem, 'Value') / 2
.5 < $lUses Then
$lKit = DllStructGetData($lItem,
'ID')
$lUses = DllStructGetData($lItem
, 'Value') / 2.5
EndIf
Case Else
ContinueLoop

EndSwitch
Next
Next
Return $lKit
EndFunc ;==>FindIDKit
;~ Description: Returns the item ID of the quoted item.
Func GetTraderCostID()
Return MemoryRead($mTraderCostID)
EndFunc ;==>GetTraderCostID
;~ Description: Returns the cost of the requested item.
Func GetTraderCostValue()
Return MemoryRead($mTraderCostValue)
EndFunc ;==>GetTraderCostValue
;~ Description: Internal use for BuyItem()
Func GetMerchantItemsBase()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x24]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMerchantItemsBase
;~ Description: Internal use for BuyItem()
Func GetMerchantItemsSize()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x28]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetMerchantItemsSize
#EndRegion Item
#Region H&H
;~ Description: Returns number of heroes you control.
Func GetHeroCount()
Local $lOffset[5]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x4C
$lOffset[3] = 0x54
$lOffset[4] = 0x2C
Local $lHeroCount = MemoryReadPtr($mBasePointer, $lOffset)
Return $lHeroCount[1]
EndFunc ;==>GetHeroCount
;~ Description: Returns agent ID of a hero.
Func GetHeroID($aHeroNumber)
If $aHeroNumber == 0 Then Return GetMyID()
Local $lOffset[6]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x4C
$lOffset[3] = 0x54
$lOffset[4] = 0x24
$lOffset[5] = 0x18 * ($aHeroNumber - 1)
Local $lAgentID = MemoryReadPtr($mBasePointer, $lOffset)
Return $lAgentID[1]
EndFunc ;==>GetHeroID
;~ Description: Returns hero number by agent ID.
Func GetHeroNumberByAgentID($aAgentID)

Local $lAgentID
Local $lOffset[6]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x4C
$lOffset[3] = 0x54
$lOffset[4] = 0x24
For $i = 1 To GetHeroCount()
$lOffset[5] = 0x18 * ($i - 1)
$lAgentID = MemoryReadPtr($mBasePointer, $lOffset)
If $lAgentID[1] == ConvertID($aAgentID) Then Return $i
Next
Return 0
EndFunc ;==>GetHeroNumberByAgentID
;~ Description: Returns hero number by hero ID.
Func GetHeroNumberByHeroID($aHeroId)
Local $lAgentID
Local $lOffset[6]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x4C
$lOffset[3] = 0x54
$lOffset[4] = 0x24
For $i = 1 To GetHeroCount()
$lOffset[5] = 8 + 0x18 * ($i - 1)
$lAgentID = MemoryReadPtr($mBasePointer, $lOffset)
If $lAgentID[1] == ConvertID($aHeroId) Then Return $i
Next
Return 0
EndFunc ;==>GetHeroNumberByHeroID
;~ Description: Returns hero's profession ID (when it can't be found by other me
ans)
Func GetHeroProfession($aHeroNumber, $aSecondary = False)
Local $lOffset[5] = [0, 0x18, 0x2C, 0x658, 0]
Local $lBuffer
$aHeroNumber = GetHeroID($aHeroNumber)
For $i = 0 To GetHeroCount()
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] = $aHeroNumber Then
$lOffset[4] += 4
If $aSecondary Then $lOffset[4] += 4
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
Return $lBuffer[1]
EndIf
$lOffset[4] += 0x14
Next
EndFunc ;==>GetHeroProfession
;~ Description: Tests if a hero's skill slot is disabled.
Func GetIsHeroSkillSlotDisabled($aHeroNumber, $aSkillSlot)
Return BitAND(2 ^ ($aSkillSlot - 1), DllStructGetData(GetSkillbar($aHero
Number), 'Disabled')) > 0
EndFunc ;==>GetIsHeroSkillSlotDisabled
#EndRegion H&H
#Region Agent
;~ Description: Returns an agent struct.
Func GetAgentByID($aAgentID = -2)

;returns dll struct if successful


Local $lAgentPtr = GetAgentPtr($aAgentID)
If $lAgentPtr = 0 Then Return 0
;Offsets: 0x2C=AgentID 0x9C=Type 0xF4=PlayerNumber 0114=Energy Pips
Local $lAgentStruct = DllStructCreate('ptr vtable;byte unknown1[24];byte
unknown2[4];ptr NextAgent;byte unknown3[8];long Id;float Z;byte unknown4[8];flo
at BoxHoverWidth;float BoxHoverHeight;byte unknown5[8];float Rotation;byte unkno
wn6[8];long NameProperties;byte unknown7[24];float X;float Y;byte unknown8[8];fl
oat NameTagX;float NameTagY;float NameTagZ;byte unknown9[12];long Type;float Mov
eX;float MoveY;byte unknown10[28];long Owner;byte unknown30[8];long ExtraType;by
te unknown11[24];float AttackSpeed;float AttackSpeedModifier;word PlayerNumber;b
yte unknown12[6];ptr Equip;byte unknown13[10];byte Primary;byte Secondary;byte L
evel;byte Team;byte unknown14[6];float EnergyPips;byte unknown[4];float EnergyPe
rcent;long MaxEnergy;byte unknown15[4];float HPPips;byte unknown16[4];float HP;l
ong MaxHP;long Effects;byte unknown17[4];byte Hex;byte unknown18[18];long ModelS
tate;long TypeMap;byte unknown19[16];long InSpiritRange;byte unknown20[16];long
LoginNumber;float ModelMode;byte unknown21[4];long ModelAnimation;byte unknown22
[32];byte LastStrike;byte Allegiance;word WeaponType;word Skill;byte unknown23[4
];word WeaponItemId;word OffhandItemId')
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $lAgentPtr, 'ptr', DllStructGetPtr($lAgentStruct), 'int', DllStructGet
Size($lAgentStruct), 'int', '')
Return $lAgentStruct
EndFunc ;==>GetAgentByID
;~ Description: Internal use for GetAgentByID()
Func GetAgentPtr($aAgentID)
Local $lOffset[3] = [0, 4 * ConvertID($aAgentID), 0]
Local $lAgentStructAddress = MemoryReadPtr($mAgentBase, $lOffset)
Return $lAgentStructAddress[0]
EndFunc ;==>GetAgentPtr
;~ Description: Test if an agent exists.
Func GetAgentExists($aAgentID)
Return (GetAgentPtr($aAgentID) > 0 And $aAgentID < GetMaxAgents())
EndFunc ;==>GetAgentExists
;~ Description: Returns the target of an agent.
Func GetTarget($aAgent)
Local $lAgentID
If IsDllStruct($aAgent) = 0 Then
$lAgentID = ConvertID($aAgent)
Else
$lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
EndFunc

Return MemoryRead(GetValue('TargetLogBase') + 4 * $lAgentID)


;==>GetTarget

;~ Description: Returns agent by player name.


Func GetAgentByPlayerName($aPlayerName)
For $i = 1 To GetMaxAgents()
If GetPlayerName($i) = $aPlayerName Then
Return GetAgentByID($i)
EndIf
Next
EndFunc ;==>GetAgentByPlayerName
;~ Description: Returns agent by name.

Func GetAgentByName($aName)
If $mUseStringLog = False Then Return
Local $lName, $lAddress
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
DisplayAll(True)
Sleep(100)
DisplayAll(False)
DisplayAll(True)
Sleep(100)
DisplayAll(False)
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
EndFunc ;==>GetAgentByName
;~ Description: Returns the nearest agent to an agent.
Func GetNearestAgentToAgent($aAgent = -2)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray()
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData(
$lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData
($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then
ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestAgentToAgent
;~ Description: Returns the nearest enemy to an agent.
Func GetNearestEnemyToAgent($aAgent = -2)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0xDB)

If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)


Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData(
$lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData
($lAgentArray[$i], 'Y')) ^ 2
If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 3 Then Co
ntinueLoop
If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLo
op
If BitAND(DllStructGetData($lAgentArray[$i], 'Effects'), 0x0010)
> 0 Then ContinueLoop
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData(
$lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData
($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then
ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestEnemyToAgent
;~ Description: Returns the nearest agent to a set of coordinates.
Func GetNearestAgentToCoords($aX, $aY)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray()
For $i = 1 To $lAgentArray[0]
$lDistance = ($aX - DllStructGetData($lAgentArray[$i], 'X')) ^ 2
+ ($aY - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestAgentToCoords
;~ Description: Returns the nearest signpost to an agent.
Func GetNearestSignpostToAgent($aAgent = -2)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0x200)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]

$lDistance = (DllStructGetData($lAgentArray[$i], 'Y') - DllStruc


tGetData($aAgent, 'Y')) ^ 2 + (DllStructGetData($lAgentArray[$i], 'X') - DllStru
ctGetData($aAgent, 'X')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then
ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestSignpostToAgent
;~ Description: Returns the nearest signpost to a set of coordinates.
Func GetNearestSignpostToCoords($aX, $aY)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0x200)
For $i = 1 To $lAgentArray[0]
$lDistance = ($aX - DllStructGetData($lAgentArray[$i], 'X')) ^ 2
+ ($aY - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestSignpostToCoords
;~ Description: Returns the nearest NPC to an agent.
Func GetNearestNPCToAgent($aAgent)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0xDB)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 6 Then Co
ntinueLoop
If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLo
op
If BitAND(DllStructGetData($lAgentArray[$i], 'Effects'), 0x0010)
> 0 Then ContinueLoop
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData(
$lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData
($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then
ContinueLoop
$lNearestAgent = $lAgentArray[$i]

$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestNPCToAgent
;~ Description: Returns the nearest NPC to a set of coordinates.
Func GetNearestNPCToCoords($aX, $aY)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0xDB)
For $i = 1 To $lAgentArray[0]
If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 6 Then Co
ntinueLoop
If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLo
op
If BitAND(DllStructGetData($lAgentArray[$i], 'Effects'), 0x0010)
> 0 Then ContinueLoop
$lDistance = ($aX - DllStructGetData($lAgentArray[$i], 'X')) ^ 2
+ ($aY - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestNPCToCoords
;~ Description: Returns the nearest item to an agent.
Func GetNearestItemToAgent($aAgent = -2, $aCanPickUp = True)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0x400)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
If $aCanPickUp And Not GetCanPickUp($lAgentArray[$i]) Then Conti
nueLoop
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData(
$lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData
($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then
ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next

SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestItemToAgent
;~ Description: Returns array of party members
;~ Param: an array returned by GetAgentArray. This is totally optional, but can
greatly improve script speed.
Func GetParty($aAgentArray = 0)
Local $lReturnArray[1] = [0]
If $aAgentArray==0 Then $aAgentArray = GetAgentArray(0xDB)
For $i = 1 To $aAgentArray[0]
If DllStructGetData($aAgentArray[$i], 'Allegiance') == 1 Then
If BitAND(DllStructGetData($aAgentArray[$i], 'TypeMap'),
131072) Then
$lReturnArray[0] += 1
ReDim $lReturnArray[$lReturnArray[0] + 1]
$lReturnArray[$lReturnArray[0]] = $aAgentArray[$
i]
EndIf
EndIf
Next
Return $lReturnArray
EndFunc ;==>GetParty
;~ Description: Quickly creates an array of agents of a given type
Func GetAgentArray($aType = 0)
Local $lStruct
Local $lCount
Local $lBuffer = ''
DllStructSetData($mMakeAgentArray, 2, $aType)
MemoryWrite($mAgentCopyCount, -1, 'long')
Enqueue($mMakeAgentArrayPtr, 8)
Local $lDeadlock = TimerInit()
Do
Sleep(1)
$lCount = MemoryRead($mAgentCopyCount, 'long')
Until $lCount >= 0 Or TimerDiff($lDeadlock) > 5000
If $lCount < 0 Then $lCount = 0
For $i = 1 To $lCount
$lBuffer &= 'Byte[448];'
Next
$lBuffer = DllStructCreate($lBuffer)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $mAgentCopyBase, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGet
Size($lBuffer), 'int', '')
Local $lReturnArray[$lCount + 1] = [$lCount]
For $i = 1 To $lCount
$lReturnArray[$i] = DllStructCreate('ptr vtable;byte unknown1[24
];byte unknown2[4];ptr NextAgent;byte unknown3[8];long Id;float Z;byte unknown4[
8];float BoxHoverWidth;float BoxHoverHeight;byte unknown5[8];float Rotation;byte
unknown6[8];long NameProperties;byte unknown7[24];float X;float Y;byte unknown8
[8];float NameTagX;float NameTagY;float NameTagZ;byte unknown9[12];long Type;flo
at MoveX;float MoveY;byte unknown10[28];long Owner;byte unknown30[8];long ExtraT
ype;byte unknown11[24];float AttackSpeed;float AttackSpeedModifier;word PlayerNu
mber;byte unknown12[6];ptr Equip;byte unknown13[10];byte Primary;byte Secondary;
byte Level;byte Team;byte unknown14[6];float EnergyPips;byte unknown[4];float En
ergyPercent;long MaxEnergy;byte unknown15[4];float HPPips;byte unknown16[4];floa
t HP;long MaxHP;long Effects;byte unknown17[4];byte Hex;byte unknown18[18];long
ModelState;long TypeMap;byte unknown19[16];long InSpiritRange;byte unknown20[16]
;long LoginNumber;float ModelMode;byte unknown21[4];long ModelAnimation;byte unk

nown22[32];byte LastStrike;byte Allegiance;word WeaponType;word Skill;byte unkno


wn23[4];word WeaponItemId;word OffhandItemId')
$lStruct = DllStructCreate('byte[448]', DllStructGetPtr($lReturn
Array[$i]))
DllStructSetData($lStruct, 1, DllStructGetData($lBuffer, $i))
Next
Return $lReturnArray
EndFunc ;==>GetAgentArray
;~ Description Returns the "danger level" of each party member
;~ Param1: an array returned by GetAgentArray(). This is totally optional, but c
an greatly improve script speed.
;~ Param2: an array returned by GetParty() This is totally optional, but can gre
atly improve script speed.
Func GetPartyDanger($aAgentArray = 0, $aParty = 0)
If $aAgentArray == 0 Then $aAgentArray = GetAgentArray(0xDB)
If $aParty == 0 Then $aParty = GetParty($aAgentArray)
Local $lReturnArray[$aParty[0]+1]
$lReturnArray[0] = $aParty[0]
For $i=1 To $lReturnArray[0]
$lReturnArray[$i] = 0
Next
For $i=1 To $aAgentArray[0]
If BitAND(DllStructGetData($aAgentArray[$i], 'Effects'), 0x0010)
> 0 Then ContinueLoop
If DllStructGetData($aAgentArray[$i], 'HP') <= 0 Then ContinueLo
op
If Not GetIsLiving($aAgentArray[$i]) Then ContinueLoop
If DllStructGetData($aAgentArray[$i], "Allegiance") > 3 Then Con
tinueLoop
; ignore NPCs, spirits, minions, pets
For $j=1 To $aParty[0]
If GetTarget(DllStructGetData($aAgentArray[$i], "ID")) =
= DllStructGetData($aParty[$j], "ID") Then
If GetDistance($aAgentArray[$i], $aParty[$j]) <
5000 Then
If DllStructGetData($aAgentArray[$i], "T
eam") <> 0 Then
If DllStructGetData($aAgentArray
[$i], "Team") <> DllStructGetData($aParty[$j], "Team") Then
$lReturnArray[$j] += 1
EndIf
ElseIf DllStructGetData($aAgentArray[$i]
, "Allegiance") <> DllStructGetData($aParty[$j], "Allegiance") Then
$lReturnArray[$j] += 1
EndIf
EndIf
EndIf
Next
Next
Return $lReturnArray
EndFunc
;~ Description: Return the number of enemy agents targeting the given agent.
Func GetAgentDanger($aAgent, $aAgentArray = 0)
If IsDllStruct($aAgent) = 0 Then
$aAgent = GetAgentByID($aAgent)
EndIf

Local $lCount = 0
If $aAgentArray == 0 Then $aAgentArray = GetAgentArray(0xDB)
For $i=1 To $aAgentArray[0]
If BitAND(DllStructGetData($aAgentArray[$i], 'Effects'), 0x0010)
> 0 Then ContinueLoop
If DllStructGetData($aAgentArray[$i], 'HP') <= 0 Then ContinueLo
op
If Not GetIsLiving($aAgentArray[$i]) Then ContinueLoop
If DllStructGetData($aAgentArray[$i], "Allegiance") > 3 Then Con
tinueLoop
; ignore NPCs, spirits, minions, pets
If GetTarget(DllStructGetData($aAgentArray[$i], "ID")) == DllStr
uctGetData($aAgent, "ID") Then
If GetDistance($aAgentArray[$i], $aAgent) < 5000 Then
If DllStructGetData($aAgentArray[$i], "Team") <>
0 Then
If DllStructGetData($aAgentArray[$i], "T
eam") <> DllStructGetData($aAgent, "Team") Then
$lCount += 1
EndIf
ElseIf DllStructGetData($aAgentArray[$i], "Alleg
iance") <> DllStructGetData($aAgent, "Allegiance") Then
$lCount += 1
EndIf
EndIf
EndIf
Next
Return $lCount
EndFunc
#EndRegion Agent
#Region AgentInfo
;~ Description: Tests if an agent is living.
Func GetIsLiving($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'Type') = 0xDB
EndFunc ;==>GetIsLiving
;~ Description: Tests if an agent is a signpost/chest/etc.
Func GetIsStatic($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'Type') = 0x200
EndFunc ;==>GetIsStatic
;~ Description: Tests if an agent is an item.
Func GetIsMovable($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'Type') = 0x400
EndFunc ;==>GetIsMovable
;~ Description: Returns energy of an agent. (Only self/heroes)
Func GetEnergy($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'EnergyPercent') * DllStructGetData($aA
gent, 'MaxEnergy')
EndFunc ;==>GetEnergy
;~ Description: Returns health of an agent. (Must have caused numerical change i
n health)

Func GetHealth($aAgent = -2)


If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxH
P')
EndFunc ;==>GetHealth
;~ Description: Tests if an agent is moving.
Func GetIsMoving($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
If DllStructGetData($aAgent, 'MoveX') <> 0 Or DllStructGetData($aAgent,
'MoveY') <> 0 Then Return True
Return False
EndFunc ;==>GetIsMoving
;~ Description: Tests if an agent is knocked down.
Func GetIsKnocked($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'ModelState') = 0x450
EndFunc ;==>GetIsKnocked
;~ Description: Tests if an agent is attacking.
Func GetIsAttacking($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Switch DllStructGetData($aAgent, 'ModelState')
Case 0x60 ; Is Attacking
Return True
Case 0x440 ; Is Attacking
Return True
Case 0x460 ; Is Attacking
Return True
Case Else
Return False
EndSwitch
EndFunc ;==>GetIsAttacking
;~ Description: Tests if an agent is casting.
Func GetIsCasting($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'Skill') <> 0
EndFunc ;==>GetIsCasting
;~ Description: Tests if an agent is bleeding.
Func GetIsBleeding($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0001) > 0
EndFunc ;==>GetIsBleeding
;~ Description: Tests if an agent has a condition.
Func GetHasCondition($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0002) > 0
EndFunc ;==>GetHasCondition
;~ Description: Tests if an agent is dead.
Func GetIsDead($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0010) > 0
EndFunc ;==>GetIsDead
;~ Description: Tests if an agent has a deep wound.

Func GetHasDeepWound($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0020) > 0
EndFunc ;==>GetHasDeepWound
;~ Description: Tests if an agent is poisoned.
Func GetIsPoisoned($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0040) > 0
EndFunc ;==>GetIsPoisoned
;~ Description: Tests if an agent is enchanted.
Func GetIsEnchanted($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0080) > 0
EndFunc ;==>GetIsEnchanted
;~ Description: Tests if an agent has a degen hex.
Func GetHasDegenHex($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0400) > 0
EndFunc ;==>GetHasDegenHex
;~ Description: Tests if an agent is hexed.
Func GetHasHex($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x0800) > 0
EndFunc ;==>GetHasHex
;~ Description: Tests if an agent has a weapon spell.
Func GetHasWeaponSpell($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'Effects'), 0x8000) > 0
EndFunc ;==>GetHasWeaponSpell
;~ Description: Tests if an agent is a boss.
Func GetIsBoss($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return BitAND(DllStructGetData($aAgent, 'TypeMap'), 1024) > 0
EndFunc ;==>GetIsBoss
;~ Description: Returns a player's name.
Func GetPlayerName($aAgent)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Local $lLogin = DllStructGetData($aAgent, 'LoginNumber')
Local $lOffset[6] = [0, 0x18, 0x2C, 0x7A8, 76 * $lLogin + 0x28, 0]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset, 'wchar[30]')
Return $lReturn[1]
EndFunc ;==>GetPlayerName
;~ Description: Returns the name of an agent.
Func GetAgentName($aAgent)
If $mUseStringLog = False Then Return
If IsDllStruct($aAgent) = 0 Then
Local $lAgentID = ConvertID($aAgent)
If $lAgentID = 0 Then Return ''
Else
Local $lAgentID = DllStructGetData($aAgent, 'ID')
EndIf

Local $lAddress = $mStringLogBase + 256 * $lAgentID


Local $lName = MemoryRead($lAddress, 'wchar [128]')
If $lName = '' Then
DisplayAll(True)
Sleep(100)
DisplayAll(False)
EndIf
Local $lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
Return $lName
EndFunc ;==>GetAgentName
#EndRegion AgentInfo
#Region Buff
;~ Description: Returns current number of buffs being maintained.
Func GetBuffCount($aHeroNumber = 0)
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4AC
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x4A4
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
Return MemoryRead($lBuffer[0] + 0xC)
EndIf
Next
Return 0
EndFunc ;==>GetBuffCount
;~ Description: Tests if you are currently maintaining buff on target.
Func GetIsTargetBuffed($aSkillID, $aAgentID, $aHeroNumber = 0)
Local $lBuffStruct = DllStructCreate('long SkillId;byte unknown1[4];long
BuffId;long TargetId')
Local $lBuffCount = GetBuffCount($aHeroNumber)
Local $lBuffStructAddress
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4AC
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x4A4
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
$lOffset[4] = 0x4 + 0x24 * $i
ReDim $lOffset[6]
For $j = 0 To $lBuffCount - 1

$lOffset[5] = 0 + 0x10 * $j
$lBuffStructAddress = MemoryReadPtr($mBasePointe
r, $lOffset)
DllCall($mKernelHandle, 'int', 'ReadProcessMemor
y', 'int', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr
($lBuffStruct), 'int', DllStructGetSize($lBuffStruct), 'int', '')
If (DllStructGetData($lBuffStruct, 'SkillID') ==
$aSkillID) And (DllStructGetData($lBuffStruct, 'TargetId') == ConvertID($aAgent
ID)) Then
Return $j + 1
EndIf
Next
EndIf
Next
Return 0
EndFunc ;==>GetIsTargetBuffed
;~ Description: Returns buff struct.
Func GetBuffByIndex($aBuffNumber, $aHeroNumber = 0)
Local $lBuffStruct = DllStructCreate('long SkillId;byte unknown1[4];long
BuffId;long TargetId')
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4AC
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x4A4
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
$lOffset[4] = 0x4 + 0x24 * $i
ReDim $lOffset[6]
$lOffset[5] = 0 + 0x10 * ($aBuffNumber - 1)
$lBuffStructAddress = MemoryReadPtr($mBasePointer, $lOff
set)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr($lBuffS
truct), 'int', DllStructGetSize($lBuffStruct), 'int', '')
Return $lBuffStruct
EndIf
Next
Return 0
EndFunc ;==>GetBuffByIndex
#EndRegion Buff
#Region Misc
;~ Description: Returns skillbar struct.
Func GetSkillbar($aHeroNumber = 0)
Local $lSkillbarStruct = DllStructCreate('long AgentId;long AdrenalineA1
;long AdrenalineB1;dword Recharge1;dword Id1;dword Event1;long AdrenalineA2;long
AdrenalineB2;dword Recharge2;dword Id2;dword Event2;long AdrenalineA3;long Adre
nalineB3;dword Recharge3;dword Id3;dword Event3;long AdrenalineA4;long Adrenalin
eB4;dword Recharge4;dword Id4;dword Event4;long AdrenalineA5;long AdrenalineB5;d
word Recharge5;dword Id5;dword Event5;long AdrenalineA6;long AdrenalineB6;dword
Recharge6;dword Id6;dword Event6;long AdrenalineA7;long AdrenalineB7;dword Recha
rge7;dword Id7;dword Event7;long AdrenalineA8;long AdrenalineB8;dword Recharge8;

dword Id8;dword Event8;dword disabled;byte unknown[8];dword Casting')


Local $lOffset[5]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x68C
For $i = 0 To GetHeroCount()
$lOffset[4] = $i * 0xBC
Local $lSkillbarStructAddress = MemoryReadPtr($mBasePointer, $lO
ffset)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $lSkillbarStructAddress[0], 'ptr', DllStructGetPtr($lSkillbarS
truct), 'int', DllStructGetSize($lSkillbarStruct), 'int', '')
If DllStructGetData($lSkillbarStruct, 'AgentId') == GetHeroID($a
HeroNumber) Then Return $lSkillbarStruct
Next
EndFunc ;==>GetSkillbar
;~ Description: Returns the skill ID of an equipped skill.
Func GetSkillbarSkillID($aSkillSlot, $aHeroNumber = 0)
Return DllStructGetData(GetSkillbar($aHeroNumber), 'ID' & $aSkillSlot)
EndFunc ;==>GetSkillbarSkillID
;~ Description: Returns the adrenaline charge of an equipped skill.
Func GetSkillbarSkillAdrenaline($aSkillSlot, $aHeroNumber = 0)
Return DllStructGetData(GetSkillbar($aHeroNumber), 'AdrenalineA' & $aSki
llSlot)
EndFunc ;==>GetSkillbarSkillAdrenaline
;~ Description: Returns the recharge time remaining of an equipped skill in mill
iseconds.
Func GetSkillbarSkillRecharge($aSkillSlot, $aHeroNumber = 0)
Local $lTimestamp = DllStructGetData(GetSkillbar($aHeroNumber), 'Recharg
e' & $aSkillSlot)
If $lTimestamp == 0 Then Return 0
Return $lTimestamp - GetSkillTimer()
EndFunc ;==>GetSkillbarSkillRecharge
;~ Description: Returns skill struct.
Func GetSkillByID($aSkillID)
Local $lSkillStruct = DllStructCreate('long ID;byte Unknown1[4];long cam
paign;long Type;long Special;long ComboReq;long Effect1;long Condition;long Effe
ct2;long WeaponReq;byte Profession;byte Attribute;byte Unknown2[2];long PvPID;by
te Combo;byte Target;byte unknown3;byte EquipType;byte Unknown4[2];dword Adrenal
ine;float Activation;float Aftercast;long Duration0;long Duration15;long Recharg
e;byte Unknown5[12];long Scale0;long Scale15;long BonusScale0;long BonusScale15;
float AoERange;float ConstEffect;byte unknown6[44]')
Local $lSkillStructAddress = $mSkillBase + 160 * $aSkillID
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandl
e, 'int', $lSkillStructAddress, 'ptr', DllStructGetPtr($lSkillStruct), 'int', Dl
lStructGetSize($lSkillStruct), 'int', '')
Return $lSkillStruct
EndFunc ;==>GetSkillByID
;~ Description: Returns energy requirement of an equipped skill
Func GetSkillEnergy($aSkillSlot)
Local $ID = GetSkillbarSkillID($aSkillSlot)
Local $Skill = GetSkillByID($ID)
Local $Energy = DllStructGetData($Skill, 'Unknown4')
$Energy = StringTrimLeft($Energy, 5)

$Energy = StringReplace($Energy, 'A', '10')


$Energy = StringReplace($Energy, 'B', '15')
$Energy = StringReplace($Energy, 'C', '25')
Return $Energy
EndFunc ;==>GetSkillEnergy
;~ Description: Returns current morale.
Func GetMorale($aHeroNumber = 0)
Local $lAgentID = GetHeroID($aHeroNumber)
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x5D4
Local $lIndex = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[6]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x5C8
$lOffset[4] = 8 + 0xC * BitAND($lAgentID, $lIndex[1])
$lOffset[5] = 0x18
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1] - 100
EndFunc ;==>GetMorale
;~ Description: Returns effect struct or array of effects.
Func GetEffect($aSkillID = 0, $aHeroNumber = 0)
Local $lEffectCount, $lEffectStructAddress
Local $lReturnArray[1] = [0]
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4AC
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x4A4
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
$lOffset[4] = 0x1C + 0x24 * $i
$lEffectCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[6]
$lOffset[4] = 0x14 + 0x24 * $i
$lOffset[5] = 0
$lEffectStructAddress = MemoryReadPtr($mBasePointer, $lO
ffset)
If $aSkillID = 0 Then
ReDim $lReturnArray[$lEffectCount[1] + 1]
$lReturnArray[0] = $lEffectCount[1]
For $i = 0 To $lEffectCount[1] - 1
$lReturnArray[$i + 1] = DllStructCreate(
'long SkillId;long EffectType;long EffectId;long AgentId;float Duration;long Tim
eStamp')

$lEffectStructAddress[1] = $lEffectStruc
tAddress[0] + 24 * $i
DllCall($mKernelHandle, 'int', 'ReadProc
essMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[1], 'ptr', DllSt
ructGetPtr($lReturnArray[$i + 1]), 'int', 24, 'int', '')
Next
ExitLoop
Else
Local $lReturn = DllStructCreate('long SkillId;l
ong EffectType;long EffectId;long AgentId;float Duration;long TimeStamp')
For $i = 0 To $lEffectCount[1] - 1
DllCall($mKernelHandle, 'int', 'ReadProc
essMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[0] + 24 * $i, 'p
tr', DllStructGetPtr($lReturn), 'int', 24, 'int', '')
If DllStructGetData($lReturn, 'SkillID')
= $aSkillID Then Return $lReturn
Next
EndIf
EndIf
Next
Return $lReturnArray
EndFunc ;==>GetEffect
;~ Description: Returns time remaining before an effect expires, in milliseconds
.
Func GetEffectTimeRemaining($aEffect)
If Not IsDllStruct($aEffect) Then $aEffect = GetEffect($aEffect)
If IsArray($aEffect) Then Return 0
Return DllStructGetData($aEffect, 'Duration') * 1000 - (GetSkillTimer()
- DllStructGetData($aEffect, 'TimeStamp'))
EndFunc ;==>GetEffectTimeRemaining
;~ Description: Returns the timestamp used for effects and skills (milliseconds)
.
Func GetSkillTimer()
Return MemoryRead($mSkillTimer, "long")
EndFunc ;==>GetSkillTimer
;~ Description: Returns level of an attribute.
Func GetAttributeByID($aAttributeID, $aWithRunes = False, $aHeroNumber = 0)
Local $lAgentID = GetHeroID($aHeroNumber)
Local $lBuffer
Local $lOffset[5]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0xAC
For $i = 0 To GetHeroCount()
$lOffset[4] = 0x3D8 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == $lAgentID Then
If $aWithRunes Then
$lOffset[4] = 0x3D8 * $i + 0x14 * $aAttributeID
+ 0xC
Else
$lOffset[4] = 0x3D8 * $i + 0x14 * $aAttributeID
+ 0x8
EndIf

$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)


Return $lBuffer[1]
EndIf
Next
EndFunc ;==>GetAttributeByID
;~ Description: Returns amount of experience.
Func GetExperience()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x6DC]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetExperience
;~ Description: Tests if an area has been vanquished.
Func GetAreaVanquished()
If GetFoesToKill() = 0 Then
Return True
Else
Return False
EndIf
EndFunc ;==>GetAreaVanquished
;~ Description: Returns number of foes that have been killed so far.
Func GetFoesKilled()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x7e8]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetFoesKilled
;~ Description: Returns number of enemies left to kill for vanquish.
Func GetFoesToKill()
Local $lOffset[4] = [0, 0x18, 0x2C, 0x7ec]
Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
Return $lReturn[1]
EndFunc ;==>GetFoesToKill
;~ Description: Returns number of agents currently loaded.
Func GetMaxAgents()
Return MemoryRead($mMaxAgents)
EndFunc ;==>GetMaxAgents
;~ Description: Returns your agent ID.
Func GetMyID()
Return MemoryRead($mMyID)
EndFunc ;==>GetMyID
;~ Description: Returns current target.
Func GetCurrentTarget()
Return GetAgentByID(GetCurrentTargetID())
EndFunc ;==>GetCurrentTarget
;~ Description: Returns current target ID.
Func GetCurrentTargetID()
Return MemoryRead($mCurrentTarget)
EndFunc ;==>GetCurrentTargetID
;~ Description: Returns current ping.
Func GetPing()
Return MemoryRead($mPing)
EndFunc ;==>GetPing

;~ Description: Returns current map ID.


Func GetMapID()
Return MemoryRead($mMapID)
EndFunc ;==>GetMapID
;~ Description: Returns current load-state.
Func GetMapLoading()
Return MemoryRead($mMapLoading)
EndFunc ;==>GetMapLoading
;~ Description: Returns if map has been loaded. Reset with InitMapLoad().
Func GetMapIsLoaded()
Return MemoryRead($mMapIsLoaded) And GetAgentExists(-2)
EndFunc ;==>GetMapIsLoaded
;~ Description: Returns current district
Func GetDistrict()
Local $lOffset[4] = [0, 0x18, 0x44, 0x1B4]
Local $lResult = MemoryReadPtr($mBasePointer, $lOffset)
Return $lResult[1]
EndFunc ;==>GetDistrict
;~ Description: Internal use for travel functions.
Func GetRegion()
Return MemoryRead($mRegion)
EndFunc ;==>GetRegion
;~ Description: Internal use for travel functions.
Func GetLanguage()
Return MemoryRead($mLanguage)
EndFunc ;==>GetLanguage
;~ Description: Wait for map to load. Returns true if successful.
Func WaitMapLoading($aMapID = 0, $aDeadlock = 15000)
;~
Waits $aDeadlock for load to start, and $aDeadLock for agent to load aft
er map is loaded.
Local $lMapLoading
Local $lDeadlock = TimerInit()
InitMapLoad()
Do
Sleep(200)
$lMapLoading = GetMapLoading()
If $lMapLoading == 2 Then $lDeadlock = TimerInit()
If TimerDiff($lDeadlock) > $aDeadlock And $aDeadlock > 0 Then Re
turn False
Until $lMapLoading <> 2 And GetMapIsLoaded() And (GetMapID() = $aMapID O
r $aMapID = 0) And GetAgentExists(-2)
EndFunc

Return True
;==>WaitMapLoading

;~ Description: Returns quest struct.


Func GetQuestByID($aQuestID = 0)
Local $lQuestStruct = DllStructCreate('long id;long LogState;byte unknow
n1[12];long MapFrom;float X;float Y;byte unknown2[8];long MapTo')
Local $lQuestPtr, $lQuestLogSize, $lQuestID
Local $lOffset[4] = [0, 0x18, 0x2C, 0x4D0]

$lQuestLogSize = MemoryReadPtr($mBasePointer, $lOffset)


If $aQuestID = 0 Then
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x4C4
$lQuestID = MemoryReadPtr($mBasePointer, $lOffset)
$lQuestID = $lQuestID[1]
Else
$lQuestID = $aQuestID
EndIf
Local $lOffset[5] = [0, 0x18, 0x2C, 0x4C8, 0]
For $i = 0 To $lQuestLogSize[1]
$lOffset[4] = 0x34 * $i
$lQuestPtr = MemoryReadPtr($mBasePointer, $lOffset)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWP
rocHandle, 'int', $lQuestPtr[0], 'ptr', DllStructGetPtr($lQuestStruct), 'int', D
llStructGetSize($lQuestStruct), 'int', '')
If DllStructGetData($lQuestStruct, 'ID') = $lQuestID Then Return
$lQuestStruct
Next
EndFunc ;==>GetQuestByID
;~ Description: Returns your characters name.
Func GetCharname()
Return MemoryRead($mCharname, 'wchar[30]')
EndFunc ;==>GetCharname
;~ Description: Returns if you're logged in.
Func GetLoggedIn()
Return MemoryRead($mLoggedIn)
EndFunc ;==>GetLoggedIn
;~ Description: Returns language currently being used.
Func GetDisplayLanguage()
Local $lOffset[6] = [0, 0x18, 0x18, 0x194, 0x4C, 0x40]
Local $lResult = MemoryReadPtr($mBasePointer, $lOffset)
Return $lResult[1]
EndFunc ;==>GetDisplayLanguage
;~ Returns how long the current instance has been active, in milliseconds.
Func GetInstanceUpTime()
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x8
$lOffset[3] = 0x1AC
Local $lTimer = MemoryReadPtr($mBasePointer, $lOffset)
Return $lTimer[1]
EndFunc ;==>GetInstanceUpTime
;~ Returns the game client's build number
Func GetBuildNumber()
Return $mBuildNumber
EndFunc ;==>GetBuildNumber
Func GetProfPrimaryAttribute($aProfession)
Switch $aProfession

Case 1
Return 17
Case 2
Return 23
Case 3
Return 16
Case 4
Return 6
Case 5
Return 0
Case 6
Return 12
Case 7
Return 35
Case 8
Return 36
Case 9
Return 40
Case 10
Return 44
EndSwitch
EndFunc ;==>GetProfPrimaryAttribute
#EndRegion Misc
#EndRegion Queries
#Region Other Functions
#Region Misc
;~ Description: Sleep a random amount of time.
Func RndSleep($aAmount)
Local $lRandom = $aAmount * Random()
Sleep($aAmount + $lRandom)
EndFunc ;==>RndSleep
;~ Description: Sleep a period of time, plus or minus a tolerance
Func TolSleep($aAmount = 150, $aTolerance = 50)
Sleep(Random($aAmount - $aTolerance, $aAmount + $aTolerance))
EndFunc ;==>TolSleep
;~ Description: Returns window handle of Guild Wars.
Func GetWindowHandle()
Return $mGWHwnd
EndFunc ;==>GetWindowHandle
;~ Description: Returns the distance between two coordinate pairs.
Func ComputeDistance($aX1, $aY1, $aX2, $aY2)
Return Sqrt(($aX1 - $aX2) ^ 2 + ($aY1 - $aY2) ^ 2)
EndFunc ;==>ComputeDistance
;~ Description: Returns the distance between two agents.
Func GetDistance($aAgent1 = -1, $aAgent2 = -2)
If IsDllStruct($aAgent1) = 0 Then $aAgent1 = GetAgentByID($aAgent1)
If IsDllStruct($aAgent2) = 0 Then $aAgent2 = GetAgentByID($aAgent2)
Return Sqrt((DllStructGetData($aAgent1, 'X') - DllStructGetData($aAgent2
, 'X')) ^ 2 + (DllStructGetData($aAgent1, 'Y') - DllStructGetData($aAgent2, 'Y')
) ^ 2)
EndFunc ;==>GetDistance
;~ Description: Return the square of the distance between two agents.
Func GetPseudoDistance($aAgent1, $aAgent2)
Return (DllStructGetData($aAgent1, 'X') - DllStructGetData($aAgent2, 'X'

)) ^ 2 + (DllStructGetData($aAgent1, 'Y') - DllStructGetData($aAgent2, 'Y')) ^ 2


EndFunc ;==>GetPseudoDistance
;~ Description: Checks if a point is within a polygon defined by an array
Func GetIsPointInPolygon($aAreaCoords, $aPosX = 0, $aPosY = 0)
Local $lPosition
Local $lEdges = UBound($aAreaCoords)
Local $lOddNodes = False
If $lEdges < 3 Then Return False
If $aPosX = 0 Then
Local $lAgent = GetAgentByID(-2)
$aPosX = DllStructGetData($lAgent, 'X')
$aPosY = DllStructGetData($lAgent, 'Y')
EndIf
$j = $lEdges - 1
For $i = 0 To $lEdges - 1
If (($aAreaCoords[$i][1] < $aPosY And $aAreaCoords[$j][1] >= $aP
osY) _
Or ($aAreaCoords[$j][1] < $aPosY And $aAreaCoord
s[$i][1] >= $aPosY)) _
And ($aAreaCoords[$i][0] <= $aPosX Or $aAreaCoor
ds[$j][0] <= $aPosX) Then
If ($aAreaCoords[$i][0] + ($aPosY - $aAreaCoords[$i][1])
/ ($aAreaCoords[$j][1] - $aAreaCoords[$i][1]) * ($aAreaCoords[$j][0] - $aAreaCo
ords[$i][0]) < $aPosX) Then
$lOddNodes = Not $lOddNodes
EndIf
EndIf
$j = $i
Next
Return $lOddNodes
EndFunc ;==>GetIsPointInPolygon
;~ Description: Internal use for handing -1 and -2 agent IDs.
Func ConvertID($aID)
If $aID = -2 Then
Return GetMyID()
ElseIf $aID = -1 Then
Return GetCurrentTargetID()
Else
Return $aID
EndIf
EndFunc ;==>ConvertID
;~ Description: Internal use only.
Func SendPacket($aSize, $aHeader, $aParam1 = 0, $aParam2 = 0, $aParam3 = 0, $aPa
ram4 = 0, $aParam5 = 0, $aParam6 = 0, $aParam7 = 0, $aParam8 = 0, $aParam9 = 0,
$aParam10 = 0)
If GetAgentExists(-2) Then
DllStructSetData($mPacket, 2, $aSize)
DllStructSetData($mPacket, 3, $aHeader)
DllStructSetData($mPacket, 4, $aParam1)
DllStructSetData($mPacket, 5, $aParam2)
DllStructSetData($mPacket, 6, $aParam3)
DllStructSetData($mPacket, 7, $aParam4)
DllStructSetData($mPacket, 8, $aParam5)
DllStructSetData($mPacket, 9, $aParam6)
DllStructSetData($mPacket, 10, $aParam7)
DllStructSetData($mPacket, 11, $aParam8)
DllStructSetData($mPacket, 12, $aParam9)

DllStructSetData($mPacket, 13, $aParam10)


Enqueue($mPacketPtr, 52)
Return True
Else
Return False
EndIf
EndFunc ;==>SendPacket
;~ Description: Internal use only.
Func PerformAction($aAction, $aFlag)
If GetAgentExists(-2) Then
DllStructSetData($mAction, 2, $aAction)
DllStructSetData($mAction, 3, $aFlag)
Enqueue($mActionPtr, 12)
Return True
Else
Return False
EndIf
EndFunc ;==>PerformAction
;~ Description: Internal use only.
Func Bin64ToDec($aBinary)
Local $lReturn = 0
For $i = 1 To StringLen($aBinary)
If StringMid($aBinary, $i, 1) == 1 Then $lReturn += 2 ^ ($i - 1)
Next
EndFunc

Return $lReturn
;==>Bin64ToDec

;~ Description: Internal use only.


Func Base64ToBin64($aCharacter)
Select
Case $aCharacter == "A"
Return "000000"
Case $aCharacter == "B"
Return "100000"
Case $aCharacter == "C"
Return "010000"
Case $aCharacter == "D"
Return "110000"
Case $aCharacter == "E"
Return "001000"
Case $aCharacter == "F"
Return "101000"
Case $aCharacter == "G"
Return "011000"
Case $aCharacter == "H"
Return "111000"
Case $aCharacter == "I"
Return "000100"
Case $aCharacter == "J"
Return "100100"
Case $aCharacter == "K"
Return "010100"
Case $aCharacter == "L"
Return "110100"
Case $aCharacter == "M"
Return "001100"

Case $aCharacter == "N"


Return "101100"
Case $aCharacter == "O"
Return "011100"
Case $aCharacter == "P"
Return "111100"
Case $aCharacter == "Q"
Return "000010"
Case $aCharacter == "R"
Return "100010"
Case $aCharacter == "S"
Return "010010"
Case $aCharacter == "T"
Return "110010"
Case $aCharacter == "U"
Return "001010"
Case $aCharacter == "V"
Return "101010"
Case $aCharacter == "W"
Return "011010"
Case $aCharacter == "X"
Return "111010"
Case $aCharacter == "Y"
Return "000110"
Case $aCharacter == "Z"
Return "100110"
Case $aCharacter == "a"
Return "010110"
Case $aCharacter == "b"
Return "110110"
Case $aCharacter == "c"
Return "001110"
Case $aCharacter == "d"
Return "101110"
Case $aCharacter == "e"
Return "011110"
Case $aCharacter == "f"
Return "111110"
Case $aCharacter == "g"
Return "000001"
Case $aCharacter == "h"
Return "100001"
Case $aCharacter == "i"
Return "010001"
Case $aCharacter == "j"
Return "110001"
Case $aCharacter == "k"
Return "001001"
Case $aCharacter == "l"
Return "101001"
Case $aCharacter == "m"
Return "011001"
Case $aCharacter == "n"
Return "111001"
Case $aCharacter == "o"
Return "000101"
Case $aCharacter == "p"
Return "100101"
Case $aCharacter == "q"
Return "010101"

Case $aCharacter == "r"


Return "110101"
Case $aCharacter == "s"
Return "001101"
Case $aCharacter == "t"
Return "101101"
Case $aCharacter == "u"
Return "011101"
Case $aCharacter == "v"
Return "111101"
Case $aCharacter == "w"
Return "000011"
Case $aCharacter == "x"
Return "100011"
Case $aCharacter == "y"
Return "010011"
Case $aCharacter == "z"
Return "110011"
Case $aCharacter == "0"
Return "001011"
Case $aCharacter == "1"
Return "101011"
Case $aCharacter == "2"
Return "011011"
Case $aCharacter == "3"
Return "111011"
Case $aCharacter == "4"
Return "000111"
Case $aCharacter == "5"
Return "100111"
Case $aCharacter == "6"
Return "010111"
Case $aCharacter == "7"
Return "110111"
Case $aCharacter == "8"
Return "001111"
Case $aCharacter == "9"
Return "101111"
Case $aCharacter == "+"
Return "011111"
Case $aCharacter == "/"
Return "111111"
EndSelect
EndFunc ;==>Base64ToBin64
#EndRegion Misc
#Region Callback
;~ Description: Controls Event System.
Func SetEvent($aSkillActivate = '', $aSkillCancel = '', $aSkillComplete = '', $a
ChatReceive = '', $aLoadFinished = '')
If Not $mUseEventSystem Then Return
If $aSkillActivate <> '' Then
WriteDetour('SkillLogStart', 'SkillLogProc')
Else
$mASMString = ''
_('inc eax')
_('mov dword[esi+10],eax')
_('pop esi')
WriteBinary($mASMString, GetValue('SkillLogStart'))
EndIf

If $aSkillCancel <> '' Then


WriteDetour('SkillCancelLogStart', 'SkillCancelLogProc')
Else
$mASMString = ''
_('push 0')
_('push 42')
_('mov ecx,esi')
WriteBinary($mASMString, GetValue('SkillCancelLogStart'))
EndIf
If $aSkillComplete <> '' Then
WriteDetour('SkillCompleteLogStart', 'SkillCompleteLogProc')
Else
$mASMString = ''
_('mov eax,dword[edi+4]')
_('test eax,eax')
WriteBinary($mASMString, GetValue('SkillCompleteLogStart'))
EndIf
If $aChatReceive <> '' Then
WriteDetour('ChatLogStart', 'ChatLogProc')
Else
$mASMString = ''
_('add edi,E')
_('cmp eax,B')
WriteBinary($mASMString, GetValue('ChatLogStart'))
EndIf
$mSkillActivate = $aSkillActivate
$mSkillCancel = $aSkillCancel
$mSkillComplete = $aSkillComplete
$mChatReceive = $aChatReceive
$mLoadFinished = $aLoadFinished
EndFunc ;==>SetEvent
;~ Description: Internal use for event system.
;~ modified by gigi, avoid getagentbyid, just pass agent id to callback
Func Event($hwnd, $msg, $wparam, $lparam)
Switch $lparam
Case 0x1
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $wparam, 'ptr', $mSkillLogStructPtr, 'int', 16, 'int',
'')
Call($mSkillActivate, DllStructGetData($mSkillLogStruct,
1), DllStructGetData($mSkillLogStruct, 2), DllStructGetData($mSkillLogStruct, 3
), DllStructGetData($mSkillLogStruct, 4))
Case 0x2
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $wparam, 'ptr', $mSkillLogStructPtr, 'int', 16, 'int',
'')
Call($mSkillCancel, DllStructGetData($mSkillLogStruct, 1
), DllStructGetData($mSkillLogStruct, 2), DllStructGetData($mSkillLogStruct, 3))
Case 0x3
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $wparam, 'ptr', $mSkillLogStructPtr, 'int', 16, 'int',
'')
Call($mSkillComplete, DllStructGetData($mSkillLogStruct,
1), DllStructGetData($mSkillLogStruct, 2), DllStructGetData($mSkillLogStruct, 3
))

Case 0x4
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int
', $mGWProcHandle, 'int', $wparam, 'ptr', $mChatLogStructPtr, 'int', 512, 'int',
'')
Local $lMessage = DllStructGetData($mChatLogStruct, 2)
Local $lChannel
Local $lSender
Switch DllStructGetData($mChatLogStruct, 1)
Case 0
$lChannel = "Alliance"
$lSender = StringMid($lMessage, 6, Strin
gInStr($lMessage, "</a>") - 6)
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 3
$lChannel = "All"
$lSender = StringMid($lMessage, 6, Strin
gInStr($lMessage, "</a>") - 6)
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 9
$lChannel = "Guild"
$lSender = StringMid($lMessage, 6, Strin
gInStr($lMessage, "</a>") - 6)
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 11
$lChannel = "Team"
$lSender = StringMid($lMessage, 6, Strin
gInStr($lMessage, "</a>") - 6)
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 12
$lChannel = "Trade"
$lSender = StringMid($lMessage, 6, Strin
gInStr($lMessage, "</a>") - 6)
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 10
If StringLeft($lMessage, 3) == "-> " The
n
$lChannel = "Sent"
$lSender = StringMid($lMessage,
10, StringInStr($lMessage, "</a>") - 10)
$lMessage = StringTrimLeft($lMes
sage, StringInStr($lMessage, "<quote>") + 6)
Else
$lChannel = "Global"
$lSender = "Guild Wars"
EndIf
Case 13
$lChannel = "Advisory"
$lSender = "Guild Wars"
$lMessage = StringTrimLeft($lMessage, St
ringInStr($lMessage, "<quote>") + 6)
Case 14
$lChannel = "Whisper"
$lSender = StringMid($lMessage, 7, Strin
gInStr($lMessage, "</a>") - 7)
$lMessage = StringTrimLeft($lMessage, St

ringInStr($lMessage, "<quote>") + 6)
Case Else
$lChannel = "Other"
$lSender = "Other"
EndSwitch
Call($mChatReceive, $lChannel, $lSender, $lMessage)
Case 0x5
Call($mLoadFinished)
EndSwitch
EndFunc ;==>Event
#EndRegion Callback
#Region Modification
;~ Description: Internal use only.
Func ModifyMemory()
$mASMSize = 0
$mASMCodeOffset = 0
$mASMString = ''
CreateData()
CreateMain()
CreateTargetLog()
CreateSkillLog()
CreateSkillCancelLog()
CreateSkillCompleteLog()
CreateChatLog()
CreateTraderHook()
CreateLoadFinished()
CreateStringLog()
CreateStringFilter1()
CreateStringFilter2()
CreateRenderingMod()
CreateCommands()
Local $lModMemory = MemoryRead(MemoryRead($mBase), 'ptr')
If $lModMemory = 0 Then
$mMemory = DllCall($mKernelHandle, 'ptr', 'VirtualAllocEx', 'han
dle', $mGWProcHandle, 'ptr', 0, 'ulong_ptr', $mASMSize, 'dword', 0x1000, 'dword'
, 0x40)
$mMemory = $mMemory[0]
MemoryWrite(MemoryRead($mBase), $mMemory)
Else
$mMemory = $lModMemory
EndIf
CompleteASMCode()
If $lModMemory = 0 Then
WriteBinary($mASMString, $mMemory + $mASMCodeOffset)
WriteBinary("83F8009090", GetValue('ClickToMoveFix'))
MemoryWrite(GetValue('QueuePtr'), GetValue('QueueBase'))
MemoryWrite(GetValue('SkillLogPtr'), GetValue('SkillLogBase'))
MemoryWrite(GetValue('ChatLogPtr'), GetValue('ChatLogBase'))
MemoryWrite(GetValue('StringLogPtr'), GetValue('StringLogBase'))
EndIf
WriteDetour('MainStart', 'MainProc')
WriteDetour('TargetLogStart', 'TargetLogProc')

WriteDetour('TraderHookStart', 'TraderHookProc')
WriteDetour('LoadFinishedStart', 'LoadFinishedProc')
WriteDetour('RenderingMod', 'RenderingModProc')
If $mUseStringLog Then
WriteDetour('StringLogStart', 'StringLogProc')
WriteDetour('StringFilter1Start', 'StringFilter1Proc')
WriteDetour('StringFilter2Start', 'StringFilter2Proc')
EndIf
EndFunc ;==>ModifyMemory
;~ Description: Internal use only.
Func WriteDetour($aFrom, $aTo)
WriteBinary('E9' & SwapEndian(Hex(GetLabelInfo($aTo) - GetLabelInfo($aFr
om) - 5)), GetLabelInfo($aFrom))
EndFunc ;==>WriteDetour
;~ Description: Internal use only.
Func CreateData()
_('CallbackHandle/4')
_('QueueCounter/4')
_('SkillLogCounter/4')
_('ChatLogCounter/4')
_('ChatLogLastMsg/4')
_('MapIsLoaded/4')
_('NextStringType/4')
_('EnsureEnglish/4')
_('TraderQuoteID/4')
_('TraderCostID/4')
_('TraderCostValue/4')
_('DisableRendering/4')
_('QueueBase/' & 256 * GetValue('QueueSize'))
_('TargetLogBase/' & 4 * GetValue('TargetLogSize'))
_('SkillLogBase/' & 16 * GetValue('SkillLogSize'))
_('StringLogBase/' & 256 * GetValue('StringLogSize'))
_('ChatLogBase/' & 512 * GetValue('ChatLogSize'))
_('AgentCopyCount/4')
_('AgentCopyBase/' & 0x1C0 * 256)
EndFunc ;==>CreateData
;~ Description: Internal use only.
Func CreateMain()
_('MainProc:')
_('pushad')
_('mov eax,dword[EnsureEnglish]')
_('test eax,eax')
_('jz MainMain')
_('mov ecx,dword[BasePointer]')
_('mov ecx,dword[ecx+18]')
_('mov ecx,dword[ecx+18]')
_('mov ecx,dword[ecx+194]')
_('mov al,byte[ecx+4f]')
_('cmp al,f')
_('ja MainMain')
_('mov ecx,dword[ecx+4c]')
_('mov al,byte[ecx+3f]')
_('cmp al,f')
_('ja MainMain')
_('mov eax,dword[ecx+40]')
_('test eax,eax')

_('jz MainMain')
_('mov ecx,dword[ActionBase]')
_('mov ecx,dword[ecx+170]')
_('mov ecx,dword[ecx+20]')
_('mov ecx,dword[ecx]')
_('push 0')
_('push 0')
_('push bb')
_('mov edx,esp')
_('push 0')
_('push edx')
_('push 18')
_('call ActionFunction')
_('pop eax')
_('pop ebx')
_('pop ecx')
_('MainMain:')
_('mov eax,dword[QueueCounter]')
_('mov ecx,eax')
_('shl eax,8')
_('add eax,QueueBase')
_('mov ebx,dword[eax]')
_('test ebx,ebx')
_('jz MainExit')
_('push ecx')
_('mov dword[eax],0')
_('jmp ebx')
_('CommandReturn:')
_('pop eax')
_('inc eax')
_('cmp eax,QueueSize')
_('jnz MainSkipReset')
_('xor eax,eax')
_('MainSkipReset:')
_('mov dword[QueueCounter],eax')
_('MainExit:')
_('popad')
_('mov ebp,esp')
_('sub esp,14')
_('ljmp MainReturn')
EndFunc ;==>CreateMain
;~ Description: Internal use only.
Func CreateTargetLog()
_('TargetLogProc:')
_('cmp ecx,4')
_('jz TargetLogMain')
_('cmp ecx,32')
_('jz TargetLogMain')
_('cmp ecx,3C')
_('jz TargetLogMain')
_('jmp TargetLogExit')
_('TargetLogMain:')
_('pushad')

_('mov ecx,dword[ebp+8]')
_('test ecx,ecx')
_('jnz TargetLogStore')
_('mov ecx,edx')
_('TargetLogStore:')
_('lea eax,dword[edx*4+TargetLogBase]')
_('mov dword[eax],ecx')
_('popad')
_('TargetLogExit:')
_('push ebx')
_('push esi')
_('push edi')
_('mov edi,edx')
_('ljmp TargetLogReturn')
EndFunc ;==>CreateTargetLog
;~ Description: Internal use only.
Func CreateSkillLog()
_('SkillLogProc:')
_('pushad')
_('mov eax,dword[SkillLogCounter]')
_('push eax')
_('shl eax,4')
_('add eax,SkillLogBase')
_('mov
_('mov
_('mov
_('mov
_('mov
_('mov
_('mov
_('mov
_('push
_('push
_('push
_('push
_('call

ecx,dword[edi]')
dword[eax],ecx')
ecx,dword[ecx*4+TargetLogBase]')
dword[eax+4],ecx')
ecx,dword[edi+4]')
dword[eax+8],ecx')
ecx,dword[edi+8]')
dword[eax+c],ecx')
1')
eax')
CallbackEvent')
dword[CallbackHandle]')
dword[PostMessage]')

_('pop eax')
_('inc eax')
_('cmp eax,SkillLogSize')
_('jnz SkillLogSkipReset')
_('xor eax,eax')
_('SkillLogSkipReset:')
_('mov dword[SkillLogCounter],eax')
_('popad')
_('inc eax')
_('mov dword[esi+10],eax')
_('pop esi')
_('ljmp SkillLogReturn')
EndFunc ;==>CreateSkillLog
;~ Description: Internal use only.
Func CreateSkillCancelLog()

_('SkillCancelLogProc:')
_('pushad')
_('mov eax,dword[SkillLogCounter]')
_('push eax')
_('shl eax,4')
_('add eax,SkillLogBase')
_('mov
_('mov
_('mov
_('mov
_('mov
_('mov
_('push
_('push
_('push
_('push
_('call

ecx,dword[edi]')
dword[eax],ecx')
ecx,dword[ecx*4+TargetLogBase]')
dword[eax+4],ecx')
ecx,dword[edi+4]')
dword[eax+8],ecx')
2')
eax')
CallbackEvent')
dword[CallbackHandle]')
dword[PostMessage]')

_('pop eax')
_('inc eax')
_('cmp eax,SkillLogSize')
_('jnz SkillCancelLogSkipReset')
_('xor eax,eax')
_('SkillCancelLogSkipReset:')
_('mov dword[SkillLogCounter],eax')
_('popad')
_('push 0')
_('push 42')
_('mov ecx,esi')
_('ljmp SkillCancelLogReturn')
EndFunc ;==>CreateSkillCancelLog
;~ Description: Internal use only.
Func CreateSkillCompleteLog()
_('SkillCompleteLogProc:')
_('pushad')
_('mov eax,dword[SkillLogCounter]')
_('push eax')
_('shl eax,4')
_('add eax,SkillLogBase')
_('mov
_('mov
_('mov
_('mov
_('mov
_('mov
_('push
_('push
_('push
_('push
_('call

ecx,dword[edi]')
dword[eax],ecx')
ecx,dword[ecx*4+TargetLogBase]')
dword[eax+4],ecx')
ecx,dword[edi+4]')
dword[eax+8],ecx')
3')
eax')
CallbackEvent')
dword[CallbackHandle]')
dword[PostMessage]')

_('pop eax')

_('inc eax')
_('cmp eax,SkillLogSize')
_('jnz SkillCompleteLogSkipReset')
_('xor eax,eax')
_('SkillCompleteLogSkipReset:')
_('mov dword[SkillLogCounter],eax')
_('popad')
_('mov eax,dword[edi+4]')
_('test eax,eax')
_('ljmp SkillCompleteLogReturn')
EndFunc ;==>CreateSkillCompleteLog
;~ Description: Internal use only.
Func CreateChatLog()
_('ChatLogProc:')
_('pushad')
_('mov ecx,dword[esp+1F4]')
_('mov ebx,eax')
_('mov eax,dword[ChatLogCounter]')
_('push eax')
_('shl eax,9')
_('add eax,ChatLogBase')
_('mov dword[eax],ebx')
_('mov edi,eax')
_('add eax,4')
_('xor ebx,ebx')
_('ChatLogCopyLoop:')
_('mov dx,word[ecx]')
_('mov word[eax],dx')
_('add ecx,2')
_('add eax,2')
_('inc ebx')
_('cmp ebx,FF')
_('jz ChatLogCopyExit')
_('test dx,dx')
_('jnz ChatLogCopyLoop')
_('ChatLogCopyExit:')
_('push 4')
_('push edi')
_('push CallbackEvent')
_('push dword[CallbackHandle]')
_('call dword[PostMessage]')
_('pop eax')
_('inc eax')
_('cmp eax,ChatLogSize')
_('jnz ChatLogSkipReset')
_('xor eax,eax')
_('ChatLogSkipReset:')
_('mov dword[ChatLogCounter],eax')
_('popad')
_('ChatLogExit:')
_('add edi,E')
_('cmp eax,B')

EndFunc

_('ljmp ChatLogReturn')
;==>CreateChatLog

;~ Description: Internal use only.


Func CreateTraderHook()
_('TraderHookProc:')
_('mov dword[TraderCostID],ecx')
_('mov dword[TraderCostValue],edx')
_('push eax')
_('mov eax,dword[TraderQuoteID]')
_('inc eax')
_('cmp eax,200')
_('jnz TraderSkipReset')
_('xor eax,eax')
_('TraderSkipReset:')
_('mov dword[TraderQuoteID],eax')
_('pop eax')
_('mov ebp,esp')
_('sub esp,8')
_('ljmp TraderHookReturn')
EndFunc ;==>CreateTraderHook
;~ Description: Internal use only.
Func CreateLoadFinished()
_('LoadFinishedProc:')
_('pushad')
_('mov eax,1')
_('mov dword[MapIsLoaded],eax')
_('xor ebx,ebx')
_('mov eax,StringLogBase')
_('LoadClearStringsLoop:')
_('mov dword[eax],0')
_('inc ebx')
_('add eax,100')
_('cmp ebx,StringLogSize')
_('jnz LoadClearStringsLoop')
_('xor ebx,ebx')
_('mov eax,TargetLogBase')
_('LoadClearTargetsLoop:')
_('mov dword[eax],0')
_('inc ebx')
_('add eax,4')
_('cmp ebx,TargetLogSize')
_('jnz LoadClearTargetsLoop')
_('push
_('push
_('push
_('push
_('call

5')
0')
CallbackEvent')
dword[CallbackHandle]')
dword[PostMessage]')

_('popad')
_('mov edx,dword[esi+1C]')
_('mov ecx,edi')
_('ljmp LoadFinishedReturn')
EndFunc ;==>CreateLoadFinished

;~ Description: Internal use only.


Func CreateStringLog()
_('StringLogProc:')
_('pushad')
_('mov eax,dword[NextStringType]')
_('test eax,eax')
_('jz StringLogExit')
_('cmp
_('jnz
_('mov
_('jmp

eax,1')
StringLogFilter2')
eax,dword[ebp+37c]')
StringLogRangeCheck')

_('StringLogFilter2:')
_('cmp eax,2')
_('jnz StringLogExit')
_('mov eax,dword[ebp+338]')
_('StringLogRangeCheck:')
_('mov dword[NextStringType],0')
_('cmp eax,0')
_('jbe StringLogExit')
_('cmp eax,StringLogSize')
_('jae StringLogExit')
_('shl eax,8')
_('add eax,StringLogBase')
_('xor ebx,ebx')
_('StringLogCopyLoop:')
_('mov dx,word[ecx]')
_('mov word[eax],dx')
_('add ecx,2')
_('add eax,2')
_('inc ebx')
_('cmp ebx,80')
_('jz StringLogExit')
_('test dx,dx')
_('jnz StringLogCopyLoop')
_('StringLogExit:')
_('popad')
_('mov esp,ebp')
_('pop ebp')
_('retn 10')
EndFunc ;==>CreateStringLog
;~ Description: Internal use only.
Func CreateStringFilter1()
_('StringFilter1Proc:')
_('mov dword[NextStringType],1')
_('push ebp')
_('mov ebp,esp')
_('push ecx')
_('push esi')
_('ljmp StringFilter1Return')
EndFunc ;==>CreateStringFilter1
;~ Description: Internal use only.

Func CreateStringFilter2()
_('StringFilter2Proc:')
_('mov dword[NextStringType],2')
_('push ebp')
_('mov ebp,esp')
_('push ecx')
_('push esi')
_('ljmp StringFilter2Return')
EndFunc ;==>CreateStringFilter2
;~ Description: Internal use only.
Func CreateRenderingMod()
_('RenderingModProc:')
_('cmp dword[DisableRendering],1')
_('jz RenderingModSkipCompare')
_('cmp eax,ebx')
_('ljne RenderingModReturn')
_('RenderingModSkipCompare:')
$mASMSize += 17
$mASMString &= StringTrimLeft(MemoryRead(getvalue("RenderingMod") + 4, "
byte[17]"), 2)
_('cmp dword[DisableRendering],1')
_('jz DisableRenderingProc')
_('retn')
_('DisableRenderingProc:')
_('push 1')
_('call dword[Sleep]')
_('retn')
EndFunc ;==>CreateRenderingMod
;~ Description: Internal use only.
Func CreateCommands()
_('CommandUseSkill:')
_('mov ecx,dword[MyID]')
_('mov edx,dword[eax+C]')
_('push edx')
_('mov edx,dword[eax+4]')
_('dec edx')
_('push dword[eax+8]')
_('call UseSkillFunction')
_('ljmp CommandReturn')
_('CommandMove:')
_('lea ecx,dword[eax+4]')
_('call MoveFunction')
_('ljmp CommandReturn')
_('CommandChangeTarget:')
_('mov ecx,dword[eax+4]')
_('xor edx,edx')
_('call ChangeTargetFunction')
_('ljmp CommandReturn')
_('CommandPacketSend:')
_('mov ecx,dword[PacketLocation]')
_('lea edx,dword[eax+8]')
_('push edx')

_('mov edx,dword[eax+4]')
_('mov eax,ecx')
_('call PacketSendFunction')
_('ljmp CommandReturn')
_('CommandWriteChat:')
_('add eax,4')
_('mov edx,eax')
_('xor ecx,ecx')
_('add eax,28')
_('push eax')
_('call WriteChatFunction')
_('ljmp CommandReturn')
_('CommandSellItem:')
_('push 0')
_('push 0')
_('push 0')
_('push dword[eax+4]')
_('push 0')
_('add eax,8')
_('push eax')
_('push 1')
_('mov ecx,b')
_('xor edx,edx')
_('call SellItemFunction')
_('ljmp CommandReturn')
_('CommandBuyItem:')
_('add eax,4')
_('push eax')
_('add eax,4')
_('push eax')
_('push 1')
_('push 0')
_('push 0')
_('push 0')
_('push 0')
_('mov ecx,1')
_('mov edx,dword[eax+4]')
_('call BuyItemFunction')
_('ljmp CommandReturn')
_('CommandAction:')
_('mov ecx,dword[ActionBase]')
_('mov ecx,dword[ecx+250]')
_('mov ecx,dword[ecx+10]')
_('mov ecx,dword[ecx]')
_('push 0')
_('push 0')
_('push dword[eax+4]')
_('mov edx,esp')
_('push 0')
_('push edx')
_('push dword[eax+8]')
_('call ActionFunction')
_('pop eax')
_('pop ebx')
_('pop ecx')
_('ljmp CommandReturn')

_('CommandToggleLanguage:')
_('mov ecx,dword[ActionBase]')
_('mov ecx,dword[ecx+170]')
_('mov ecx,dword[ecx+20]')
_('mov ecx,dword[ecx]')
_('push 0')
_('push 0')
_('push bb')
_('mov edx,esp')
_('push 0')
_('push edx')
_('push dword[eax+4]')
_('call ActionFunction')
_('pop eax')
_('pop ebx')
_('pop ecx')
_('ljmp CommandReturn')
_('CommandUseHeroSkill:')
_('mov ecx,dword[eax+4]')
_('mov edx,dword[eax+c]')
_('mov eax,dword[eax+8]')
_('push eax')
_('call UseHeroSkillFunction')
_('ljmp CommandReturn')
_('CommandSendChat:')
_('mov ecx,dword[PacketLocation]')
_('add eax,4')
_('push eax')
_('mov edx,11c')
_('mov eax,ecx')
_('call PacketSendFunction')
_('ljmp CommandReturn')
_('CommandRequestQuote:')
_('mov dword[TraderCostID],0')
_('mov dword[TraderCostValue],0')
_('add eax,4')
_('push eax')
_('push 1')
_('push 0')
_('push 0')
_('push 0')
_('push 0')
_('mov ecx,c')
_('xor edx,edx')
_('call RequestQuoteFunction')
_('ljmp CommandReturn')
_('CommandRequestQuoteSell:')
_('mov dword[TraderCostID],0')
_('mov dword[TraderCostValue],0')
_('push 0')
_('push 0')
_('push 0')
_('add eax,4')
_('push eax')
_('push 1')

_('push 0')
_('mov ecx,d')
_('xor edx,edx')
_('call RequestQuoteFunction')
_('ljmp CommandReturn')
_('CommandTraderBuy:')
_('push 0')
_('push TraderCostID')
_('push 1')
_('push 0')
_('push 0')
_('push 0')
_('push 0')
_('mov ecx,c')
_('mov edx,dword[TraderCostValue]')
_('call TraderFunction')
_('mov dword[TraderCostID],0')
_('mov dword[TraderCostValue],0')
_('ljmp CommandReturn')
_('CommandTraderSell:')
_('push 0')
_('push 0')
_('push 0')
_('push dword[TraderCostValue]')
_('push 0')
_('push TraderCostID')
_('push 1')
_('mov ecx,d')
_('xor edx,edx')
_('call TraderFunction')
_('mov dword[TraderCostID],0')
_('mov dword[TraderCostValue],0')
_('ljmp CommandReturn')
_('CommandSalvage:')
_('mov ebx,SalvageGlobal')
_('mov ecx,dword[eax+4]')
_('mov dword[ebx],ecx')
_('push ecx')
_('mov ecx,dword[eax+8]')
_('add ebx,4')
_('mov dword[ebx],ecx')
_('mov edx,dword[eax+c]')
_('mov dword[ebx],ecx')
_('call SalvageFunction')
_('ljmp CommandReturn')
_('CommandIncreaseAttribute:')
_('mov edx,dword[eax+4]')
_('mov ecx,dword[eax+8]')
_('call IncreaseAttributeFunction')
_('ljmp CommandReturn')
_('CommandDecreaseAttribute:')
_('mov edx,dword[eax+4]')
_('mov ecx,dword[eax+8]')
_('call DecreaseAttributeFunction')
_('ljmp CommandReturn')

_('CommandMakeAgentArray:')
_('mov eax,dword[eax+4]')
_('xor ebx,ebx')
_('xor edx,edx')
_('mov edi,AgentCopyBase')
_('AgentCopyLoopStart:')
_('inc ebx')
_('cmp ebx,dword[MaxAgents]')
_('jge AgentCopyLoopExit')
_('mov esi,dword[AgentBase]')
_('lea esi,dword[esi+ebx*4]')
_('mov esi,dword[esi]')
_('test esi,esi')
_('jz AgentCopyLoopStart')
_('cmp eax,0')
_('jz CopyAgent')
_('cmp eax,dword[esi+9C]')
_('jnz AgentCopyLoopStart')
_('CopyAgent:')
_('mov ecx,1C0')
_('clc')
_('repe movsb')
_('inc edx')
_('jmp AgentCopyLoopStart')
_('AgentCopyLoopExit:')
_('mov dword[AgentCopyCount],edx')
_('ljmp CommandReturn')
EndFunc ;==>CreateCommands
#EndRegion Modification
#Region Assembler
;~ Description: Internal use only.
Func _($aASM)
;quick and dirty x86assembler unit:
;relative values stringregexp
;static values hardcoded
Local $lBuffer
Select
Case StringRight($aASM, 1) = ':'
SetValue('Label_' & StringLeft($aASM, StringLen($aASM) 1), $mASMSize)
Case StringInStr($aASM, '/') > 0
SetValue('Label_' & StringLeft($aASM, StringInStr($aASM,
'/') - 1), $mASMSize)
Local $lOffset = StringRight($aASM, StringLen($aASM) - S
tringInStr($aASM, '/'))
$mASMSize += $lOffset
$mASMCodeOffset += $lOffset
Case StringLeft($aASM, 5) = 'nop x'
$lBuffer = Int(Number(StringTrimLeft($aASM, 5)))
$mASMSize += $lBuffer
For $i = 1 To $lBuffer
$mASMString &= '90'
Next

Case StringLeft($aASM, 5) = 'ljmp '


$mASMSize += 5
$mASMString &= 'E9{' & StringRight($aASM, StringLen($aAS
M) - 5) & '}'
Case StringLeft($aASM, 5) = 'ljne '
$mASMSize += 6
$mASMString &= '0F85{' & StringRight($aASM, StringLen($a
ASM) - 5) & '}'
Case StringLeft($aASM, 4) = 'jmp ' And StringLen($aASM) > 7
$mASMSize += 2
$mASMString &= 'EB(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'
Case StringLeft($aASM, 4) = 'jae '
$mASMSize += 2
$mASMString &= '73(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'
Case StringLeft($aASM, 3) = 'jz '
$mASMSize += 2
$mASMString &= '74(' & StringRight($aASM, StringLen($aAS
M) - 3) & ')'
Case StringLeft($aASM, 4) = 'jnz '
$mASMSize += 2
$mASMString &= '75(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'
Case StringLeft($aASM, 4) = 'jbe '
$mASMSize += 2
$mASMString &= '76(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'
Case StringLeft($aASM, 3) = 'ja '
$mASMSize += 2
$mASMString &= '77(' & StringRight($aASM, StringLen($aAS
M) - 3) & ')'
Case StringLeft($aASM, 3) = 'jl '
$mASMSize += 2
$mASMString &= '7C(' & StringRight($aASM, StringLen($aAS
M) - 3) & ')'
Case StringLeft($aASM, 4) = 'jge '
$mASMSize += 2
$mASMString &= '7D(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'
Case StringLeft($aASM, 4) = 'jle '
$mASMSize += 2
$mASMString &= '7E(' & StringRight($aASM, StringLen($aAS
M) - 4) & ')'

ASM) - 15) &

$aASM) - 15)

$aASM) - 15)

$aASM) - 15)

Case StringRegExp($aASM, 'mov eax,dword[[][a-z,A-Z]{4,}[]]')


$mASMSize += 5
$mASMString &= 'A1[' & StringMid($aASM, 15, StringLen($a
']'
Case StringRegExp($aASM, 'mov ebx,dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= '8B1D[' & StringMid($aASM, 15, StringLen(
& ']'
Case StringRegExp($aASM, 'mov ecx,dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= '8B0D[' & StringMid($aASM, 15, StringLen(
& ']'
Case StringRegExp($aASM, 'mov edx,dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= '8B15[' & StringMid($aASM, 15, StringLen(
& ']'

Case StringRegExp($aASM, 'mov esi,dword[[][a-z,A-Z]{4,}[]]')


$mASMSize += 6
$mASMString &= '8B35[' & StringMid($aASM, 15, StringLen(
$aASM) - 15) & ']'
Case StringRegExp($aASM, 'mov edi,dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= '8B3D[' & StringMid($aASM, 15, StringLen(
$aASM) - 15) & ']'
Case StringRegExp($aASM, 'cmp ebx,dword\[[a-z,A-Z]{4,}\]')
$mASMSize += 6
$mASMString &= '3B1D[' & StringMid($aASM, 15, StringLen(
$aASM) - 15) & ']'
Case StringRegExp($aASM, 'lea eax,dword[[]ecx[*]8[+][a-z,A-Z]{4,
}[]]')
$mASMSize += 7
$mASMString &= '8D04CD[' & StringMid($aASM, 21, StringLe
n($aASM) - 21) & ']'
Case StringRegExp($aASM, 'lea edi,dword\[edx\+[a-z,A-Z]{4,}\]')
$mASMSize += 7
$mASMString &= '8D3C15[' & StringMid($aASM, 19, StringLe
n($aASM) - 19) & ']'
Case StringRegExp($aASM, 'cmp dword[[][a-z,A-Z]{4,}[]],[-[:xdigi
t:]]')
$lBuffer = StringInStr($aASM, ",")
$lBuffer = ASMNumber(StringMid($aASM, $lBuffer + 1), Tru
e)
If @extended Then
$mASMSize += 7
$mASMString &= '833D[' & StringMid($aASM, 11, St
ringInStr($aASM, ",") - 12) & ']' & $lBuffer
Else
$mASMSize += 10
$mASMString &= '813D[' & StringMid($aASM, 11, St
ringInStr($aASM, ",") - 12) & ']' & $lBuffer
EndIf
Case StringRegExp($aASM, 'cmp ecx,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 6
$mASMString &= '81F9[' & StringRight($aASM, StringLen($a
ASM) - 8) & ']'
Case StringRegExp($aASM, 'cmp ebx,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 6
$mASMString &= '81FB[' & StringRight($aASM, StringLen($a
ASM) - 8) & ']'
Case StringRegExp($aASM, 'cmp eax,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= '3D[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'add eax,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= '05[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'mov eax,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= 'B8[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'

Case StringRegExp($aASM, 'mov ebx,[a-z,A-Z]{4,}') And StringInSt


r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= 'BB[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'mov esi,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= 'BE[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'mov edi,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= 'BF[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'mov edx,[a-z,A-Z]{4,}') And StringInSt
r($aASM, ',dword') = 0
$mASMSize += 5
$mASMString &= 'BA[' & StringRight($aASM, StringLen($aAS
M) - 8) & ']'
Case StringRegExp($aASM, 'mov dword[[][a-z,A-Z]{4,}[]],ecx')
$mASMSize += 6
$mASMString &= '890D[' & StringMid($aASM, 11, StringLen(
$aASM) - 15) & ']'
Case StringRegExp($aASM, 'fstp dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= 'D91D[' & StringMid($aASM, 12, StringLen(
$aASM) - 12) & ']'
Case StringRegExp($aASM, 'mov dword[[][a-z,A-Z]{4,}[]],edx')
$mASMSize += 6
$mASMString &= '8915[' & StringMid($aASM, 11, StringLen(
$aASM) - 15) & ']'
Case StringRegExp($aASM, 'mov dword[[][a-z,A-Z]{4,}[]],eax')
$mASMSize += 5
$mASMString &= 'A3[' & StringMid($aASM, 11, StringLen($a
ASM) - 15) & ']'
Case StringRegExp($aASM, 'lea eax,dword[[]edx[*]4[+][a-z,A-Z]{4,
}[]]')
$mASMSize += 7
$mASMString &= '8D0495[' & StringMid($aASM, 21, StringLe
n($aASM) - 21) & ']'
Case StringRegExp($aASM, 'mov eax,dword[[]ecx[*]4[+][a-z,A-Z]{4,
}[]]')
$mASMSize += 7
$mASMString &= '8B048D[' & StringMid($aASM, 21, StringLe
n($aASM) - 21) & ']'
Case StringRegExp($aASM, 'mov ecx,dword[[]ecx[*]4[+][a-z,A-Z]{4,
}[]]')
$mASMSize += 7
$mASMString &= '8B0C8D[' & StringMid($aASM, 21, StringLe
n($aASM) - 21) & ']'
Case StringRegExp($aASM, 'push dword[[][a-z,A-Z]{4,}[]]')
$mASMSize += 6
$mASMString &= 'FF35[' & StringMid($aASM, 12, StringLen(
$aASM) - 12) & ']'
Case StringRegExp($aASM, 'push [a-z,A-Z]{4,}\z')
$mASMSize += 5
$mASMString &= '68[' & StringMid($aASM, 6, StringLen($aA
SM) - 5) & ']'
Case StringRegExp($aASM, 'call dword[[][a-z,A-Z]{4,}[]]')

$mASMSize += 6
$mASMString &= 'FF15[' & StringMid($aASM, 12, StringLen(
$aASM) - 12) & ']'
Case StringLeft($aASM, 5) = 'call ' And StringLen($aASM) > 8
$mASMSize += 5
$mASMString &= 'E8{' & StringMid($aASM, 6, StringLen($aA
SM) - 5) & '}'
Case StringRegExp($aASM, 'mov dword\[[a-z,A-Z]{4,}\],[-[:xdigit:
]]{1,8}\z')
$lBuffer = StringInStr($aASM, ",")
$mASMSize += 10
$mASMString &= 'C705[' & StringMid($aASM, 11, $lBuffer 12) & ']' & ASMNumber(StringMid($aASM, $lBuffer + 1))
Case StringRegExp($aASM, 'push [-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 6), True)
If @extended Then
$mASMSize += 2
$mASMString &= '6A' & $lBuffer
Else
$mASMSize += 5
$mASMString &= '68' & $lBuffer
EndIf
Case StringRegExp($aASM, 'mov eax,[-[:xdigit:]]{1,8}\z')
$mASMSize += 5
$mASMString &= 'B8' & ASMNumber(StringMid($aASM, 9))
Case StringRegExp($aASM, 'mov ebx,[-[:xdigit:]]{1,8}\z')
$mASMSize += 5
$mASMString &= 'BB' & ASMNumber(StringMid($aASM, 9))
Case StringRegExp($aASM, 'mov ecx,[-[:xdigit:]]{1,8}\z')
$mASMSize += 5
$mASMString &= 'B9' & ASMNumber(StringMid($aASM, 9))
Case StringRegExp($aASM, 'mov edx,[-[:xdigit:]]{1,8}\z')
$mASMSize += 5
$mASMString &= 'BA' & ASMNumber(StringMid($aASM, 9))
Case StringRegExp($aASM, 'add eax,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83C0' & $lBuffer
Else
$mASMSize += 5
$mASMString &= '05' & $lBuffer
EndIf
Case StringRegExp($aASM, 'add ebx,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83C3' & $lBuffer
Else
$mASMSize += 6
$mASMString &= '81C3' & $lBuffer
EndIf
Case StringRegExp($aASM, 'add ecx,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83C1' & $lBuffer
Else
$mASMSize += 6
$mASMString &= '81C1' & $lBuffer

EndIf
Case StringRegExp($aASM, 'add edx,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83C2' & $lBuffer
Else
$mASMSize += 6
$mASMString &= '81C2' & $lBuffer
EndIf
Case StringRegExp($aASM, 'add edi,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83C7' & $lBuffer
Else
$mASMSize += 6
$mASMString &= '81C7' & $lBuffer
EndIf
Case StringRegExp($aASM, 'cmp ebx,[-[:xdigit:]]{1,8}\z')
$lBuffer = ASMNumber(StringMid($aASM, 9), True)
If @extended Then
$mASMSize += 3
$mASMString &= '83FB' & $lBuffer
Else
$mASMSize += 6
$mASMString &= '81FB' & $lBuffer
EndIf
Case Else
Local $lOpCode
Switch $aASM
Case 'nop'
$lOpCode = '90'
Case 'pushad'
$lOpCode = '60'
Case 'popad'
$lOpCode = '61'
Case 'mov ebx,dword[eax]'
$lOpCode = '8B18'
Case 'test eax,eax'
$lOpCode = '85C0'
Case 'test ebx,ebx'
$lOpCode = '85DB'
Case 'test ecx,ecx'
$lOpCode = '85C9'
Case 'mov dword[eax],0'
$lOpCode = 'C70000000000'
Case 'push eax'
$lOpCode = '50'
Case 'push ebx'
$lOpCode = '53'
Case 'push ecx'
$lOpCode = '51'
Case 'push edx'
$lOpCode = '52'
Case 'push ebp'
$lOpCode = '55'
Case 'push esi'
$lOpCode = '56'
Case 'push edi'

$lOpCode = '57'
Case 'jmp ebx'
$lOpCode = 'FFE3'
Case 'pop eax'
$lOpCode = '58'
Case 'pop ebx'
$lOpCode = '5B'
Case 'pop edx'
$lOpCode = '5A'
Case 'pop ecx'
$lOpCode = '59'
Case 'pop esi'
$lOpCode = '5E'
Case 'inc eax'
$lOpCode = '40'
Case 'inc ecx'
$lOpCode = '41'
Case 'inc ebx'
$lOpCode = '43'
Case 'dec edx'
$lOpCode = '4A'
Case 'mov edi,edx'
$lOpCode = '8BFA'
Case 'mov ecx,esi'
$lOpCode = '8BCE'
Case 'mov ecx,edi'
$lOpCode = '8BCF'
Case 'xor eax,eax'
$lOpCode = '33C0'
Case 'xor ecx,ecx'
$lOpCode = '33C9'
Case 'xor edx,edx'
$lOpCode = '33D2'
Case 'xor ebx,ebx'
$lOpCode = '33DB'
Case 'mov edx,eax'
$lOpCode = '8BD0'
Case 'mov ebp,esp'
$lOpCode = '8BEC'
Case 'sub esp,8'
$lOpCode = '83EC08'
Case 'sub esp,14'
$lOpCode = '83EC14'
Case 'cmp ecx,4'
$lOpCode = '83F904'
Case 'cmp ecx,32'
$lOpCode = '83F932'
Case 'cmp ecx,3C'
$lOpCode = '83F93C'
Case 'mov ecx,edx'
$lOpCode = '8BCA'
Case 'mov eax,ecx'
$lOpCode = '8BC1'
Case 'mov ecx,dword[ebp+8]'
$lOpCode = '8B4D08'
Case 'mov ecx,dword[esp+1F4]'
$lOpCode = '8B8C24F4010000'
Case 'mov ecx,dword[edi+4]'
$lOpCode = '8B4F04'
Case 'mov ecx,dword[edi+8]'

$lOpCode = '8B4F08'
Case 'mov eax,dword[edi+4]'
$lOpCode = '8B4704'
Case 'mov dword[eax+4],ecx'
$lOpCode = '894804'
Case 'mov dword[eax+8],ecx'
$lOpCode = '894808'
Case 'mov dword[eax+C],ecx'
$lOpCode = '89480C'
Case 'mov dword[esi+10],eax'
$lOpCode = '894610'
Case 'mov ecx,dword[edi]'
$lOpCode = '8B0F'
Case 'mov dword[eax],ecx'
$lOpCode = '8908'
Case 'mov dword[eax],ebx'
$lOpCode = '8918'
Case 'mov edx,dword[eax+4]'
$lOpCode = '8B5004'
Case 'mov edx,dword[eax+c]'
$lOpCode = '8B500C'
Case 'mov edx,dword[esi+1c]'
$lOpCode = '8B561C'
Case 'push dword[eax+8]'
$lOpCode = 'FF7008'
Case 'lea eax,dword[eax+18]'
$lOpCode = '8D4018'
Case 'lea ecx,dword[eax+4]'
$lOpCode = '8D4804'
Case 'lea edx,dword[eax+4]'
$lOpCode = '8D5004'
Case 'lea edx,dword[eax+8]'
$lOpCode = '8D5008'
Case 'mov ecx,dword[eax+4]'
$lOpCode = '8B4804'
Case 'mov ecx,dword[eax+8]'
$lOpCode = '8B4808'
Case 'mov eax,dword[eax+8]'
$lOpCode = '8B4008'
Case 'mov eax,dword[eax+4]'
$lOpCode = '8B4004'
Case 'push dword[eax+4]'
$lOpCode = 'FF7004'
Case 'push dword[eax+c]'
$lOpCode = 'FF700C'
Case 'mov esp,ebp'
$lOpCode = '8BE5'
Case 'mov esp,ebp'
$lOpCode = '8BE5'
Case 'pop ebp'
$lOpCode = '5D'
Case 'retn 10'
$lOpCode = 'C21000'
Case 'cmp eax,2'
$lOpCode = '83F802'
Case 'cmp eax,0'
$lOpCode = '83F800'
Case 'cmp eax,B'
$lOpCode = '83F80B'
Case 'cmp eax,200'

$lOpCode = '3D00020000'
Case 'shl eax,4'
$lOpCode = 'C1E004'
Case 'shl eax,8'
$lOpCode = 'C1E008'
Case 'shl eax,6'
$lOpCode = 'C1E006'
Case 'shl eax,7'
$lOpCode = 'C1E007'
Case 'shl eax,8'
$lOpCode = 'C1E008'
Case 'shl eax,9'
$lOpCode = 'C1E009'
Case 'mov edi,eax'
$lOpCode = '8BF8'
Case 'mov dx,word[ecx]'
$lOpCode = '668B11'
Case 'mov dx,word[edx]'
$lOpCode = '668B12'
Case 'mov word[eax],dx'
$lOpCode = '668910'
Case 'test dx,dx'
$lOpCode = '6685D2'
Case 'cmp word[edx],0'
$lOpCode = '66833A00'
Case 'cmp eax,ebx'
$lOpCode = '3BC3'
Case 'cmp eax,ecx'
$lOpCode = '3BC1'
Case 'mov eax,dword[esi+8]'
$lOpCode = '8B4608'
Case 'mov ecx,dword[eax]'
$lOpCode = '8B08'
Case 'mov ebx,edi'
$lOpCode = '8BDF'
Case 'mov ebx,eax'
$lOpCode = '8BD8'
Case 'mov eax,edi'
$lOpCode = '8BC7'
Case 'mov al,byte[ebx]'
$lOpCode = '8A03'
Case 'test al,al'
$lOpCode = '84C0'
Case 'mov eax,dword[ecx]'
$lOpCode = '8B01'
Case 'lea ecx,dword[eax+180]'
$lOpCode = '8D8880010000'
Case 'mov ebx,dword[ecx+14]'
$lOpCode = '8B5914'
Case 'mov eax,dword[ebx+c]'
$lOpCode = '8B430C'
Case 'mov ecx,eax'
$lOpCode = '8BC8'
Case 'cmp eax,-1'
$lOpCode = '83F8FF'
Case 'mov al,byte[ecx]'
$lOpCode = '8A01'
Case 'mov ebx,dword[edx]'
$lOpCode = '8B1A'
Case 'lea edi,dword[edx+ebx]'

$lOpCode = '8D3C1A'
Case 'mov ah,byte[edi]'
$lOpCode = '8A27'
Case 'cmp al,ah'
$lOpCode = '3AC4'
Case 'mov dword[edx],0'
$lOpCode = 'C70200000000'
Case 'mov dword[ebx],ecx'
$lOpCode = '890B'
Case 'cmp edx,esi'
$lOpCode = '3BD6'
Case 'cmp ecx,900000'
$lOpCode = '81F900009000'
Case 'mov edi,dword[edx+4]'
$lOpCode = '8B7A04'
Case 'cmp ebx,edi'
$lOpCode = '3BDF'
Case 'mov dword[edx],ebx'
$lOpCode = '891A'
Case 'lea edi,dword[edx+8]'
$lOpCode = '8D7A08'
Case 'mov dword[edi],ecx'
$lOpCode = '890F'
Case 'retn'
$lOpCode = 'C3'
Case 'mov dword[edx],-1'
$lOpCode = 'C702FFFFFFFF'
Case 'cmp eax,1'
$lOpCode = '83F801'
Case 'mov eax,dword[ebp+37c]'
$lOpCode = '8B857C030000'
Case 'mov eax,dword[ebp+338]'
$lOpCode = '8B8538030000'
Case 'mov ecx,dword[ebx+250]'
$lOpCode = '8B8B50020000'
Case 'mov ecx,dword[ebx+194]'
$lOpCode = '8B8B94010000'
Case 'mov ecx,dword[ebx+18]'
$lOpCode = '8B5918'
Case 'mov ecx,dword[ebx+40]'
$lOpCode = '8B5940'
Case 'mov ebx,dword[ecx+10]'
$lOpCode = '8B5910'
Case 'mov ebx,dword[ecx+18]'
$lOpCode = '8B5918'
Case 'mov ebx,dword[ecx+4c]'
$lOpCode = '8B594C'
Case 'mov ecx,dword[ebx]'
$lOpCode = '8B0B'
Case 'mov edx,esp'
$lOpCode = '8BD4'
Case 'mov ecx,dword[ebx+170]'
$lOpCode = '8B8B70010000'
Case 'cmp eax,dword[esi+9C]'
$lOpCode = '3B869C000000'
Case 'mov ebx,dword[ecx+20]'
$lOpCode = '8B5920'
Case 'mov ecx,dword[ecx]'
$lOpCode = '8B09'
Case 'mov eax,dword[ecx+40]'

$lOpCode = '8B4140'
Case 'mov ecx,dword[ecx+10]'
$lOpCode = '8B4910'
Case 'mov ecx,dword[ecx+18]'
$lOpCode = '8B4918'
Case 'mov ecx,dword[ecx+20]'
$lOpCode = '8B4920'
Case 'mov ecx,dword[ecx+4c]'
$lOpCode = '8B494C'
Case 'mov ecx,dword[ecx+170]'
$lOpCode = '8B8970010000'
Case 'mov ecx,dword[ecx+194]'
$lOpCode = '8B8994010000'
Case 'mov ecx,dword[ecx+250]'
$lOpCode = '8B8950020000'
Case 'mov al,byte[ecx+4f]'
$lOpCode = '8A414F'
Case 'mov al,byte[ecx+3f]'
$lOpCode = '8A413F'
Case 'cmp al,f'
$lOpCode = '3C0F'
Case 'lea esi,dword[esi+ebx*4]'
$lOpCode = '8D349E'
Case 'mov esi,dword[esi]'
$lOpCode = '8B36'
Case 'test esi,esi'
$lOpCode = '85F6'
Case 'clc'
$lOpCode = 'F8'
Case 'repe movsb'
$lOpCode = 'F3A4'
Case 'inc edx'
$lOpCode = '42'
Case Else
MsgBox(0, 'ASM', 'Could not assemble: '
& $aASM)
Exit
EndSwitch
$mASMSize += 0.5 * StringLen($lOpCode)
$mASMString &= $lOpCode
EndFunc

EndSelect
;==>_

;~ Description: Internal use only.


Func CompleteASMCode()
Local $lInExpression = False
Local $lExpression
Local $lTempASM = $mASMString
Local $lCurrentOffset = Dec(Hex($mMemory)) + $mASMCodeOffset
Local $lToken
For $i = 1 To $mLabels[0][0]
If StringLeft($mLabels[$i][0], 6) = 'Label_' Then
$mLabels[$i][0] = StringTrimLeft($mLabels[$i][0], 6)
$mLabels[$i][1] = $mMemory + $mLabels[$i][1]
EndIf
Next
$mASMString = ''
For $i = 1 To StringLen($lTempASM)

$lToken = StringMid($lTempASM, $i, 1)


Switch $lToken
Case '(', '[', '{'
$lInExpression = True
Case ')'
$mASMString &= Hex(GetLabelInfo($lExpression) Int($lCurrentOffset) - 1, 2)
$lCurrentOffset += 1
$lInExpression = False
$lExpression = ''
Case ']'
$mASMString &= SwapEndian(Hex(GetLabelInfo($lExp
ression), 8))
$lCurrentOffset += 4
$lInExpression = False
$lExpression = ''
Case '}'
$mASMString &= SwapEndian(Hex(GetLabelInfo($lExp
ression) - Int($lCurrentOffset) - 4, 8))
$lCurrentOffset += 4
$lInExpression = False
$lExpression = ''
Case Else
If $lInExpression Then
$lExpression &= $lToken
Else
$mASMString &= $lToken
$lCurrentOffset += 0.5
EndIf
EndSwitch
Next
EndFunc ;==>CompleteASMCode
;~ Description: Internal use only.
Func GetLabelInfo($aLabel)
Local $lValue = GetValue($aLabel)
If $lValue = -1 Then Exit MsgBox(0, 'Label', 'Label: ' & $aLabel & ' not
provided')
Return $lValue ;Dec(StringRight($lValue, 8))
EndFunc ;==>GetLabelInfo
;~ Description: Internal use only.
Func ASMNumber($aNumber, $aSmall = False)
If $aNumber >= 0 Then
$aNumber = Dec($aNumber)
EndIf
If $aSmall And $aNumber <= 127 And $aNumber >= -128 Then
Return SetExtended(1, Hex($aNumber, 2))
Else
Return SetExtended(0, SwapEndian(Hex($aNumber, 8)))
EndIf
EndFunc ;==>ASMNumber
#EndRegion Assembler
#EndRegion Other Functions
; #FUNCTION# ===================================================================
=================================================
; Name...........: _ProcessGetName
; Description ...: Returns a string containing the process name that belongs to
a given PID.

; Syntax.........: _ProcessGetName( $iPID )


; Parameters ....: $iPID - The PID of a currently running process
; Return values .: Success
- The name of the process
;
Failure
- Blank string and sets @error
;
1 - Process doesn't exist
;
2 - Error getting process list
;
3 - No processes found
; Author ........: Erifash <erifash [at] gmail [dot] com>, Wouter van Kesteren.
; Remarks .......: Supplementary to ProcessExists().
; ==============================================================================
=================================================
Func __ProcessGetName($i_PID)
If Not ProcessExists($i_PID) Then Return SetError(1, 0, '')
If Not @error Then
Local $a_Processes = ProcessList()
For $i = 1 To $a_Processes[0][0]
If $a_Processes[$i][1] = $i_PID Then Return $a_Processes
[$i][0]
Next
EndIf
Return SetError(1, 0, '')
EndFunc ;==>_ProcessGetName
Func GetItemByAgentID2($iAgentID)
Return GetItemByItemID(MemoryRead(GetAgentPtr($iAgentID) + 0xC8))
EndFunc ;==>GetItemByAgentID2
Func CountFreeSlots($NumOfBags = 4)
Local $FreeSlots, $Slots
For $Bag = 1 to $NumOfBags
$Slots += DllStructGetData(GetBag($Bag), 'Slots')
$Slots -= DllStructGetData(GetBag($Bag), 'ItemsCount')
Next
Return $Slots
EndFunc
Func Disconnected()
;Out("Disconnected!")
;Out("Attempting to reconnect.")
ControlSend(getwindowhandle(), "", "", "{Enter}")
Local $lcheck = False
Local $ldeadlock = TimerInit()
Do
Sleep(20)
$lcheck = getmaploading() <> 2 AND getagentexists(-2)
Until $lcheck OR TimerDiff($ldeadlock) > 60000
If $lcheck = False Then
;Out("Failed to Reconnect!")
;Out("Retrying...")
ControlSend(getwindowhandle(), "", "", "{Enter}")
$ldeadlock = TimerInit()
Do
Sleep(20)
$lcheck = getmaploading() <> 2 AND getagentexists(-2)
Until $lcheck OR TimerDiff($ldeadlock) > 60000
If $lcheck = False Then
;Out("Could not reconnect!")
;Out("Exiting.")

EndIf
EndIf
;Out("Reconnected!")
Sleep(2000)
EndFunc

You might also like