Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;###########################
- ;# by rheek #
- ;# modified by mhaendler #
- ;###########################
- ; v1.6, source: github.com/rheek123/GwBotApiPatcher
- ;
- ; This file contains all headers that gwa2 uses to communicate with the gameservers directly.
- ;
- ; The headers are named variables. The names should indicate what the header is about.
- ; The comments give a litte more detail about what the header does.
- ;
- ; This makes the source code of gwa2 a little better readable. Also it allows to update headers more easily, as they
- ; are all now in a small separate place as a list to work yourself through.
- ; If you need to update the headers, the comments give hints about what action to trigger while recording CtoGS packets.
- #include-once
- ;=QUEST=
- Global Const $HEADER_QUEST_ACCEPT = 0x41 ;Accepts a quest from the NPC
- Global Const $HEADER_QUEST_REWARD = 0x41 ;Retrieves Quest reward from NPC
- Global Const $HEADER_QUEST_ABANDON = 0x12 ;Abandons the quest
- ;=HERO= not touched
- Global Const $HEADER_HERO_AGGRESSION = 0x17 ;Sets the heroes aggression level
- Global Const $HEADER_HERO_LOCK = 0x18 ;Locks the heroes target
- Global Const $HEADER_HERO_TOGGLE_SKILL = 0x1C ;Enables or disables the heroes skill
- Global Const $HEADER_HERO_CLEAR_FLAG = 0x1E ;Clears the heroes position flag
- Global Const $HEADER_HERO_PLACE_FLAG = 0x1E ;Sets the heroes position flag, hero runs to position
- Global Const $HEADER_HERO_ADD = 0x23 ;Adds hero to party
- Global Const $HEADER_HERO_KICK = 0x24 ;Kicks hero from party
- Global Const $HEADER_HEROES_KICK = 0x24 ;Kicks ALL heroes from party
- ;=PARTY= not touched
- Global Const $HEADER_PARTY_PLACE_FLAG = 0x1F ;Sets the party position flag, all party-npcs runs to position
- Global Const $HEADER_PARTY_CLEAR_FLAG = 0x1F ;Clears the party position flag
- Global Const $HEADER_HENCHMAN_ADD = 0xA6 ;Adds henchman to party
- Global Const $HEADER_PARTY_LEAVE = 0xA9 ;Leaves the party
- Global Const $HEADER_HENCHMAN_KICK = 0xAD ;Kicks a henchman from party
- Global Const $HEADER_INVITE_TARGET = 0xA6 ;Invite target player to party
- Global Const $HEADER_INVITE_CANCEL = 0xA3 ;Cancel invitation of player
- Global Const $HEADER_INVITE_ACCEPT = 0xA2 ;Accept invitation to party
- ;=TARGET (Enemies or NPC)= not touched
- Global Const $HEADER_CALL_TARGET = 0x2C ;Calls the target without attacking (Ctrl+Shift+Space)
- Global Const $HEADER_ATTACK_AGENT = 0x2C ;Attacks agent (Space IIRC)
- Global Const $HEADER_CANCEL_ACTION = 0x2E ;Cancels the current action
- Global Const $HEADER_AGENT_FOLLOW = 0x39 ;Follows the agent/npc. Ctrl+Click triggers "I am following Person" in chat
- Global Const $HEADER_NPC_TALK = 0x3F ;talks/goes to npc
- Global Const $HEADER_SIGNPOST_RUN = 0x57 ;Runs to signpost
- ;=DROP=
- Global Const $HEADER_ITEM_DROP = 0x32 ;Drops item from inventory to ground
- Global Const $HEADER_GOLD_DROP = 0x35 ;Drops gold from inventory to ground
- ;=BUFFS= not touched
- Global Const $HEADER_STOP_MAINTAIN_ENCH = 0x2F ;Drops buff, cancel enchantmant, whatever you call it
- ;=ITEMS=
- Global Const $HEADER_ITEM_EQUIP = 0x36 ;Equips item from inventory/chest/no idea
- Global Const $HEADER_ITEM_PICKUP = 0x45 ;Picks up an item from ground
- Global Const $HEADER_ITEM_DESTROY = 0x6F ;Destroys the item
- Global Const $HEADER_ITEM_ID = 0x72 ;Identifies item in inventory
- Global Const $HEADER_ITEM_MOVE = 0x78 ;Moves item in inventory
- Global Const $HEADER_ITEMS_ACCEPT_UNCLAIMED = 0x79 ;Accepts ITEMS not picked up in missions
- Global Const $HEADER_ITEM_MOVE_EX = 0x7B ;Moves an item, with amount to be moved.
- Global Const $HEADER_SALVAGE_MATS = 0x80 ;Salvages materials from item
- Global Const $HEADER_SALVAGE_MODS = 0x81 ;Salvages mods from item
- Global Const $HEADER_ITEM_USE = 0x84 ;Uses item from inventory/chest
- Global Const $HEADER_ITEM_UNEQUIP = 0x55 ;Unequip item
- Global Const $HEADER_UPGRADE = 0x87 ;used by gwapi. is it even useful? NOT TESTED
- Global Const $HEADER_UPGRADE_ARMOR_1 = 0x84 ;used by gwapi. is it even useful? NOT TESTED
- Global Const $HEADER_UPGRADE_ARMOR_2 = 0x87 ;used by gwapi. is it even useful? NOT TESTED
- ;=TRADE= not touched
- Global Const $HEADER_TRADE_PLAYER = 0x4F ;Send trade request to player
- Global Const $HEADER_TRADE_OFFER_ITEM = 0x02 ;Add item to trade window
- Global Const $HEADER_TRADE_SUBMIT_OFFER = 0x03 ;Submit offer
- Global Const $HEADER_TRADE_CHANGE_OFFER = 0x06 ;Change offer
- Global Const $HEADER_TRADE_CANCEL = 0x01 ;Cancel trade
- Global Const $HEADER_TRADE_ACCEPT = 0x07 ;Accept trade
- ;=TRAVEL=
- Global Const $HEADER_MAP_TRAVEL = 0xB8 ;Travels to outpost via worldmap
- Global Const $HEADER_GUILDHALL_TRAVEL = 0xB7 ;Travels to guild hall
- Global Const $HEADER_GUILDHALL_LEAVE = 0xB9 ;Leaves Guildhall
- ;=FACTION= not touched
- Global Const $HEADER_FACTION_DONATE = 0x3B ;Donates kurzick/luxon faction to ally
- ;=TITLE=
- Global Const $HEADER_TITLE_DISPLAY = 0x5E ;Displays title (from Gigis Vaettir Bot)
- Global Const $HEADER_TITLE_CLEAR = 0x5F ;Hides title (from Gigis Vaettir Bot)
- ;=DIALOG= Not touched
- Global Const $HEADER_DIALOG = 0x41 ;Sends a dialog to NPC
- Global Const $HEADER_CINEMATIC_SKIP = 0x69 ;Skips the cinematic
- ;=SKILL / BUILD=
- Global Const $HEADER_SKILL_CHANGE = 0x62 ;Changes a skill on the skillbar
- Global Const $HEADER_BUILD_LOAD = 0x63 ;Loads a complete build
- Global Const $HEADER_CHANGE_SECONDARY = 0x47 ;Changes Secondary class (from Build window, not class changer)
- ;= Not touched
- Global Const $HEADER_SKILL_USE_ALLY = 0x4C ;used by gwapi. appears to have changed
- Global Const $HEADER_SKILL_USE_FOE = 0x4C ;used by gwapi. appears to have changed
- Global Const $HEADER_SKILL_USE_ID = 0x4C ;
- Global Const $HEADER_SET_ATTRIBUTES = 0x10 ;hidden in init stuff like sendchat
- ;=CHEST= not touched
- Global Const $HEADER_CHEST_OPEN = 0x59 ;Opens a chest (with key AFAIK)
- Global Const $HEADER_GOLD_MOVE = 0x82 ;Moves Gold (from chest to inventory, and otherway around IIRC)
- ;=MISSION=
- Global Const $HEADER_MODE_SWITCH = 0xA2 ;Toggles hard- and normal mode
- Global Const $HEADER_MISSION_ENTER = 0xAC ;Enter a mission/challenge
- Global Const $HEADER_MISSION_FOREIGN_ENTER = 0xAC ;Enters a foreign mission/challenge (no idea honestly)
- Global Const $HEADER_OUTPOST_RETURN = 0xAE ;Returns to outpost after /resign
- ;=CHAT=
- Global Const $HEADER_SEND_CHAT = 0x6A ;Needed for sending messages in chat
- ;=OTHER CONSTANTS=
- Global Const $HEADER_MAX_ATTRIBUTES_CONST_5 = 0x04 ;constant at word 5 of max attrib packet. Changed from 3 to four in most recent update
- Global Const $HEADER_MAX_ATTRIBUTES_CONST_22 = 0x04 ;constant at word 22 of max attrib packet. Changed from 3 to four in most recent update
- ; Version 3.7.11
- ; After the Update from 2019/05/01
- #include-once
- #RequireAdmin
- #include "GWA2_Headers.au3"
- If @AutoItX64 Then
- MsgBox(16, "Error!", "Please run all bots in 32-bit (x86) mode.")
- Exit
- EndIf
- #Region Declarations
- Local $Rendering = True
- Local $mGWA2Version = '3.7.11'
- Local $mKernelHandle
- Local $mGWProcHandle
- Local $mGWProcessId
- Local $mGWWindowHandle
- Local $mMemory
- Local $mLabels[1][2]
- Local $mBase = 0x00DE0000
- Local $mASMString
- Local $mASMSize
- Local $mASMCodeOffset
- Local $mGUI = GUICreate('GWA2')
- Local $mSkillActivate
- Local $mSkillCancel
- Local $mSkillComplete
- Local $mChatReceive
- Local $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 $mCharname
- Local $mBasePointer
- Local $mAgentBase
- Local $mMaxAgents
- Local $mMyID
- Local $mMapLoading
- Local $mCurrentTarget
- Local $mPing
- Local $mMapID
- Local $mLoggedIn
- Local $mRegion
- Local $mLanguage
- Local $mSkillBase
- Local $mSkillTimer
- Local $mBuildNumber
- Local $mZoomStill
- Local $mZoomMoving
- Local $mCurrentStatus
- Local $mQueueCounter
- Local $mQueueSize
- Local $mQueueBase
- Local $mTargetLogBase
- Local $mStringLogBase
- Local $mMapIsLoaded
- Local $mEnsureEnglish
- Local $mTraderQuoteID
- Local $mTraderCostID
- Local $mTraderCostValue
- Local $mDisableRendering
- Local $mAgentCopyCount
- Local $mAgentCopyBase
- Local $mCharslots
- #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 $mPacket = DllStructCreate('ptr;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword')
- Local $mPacketPtr = DllStructGetPtr($mPacket)
- 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 $mWriteChat = DllStructCreate('ptr')
- Local $mWriteChatPtr = DllStructGetPtr($mWriteChat)
- 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 $mSetAttributes = DllStructCreate("ptr;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword")
- Local $mSetAttributesPtr = DllStructGetPtr($mSetAttributes)
- Local $mMakeAgentArray = DllStructCreate('ptr;dword')
- Local $mMakeAgentArrayPtr = DllStructGetPtr($mMakeAgentArray)
- Local $mChangeStatus = DllStructCreate('ptr;dword')
- Local $mChangeStatusPtr = DllStructGetPtr($mChangeStatus)
- #EndRegion CommandStructs
- #Region Headers
- $SalvageMaterialsHeader = 0x80
- $SalvageModHeader = 0x81
- $IdentifyItemHeader = 0x72
- $EquipItemHeader = 0x36
- $UseItemHeader = 0x84
- $PickUpItemHeader = 0x45
- $DropItemHeader = 0x32
- $MoveItemHeader = 0x78
- $AcceptAllItemsHeader = 0x79
- $DropGoldHeader = 0x35
- $ChangeGoldHeader = 0x82
- $AddHeroHeader = 0x23
- $KickHeroHeader = 0x24
- $AddNpcHeader = 0xA5
- $KickNpcHeader = 0xAD
- $CommandHeroHeader = 0x1E
- $CommandAllHeader = 0x1F
- $LockHeroTargetHeader = 0x18
- $SetHeroAggressionHeader = 0x17
- $ChangeHeroSkillSlotStateHeader = 0x1C
- $SetDisplayedTitleHeader = 0x5E
- $RemoveDisplayedTitleHeader = 0x5F
- $GoPlayerHeader = 0x39
- $GoNPCHeader = 0x3F
- $GoSignpostHeader = 0x57
- $AttackHeader = 0x2C
- $MoveMapHeader = 0xB8
- $ReturnToOutpostHeader = 0xAE
- $EnterChallengeHeader = 0xAC
- $TravelGHHeader = 0xB7
- $LeaveGHHeader = 0xB9
- $AbandonQuestHeader = 0x12
- $CallTargetHeader = 0x2C
- $CancelActionHeader = 0x2E
- $OpenChestHeader = 0x59
- $DropBuffHeader = 0x2F
- $LeavePartyHeader = 0xA8
- $SwitchModeHeader = 0xA2
- $DonateFactionHeader = 0x3B
- $DialogHeader = 0x41
- $SkipCinematicHeader = 0x68
- $SetSkillbarSkillHeader = 0x62
- $LoadSkillbarHeader = 0x63
- $ChangeSecondProfessionHeader = 0x47
- $SendChatHeader = 0x6A
- $SetAttributesHeader = 0x10
- #EndRegion Headers
- #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', $mGWProcHandle, 'ptr', $aAddress, 'ptr', DllStructGetPtr($lData), 'int', DllStructGetSize($lData), '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', $mGWProcHandle, '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', $mGWProcHandle, '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', $mGWProcHandle, 'int', $aAddress, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($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', $mGWProcHandle, '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] <= 0 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 there is the size of the array)
- Func ScanGW()
- Local $lProcessList = processList("gw.exe")
- Local $lReturnArray[1] = [0]
- Local $lPid
- For $i = 1 To $lProcessList[0][0]
- MemoryOpen($lProcessList[$i][1])
- If $mGWProcHandle Then
- $lReturnArray[0] += 1
- ReDim $lReturnArray[$lReturnArray[0] + 1]
- $lReturnArray[$lReturnArray[0]] = ScanForCharname()
- EndIf
- MemoryClose()
- $mGWProcHandle = 0
- Next
- Return $lReturnArray
- EndFunc
- Func GetHwnd($aProc)
- Local $wins = WinList()
- For $i = 1 To UBound($wins)-1
- If (WinGetProcess($wins[$i][1]) == $aProc) And (BitAND(WinGetState($wins[$i][1]), 2)) Then Return $wins[$i][1]
- Next
- EndFunc
- ;~ Description: Injects GWA² into the game client. 3rd and 4th arguments are here for legacy purposes
- Func Initialize($aGW, $bChangeTitle = True, $notUsed1 = 0, $notUsed2 = 0)
- If IsString($aGW) Then
- Local $lProcessList = processList("gw.exe")
- For $i = 1 To $lProcessList[0][0]
- $mGWProcessId = $lProcessList[$i][1]
- $mGWWindowHandle = GetHwnd($mGWProcessId)
- MemoryOpen($mGWProcessId)
- If $mGWProcHandle Then
- If StringRegExp(ScanForCharname(), $aGW) = 1 Then ExitLoop
- EndIf
- MemoryClose()
- $mGWProcHandle = 0
- Next
- Else
- $mGWProcessId = $aGW
- $mGWWindowHandle = GetHwnd($mGWProcessId)
- MemoryOpen($aGW)
- ScanForCharname()
- EndIf
- If $mGWProcHandle = 0 Then Return False
- 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('ScanBaseOffset', -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)
- $mCurrentStatus = MemoryRead(GetScannedAddress('ScanChangeStatusFunction', -3))
- $mCharslots = MemoryRead(GetScannedAddress('ScanCharslots', 22))
- 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 + 138, 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('ScanLoadFinished', 79), 8))
- SetValue('PostMessage', '0x' & Hex(MemoryRead(GetScannedAddress('ScanPostMessage', 11)), 8))
- SetValue('Sleep', MemoryRead(MemoryRead(GetValue('ScanSleep') + 8) + 3))
- SetValue('SalvageFunction', MemoryRead(GetValue('ScanSalvageFunction') + 8) - 18)
- SetValue('SalvageGlobal', MemoryRead(MemoryRead(GetValue('ScanSalvageGlobal') + 8) + 1))
- SetValue('MoveFunction', '0x' & Hex(GetScannedAddress('ScanMoveFunction', 1), 8))
- SetValue('UseSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseSkillFunction', 1), 8))
- SetValue('ChangeTargetFunction', '0x' & Hex(GetScannedAddress('ScanChangeTargetFunction', -0x78), 8))
- SetValue('WriteChatFunction', '0x' & Hex(GetScannedAddress('ScanWriteChatFunction', 1), 8))
- SetValue('SellItemFunction', '0x' & Hex(GetScannedAddress('ScanSellItemFunction', -85), 8))
- SetValue('PacketSendFunction', '0x' & Hex(GetScannedAddress('ScanPacketSendFunction', 1), 8))
- SetValue('ActionBase', '0x' & Hex(MemoryRead(GetScannedAddress('ScanActionBase', -9)), 8))
- SetValue('ActionFunction', '0x' & Hex(GetScannedAddress('ScanActionFunction', -5), 8))
- SetValue('UseHeroSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseHeroSkillFunction', -0xA1), 8))
- SetValue('BuyItemFunction', '0x' & Hex(GetScannedAddress('ScanBuyItemFunction', 1), 8))
- SetValue('RequestQuoteFunction', '0x' & Hex(GetScannedAddress('ScanRequestQuoteFunction', -2), 8))
- SetValue('TraderFunction', '0x' & Hex(GetScannedAddress('ScanTraderFunction', -71), 8))
- SetValue('ClickToMoveFix', '0x' & Hex(GetScannedAddress("ScanClickToMoveFix", 1), 8))
- SetValue('ChangeStatusFunction', '0x' & Hex(GetScannedAddress("ScanChangeStatusFunction", 12), 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')
- ;EventSystem
- 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, $HEADER_SEND_CHAT)
- DllStructSetData($mWriteChat, 1, GetValue('CommandWriteChat'))
- DllStructSetData($mRequestQuote, 1, GetValue('CommandRequestQuote'))
- DllStructSetData($mRequestQuoteSell, 1, GetValue('CommandRequestQuoteSell'))
- DllStructSetData($mTraderBuy, 1, GetValue('CommandTraderBuy'))
- DllStructSetData($mTraderSell, 1, GetValue('CommandTraderSell'))
- DllStructSetData($mSalvage, 1, GetValue('CommandSalvage'))
- DllStructSetData($mSetAttributes, 1, GetValue('CommandPacketSend'))
- DllStructSetData($mSetAttributes, 2, 0x90)
- DllStructSetData($mSetAttributes, 3, $HEADER_SET_ATTRIBUTES)
- DllStructSetData($mMakeAgentArray, 1, GetValue('CommandMakeAgentArray'))
- DllStructSetData($mChangeStatus, 1, GetValue('CommandChangeStatus'))
- If $bChangeTitle Then WinSetTitle($mGWWindowHandle, '', 'Guild Wars - ' & GetCharname())
- Return $mGWWindowHandle
- EndFunc ;==>Initialize
- ;~ 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('894DD88B4D0C8955DC8B')
- _('ScanPostMessage:')
- AddPattern('6A00680080000051FF15')
- _('ScanTargetLog:')
- AddPattern('5356578BFA894DF4E8')
- _('ScanChangeTargetFunction:')
- AddPattern('33C03BDA0F95C033')
- _('ScanMoveFunction:')
- AddPattern('558BEC83EC2056578BF98D4DF0')
- _('ScanPing:')
- AddPattern('C390908BD1B9')
- _('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('8D0C765F5E8B')
- _('ScanBuyItemFunction:')
- AddPattern('558BEC81ECC000000053568B75085783FE108BFA8BD97614')
- _('ScanRequestQuoteFunction:')
- AddPattern('81EC9C00000053568B')
- _('ScanTraderFunction:')
- AddPattern('8B45188B551085')
- _('ScanTraderHook:')
- AddPattern('8955FC6A008D55F8B9BA')
- _('ScanSleep:')
- AddPattern('5F5E5B741A6860EA0000')
- _('ScanSalvageFunction:')
- AddPattern('8BFA8BD9897DF0895DF4')
- _('ScanSalvageGlobal:')
- AddPattern('8B018B4904A3')
- _('ScanSkillTimer:')
- AddPattern('85c974158bd62bd183fa64')
- _('ScanClickToMoveFix:')
- AddPattern('3DD301000074')
- _('ScanZoomStill:')
- AddPattern('3B448BCB')
- _('ScanZoomMoving:')
- AddPattern('50EB116800803B448BCE')
- _('ScanBuildNumber:')
- AddPattern('8D8500FCFFFF8D')
- _('ScanChangeStatusFunction:')
- AddPattern('C390909090909090909090568BF183FE04')
- _('ScanCharslots:')
- AddPattern('8B551041897E38897E3C897E34897E48897E4C890D')
- _('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', 'handle', $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', 'CreateRemoteThread', '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', 'WaitForSingleObject', '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' & $aPattern
- $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;dword;dword;dword')
- Local $lSearch, $lTmpMemData, $lTmpAddress, $lTmpBuffer = DllStructCreate('ptr'), $i
- While $lCurrentSearchAddress < 0x00900000
- Local $lMBI[7]
- DllCall($mKernelHandle, 'int', 'VirtualQueryEx', 'int', $mGWProcHandle, '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($lBuffer), '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', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lTmpAddress + 0x6, 'ptr', DllStructGetPtr($lTmpBuffer), '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, $aExpert = False)
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x690]
- Local $lSalvageSessionID = MemoryReadPtr($mBasePointer, $lOffset)
- If IsDllStruct($aItem) = 0 Then
- Local $lItemID = $aItem
- Else
- Local $lItemID = DllStructGetData($aItem, 'ID')
- EndIf
- Local $lSalvageKit = 0
- If $aExpert Then
- $lSalvageKit = FindExpertSalvageKit()
- Else
- $lSalvageKit = FindSalvageKit()
- EndIf
- If $lSalvageKit = 0 Then Return
- DllStructSetData($mSalvage, 2, $lItemID)
- DllStructSetData($mSalvage, 3, $lSalvageKit)
- DllStructSetData($mSalvage, 4, $lSalvageSessionID[1])
- Enqueue($mSalvagePtr, 16)
- EndFunc ;==>StartSalvage
- ;~ Description: Salvage the materials out of an item.
- Func SalvageMaterials()
- Return SendPacket(0x4, $HEADER_SALVAGE_MATS)
- EndFunc ;==>SalvageMaterials
- ;~ Description: Salvages a mod out of an item.
- Func SalvageMod($aModIndex)
- Return SendPacket(0x8, $HEADER_SALVAGE_MODS, $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, $HEADER_ITEM_ID, $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 ContinueLoop
- If GetRarity($lItem) == 2624 And $aGolds == False Then ContinueLoop
- 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
- Return SendPacket(0x8, $HEADER_ITEM_EQUIP, $lItemID)
- EndFunc ;==>EquipItem
- ;~ Description: Uses an item.
- Func UseItem($aItem)
- Local $lItemID
- If IsDllStruct($aItem) = 0 Then
- $lItemID = $aItem
- Else
- $lItemID = DllStructGetData($aItem, 'ID')
- EndIf
- Return SendPacket(0x8, $HEADER_ITEM_USE, $lItemID)
- EndFunc ;==>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
- Return SendPacket(0xC, $HEADER_ITEM_PICKUP, $lAgentID, 0)
- EndFunc ;==>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), 'Quantity')
- EndIf
- Else
- $lItemID = DllStructGetData($aItem, 'ID')
- If $aAmount > 0 Then
- $lAmount = $aAmount
- Else
- $lAmount = DllStructGetData($aItem, 'Quantity')
- EndIf
- EndIf
- Return SendPacket(0xC, $HEADER_ITEM_DROP, $lItemID, $lAmount)
- EndFunc ;==>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
- Return SendPacket(0x10, $HEADER_ITEM_MOVE, $lItemID, $lBagID, $aSlot - 1)
- EndFunc ;==>MoveItem
- ;~ Description: Accepts unclaimed items after a mission.
- Func AcceptAllItems()
- Return SendPacket(0x8, $HEADER_ITEMS_ACCEPT_UNCLAIMED, 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') Then $aQuantity = DllStructGetData($aItem, 'Quantity')
- DllStructSetData($mSellItem, 2, $aQuantity * DllStructGetData($aItem, 'Value'))
- 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 * ($aItem - 1)))
- DllStructSetData($mBuyItem, 4, $aQuantity * $aValue)
- Enqueue($mBuyItemPtr, 16)
- EndFunc ;==>BuyItem
- ;~ Description: Legacy function, use BuyIdentificationKit instead.
- Func BuyIDKit($aQuantity = 1)
- BuyIdentificationKit($aQuantity)
- EndFunc ;==>BuyIDKit
- ;~ Description: Buys an ID kit.
- Func BuyIdentificationKit($aQuantity = 1)
- BuyItem(5, $aQuantity, 100)
- EndFunc ;==>BuyIdentificationKit
- ;~ Description: Legacy function, use BuySuperiorIdentificationKit instead.
- Func BuySuperiorIDKit($aQuantity = 1)
- BuySuperiorIdentificationKit($aQuantity)
- EndFunc ;==>BuySuperiorIDKit
- ;~ Description: Buys a superior ID kit.
- Func BuySuperiorIdentificationKit($aQuantity = 1)
- BuyItem(6, $aQuantity, 500)
- EndFunc ;==>BuySuperiorIdentificationKit
- func BuySalvageKit($aQuantity = 1)
- buyItem(2, $aQuantity, 100)
- endFunc ;==>buySalvageKit
- func BuyExpertSalvageKit($aQuantity = 1)
- buyItem(3, $aQuantity, 400)
- endFunc ;==>buyExpertSalvageKit
- ;~ Description: Request a quote to buy an item from a trader. Returns true if successful.
- 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];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;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', $mGWProcHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGetSize($lItemStruct), 'int', '')
- If DllStructGetData($lItemStruct, 'ModelID') = $aModelID And DllStructGetData($lItemStruct, 'bag') = 0 And DllStructGetData($lItemStruct, 'AgentID') == 0 Then
- If $aExtraID = -1 Or DllStructGetData($lItemStruct, 'ExtraID') = $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
- Return SendPacket(0x8, $HEADER_GOLD_DROP, $lAmount)
- EndFunc ;==>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
- ChangeGold($lCharacter - $lAmount, $lStorage + $lAmount)
- EndFunc ;==>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
- ChangeGold($lCharacter + $lAmount, $lStorage - $lAmount)
- EndFunc ;==>WithdrawGold
- ;~ Description: Internal use for moving gold.
- Func ChangeGold($aCharacter, $aStorage)
- Return SendPacket(0xC, $HEADER_GOLD_MOVE, $aCharacter, $aStorage)
- EndFunc ;==>ChangeGold
- #EndRegion Item
- #Region H&H
- ;~ Description: Adds a hero to the party.
- Func AddHero($aHeroId)
- Return SendPacket(0x8, $HEADER_HERO_ADD, $aHeroId)
- EndFunc ;==>AddHero
- ;~ Description: Kicks a hero from the party.
- Func KickHero($aHeroId)
- Return SendPacket(0x8, $HEADER_HERO_KICK, $aHeroId)
- EndFunc ;==>KickHero
- ;~ Description: Kicks all heroes from the party.
- Func KickAllHeroes()
- Return SendPacket(0x8, $HEADER_HEROES_KICK, 0x24)
- EndFunc ;==>KickAllHeroes
- ;~ Description: Add a henchman to the party.
- Func AddNpc($aNpcId)
- Return SendPacket(0x8, $HEADER_HENCHMAN_ADD, $aNpcId)
- EndFunc ;==>AddNpc
- ;~ Description: Kick a henchman from the party.
- Func KickNpc($aNpcId)
- Return SendPacket(0x8, $HEADER_HENCHMAN_KICK, $aNpcId)
- EndFunc ;==>KickNpc
- ;~ Description: Clear the position flag from a hero.
- Func CancelHero($aHeroNumber)
- Local $lAgentID = GetHeroID($aHeroNumber)
- Return SendPacket(0x14, $HEADER_HERO_CLEAR_FLAG, $lAgentID, 0x7F800000, 0x7F800000, 0)
- EndFunc ;==>CancelHero
- ;~ Description: Clear the position flag from all heroes.
- Func CancelAll()
- Return SendPacket(0x10, $HEADER_PARTY_CLEAR_FLAG, 0x7F800000, 0x7F800000, 0)
- EndFunc ;==>CancelAll
- ;~ Description: Place a hero's position flag.
- Func CommandHero($aHeroNumber, $aX, $aY)
- Return SendPacket(0x14, $HEADER_HERO_PLACE_FLAG, GetHeroID($aHeroNumber), FloatToInt($aX), FloatToInt($aY), 0)
- EndFunc ;==>CommandHero
- ;~ Description: Place the full-party position flag.
- Func CommandAll($aX, $aY)
- Return SendPacket(0x10, $HEADER_PARTY_PLACE_FLAG, 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, $HEADER_HERO_LOCK, $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, $HEADER_HERO_AGGRESSION, $lHeroID, $aAggression)
- EndFunc ;==>SetHeroAggression
- ;~ Description: Disable a skill on a hero's skill bar.
- Func DisableHeroSkillSlot($aHeroNumber, $aSkillSlot)
- If Not GetIsHeroSkillSlotDisabled($aHeroNumber, $aSkillSlot) Then ChangeHeroSkillSlotState($aHeroNumber, $aSkillSlot)
- EndFunc ;==>DisableHeroSkillSlot
- ;~ Description: Enable a skill on a hero's skill bar.
- Func EnableHeroSkillSlot($aHeroNumber, $aSkillSlot)
- If GetIsHeroSkillSlotDisabled($aHeroNumber, $aSkillSlot) Then ChangeHeroSkillSlotState($aHeroNumber, $aSkillSlot)
- EndFunc ;==>EnableHeroSkillSlot
- ;~ Description: Internal use for enabling or disabling hero skills
- Func ChangeHeroSkillSlotState($aHeroNumber, $aSkillSlot)
- Return SendPacket(0xC, $HEADER_HERO_TOGGLE_SKILL, 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
- Func SetDisplayedTitle($aTitle = 0)
- If $aTitle Then
- Return SendPacket(0x8, $HEADER_TITLE_DISPLAY, $aTitle)
- Else
- Return SendPacket(0x4, $HEADER_TITLE_CLEAR)
- EndIf
- EndFunc ;==>SetDisplayedTitle
- #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)
- 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($lMe, '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
- Return SendPacket(0x8, $HEADER_AGENT_FOLLOW, $lAgentID)
- EndFunc ;==>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
- Return SendPacket(0xC, $HEADER_NPC_TALK, $lAgentID)
- EndFunc ;==>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($lMe, 'MoveY') == 0 Then
- $lBlocked += 1
- Move(DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, '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
- Return SendPacket(0xC, $HEADER_SIGNPOST_RUN, $lAgentID, 0)
- EndFunc ;==>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($lMe, 'MoveY') == 0 Then
- $lBlocked += 1
- Move(DllStructGetData($aAgent, 'X'), DllStructGetData($aAgent, '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
- Return SendPacket(0xC, $HEADER_ATTACK_AGENT, $lAgentID, $aCallTarget)
- EndFunc ;==>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 Return 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, $HEADER_MAP_TRAVEL, $aMapID, $aRegion, $aDistrict, $aLanguage, False)
- EndFunc ;==>MoveMap
- ;~ Description: Returns to outpost after resigning/failure.
- Func ReturnToOutpost()
- Return SendPacket(0x4, $HEADER_OUTPOST_RETURN)
- EndFunc ;==>ReturnToOutpost
- ;~ Description: Enter a challenge mission/pvp.
- Func EnterChallenge()
- Return SendPacket(0x8, $HEADER_MISSION_ENTER, 1)
- EndFunc ;==>EnterChallenge
- ;~ Description: Enter a foreign challenge mission/pvp.
- Func EnterChallengeForeign()
- Return SendPacket(0x8, $HEADER_MISSION_FOREIGN_ENTER, 0)
- EndFunc ;==>EnterChallengeForeign
- ;~ Description: Travel to your guild hall.
- Func TravelGH()
- Local $lOffset[3] = [0, 0x18, 0x3C]
- Local $lGH = MemoryReadPtr($mBasePointer, $lOffset)
- SendPacket(0x18, $HEADER_GUILDHALL_TRAVEL, 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, $HEADER_GUILDHALL_LEAVE, 1)
- Return WaitMapLoading()
- EndFunc ;==>LeaveGH
- #EndRegion Travel
- #Region Quest
- ;~ Description: Accept a quest from an NPC.
- Func AcceptQuest($aQuestID)
- Return SendPacket(0x8, $HEADER_QUEST_ACCEPT, '0x008' & Hex($aQuestID, 3) & '01')
- EndFunc ;==>AcceptQuest
- ;~ Description: Accept the reward for a quest.
- Func QuestReward($aQuestID)
- Return SendPacket(0x8, $HEADER_QUEST_REWARD, '0x008' & Hex($aQuestID, 3) & '07')
- EndFunc ;==>QuestReward
- ;~ Description: Abandon a quest.
- Func AbandonQuest($aQuestID)
- Return SendPacket(0x8, $HEADER_QUEST_ABANDON, $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
- Return SendPacket(0xC, $HEADER_CALL_TARGET, 0xA, $lTargetID)
- EndFunc ;==>CallTarget
- ;~ Description: Clear current target.
- Func ClearTarget()
- Return PerformAction(0xE3, 0x18)
- EndFunc ;==>ClearTarget
- ;~ Description: Target the nearest enemy.
- Func TargetNearestEnemy()
- Local $target = GetNearestEnemyToAgent(-2)
- ChangeTarget($target)
- ;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 + $aNumber, 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)
- EndFunc ;==>EnableRendering
- ;~ Description: Disable graphics rendering.
- Func DisableRendering()
- MemoryWrite($mDisableRendering, 1)
- EndFunc ;==>DisableRendering
- ;~ 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 = 'GWA2')
- 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', $mGWProcHandle, 'int', $lAddress, 'ptr', $mWriteChatPtr, 'int', 4, 'int', '')
- If StringLen($aMessage) > 100 Then WriteChat(StringTrimLeft($aMessage, 100), $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]')
- MemoryWrite($lAddress + 12, $aChannel & $lMessage, 'wchar[122]')
- DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHandle, 'int', $lAddress, 'ptr', $mSendChatPtr, 'int', 8, 'int', '')
- If StringLen($aMessage) > 120 Then SendChat(StringTrimLeft($aMessage, 120), $aChannel)
- EndFunc ;==>SendChat
- #EndRegion Chat
- #Region Misc
- ;~ Description: Change weapon sets.
- Func ChangeWeaponSet($aSet)
- Return PerformAction(0x8 + $aSet, 0x38 )
- EndFunc ;==>ChangeWeaponSet
- ;~ Description: Use a skill.
- Func UseSkill($aSkillSlot, $aTarget = 0, $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: Cancel current action.
- Func CancelAction()
- Return SendPacket(0x4, $HEADER_CANCEL_ACTION)
- EndFunc ;==>CancelAction
- ;~ Description: Same as hitting spacebar.
- Func ActionInteract()
- Return PerformAction(0x80, 0x18)
- EndFunc ;==>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, $HEADER_CHEST_OPEN, 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] = 0x510
- Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[5]
- $lOffset[3] = 0x508
- 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($mBasePointer, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr($lBuffStruct), 'int', DllStructGetSize($lBuffStruct), 'int', '')
- If (DllStructGetData($lBuffStruct, 'SkillID') == $aSkillID) And (DllStructGetData($lBuffStruct, 'TargetId') == ConvertID($aAgentID)) Then
- Return SendPacket(0x8, $HEADER_STOP_MAINTAIN_ENCH, DllStructGetData($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, $HEADER_PARTY_LEAVE)
- EndFunc ;==>LeaveGroup
- ;~ Description: Switches to/from Hard Mode.
- Func SwitchMode($aMode)
- Return SendPacket(0x8, $HEADER_MODE_SWITCH, $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, $HEADER_FACTION_DONATE, 0, 0, 0x1388)
- ElseIf StringLeft($aFaction, 1) = 'l' Then
- Return SendPacket(0x10, $HEADER_FACTION_DONATE, 0, 1, 0x1388)
- EndIf
- EndFunc ;==>DonateFaction
- ;~ Description: Open a dialog.
- Func Dialog($aDialogID)
- Return SendPacket(0x8, $HEADER_DIALOG, $aDialogID)
- EndFunc ;==>Dialog
- ;~ Description: Skip a cinematic.
- Func SkipCinematic()
- Return SendPacket(0x4, $HEADER_CINEMATIC_SKIP)
- EndFunc ;==>SkipCinematic
- ;~ Description: Change a skill on the skillbar.
- Func SetSkillbarSkill($aSlot, $aSkillID, $aHeroNumber = 0)
- Return SendPacket(0x14, $HEADER_SKILL_CHANGE, GetHeroID($aHeroNumber), $aSlot - 1, $aSkillID, 0)
- EndFunc ;==>SetSkillbarSkill
- ;~ Description: Load all skills onto a skillbar simultaneously.
- Func LoadSkillBar($aSkill1 = 0, $aSkill2 = 0, $aSkill3 = 0, $aSkill4 = 0, $aSkill5 = 0, $aSkill6 = 0, $aSkill7 = 0, $aSkill8 = 0, $aHeroNumber = 0)
- SendPacket(0x2C, $HEADER_BUILD_LOAD, 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 $lAttributeStr = ""
- Local $lAttributeLevelStr = ""
- Local $lTemplateType ; 4 Bits
- Local $lVersionNumber ; 4 Bits
- Local $lProfBits ; 2 Bits -> P
- Local $lProfPrimary ; P Bits
- Local $lProfSecondary ; P Bits
- Local $lAttributesCount ; 4 Bits
- Local $lAttributesBits ; 4 Bits -> A
- ;Local $lAttributes[1][2] ; A Bits + 4 Bits (for each Attribute)
- Local $lSkillsBits ; 4 Bits -> S
- Local $lSkills[8] ; S Bits * 8
- Local $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)
- For $i = 1 To $lAttributesCount
- ;Attribute ID
- $lAttributeStr &= Bin64ToDec(StringLeft($aTemplate, $lAttributesBits))
- If $i <> $lAttributesCount Then $lAttributeStr &= "|"
- $aTemplate = StringTrimLeft($aTemplate, $lAttributesBits)
- ;Attribute level of above ID
- $lAttributeLevelStr &= Bin64ToDec(StringLeft($aTemplate, 4))
- If $i <> $lAttributesCount Then $lAttributeLevelStr &= "|"
- $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)
- ChangeSecondProfession($lProfSecondary, $aHeroNumber)
- SetAttributes($lAttributeStr, $lAttributeLevelStr, $aHeroNumber)
- LoadSkillBar($lSkills[0], $lSkills[1], $lSkills[2], $lSkills[3], $lSkills[4], $lSkills[5], $lSkills[6], $lSkills[7], $aHeroNumber)
- EndFunc ;==>LoadSkillTemplate
- ;~ Description: Set attributes to the given values
- Func SetAttributes($fAttsID, $fAttsLevel, $aHeroNumber = 0)
- Local $lAttsID = StringSplit(String($fAttsID), "|")
- Local $lAttsLevel = StringSplit(String($fAttsLevel), "|")
- DllStructSetData($mSetAttributes, 4, GetHeroID($aHeroNumber))
- DllStructSetData($mSetAttributes, 5, $lAttsID[0]) ;# of attributes
- DllStructSetData($mSetAttributes, 22, $lAttsID[0]) ;# of attributes
- For $i = 1 To $lAttsID[0]
- DllStructSetData($mSetAttributes, 5 + $i, $lAttsID[$i]) ;ID ofAttributes
- Next
- For $i = 1 To $lAttsLevel[0]
- DllStructSetData($mSetAttributes, 22 + $i, $lAttsLevel[$i]) ;Attribute Levels
- Next
- Enqueue($mSetAttributesPtr, 152)
- EndFunc ;==>SetAttributes
- ;~ Description: Change your secondary profession.
- Func ChangeSecondProfession($aProfession, $aHeroNumber = 0)
- Return SendPacket(0xC, $HEADER_CHANGE_SECONDARY, 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', $mGWProcHandle, 'int', -1, 'int', -1)
- EndFunc ;==>ClearMemory
- ;~ Description: Changes the maximum memory Guild Wars can use.
- Func SetMaxMemory($aMemory = 157286400)
- DllCall($mKernelHandle, 'int', 'SetProcessWorkingSetSizeEx', 'int', $mGWProcHandle, 'int', 1, 'int', $aMemory, 'int', 6)
- EndFunc ;==>SetMaxMemory
- #EndRegion Misc
- #Region Online Status
- ;~ Description: Change online status. 0 = Offline, 1 = Online, 2 = Do not disturb, 3 = Away
- Func SetPlayerStatus($iStatus)
- If (($iStatus >= 0 And $iStatus <= 3) And (GetPlayerStatus() <> $iStatus)) Then
- DllStructSetData($mChangeStatus, 2, $iStatus)
- Enqueue($mChangeStatusPtr, 8)
- Return True
- Else
- Return False
- EndIf
- EndFunc ;==>SetPlayerStatus
- Func GetPlayerStatus()
- Return MemoryRead($mCurrentStatus)
- EndFunc ;==>GetPlayerStatus
- #EndRegion Online Status
- ;~ Description: Internal use only.
- Func Enqueue($aPtr, $aSize)
- DllCall($mKernelHandle, 'int', 'WriteProcessMemory', 'int', $mGWProcHandle, '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, 0x81C, 0x4]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetHeroTitle
- ;~ Description: Returns Gladiator title progress.
- Func GetGladiatorTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x7C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetGladiatorTitle
- ;~ Description: Returns Kurzick title progress.
- Func GetKurzickTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0xCC]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetKurzickTitle
- ;~ Description: Returns Luxon title progress.
- Func GetLuxonTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0xF4]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetLuxonTitle
- ;~ Description: Returns drunkard title progress.
- Func GetDrunkardTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x11C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetDrunkardTitle
- ;~ Description: Returns survivor title progress.
- Func GetSurvivorTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x16C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetSurvivorTitle
- ;~ Description: Returns max titles
- Func GetMaxTitles()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x194]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetMaxTitles
- ;~ Description: Returns lucky title progress.
- Func GetLuckyTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x25C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetLuckyTitle
- ;~ Description: Returns unlucky title progress.
- Func GetUnluckyTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x284]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetUnluckyTitle
- ;~ Description: Returns Sunspear title progress.
- Func GetSunspearTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x2AC]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetSunspearTitle
- ;~ Description: Returns Lightbringer title progress.
- Func GetLightbringerTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x324]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetLightbringerTitle
- ;~ Description: Returns Commander title progress.
- Func GetCommanderTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x374]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetCommanderTitle
- ;~ Description: Returns Gamer title progress.
- Func GetGamerTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 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, 0x81C, 0x4DC]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetLegendaryGuardianTitle
- ;~ Description: Returns sweets title progress.
- Func GetSweetTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x554]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetSweetTitle
- ;~ Description: Returns Asura title progress.
- Func GetAsuraTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x5F4]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetAsuraTitle
- ;~ Description: Returns Deldrimor title progress.
- Func GetDeldrimorTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x61C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetDeldrimorTitle
- ;~ Description: Returns Vanguard title progress.
- Func GetVanguardTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x644]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetVanguardTitle
- ;~ Description: Returns Norn title progress.
- Func GetNornTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 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, 0x81C, 0x694]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetNorthMasteryTitle
- ;~ Description: Returns party title progress.
- Func GetPartyTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x6BC]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetPartyTitle
- ;~ Description: Returns Zaishen title progress.
- Func GetZaishenTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 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, 0x81C, 0x70C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetTreasureTitle
- ;~ Description: Returns wisdom title progress.
- Func GetWisdomTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x734]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetWisdomTitle
- ;~ Description: Returns codex title progress.
- Func GetCodexTitle()
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x75C] ;0x7B8 before apr20
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetCodexTitle
- ;~ Description: Returns current Tournament points.
- Func GetTournamentPoints()
- Local $lOffset[5] = [0 ,0x18, 0x2C, 0, 0x18]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetTournamentPoints
- #EndRegion Titles
- #Region Faction
- ;~ Description: Returns current Kurzick faction.
- Func GetKurzickFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x748]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetKurzickFaction
- ;~ Description: Returns max Kurzick faction.
- Func GetMaxKurzickFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x7B8]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetMaxKurzickFaction
- ;~ Description: Returns current Luxon faction.
- Func GetLuxonFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x758]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetLuxonFaction
- ;~ Description: Returns max Luxon faction.
- Func GetMaxLuxonFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x7BC]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetMaxLuxonFaction
- ;~ Description: Returns current Balthazar faction.
- Func GetBalthazarFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x798]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetBalthazarFaction
- ;~ Description: Returns max Balthazar faction.
- Func GetMaxBalthazarFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x7C0]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetMaxBalthazarFaction
- ;~ Description: Returns current Imperial faction.
- Func GetImperialFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x76C]
- Local $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- Return $lReturn[1]
- EndFunc ;==>GetImperialFaction
- ;~ Description: Returns max Imperial faction.
- Func GetMaxImperialFaction()
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x7C4]
- 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: Returns if material is Rare.
- Func GetIsRareMaterial($aItem)
- If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
- If DllStructGetData($aItem, "Type") <> 11 Then Return False
- Return Not GetIsCommonMaterial($aItem)
- EndFunc ;==>GetIsRareMaterial
- ;~ Description: Returns if material is Common.
- Func GetIsCommonMaterial($aItem)
- If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
- Return BitAND(DllStructGetData($aItem, "Interaction"), 0x20) <> 0
- EndFunc ;==>GetIsCommonMaterial
- ;~ Description: Legacy function, use GetIsIdentified instead.
- Func GetIsIDed($aItem)
- Return GetIsIdentified($aItem)
- EndFunc ;==>GetIsIDed
- ;~ Description: Tests if an item is identified.
- Func GetIsIdentified($aItem)
- If Not IsDllStruct($aItem) Then $aItem = GetItemByItemID($aItem)
- Return BitAND(DllStructGetData($aItem, 'interaction'), 1) > 0
- EndFunc ;==>GetIsIdentified
- ;~ 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[' & DllStructGetData($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 Then
- 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 index;long id;ptr containerItem;long ItemsCount;ptr bagArray;ptr itemArray;long fakeSlots;long slots')
- Local $lBagPtr = MemoryReadPtr($mBasePointer, $lOffset)
- If $lBagPtr[1] = 0 Then Return
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lBagPtr[1], 'ptr', DllStructGetPtr($lBagStruct), 'int', DllStructGetSize($lBagStruct), 'int', '')
- Return $lBagStruct
- EndFunc ;==>GetBag
- ;~ 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];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;byte Slot')
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', DllStructGetData($lBag, 'ItemArray') + 4 * ($aSlot - 1), 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($lBuffer), 'int', '')
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, '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];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;byte Slot')
- Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0x4 * $aItemID]
- Local $lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGetSize($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];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;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', $mGWProcHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGetSize($lItemStruct), 'int', '')
- If DllStructGetData($lItemStruct, 'AgentID') = $lAgentID Then Return $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];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;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', $mGWProcHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGetSize($lItemStruct), 'int', '')
- If DllStructGetData($lItemStruct, 'ModelID') = $aModelID Then Return $lItemStruct
- Next
- EndFunc ;==>GetItemByModelID
- ;~ Description: Returns amount of gold in storage.
- Func GetGoldStorage()
- Local $lOffset[5] = [0, 0x18, 0x40, 0xF8, 0x94]
- 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, 0x90]
- 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 2992
- If DllStructGetData($lItem, 'Value') / 2 < $lUses Then
- $lKit = DllStructGetData($lItem, 'ID')
- $lUses = DllStructGetData($lItem, 'Value') / 2
- EndIf
- ContinueLoop
- EndSwitch
- Next
- Next
- Return $lKit
- EndFunc ;==>FindSalvageKit
- ;~ Description: Returns item ID of expert salvage kit in inventory.
- Func FindExpertSalvageKit()
- Local $lItem
- Local $lKit = 0
- Local $lUses = 101
- For $i = 1 To 4
- 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') / 10 < $lUses Then
- $lKit = DllStructGetData($lItem, 'ID')
- $lUses = DllStructGetData($lItem, 'Value') / 10
- EndIf
- Case Else
- ContinueLoop
- EndSwitch
- Next
- Next
- Return $lKit
- EndFunc ;==>FindExpertSalvageKit
- ;~ Description: Legacy function, use FindIdentificationKit instead.
- Func FindIDKit()
- Return FindIdentificationKit()
- EndFunc ;==>FindIDKit
- ;~ Description: Returns item ID of ID kit in inventory.
- Func FindIdentificationKit()
- Local $lItem
- Local $lKit = 0
- Local $lUses = 101
- For $i = 1 To 4
- 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 ;==>FindIdentificationKit
- ;~ 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 means)
- Func GetHeroProfession($aHeroNumber, $aSecondary = False)
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x6BC, 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($aHeroNumber), '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];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;float MoveX;float MoveY;byte unknown10[28];long Owner;byte unknown30[8];long ExtraType;byte unknown11[24];float AttackSpeed;float AttackSpeedModifier;word PlayerNumber;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 EnergyPercent;long MaxEnergy;byte unknown15[4];float HPPips;byte unknown16[4];float 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 unknown22[32];byte LastStrike;byte Allegiance;word WeaponType;word Skill;byte unknown23[4];word WeaponItemId;word OffhandItemId')
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lAgentPtr, 'ptr', DllStructGetPtr($lAgentStruct), 'int', DllStructGetSize($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 = -2)
- Return (GetAgentPtr($aAgentID) > 0 And $aAgentID < GetMaxAgents())
- EndFunc ;==>GetAgentExists
- ;~ Description: Returns the target of an agent.
- Func GetTarget($aAgent = -2)
- Local $lAgentID
- If IsDllStruct($aAgent) = 0 Then
- $lAgentID = ConvertID($aAgent)
- Else
- $lAgentID = DllStructGetData($aAgent, 'ID')
- EndIf
- Return MemoryRead(GetValue('TargetLogBase') + 4 * $lAgentID)
- EndFunc ;==>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)
- 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]
- If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 3 Then ContinueLoop
- If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLoop
- 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') - DllStructGetData($aAgent, 'Y')) ^ 2 + (DllStructGetData($lAgentArray[$i], 'X') - DllStructGetData($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 = -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]
- If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 6 Then ContinueLoop
- If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLoop
- 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 ContinueLoop
- If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLoop
- 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 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 ;==>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', $mGWProcHandle, 'int', $mAgentCopyBase, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($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;float MoveX;float MoveY;byte unknown10[28];long Owner;byte unknown30[8];long ExtraType;byte unknown11[24];float AttackSpeed;float AttackSpeedModifier;word PlayerNumber;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 EnergyPercent;long MaxEnergy;byte unknown15[4];float HPPips;byte unknown16[4];float 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 unknown22[32];byte LastStrike;byte Allegiance;word WeaponType;word Skill;byte unknown23[4];word WeaponItemId;word OffhandItemId')
- $lStruct = DllStructCreate('byte[448]', DllStructGetPtr($lReturnArray[$i]))
- DllStructSetData($lStruct, 1, DllStructGetData($lBuffer, $i))
- Next
- Return $lReturnArray
- EndFunc ;==>GetAgentArray
- Func GetPartySize()
- Local $lSize = 0, $lReturn
- Local $lOffset[5] = [0, 0x18, 0x4C, 0x54, 0]
- For $i=0 To 2
- $lOffset[4] = $i * 0x10 + 0xC
- $lReturn = MemoryReadPtr($mBasePointer, $lOffset)
- $lSize += $lReturn[1]
- Next
- Return $lSize
- EndFunc
- ;~ Description: Returns different States about Party. Check with BitAND.
- ;~ 0x8 = Leader starts Mission / Leader is travelling with Party
- ;~ 0x10 = Hardmode enabled
- ;~ 0x20 = Party defeated
- ;~ 0x40 = Guild Battle
- ;~ 0x80 = Party Leader
- ;~ 0x100 = Observe-Mode
- Func GetPartyState($aFlag)
- Local $lOffset[4] = [0, 0x18, 0x4C, 0x14]
- Local $lBitMask = MemoryReadPtr($mBasePointer,$lOffset)
- Return BitAND($lBitMask[1], $aFlag) > 0
- EndFunc ;==>GetPartyState
- Func GetPartyWaitingForMission()
- Return GetPartyState(0x8)
- EndFunc
- Func GetIsHardMode()
- Return GetPartyState(0x10)
- EndFunc
- Func GetPartyDefeated()
- Return GetPartyState(0x20)
- EndFunc
- ;~ Description Returns the "danger level" of each party member
- ;~ Param1: an array returned by GetAgentArray(). This is totally optional, but can greatly improve script speed.
- ;~ Param2: an array returned by GetParty() This is totally optional, but can greatly 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 ContinueLoop
- If Not GetIsLiving($aAgentArray[$i]) Then ContinueLoop
- If DllStructGetData($aAgentArray[$i], "Allegiance") > 3 Then ContinueLoop ; 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], "Team") <> 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 = -2, $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 ContinueLoop
- If Not GetIsLiving($aAgentArray[$i]) Then ContinueLoop
- If DllStructGetData($aAgentArray[$i], "Allegiance") > 3 Then ContinueLoop ; ignore NPCs, spirits, minions, pets
- If GetTarget(DllStructGetData($aAgentArray[$i], "ID")) == DllStructGetData($aAgent, "ID") Then
- If GetDistance($aAgentArray[$i], $aAgent) < 5000 Then
- If DllStructGetData($aAgentArray[$i], "Team") <> 0 Then
- If DllStructGetData($aAgentArray[$i], "Team") <> DllStructGetData($aAgent, "Team") Then
- $lCount += 1
- EndIf
- ElseIf DllStructGetData($aAgentArray[$i], "Allegiance") <> 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 = -2)
- 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($aAgent, 'MaxEnergy')
- EndFunc ;==>GetEnergy
- ;~ Description: Returns health of an agent. (Must have caused numerical change in health)
- Func GetHealth($aAgent = -2)
- If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
- Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxHP')
- EndFunc ;==>GetHealth
- ;~ Description: Tests if an agent is moving.
- Func GetIsMoving($aAgent = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- 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 = -2)
- If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
- Local $lLogin = DllStructGetData($aAgent, 'LoginNumber')
- Local $lOffset[6] = [0, 0x18, 0x2C, 0x80C, 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 = -2)
- 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] = 0x510
- Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[5]
- $lOffset[3] = 0x508
- 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] = 0x510
- Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[5]
- $lOffset[3] = 0x508
- 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($mBasePointer, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr($lBuffStruct), 'int', DllStructGetSize($lBuffStruct), 'int', '')
- If (DllStructGetData($lBuffStruct, 'SkillID') == $aSkillID) And (DllStructGetData($lBuffStruct, 'TargetId') == ConvertID($aAgentID)) 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] = 0x510
- Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[5]
- $lOffset[3] = 0x508
- 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, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lBuffStructAddress[0], 'ptr', DllStructGetPtr($lBuffStruct), '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 AdrenalineB3;dword Recharge3;dword Id3;dword Event3;long AdrenalineA4;long AdrenalineB4;dword Recharge4;dword Id4;dword Event4;long AdrenalineA5;long AdrenalineB5;dword Recharge5;dword Id5;dword Event5;long AdrenalineA6;long AdrenalineB6;dword Recharge6;dword Id6;dword Event6;long AdrenalineA7;long AdrenalineB7;dword Recharge7;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] = 0x6F0
- For $i = 0 To GetHeroCount()
- $lOffset[4] = $i * 0xBC
- Local $lSkillbarStructAddress = MemoryReadPtr($mBasePointer, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lSkillbarStructAddress[0], 'ptr', DllStructGetPtr($lSkillbarStruct), 'int', DllStructGetSize($lSkillbarStruct), 'int', '')
- If DllStructGetData($lSkillbarStruct, 'AgentId') == GetHeroID($aHeroNumber) 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' & $aSkillSlot)
- EndFunc ;==>GetSkillbarSkillAdrenaline
- ;~ Description: Returns the recharge time remaining of an equipped skill in milliseconds.
- Func GetSkillbarSkillRecharge($aSkillSlot, $aHeroNumber = 0)
- Local $lTimestamp = DllStructGetData(GetSkillbar($aHeroNumber), 'Recharge' & $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 campaign;long Type;long Special;long ComboReq;long Effect1;long Condition;long Effect2;long WeaponReq;byte Profession;byte Attribute;byte Unknown2[2];long PvPID;byte Combo;byte Target;byte unknown3;byte EquipType;byte Unknown4;byte Energy;byte Unknown5[2];dword Adrenaline;float Activation;float Aftercast;long Duration0;long Duration15;long Recharge;byte Unknown6[12];long Scale0;long Scale15;long BonusScale0;long BonusScale15;float AoERange;float ConstEffect;byte unknown7[44]')
- Local $lSkillStructAddress = $mSkillBase + 160 * $aSkillID
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lSkillStructAddress, 'ptr', DllStructGetPtr($lSkillStruct), 'int', DllStructGetSize($lSkillStruct), 'int', '')
- Return $lSkillStruct
- EndFunc ;==>GetSkillByID
- ;~ Description: Returns energy cost of a skill.
- Func GetEnergyCost($aSkillId)
- Local $lInitCost = DllStructGetData(GetSkillByID($aSkillId), 'energy')
- Switch $lInitCost
- Case 11
- Return 15
- Case 12
- Return 25
- Case Else
- Return $lInitCost
- EndSwitch
- EndFunc ;==>GetEnergyCost
- ;~ 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] = 0x638
- Local $lIndex = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[6]
- $lOffset[0] = 0
- $lOffset[1] = 0x18
- $lOffset[2] = 0x2C
- $lOffset[3] = 0x62C
- $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] = 0x510
- Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
- ReDim $lOffset[5]
- $lOffset[3] = 0x508
- 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, $lOffset)
- 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 TimeStamp')
- $lEffectStructAddress[1] = $lEffectStructAddress[0] + 24 * $i
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[1], 'ptr', DllStructGetPtr($lReturnArray[$i + 1]), 'int', 24, 'int', '')
- Next
- ExitLoop
- Else
- Local $lReturn = DllStructCreate('long SkillId;long EffectType;long EffectId;long AgentId;float Duration;long TimeStamp')
- For $i = 0 To $lEffectCount[1] - 1
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[0] + 24 * $i, 'ptr', 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, 0x740]
- 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, 0x84C]
- 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, 0x850]
- 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 after map is loaded.
- Local $lMapLoading
- Local $lDeadlock = TimerInit()
- InitMapLoad()
- Do
- Sleep(100)
- $lMapLoading = GetMapLoading()
- If $lMapLoading == 2 Then $lDeadlock = TimerInit()
- If TimerDiff($lDeadlock) > $aDeadlock And $aDeadlock > 0 Then Return False
- Until $lMapLoading <> 2 And GetMapIsLoaded() And (GetMapID() = $aMapID Or $aMapID = 0)
- RndSleep(500)
- Return True
- EndFunc ;==>WaitMapLoading
- ;~ Description: Returns quest struct.
- Func GetQuestByID($aQuestID = 0)
- Local $lQuestStruct = DllStructCreate('long id;long LogState;byte unknown1[12];long MapFrom;float X;float Y;byte unknown2[8];long MapTo')
- Local $lQuestPtr, $lQuestLogSize, $lQuestID
- Local $lOffset[4] = [0, 0x18, 0x2C, 0x534]
- $lQuestLogSize = MemoryReadPtr($mBasePointer, $lOffset)
- If $aQuestID = 0 Then
- $lOffset[1] = 0x18
- $lOffset[2] = 0x2C
- $lOffset[3] = 0x528
- $lQuestID = MemoryReadPtr($mBasePointer, $lOffset)
- $lQuestID = $lQuestID[1]
- Else
- $lQuestID = $aQuestID
- EndIf
- Local $lOffset[5] = [0, 0x18, 0x2C, 0x52C, 0]
- For $i = 0 To $lQuestLogSize[1]
- $lOffset[4] = 0x34 * $i
- $lQuestPtr = MemoryReadPtr($mBasePointer, $lOffset)
- DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lQuestPtr[0], 'ptr', DllStructGetPtr($lQuestStruct), 'int', DllStructGetSize($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 the number of character slots you have. Only works on character select.
- Func GetCharacterSlots()
- Return MemoryRead($mCharslots)
- 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, $aRandom = 0.05)
- Local $lRandom = $aAmount * $aRandom
- Sleep(Random($aAmount - $lRandom, $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 $mGWWindowHandle
- 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] >= $aPosY) _
- Or ($aAreaCoords[$j][1] < $aPosY And $aAreaCoords[$i][1] >= $aPosY)) _
- And ($aAreaCoords[$i][0] <= $aPosX Or $aAreaCoords[$j][0] <= $aPosX) Then
- If ($aAreaCoords[$i][0] + ($aPosY - $aAreaCoords[$i][1]) / ($aAreaCoords[$j][1] - $aAreaCoords[$i][1]) * ($aAreaCoords[$j][0] - $aAreaCoords[$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, $aParam4 = 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
- Return $lReturn
- EndFunc ;==>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 = '', $aChatReceive = '', $aLoadFinished = '')
- 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, StringInStr($lMessage, "</a>") - 6)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 3
- $lChannel = "All"
- $lSender = StringMid($lMessage, 6, StringInStr($lMessage, "</a>") - 6)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 9
- $lChannel = "Guild"
- $lSender = StringMid($lMessage, 6, StringInStr($lMessage, "</a>") - 6)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 11
- $lChannel = "Team"
- $lSender = StringMid($lMessage, 6, StringInStr($lMessage, "</a>") - 6)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 12
- $lChannel = "Trade"
- $lSender = StringMid($lMessage, 6, StringInStr($lMessage, "</a>") - 6)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 10
- If StringLeft($lMessage, 3) == "-> " Then
- $lChannel = "Sent"
- $lSender = StringMid($lMessage, 10, StringInStr($lMessage, "</a>") - 10)
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Else
- $lChannel = "Global"
- $lSender = "Guild Wars"
- EndIf
- Case 13
- $lChannel = "Advisory"
- $lSender = "Guild Wars"
- $lMessage = StringTrimLeft($lMessage, StringInStr($lMessage, "<quote>") + 6)
- Case 14
- $lChannel = "Whisper"
- $lSender = StringMid($lMessage, 7, StringInStr($lMessage, "</a>") - 7)
- $lMessage = StringTrimLeft($lMessage, StringInStr($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', 'handle', $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')
- WriteDetour('StringLogStart', 'StringLogProc')
- WriteDetour('StringFilter1Start', 'StringFilter1Proc')
- WriteDetour('StringFilter2Start', 'StringFilter2Proc')
- EndFunc ;==>ModifyMemory
- ;~ Description: Internal use only.
- Func WriteDetour($aFrom, $aTo)
- WriteBinary('E9' & SwapEndian(Hex(GetLabelInfo($aTo) - GetLabelInfo($aFrom) - 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 ecx,dword[edi]')
- _('mov dword[eax],ecx')
- _('mov ecx,dword[ecx*4+TargetLogBase]')
- _('mov dword[eax+4],ecx')
- _('mov ecx,dword[edi+4]')
- _('mov dword[eax+8],ecx')
- _('mov ecx,dword[edi+8]')
- _('mov dword[eax+c],ecx')
- _('push 1')
- _('push eax')
- _('push CallbackEvent')
- _('push dword[CallbackHandle]')
- _('call 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 ecx,dword[edi]')
- _('mov dword[eax],ecx')
- _('mov ecx,dword[ecx*4+TargetLogBase]')
- _('mov dword[eax+4],ecx')
- _('mov ecx,dword[edi+4]')
- _('mov dword[eax+8],ecx')
- _('push 2')
- _('push eax')
- _('push CallbackEvent')
- _('push dword[CallbackHandle]')
- _('call 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 ecx,dword[edi]')
- _('mov dword[eax],ecx')
- _('mov ecx,dword[ecx*4+TargetLogBase]')
- _('mov dword[eax+4],ecx')
- _('mov ecx,dword[edi+4]')
- _('mov dword[eax+8],ecx')
- _('push 3')
- _('push eax')
- _('push CallbackEvent')
- _('push dword[CallbackHandle]')
- _('call 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[ebx]')
- _('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')
- _('ljmp ChatLogReturn')
- EndFunc ;==>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,80')
- _('cmp ebx,200')
- _('jnz LoadClearStringsLoop')
- _('xor ebx,ebx')
- _('mov eax,TargetLogBase')
- _('LoadClearTargetsLoop:')
- _('mov dword[eax],0')
- _('inc ebx')
- _('add eax,4')
- _('cmp ebx,200')
- _('jnz LoadClearTargetsLoop')
- _('push 5')
- _('push 0')
- _('push CallbackEvent')
- _('push dword[CallbackHandle]')
- _('call dword[PostMessage]')
- _('popad')
- _('mov esp,ebp')
- _('pop ebp')
- _('retn 10')
- EndFunc ;==>CreateLoadFinished
- ;~ Description: Internal use only.
- Func CreateStringLog()
- _('StringLogProc:')
- _('pushad')
- _('mov eax,dword[NextStringType]')
- _('test eax,eax')
- _('jz StringLogExit')
- _('cmp eax,1')
- _('jnz StringLogFilter2')
- _('mov eax,dword[ebp+37c]')
- _('jmp 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')
- _('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')
- _('CommandChangeStatus:')
- _('mov ecx,dword[eax+4]')
- _('call ChangeStatusFunction')
- _('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) - StringInStr($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($aASM) - 5) & '}'
- Case StringLeft($aASM, 5) = 'ljne '
- $mASMSize += 6
- $mASMString &= '0F85{' & StringRight($aASM, StringLen($aASM) - 5) & '}'
- Case StringLeft($aASM, 4) = 'jmp ' And StringLen($aASM) > 7
- $mASMSize += 2
- $mASMString &= 'EB(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringLeft($aASM, 4) = 'jae '
- $mASMSize += 2
- $mASMString &= '73(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringLeft($aASM, 3) = 'jz '
- $mASMSize += 2
- $mASMString &= '74(' & StringRight($aASM, StringLen($aASM) - 3) & ')'
- Case StringLeft($aASM, 4) = 'jnz '
- $mASMSize += 2
- $mASMString &= '75(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringLeft($aASM, 4) = 'jbe '
- $mASMSize += 2
- $mASMString &= '76(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringLeft($aASM, 3) = 'ja '
- $mASMSize += 2
- $mASMString &= '77(' & StringRight($aASM, StringLen($aASM) - 3) & ')'
- Case StringLeft($aASM, 3) = 'jl '
- $mASMSize += 2
- $mASMString &= '7C(' & StringRight($aASM, StringLen($aASM) - 3) & ')'
- Case StringLeft($aASM, 4) = 'jge '
- $mASMSize += 2
- $mASMString &= '7D(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringLeft($aASM, 4) = 'jle '
- $mASMSize += 2
- $mASMString &= '7E(' & StringRight($aASM, StringLen($aASM) - 4) & ')'
- Case StringRegExp($aASM, 'mov eax,dword[[][a-z,A-Z]{4,}[]]')
- $mASMSize += 5
- $mASMString &= 'A1[' & StringMid($aASM, 15, StringLen($aASM) - 15) & ']'
- Case StringRegExp($aASM, 'mov ebx,dword[[][a-z,A-Z]{4,}[]]')
- $mASMSize += 6
- $mASMString &= '8B1D[' & StringMid($aASM, 15, StringLen($aASM) - 15) & ']'
- Case StringRegExp($aASM, 'mov ecx,dword[[][a-z,A-Z]{4,}[]]')
- $mASMSize += 6
- $mASMString &= '8B0D[' & StringMid($aASM, 15, StringLen($aASM) - 15) & ']'
- Case StringRegExp($aASM, 'mov edx,dword[[][a-z,A-Z]{4,}[]]')
- $mASMSize += 6
- $mASMString &= '8B15[' & StringMid($aASM, 15, StringLen($aASM) - 15) & ']'
- 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, StringLen($aASM) - 21) & ']'
- Case StringRegExp($aASM, 'lea edi,dword\[edx\+[a-z,A-Z]{4,}\]')
- $mASMSize += 7
- $mASMString &= '8D3C15[' & StringMid($aASM, 19, StringLen($aASM) - 19) & ']'
- Case StringRegExp($aASM, 'cmp dword[[][a-z,A-Z]{4,}[]],[-[:xdigit:]]')
- $lBuffer = StringInStr($aASM, ",")
- $lBuffer = ASMNumber(StringMid($aASM, $lBuffer + 1), True)
- If @extended Then
- $mASMSize += 7
- $mASMString &= '833D[' & StringMid($aASM, 11, StringInStr($aASM, ",") - 12) & ']' & $lBuffer
- Else
- $mASMSize += 10
- $mASMString &= '813D[' & StringMid($aASM, 11, StringInStr($aASM, ",") - 12) & ']' & $lBuffer
- EndIf
- Case StringRegExp($aASM, 'cmp ecx,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 6
- $mASMString &= '81F9[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'cmp ebx,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 6
- $mASMString &= '81FB[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'cmp eax,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= '3D[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'add eax,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= '05[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'mov eax,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= 'B8[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'mov ebx,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= 'BB[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'mov esi,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= 'BE[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'mov edi,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= 'BF[' & StringRight($aASM, StringLen($aASM) - 8) & ']'
- Case StringRegExp($aASM, 'mov edx,[a-z,A-Z]{4,}') And StringInStr($aASM, ',dword') = 0
- $mASMSize += 5
- $mASMString &= 'BA[' & StringRight($aASM, StringLen($aASM) - 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($aASM) - 15) & ']'
- Case StringRegExp($aASM, 'lea eax,dword[[]edx[*]4[+][a-z,A-Z]{4,}[]]')
- $mASMSize += 7
- $mASMString &= '8D0495[' & StringMid($aASM, 21, StringLen($aASM) - 21) & ']'
- Case StringRegExp($aASM, 'mov eax,dword[[]ecx[*]4[+][a-z,A-Z]{4,}[]]')
- $mASMSize += 7
- $mASMString &= '8B048D[' & StringMid($aASM, 21, StringLen($aASM) - 21) & ']'
- Case StringRegExp($aASM, 'mov ecx,dword[[]ecx[*]4[+][a-z,A-Z]{4,}[]]')
- $mASMSize += 7
- $mASMString &= '8B0C8D[' & StringMid($aASM, 21, StringLen($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($aASM) - 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($aASM) - 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
- EndSelect
- EndFunc ;==>_
- ;~ 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($lExpression), 8))
- $lCurrentOffset += 4
- $lInExpression = False
- $lExpression = ''
- Case '}'
- $mASMString &= SwapEndian(Hex(GetLabelInfo($lExpression) - 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
- Func ToggleRendering()
- If $Rendering Then
- DisableRendering()
- WinSetState(GetWindowHandle(), "", @SW_HIDE)
- ClearMemory()
- Else
- EnableRendering()
- WinSetState(GetWindowHandle(), "", @SW_SHOW)
- EndIf
- $Rendering = Not $Rendering
- EndFunc
- Func GetNumberOfFoesInRangeOfAgent($aAgent = -2, $aRange = 1250)
- Local $lAgent, $lDistance
- Local $lCount = 0
- If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
- For $i = 1 To GetMaxAgents()
- $lAgent = GetAgentByID($i)
- If BitAND(DllStructGetData($lAgent, 'typemap'), 262144) Then ContinueLoop
- If DllStructGetData($lAgent, 'Type') <> 0xDB Then ContinueLoop
- If DllStructGetData($lAgent, 'Allegiance') <> 3 Then ContinueLoop
- If DllStructGetData($lAgent, 'HP') <= 0 Then ContinueLoop
- If BitAND(DllStructGetData($lAgent, 'Effects'), 0x0010) > 0 Then ContinueLoop
- $lDistance = GetDistance($lAgent)
- If $lDistance > $aRange Then ContinueLoop
- $lCount += 1
- Next
- Return $lCount
- EndFunc ;==>GetNumberOfFoesInRangeOfAgent
- Func IsRecharged($lSkill)
- Return GetSkillbarSkillRecharge($lSkill) == 0
- EndFunc ;==>IsRecharged
- Func _PurgeHook()
- ; ToggleRendering()
- Sleep(Random(4000, 5000))
- ; ToggleRendering()
- EndFunc ;==>_PurgeHook
- #EndRegion Other Functions
Add Comment
Please, Sign In to add comment