; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ; before starting, Ctrl+F for every instance of Send/ControlSend ; update the hotkeys to the hotkeys you have set ; Set your zoom, then never adjust it, or else the macro will click the wrong coordinates. ; ========================================================================================== ; -=KEYS YOU MUST SET UP=- ; ; win+p ===> POPULATE vars with saved values ; win+s ===> SAVE vars to an ini file, that way next run only needs to do win+p ; ; ; ctrl+1 TOP LEFT NARROW ; ctrl+2 BOTTOM RIGHT NARROW ; ctrl+3 TOP LEFT WIDE ; ctrl+4 BOTTOM RIGHT WIDE ; ctrl+7 BLACK FLY WING IN A HOTKEY BAR, See http://i.imgur.com/HoOge.jpg or http://puu.sh/bbVpg/b1f83532fa.jpg for visual instructions ; Storage update (only if you need to use storage!!) - Open your inventory and select a point on the upper left of the window. the script drags items out of your inventory to the right and up *LEAVE YOUR INVENTORY OPEN!!* ; ctrl+8 UPPER LEFT ; win+h healer ; win+w warper ; win+t tool dealer ; win+b buy button to open tool dealer ; win+d down arrow in the dealer ; ctrl+m set target map id to where you're at ; -=EXECUTE=- ; Set your last warp to the desired destination, start off in town and press Home. Press End to pause the script. PACKETVER := 20151104 #SingleInstance Force #MaxThreadsPerHotkey 1 #NoEnv #Warn #UseHook #InstallKeybdHook #InstallMouseHook SetWorkingDir %A_ScriptDir% SetKeyDelay -1,-1,-1 SetBatchLines -1 #Include ragaddr.ahk #Include classMemory.ahk ; for iaras ;targetMap := 1600221794 ;targetMap := 1600942195 ; TIME SPENT (IN MS) WAITING FOR MAPS TO LOAD mapChangeDelay := 1500 ; TIME BETWEEN SENDING STUFF TO NPC npcDelay := 650 ; YOUR ASPD DELAY aspdDelay := 0 ; RETURN TO TOWN TIMER (AGI/BLESS) returnTime := 235000 ; !!!LAST WARP ENTER AMOUNT (CHANGES DEPENDING ON SERVER)!!! lastWarpEnterCount := 1 ; DON'T CHANGE purchaseWings := 0 ; HEAL AFTER BUFFING? rehealAfterBuffs := 0 ; this is set for AC on F9, TS on F2, and awakes on F6 buffs := Array( "{F5}", "{F2}", "{F6}") buffTimers := Array(4*60*1000,30*1000,30*60*1000) buffAlwaysInTown := Array( 1, 1, 1) Tick_buffTimers := Object() for idxvalue, keyvalue in buffTimers { Tick_buffTimers.Insert(0) } searchColors := Object() searchColors.Insert(0x00FF00) ;GREEN ; ENEMY COLOR SEARCH ; jokers = 0x8894F9, porings = 0x8C94FF, (ADD NEW COLOR REMINDERS HERE) Tick_LastFood := A_TickCount - foodTime*2 g_addrMapNameRsw := 0xE48608 ;0x00814268 ; 0x00D1805C October 20, 2014 client addresses g_addrWeightMax := 0x00E492BC ; 0x0083C54C ; 0x00D18DA8 g_addrWeightMax := 0x00E492BC ;0x0083C54C ; 0x00D18DA8 g_addrWeight := 0x00E492C8 ;0x0083C558 ; 0x00D18DB4 g_addrCHP := 0xE4CAF4 ;0x0083E1B4 ; 0x00D1CA6C ;g_addrMHP := ;0x0083E1B8 ; 0x00D1CA70 ;g_addrCSP := ;0x0083E1BC ; 0x00D1CA74 ;g_addrMSP := ;0x0083E1C0 ; g_addrMHP := g_addrCHP+4 g_addrCSP := g_addrMHP+4 g_addrMSP := g_addrCSP+4 ;skillinitial := 10 ; ========================================================================================== ; YOU DON'T NEED TO CHANGE ANYTHING HERE ^1:: { MouseGetPos tl_n_xpos, tl_n_ypos return } ^2:: { MouseGetPos br_n_xpos, br_n_ypos return } ^3:: { MouseGetPos tl_w_xpos, tl_w_ypos return } ^4:: { MouseGetPos br_w_xpos, br_w_ypos return } ^7:: ; FLY WINGS { MouseGetPos fwing_xpos, fwing_ypos purchaseWings := 0 return } ^8:: ; INVENTORY (UPPER LEFT) { MouseGetPos tl_inventory_xpos, tl_inventory_ypos br_inventory_xpos := tl_inventory_xpos + 120 br_inventory_ypos := tl_inventory_ypos + 40 return } ^M:: { WinGet mPID, PID, A targetMap := ReadMemory(g_addrMapNameRsw, mPID) } #H:: ; HEALER { MouseGetPos hxpos, hypos return } #W:: ; WARPER { MouseGetPos wxpos, wypos return } #T:: ; TOOL DEALER { MouseGetPos txpos, typos return } #B:: ; TOOL DEALER BUY WINDOW { MouseGetPos bxpos, bypos return } #D:: ; DOWN ARROW { MouseGetPos dxpos, dypos return } #Q:: ; Tool dealers BUY confirm button {MouseGetPos qxpos, qypos return } #S:: { SaveVariables() return } #P:: { LoadVariables() return } ; ========================================================================================== Home:: { SetKeyDelay -1,-1,-1 WinGet mPID, PID, A maxWeight := ReadMemory(g_addrWeightMax, mPID) ; ========================================================================================== ; ACTION ; ========================================================================================== loop { Sleep %mapChangeDelay% wingAttempts := 0 skillAttempts := 0 UseHealer() ;Selfbuff() ;EquipGear() if ( rehealAfterBuffs = 1 ) { UseHealer() } UseWarper(lastWarpEnterCount) Sleep %mapChangeDelay% Loop { Sleep 50 if ( (A_TickCount - Tick_LastBuff) >= returnTime ) { ReturnToTown() Break } result := ReadMemory(g_addrMapNameRsw, mPID) if ( result != targetMap ) { ReturnToTown() Break } ; if ( CheckFlyWings() = 0) ; { ; ReturnToTown() ; BuyFlyWings(100) ; Break ; } if ( CheckHPSP() = 0) { ReturnToTown() Break } if ( CheckWeight() >= 84 ) { ReturnToTown() UseStorage() Break } for idxvalue, keyvalue in Tick_buffTimers { if ( (A_TickCount - keyvalue) >= buffTimers[idxvalue] ) { ControlSend ,,% buffs[idxvalue], ahk_pid %mPID% Tick_buffTimers[idxvalue] := A_TickCount Sleep getASPDDelay() + 200 ;300 } } if ( skillAttempts >= 18) { ControlSend ,,{F1}, ahk_pid %mPID% Sleep 380 ;500 wingAttempts := wingAttempts + 1 skillAttempts := 0 } if ( wingAttempts >= 300) { ReturnToTown() Break } else { for idxvalue, colorvalue in searchColors { ;ErrorLevel := 5 PixelSearch FoundX, FoundY, %tl_n_xpos%, %tl_n_ypos%, %br_n_xpos%, %br_n_ypos%, %colorvalue%, 0, Fast if (ErrorLevel = 0) { Cast(FoundX, FoundY) } else { PixelSearch FoundX, FoundY, %tl_w_xpos%, %tl_w_ypos%, %br_w_xpos%, %br_w_ypos%, %colorvalue%, 0, Fast if (ErrorLevel = 0) { Cast(FoundX, FoundY) } else { ControlSend ,,{F1}, ahk_pid %mPID% ; teleport hotkey Sleep 580 ;700 skillAttempts := 0 wingAttempts := wingAttempts + 1 } } } } } } return ; ========================================================================================== UseFood() { global ; FOOD HOTKEY ControlSend ,,{F6}, ahk_pid %mPID% Sleep 100 Tick_LastFood := A_TickCount return } ; ========================================================================================== EquipGear() { global Sleep 200 ControlSend ,,{F5}, ahk_pid %mPID% Sleep 200 return } ; ========================================================================================== UseStorage() { global SetMouseDelay 20 ControlSend ,,{F11}, ahk_pid %mPID% Sleep %npcDelay% itemColors := Object() ;itemColors.Insert(0x949CF7) ;witherless rose ;itemColors.Insert(0xEEC5CE) ;crystal shitmirror ;itemColors.Insert(0xBD8C9C) ;crystal shitmirror (AGAIN) itemColors.Insert(0x0000FF) ;fuckin everything itemColors.Insert(0x0000FF) ;fuckin everything ;itemColors.Insert(0x00FFFF) ;YELLOW ;itemColors.Insert(0x00FF00) ;GREEN ;itemColors.Insert(0xFFFF00) ;CYAN ;itemColors.Insert(0x00FFA5) ;ORANGE ; doubled up on leaf colors ;itemColors.Insert(0x94d6c5) ;itemColors.Insert(0x94d6c5) for idxvalue, colorvalue in itemColors { PixelSearch FoundX, FoundY, %tl_inventory_xpos%, %tl_inventory_ypos%, %br_inventory_xpos%, %br_inventory_ypos%, colorvalue, 0, Fast if (ErrorLevel = 0) { Sleep 500 MouseMove %FoundX%, %FoundY% Sleep 1000 ;MouseClickDrag L, 0, 0, 300, 50, 10, R MouseClickDrag L, 0, 0, 0, -80, 10, R Sleep 1000 ControlSend ,,{Enter}, ahk_pid %mPID% Sleep 1000 } } SetMouseDelay -1 ReturnToTown() return } ; ========================================================================================== CheckWeight() { global currentWeight := ReadMemory(g_addrWeight, mPID) return round(currentWeight * 100 / maxWeight) } ; ========================================================================================== ReadMemory(MADDRESS, PROGRAM) { cm_exe := new _ClassMemory(PROGRAM, "", proccopy) if (ErrorLevel) MsgBox % "ClassMemory errorlevel: " . ErrorLevel if (A_LastError) MsgBox % "ClassMemory LastError: " . A_LastError if !isObject(cm_exe) { MsgBox % "Failed to open a handle" if (proccopy = 0) MsgBox % "The program isn't running (not found) or you passed an incorrect program identifier parameter. In some cases _ClassMemory.setSeDebugPrivilege() may be required. " else if (proccopy = "") MsgBox % "OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. _ClassMemory.setSeDebugPrivilege() may also be required. Consult A_LastError for more information." ExitApp } return cm_exe.read(MADDRESS) } ; ========================================================================================== CheckHPSP() { global current := ReadMemory(g_addrCHP, mPID) maximum := ReadMemory(g_addrMHP, mPID) If ( Floor( current * 100 / maximum ) <= 25 ) { return 0 } ;read sp, pot if needed current := ReadMemory(g_addrCSP, mPID) maximum := ReadMemory(g_addrMSP, mPID) If ( Floor( current * 100 / maximum ) <= 25 ) { return 0 } return 1 } ; ========================================================================================== BuyFlyWings(amount) { global SetMouseDelay 20 ;MorningRO MouseMove %txpos%, %typos%, 10 ; Tool Dealer Sleep 500 Click %txpos%, %typos% Sleep %npcDelay% Loop 3 { Send {Enter} Sleep %npcDelay% } MouseMove %dxpos%, %dypos%, 1 ; to click arrow down Sleep 400 MouseClickDrag L, 0, 0, 75, 60, 30, R ; Fl ywing Drag & Drop Choose amount and choose it. Make sure the y between both is CONSTANT r you will buy other shit Sleep 1000 SendInput %amount% Sleep 500 Send {Enter} MouseMove %qxpos%, %qypos%, 1 Sleep %npcDelay% Click %qxpos%, %qypos% Sleep 500 SetMouseDelay -1 if (CheckWeight() >= 85) { UseStorage() } return } ; ========================================================================================== CheckFlyWings() { global PixelGetColor color, %fwing_xpos%, %fwing_ypos%, 10 ; position of flywings in your hotkey bar if (color = 0xFFFFFF) { return 0 } return 1 } ; ========================================================================================== ReturnToTown() { global Sleep getASPDDelay() ControlSend ,,{Insert},ahk_pid %mPID% ;@go town hotkey --> set it to a single key (eg `), because alt sends are completely unreliable Sleep %mapChangeDelay% } ; ========================================================================================== UseWarper(lastWarpEnterCount) ;lwEnterCount { global Sleep %npcDelay% MouseMove %wxpos%, %wypos% Sleep 300 Click %wxpos%, %wypos% Sleep %npcDelay% Loop %lastWarpEnterCount% ;lwEnterCount { Sleep %npcDelay% ControlSend ,,{Enter},ahk_pid %mPID% } } ; ========================================================================================== UseHealer() { global Sleep %npcDelay% MouseMove %hxpos%, %hypos% Sleep 300 Click %hxpos%, %hypos% Sleep %npcDelay% Tick_LastBuff := A_TickCount } ; ========================================================================================== ; ========================================================================================== Selfbuff() { global WinGetActiveStats windowName, windowWidth, windowHeight, winX, winY winCenterX := windowWidth >> 1 winCenterY := windowHeight >> 1 Sleep 250 for idxvalue, keyvalue in buffAlwaysInTown { if ( keyvalue == 0) continue ControlSend ,,% buffs[idxvalue], ahk_pid %mPID% Sleep GetASPDDelay() + 300 Tick_buffTimers[idxvalue] := A_TickCount } } ;================================================================= ; ========================================================================================== Cast(x, y) { global Loop 3 { ControlSend ,,{F3},ahk_pid %mPID% ; skill hotkey Sleep 10 Click %x%, %y% Sleep 10 } skillAttempts := skillAttempts + 1 return } ; ========================================================================================== LoadVariables() { global IniRead tl_n_xpos, autofarm.ini, search_position, tl_n_x, 0 IniRead tl_n_ypos, autofarm.ini, search_position, tl_n_y, 0 IniRead br_n_xpos, autofarm.ini, search_position, br_n_x, 0 IniRead br_n_ypos, autofarm.ini, search_position, br_n_y, 0 IniRead tl_w_xpos, autofarm.ini, search_position, tl_w_x, 0 IniRead tl_w_ypos, autofarm.ini, search_position, tl_w_y, 0 IniRead br_w_xpos, autofarm.ini, search_position, br_w_x, 0 IniRead br_w_ypos, autofarm.ini, search_position, br_w_y, 0 IniRead fwing_xpos, autofarm.ini, wnd_position, fwing_x, 0 IniRead fwing_ypos, autofarm.ini, wnd_position, fwing_y, 0 IniRead tl_inventory_xpos, autofarm.ini, wnd_position, tl_inv_x, 0 IniRead tl_inventory_ypos, autofarm.ini, wnd_position, tl_inv_y, 0 IniRead br_inventory_xpos, autofarm.ini, wnd_position, br_inv_x, 0 IniRead br_inventory_ypos, autofarm.ini, wnd_position, br_inv_y, 0 IniRead hxpos, autofarm.ini, npc_position, healer_x, 0 IniRead hypos, autofarm.ini, npc_position, healer_y, 0 IniRead txpos, autofarm.ini, npc_position, dealer_x, 0 IniRead typos, autofarm.ini, npc_position, dealer_y, 0 IniRead wxpos, autofarm.ini, npc_position, warper_x, 0 IniRead wypos, autofarm.ini, npc_position, warper_y, 0 IniRead bxpos, autofarm.ini, npc_position, buy_x, 0 IniRead bypos, autofarm.ini, npc_position, buy_y, 0 IniRead dxpos, autofarm.ini, npc_position, down_x, 0 IniRead dypos, autofarm.ini, npc_position, down_y, 0 IniRead qxpos, autofarm.ini, npc_position, button_x, 0 IniRead qypos, autofarm.ini, npc_position, button_y, 0 ; ENEMY COLOR SEARCH ; jokers = 0x8894F9, porings = 0x8C94FF, (ADD NEW COLOR REMINDERS HERE) ;IniRead searchColor, autofarm.ini, search_setting, enemy_color, 0x8C94FF ;IniRead searchTolerance, autofarm.ini, search_setting, color_tolerance, 0 IniRead targetMap, autofarm.ini, search_setting, target_map } ; ========================================================================================== SaveVariables() { global ; SEARCH WINDOW IniWrite %tl_n_xpos%, autofarm.ini, search_position, tl_n_x IniWrite %tl_n_ypos%, autofarm.ini, search_position, tl_n_y IniWrite %br_n_xpos%, autofarm.ini, search_position, br_n_x IniWrite %br_n_ypos%, autofarm.ini, search_position, br_n_y IniWrite %tl_w_xpos%, autofarm.ini, search_position, tl_w_x IniWrite %tl_w_ypos%, autofarm.ini, search_position, tl_w_y IniWrite %br_w_xpos%, autofarm.ini, search_position, br_w_x IniWrite %br_w_ypos%, autofarm.ini, search_position, br_w_y ; FLY WINGS IniWrite %fwing_xpos%, autofarm.ini, wnd_position, fwing_x IniWrite %fwing_ypos%, autofarm.ini, wnd_position, fwing_y ; STORAGE IniWrite %tl_inventory_xpos%, autofarm.ini, wnd_position, tl_inv_x IniWrite %tl_inventory_ypos%, autofarm.ini, wnd_position, tl_inv_y IniWrite %br_inventory_xpos%, autofarm.ini, wnd_position, br_inv_x IniWrite %br_inventory_ypos%, autofarm.ini, wnd_position, br_inv_y ;HEALER IniWrite %hxpos%, autofarm.ini, npc_position, healer_x IniWrite %hypos%, autofarm.ini, npc_position, healer_y ;TOOL DEALER IniWrite %txpos%, autofarm.ini, npc_position, dealer_x IniWrite %typos%, autofarm.ini, npc_position, dealer_y ; WARPER IniWrite %wxpos%, autofarm.ini, npc_position, warper_x IniWrite %wypos%, autofarm.ini, npc_position, warper_y ; BUY BUTTON / to open the shop IniWrite %bxpos%, autofarm.ini, npc_position, buy_x IniWrite %bypos%, autofarm.ini, npc_position, buy_y ; Buy buttin to buy the item IniWrite %qxpos%, autofarm.ini, npc_position, button_x IniWrite %qypos%, autofarm.ini, npc_position, button_y ; DOWN ARROW IniWrite %dxpos%, autofarm.ini, npc_position, down_x IniWrite %dypos%, autofarm.ini, npc_position, down_y IniWrite %targetMap%, autofarm.ini, search_setting, target_map ;IniWrite %searchColor%, autofarm.ini, search_setting, enemy_color ;IniWrite %searchTolerance%, autofarm.ini, search_setting, color_tolerance return } ; ========================================================================================== getASPDDelay() { Global tick, aspdDelay, g_addrDelayASPD, mPID ;Return 500 If ( (A_TickCount - tick) >= 2000 ) ;update interval of 2 sec { tick := A_TickCount aspdDelay := 2 * ReadMemory(g_addrDelayASPD, mPID) + 10 } Return aspdDelay } ; ========================================================================================== } End::Pause