GWA2
GWA2
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
Local $mUseStringLog
Local $mUseEventSystem
#EndRegion Declarations
#Region CommandStructs
Local $mUseSkill = DllStructCreate('ptr;dword;dword;dword')
#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
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
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
Enqueue($mSalvagePtr, 16)
;==>StartSalvage
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
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
EndFunc
;==>TraderSell
$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
$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
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)
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
EndFunc
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
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
#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
EndFunc
Return $lReturn[1]
;==>GetDeldrimorTitle
index;long id
fakeSlots;lon
$mGWProcHandl
DllStructGetS
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)
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)
$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
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 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
$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;
$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
Return True
;==>WaitMapLoading
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'
Return $lReturn
;==>Bin64ToDec
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
5')
0')
CallbackEvent')
dword[CallbackHandle]')
dword[PostMessage]')
_('popad')
_('mov edx,dword[esi+1C]')
_('mov ecx,edi')
_('ljmp LoadFinishedReturn')
EndFunc ;==>CreateLoadFinished
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
$aASM) - 15)
$aASM) - 15)
$aASM) - 15)
$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
;==>_
EndIf
EndIf
;Out("Reconnected!")
Sleep(2000)
EndFunc