Ok guys it took me many hours to figure this out so don't give up and I'll try to help you out as much as I can. Hope this works for you as well as it did for me.
What it does is:
Player 1 hits 1 time and player 2 parries that hit.
Player 2 hits 1 time and player 1 parries that hit.
x times, untill emo mode.
Emo mode is where both players hits each other x times without parry
Then it rests and repeats all over.
This program runs in AutoHotKey. Download it in
www.autohotkey.com
First, there has to be two accounts. It can be either 2 different people or two accounts under the same owner. If you have two accounts under the same owner then you should have a virtual PC on your computer so it thinks there's 2 computers.
How to install:
Anyway, each person must chose either server or client. One person will be client, the other will be server (Remember that).
Remember to copy the scripts to
C:\AHK\ (It must be to that directory cause it creates a preference file later).
Paste the script on a notepad. Server side must save as server.ahk and client side must save as client.ahk
The ONLY thing you need to edit are the KEY CONFIGURATION, which you can find at the beginning of each script. This is a link that has the shortcuts to every key in the keyboard
http://www.autohotkey.com/docs/commands/Send.htm
My KEY CONFIGURATION looks like this:
; -----------KEY CONFIGURATION--------------
khit = {LButton}
kparrydown = {v down}
kparryup = {v up}
karm = {r}
krest = {0}
kmove = {w}
kmenuopen = {RButton}
kmenuclose = {RButton}
kmenuclick = left
khit is the button you use to attack.
kparrydown and kparry up you must put in the button you use to parry but leave the down and up.
karm is the button you use to unsheath. krest is the button you have rest on.
kmove is the button you use to move forward or stand up.
kmenuopen and kmenuclose is the button you use to open and close menu. and
kmenuclick is the button you use to choose things in the menu.
Once you have that save the text as .ahk file. (The client side will do client. ahk and the serverside will do server.ahk)
Ok second step is, once you open it.
Server side will need to put the in the Local IP. To get that you go to Start, Run, and type CMD. The command prompt should appear and you type in IPCONFIG You can now see your local IP. Enter that IP on the server side.
Client side, if it's over the internet, the player with the server script must go to
www.myip.dk and give that IP address to the client side.
Remember to use the same port and NAT it on your router/firewall. (I used
8750). (I personally disconnected my router and did a direct connection to make it easier. IE. My local IP was the same as my network IP.)
You will also get a window to set up your ingame paperdoll, bag and weapons. Remember to press 1 on the weapons slot in paperdoll, press 2 on the shield slot in the paperdoll (Do it in the slot not on an equipped weapon). Press 3 in the upper left corner of your backpack. Press 4 in the lower right corner of your backpack. Then 5 press over the weapon you will be using and 6 over the shield. If you're using 2h weapons then press both numbers over the same weapon. Remember when you press 5 and 6 over the weapon to place it in a distinguishable color because that's how it detects the weapons, thru pixels. Once you finish this step hit done.
I think by this moment it will ask your melee options.
Without armor I use:
Number of hits:10
Number of emo hits:3
Rest: 50
Delay between hits: (1h 900) (2h 3000)
With armor I use:
Number of hits:10
Number of emo hits:10
Rest:50
Delay between hits: same
Finally here are the 2 scripts. Remember one char must be server the other must be client.
Server:
; ------------------------------------------
; ------------SERVERSCRIPT------------------
; ---------------v-0.03b--------------------
; -----------KEY CONFIGURATION--------------
khit = {RButton}
kparrydown = {LButton down}
kparryup = {LButton up}
karm = {MButton}
krest = {7}
kmove = {numpad8}
kmenuopen = {PgDn}
kmenuclose = {PgDn}
kmenuclick = right
; -------CHECK CONFIGURATION SECTION--------
Gosub, IniReadSettings
if (Network_Address = "ERROR" )
{
Gosub, IPPORTGUI
return
}
if (oEmo = "ERROR" OR oHits = "ERROR" OR oShields = "ERROR" OR oHitDelay = "ERROR" OR oRest = "ERROR" OR oProfile = "ERROR" )
{
Gosub, MeleeOptionsGUI
return
}
if (oEmo = "" OR oHits = "" OR oShields = "" OR oHitDelay = "" OR oRest = "" OR oProfile = "" )
{
Gosub, MeleeOptionsGUI
return
}
if (pweapon = "" OR pweapon = "ERROR" OR pshield = "" OR pshield = "ERROR")
{
Gosub, BPSetup
return
}
if (pxu = "ERROR")
{
Gosub, BPSetup
return
}
Main:
Gui, Destroy
Gui, Add, Button, gIPPORTGUI, IP and Port Setup
Gui, Add, Button, gBPSetup, Backpack and Paperdoll Setup
Gui, Add, Button, gItemSearchGUI, Item Search Test
Gui, Add, Button, gKeySetupGUI, Key Setup
Gui, Add, Button, gTeleportGUI, Teleporthack
Gui, Add, Button, gMeleeOptionsGUI, Melee Options
Gui, Add, Button, gMeleeStart, Melee Start
Gui, Add, Button, gAbout, About
Gui, Show
Gosub Connection_Init
return
MeleeStart:
Gui, Submit, NoHide
loop
{
;Gosub, IniReadSettings
weapons = 1
counter = 1
;change = 10
dcast = 5000
darm = 1000
dsmall = 1000
dserver = 200
sleep 3000
loop
{
if(oProfile = 1 OR oProfile = 2)
{
;Hit start
SendText = parry %oHitDelay%
SendData(conectioncheck,SendText)
sleep dserver
send % khit
sleep oHitDelay
sleep 100
;Hit end
}
if(oProfile = 1 OR oProfile = 3 )
{
;Parry start
SendText = hit %oHitDelay%
SendData(conectioncheck,SendText)
dparry := oHitDelay - 400
sleep 500
send % kparrydown
sleep dparry
send % kparryup
;Parry end
}
sleep dserver
if(counter = oHits)
{
;Emo-donkey-mode
loop, % oEmo
{
;Hit start
SendText = hit %oHitDelay%
SendData(conectioncheck,SendText)
sleep dserver
send % khit
sleep oHitDelay
sleep 100
;Hit end
}
sleep 1000
SendText = rest %oRest%
SendData(conectioncheck,SendText)
counter = 0
;rest start
loop, % oRest
{
send % karm
sleep darm
send % krest
sleep dserver
send % khit
}
sleep darm
loop, 3
{
send % kmove
sleep dsmall
}
sleep 2000
;rest stop
send % kmenuopen
sleep 1000
;Weapon Change Start
Gosub, SearchWeaponPaperdoll
sleep 1000
if oShields = 1
Gosub, SearchShieldPaperdoll
sleep 2000
send % kmenuclose
sleep 1000
send % karm
sleep darm
;Weapon Change Stop
sleep 5000
}
counter++
}
}
SentText =
return
; ------------GUI-MISC------------------
Restart:
Reload
return
ItemSearchGUI:
Gui, Destroy
Gui, Add, Text,, Remove your weapon and shield from the paperdoll!
Gui, Add, Text,, Mouse have to be in menu mode, not mouselook mode:
Gui, Add, Text,, Click button 1 ingame to test weapon search and equip paperdoll.
Gui, Add, Text,, Click button 2 ingame to test shield search and equip paperdoll.
Gui, Add, Button, gRestart, Exit
Gui, Show
Loop
{
if GetKeyState("1","P")
{
Gosub, SearchWeaponPaperdoll
}
else if GetKeyState("2","P")
{
Gosub, SearchShieldPaperdoll
}
}
return
MeleeOptionsGUI:
Gui, Destroy
Gui, Add, Text,, Number of hits before going to emo:
Gui, Add, Edit, voHits
Gui, Add, Text,, Number of emo-hits:
Gui, Add, Edit, voEmo
Gui, Add, Text,, Delay between hits, in ms (1 sec = 1000 ms):
Gui, Add, Edit, voHitDelay
Gui, Add, Text,, How many times to rest 1200ms:
Gui, Add, Edit, voRest
Gui, Add, Text,, Check if using shields:
Gui, Add, Checkbox, voShields
Gui, Add, Text,, Profile 1: Server and client hit n parry
Gui, Add, Text,, Profile 2: Server hit only, client parry only
Gui, Add, Text,, Profile 3: Server parry only, client hit only
Gui, Add, Text,, Select a profile:
Gui, Add, DropDownList, voProfile, 1|2|3
Gui, Add, Button, gIniMelee, Save
Gui, Add, Button, gRestart, Exit
Gui, Show
return
IniMelee:
Gui, Submit
IniWrite, %oHits%, C:\ahk\config.ini, MeleeOptions, Hits
IniWrite, %oEmo%, C:\ahk\config.ini, MeleeOptions, Emo
IniWrite, %oShields%, C:\ahk\config.ini, MeleeOptions, Shields
IniWrite, %oHitDelay%, C:\ahk\config.ini, MeleeOptions, HitDelay
IniWrite, %oRest%, C:\ahk\config.ini, MeleeOptions, Rest
IniWrite, %oProfile%, C:\ahk\config.ini, MeleeOptions, Profile
Reload
return
KeySetupGUI:
MsgBox Not done yet, will be added in the future.
return
TeleportGUI:
MsgBox HAR! You damn dirty cheating punk! Got ya noob
return
About:
MsgBox Network connection code was made by Zed Gecko @ Autohotkey forum. Thanks!
MsgBox Rest was made by a donkey. Yada yada blah blah... Version 0.03b
return
IPPORTGUI:
Gui, Destroy
Gui, Add, Text,, Please enter your network IP:
Gui, Add, Edit, vIP
Gui, Add, Text,, Please enter your network port:
Gui, Add, Edit, vPort
Gui, Add, Button, gIniIPPort, Save
Gui, Add, Button, gRestart, Exit
Gui, Show
return
IniIPPort:
Gui, Submit
IniWrite, %IP%, C:\ahk\config.ini, Network, IP
IniWrite, %Port%, C:\ahk\config.ini, Network, Port
Reload
return
; ------------TrainerSetupHandling------------------
BPSetup:
Gui, Destroy
Gui, Add, Text,, Paperdoll:
Gui, Add, Text,, Push key 1 in upper left above your weapon slots
Gui, Add, Text,, Push key 2 in lower right under your shield slots
Gui, Add, Text,, Backpack:
Gui, Add, Text,, Push key 3 in upper left (inside the wood please) corner of your backpack
Gui, Add, Text,, Push key 4 in lower right (inside the wood please) corner of your backpack
Gui, Add, Text,, Click the backpack, then push key 5 On your weapon and wait untill the mouse moves back (try to pick a unike color on that item, if possible)
Gui, Add, Text,, Click the backpack, then push key 6 On your shield and wait untill the mouse moves back (try to pick a unike color on that item, if possible)
Gui, Add, Button, gRestart, Done
Gui, Show
loop
{
if GetKeyState("1","P")
{
Gosub, IniWriteUpperPaperdoll
}
else if GetKeyState("2","P")
{
Gosub, IniWriteLowerPaperdoll
}
else if GetKeyState("3","P")
{
Gosub, IniWriteUpperBackpack
}
else if GetKeyState("4","P")
{
Gosub, IniWriteLowerBackpack
}
else if GetKeyState("5","P")
{
Gosub, IniWriteWeaponPixel
}
else if GetKeyState("6","P")
{
Gosub, IniWriteShieldPixel
}
}
return
IniReadSettings:
IniRead, pweapon, C:\AHK\config.ini, Items, weapon
IniRead, pshield, C:\AHK\config.ini, Items, shield
IniRead, pxu, C:\AHK\config.ini, paperdollCordsUpperLeft, x
IniRead, pyu, C:\AHK\config.ini, paperdollCordsUpperLeft, y
IniRead, pxl, C:\AHK\config.ini, paperdollCordsLowerRight, x
IniRead, pyl, C:\AHK\config.ini, paperdollCordsLowerRight, y
IniRead, bxu, C:\AHK\config.ini, backpackCordsUpperLeft, x
IniRead, byu, C:\AHK\config.ini, backpackCordsUpperLeft, y
IniRead, bxl, C:\AHK\config.ini, backpackCordsLowerRight, x
IniRead, byl, C:\AHK\config.ini, backpackCordsLowerRight, y
IniRead, Network_Address, C:\AHK\config.ini, Network, IP
IniRead, Network_Port, C:\AHK\config.ini, Network, Port
IniRead, oHits, C:\AHK\config.ini, MeleeOptions, Hits
IniRead, oEmo, C:\AHK\config.ini, MeleeOptions, Emo
IniRead, oShields, C:\AHK\config.ini, MeleeOptions, Shields
IniRead, oHitDelay, C:\AHK\config.ini, MeleeOptions, HitDelay
IniRead, oRest, C:\AHK\config.ini, MeleeOptions, Rest
IniRead, oProfile, C:\AHK\config.ini, MeleeOptions, Profile
return
IniWriteUpperPaperdoll:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, paperdollCordsUpperLeft, x
IniWrite, %y%, C:\ahk\config.ini, paperdollCordsUpperLeft, y
return
IniWriteLowerPaperdoll:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, paperdollCordsLowerRight, x
IniWrite, %y%, C:\ahk\config.ini, paperdollCordsLowerRight, y
return
IniWriteUpperBackpack:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, backpackCordsUpperLeft, x
IniWrite, %y%, C:\ahk\config.ini, backpackCordsUpperLeft, y
return
IniWriteLowerBackpack:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, backpackCordsLowerRight, x
IniWrite, %y%, C:\ahk\config.ini, backpackCordsLowerRight, y
return
; ------------PixelSearchHandlingNEW------------------
IniWriteWeaponPixel:
MouseGetPos, x, y
MouseMove, 0, 0
sleep 1000
PixelGetColor, color, %x%, %y%
IniWrite, %color%, C:\ahk\config.ini, Items, weapon
sleep 1000
MouseMove, x, y
return
IniWriteShieldPixel:
MouseGetPos, x, y
MouseMove, 0, 0
sleep 1000
PixelGetColor, color, %x%, %y%
IniWrite, %color%, C:\ahk\config.ini, Items, shield
sleep 1000
MouseMove, x, y
return
; ------------ItemSearchHandling------------------
SearchWeaponPaperdoll:
px := round((pxl - pxu )/2+ pxu)
py := round(pyu-(pyl - pyu ))
MouseClick, %kmenuclick%, %px%, %py%, 1
sleep 300
PixelSearch oX, oY, pxu, pyu, pxl, pyl, pweapon, 1, Fast
if ErrorLevel
Gosub, SearchWeaponBackpack
return
return
SearchShieldPaperdoll:
px := round((pxl - pxu )/2+ pxu)
py := round(pyu-(pyl - pyu ))
MouseClick, %kmenuclick%, %px%, %py%, 1
sleep 300
PixelSearch, oX, oY, pxu, pyu, pxl, pyl, pshield, 1, Fast
if ErrorLevel
Gosub, SearchShieldBackpack
return
return
SearchWeaponBackpack:
bx := round((bxl - bxu )/2 + bxu)
by := round((byl - byu )/2 + byu)
MouseClick, %kmenuclick%, %bx%, %by%, 1
sleep 300
PixelSearch, oX, oY, bxu, byu, bxl, byl, pweapon, 1, Fast
if ErrorLevel
return
else
MouseClick, %kmenuclick%, %oX%, %oY%, 3
return
return
SearchShieldBackpack:
bx := round((bxl - bxu )/2 + bxu)
by := round((byl - byu )/2 + byu)
MouseClick, %kmenuclick%, %bx%, %by%, 1
sleep 300
PixelSearch, oX, oY, bxu, byu, bxl, byl, pshield, 1, Fast
if ErrorLevel
return
else
MouseClick, %kmenuclick%, %oX%, %oY%, 3
return
return
Menu:
sleep 200
send % kmenuopen
sleep 200
return
; ------------ConnectionHandling------------------
Connection_Init:
OnExit, ExitSub ; For connection cleanup purposes.
socket := PrepareForIncomingConnection(Network_Address, Network_Port)
if socket = -1 ; Connection failed (it already displayed the reason).
ExitApp
Process, Exist ; This sets ErrorLevel to this script's PID (it's done this way to support compiled scripts).
DetectHiddenWindows On
ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel)
DetectHiddenWindows Off
NotificationMsg = 0x5555 ; An arbitrary message number, but should be greater than 0x1000.
OnMessage(NotificationMsg, "ReceiveData")
FD_READ = 1 ; Received when data is available to be read.
FD_CLOSE = 32 ; Received when connection has been closed.
FD_CONNECT = 20 ; Recieved when connection has been made.
if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, "UInt", ScriptMainWindowId, "UInt", NotificationMsg, "Int", FD_READ|FD_CLOSE|FD_CONNECT)
{
MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
ExitApp
}
Loop ; Wait for incomming connections
{
conectioncheck := DllCall("Ws2_32\accept", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress)
if conectioncheck> 1
{
MsgBox Incoming connection accepted
break
}
sleep 500
}
return
PrepareForIncomingConnection(IPAddress, Port)
{
VarSetCapacity(wsaData, 32) ; The struct is only about 14 in size, so 32 is conservative.
result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsaData) ; Request Winsock 2.0 (0x0002)
if ErrorLevel
{
MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required.
return -1
}
if result ; Non-zero, which means it failed (most Winsock functions return 0 upon success).
{
MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
return -1
}
AF_INET = 2
SOCK_STREAM = 1
IPPROTO_TCP = 6
socket := DllCall("Ws2_32\socket", "Int", AF_INET, "Int", SOCK_STREAM, "Int", IPPROTO_TCP)
if socket = -1
{
MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
return -1
}
SizeOfSocketAddress = 16
VarSetCapacity(SocketAddress, SizeOfSocketAddress)
InsertInteger(2, SocketAddress, 0, AF_INET) ; sin_family
InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2) ; sin_port
InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), SocketAddress, 4, 4) ; sin_addr.s_addr
if DllCall("Ws2_32\bind", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress)
{
MsgBox % "bind() indicated ---- Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?"
return -1
}
if DllCall("Ws2_32\listen", "UInt", socket, "UInt", "SOMAXCONN")
{
MsgBox % "LISTEN() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?"
return -1
}
return socket ; Indicate success by returning a valid socket ID rather than -1.
}
ReceiveData(wParam, lParam)
{
global ShowRecieved
socket := wParam
ReceivedDataSize = 4096 ; Large in case a lot of data gets buffered due to delay in processing previous data.
Loop
{
VarSetCapacity(ReceivedData, ReceivedDataSize, 0)
ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", socket, "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0)
if ReceivedDataLength = 0 ; The connection was gracefully closed,
ExitApp ; The OnExit routine will call WSACleanup() for us.
if ReceivedDataLength = -1
{
WinsockError := DllCall("Ws2_32\WSAGetLastError")
if WinsockError = 10035 ; WSAEWOULDBLOCK, which means "no more data to be read".
return 1
if WinsockError <10054> welcome, strlen(welcome) + 1, NULL);
}
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
; The caller must ensure that pDest has sufficient capacity. To preserve any existing contents in pDest,
; only pSize number of bytes starting at pOffset are altered in it.
{
Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data.
DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger>> 8*(A_Index-1) & 0xFF)
}
ExitSub: ; This subroutine is called automatically when the script exits for any reason.
DllCall("Ws2_32\WSACleanup")
ExitApp
Client:
; ------------------------------------------
;--------------CLIENTSCRIPT-----------------
; ---------------v-0.03b--------------------
; -----------KEY CONFIGURATION--------------
khit = {LButton}
kparrydown = {p down}
kparryup = {p up}
karm = {r}
krest = {7}
kmove = {up}
kmenuopen = {RButton}
kmenuclose = {LButton}
kmenuclick = right
; -------CHECK CONFIGURATION SECTION--------
Gosub, IniReadSettings
if (Network_Address = "ERROR" )
{
Gosub, IPPORTGUI
return
}
if (oShields = "ERROR")
{
Gosub, MeleeOptionsGUI
return
}
if (oShields = "")
{
Gosub, MeleeOptionsGUI
return
}
if (pweapon = "" OR pweapon = "ERROR" OR pshield = "" OR pshield = "ERROR")
{
Gosub, BPSetup
return
}
if (pxu = "ERROR")
{
Gosub, BPSetup
return
}
Gui, Add, Button, gIPPORTGUI, IP and Port Setup
Gui, Add, Button, gBPSetup, Backpack and Paperdoll Setup
Gui, Add, Button, gItemSearchGUI, Item Search Test
Gui, Add, Button, gKeySetupGUI, Key Setup
Gui, Add, Button, gTeleportGUI, Teleporthack
Gui, Add, Button, gMeleeOptionsGUI, Melee Options
Gui, Add, Button, gConnection_Init, Connect
Gui, Add, Button, gAbout, About
Gui, Show
return
; ------------GUI-MISC------------------
Restart:
Reload
return
ItemSearchGUI:
Gui, Destroy
Gui, Add, Text,, Remove your weapon and shield from the paperdoll!
Gui, Add, Text,, Mouse have to be in menu mode, not mouselook mode:
Gui, Add, Text,, Click button 1 ingame to test weapon search and equip paperdoll.
Gui, Add, Text,, Click button 2 ingame to test shield search and equip paperdoll.
Gui, Add, Button, gRestart, Exit
Gui, Show
Loop
{
if GetKeyState("1","P")
{
Gosub, SearchWeaponPaperdoll
}
else if GetKeyState("2","P")
{
Gosub, SearchShieldPaperdoll
}
}
return
MeleeOptionsGUI:
Gui, Destroy
Gui, Add, Text,, Check if using shields:
Gui, Add, Checkbox, voShields
Gui, Add, Button, gIniMelee, Save
Gui, Add, Button, gRestart, Exit
Gui, Show
return
IniMelee:
Gui, Submit
IniWrite, %oShields%, C:\ahk\config.ini, MeleeOptions, Shields
Reload
return
KeySetupGUI:
MsgBox Not done yet, will be added in the future.
return
TeleportGUI:
MsgBox HAR! You damn dirty cheating punk! Got ya noob
return
About:
MsgBox Network connection code was made by Zed Gecko @ Autohotkey forum. Thanks!
MsgBox Rest was made by a donkey. Yada yada blah blah... Version 0.03b
return
IPPORTGUI:
Gui, Destroy
Gui, Add, Text,, Please enter server network IP:
Gui, Add, Edit, vIP
Gui, Add, Text,, Please enter server network port:
Gui, Add, Edit, vPort
Gui, Add, Button, gIniIPPort, Save
Gui, Add, Button, gRestart, Exit
Gui, Show
return
IniIPPort:
Gui, Submit
IniWrite, %IP%, C:\ahk\config.ini, Network, IP
IniWrite, %Port%, C:\ahk\config.ini, Network, Port
Reload
return
; ------------TrainerSetupHandling------------------
BPSetup:
Gui, Destroy
Gui, Add, Text,, Paperdoll:
Gui, Add, Text,, Push key 1 in upper left above your weapon slots
Gui, Add, Text,, Push key 2 in lower right under your shield slots
Gui, Add, Text,, Backpack:
Gui, Add, Text,, Push key 3 in upper left (inside the wood please) corner of your backpack
Gui, Add, Text,, Push key 4 in lower right (inside the wood please) corner of your backpack
Gui, Add, Text,, Click the backpack, then push key 5 On your weapon and wait untill the mouse moves back (try to pick a unike color on that item, if possible)
Gui, Add, Text,, Click the backpack, then push key 6 On your shield and wait untill the mouse moves back (try to pick a unike color on that item, if possible)
Gui, Add, Button, gRestart, Done
Gui, Show
loop
{
if GetKeyState("1","P")
{
Gosub, IniWriteUpperPaperdoll
}
else if GetKeyState("2","P")
{
Gosub, IniWriteLowerPaperdoll
}
else if GetKeyState("3","P")
{
Gosub, IniWriteUpperBackpack
}
else if GetKeyState("4","P")
{
Gosub, IniWriteLowerBackpack
}
else if GetKeyState("5","P")
{
Gosub, IniWriteWeaponPixel
}
else if GetKeyState("6","P")
{
Gosub, IniWriteShieldPixel
}
}
return
IniReadSettings:
IniRead, pweapon, C:\AHK\config.ini, Items, weapon
IniRead, pshield, C:\AHK\config.ini, Items, shield
IniRead, pxu, C:\AHK\config.ini, paperdollCordsUpperLeft, x
IniRead, pyu, C:\AHK\config.ini, paperdollCordsUpperLeft, y
IniRead, pxl, C:\AHK\config.ini, paperdollCordsLowerRight, x
IniRead, pyl, C:\AHK\config.ini, paperdollCordsLowerRight, y
IniRead, bxu, C:\AHK\config.ini, backpackCordsUpperLeft, x
IniRead, byu, C:\AHK\config.ini, backpackCordsUpperLeft, y
IniRead, bxl, C:\AHK\config.ini, backpackCordsLowerRight, x
IniRead, byl, C:\AHK\config.ini, backpackCordsLowerRight, y
IniRead, Network_Address, C:\AHK\config.ini, Network, IP
IniRead, Network_Port, C:\AHK\config.ini, Network, Port
IniRead, oShields, C:\AHK\config.ini, MeleeOptions, Shields
return
IniWriteUpperPaperdoll:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, paperdollCordsUpperLeft, x
IniWrite, %y%, C:\ahk\config.ini, paperdollCordsUpperLeft, y
return
IniWriteLowerPaperdoll:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, paperdollCordsLowerRight, x
IniWrite, %y%, C:\ahk\config.ini, paperdollCordsLowerRight, y
return
IniWriteUpperBackpack:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, backpackCordsUpperLeft, x
IniWrite, %y%, C:\ahk\config.ini, backpackCordsUpperLeft, y
return
IniWriteLowerBackpack:
MouseGetPos, x, y
IniWrite, %x%, C:\ahk\config.ini, backpackCordsLowerRight, x
IniWrite, %y%, C:\ahk\config.ini, backpackCordsLowerRight, y
return
; ------------PixelSearchHandlingNEW------------------
IniWriteWeaponPixel:
MouseGetPos, x, y
MouseMove, 0, 0
sleep 1000
PixelGetColor, color, %x%, %y%
IniWrite, %color%, C:\ahk\config.ini, Items, weapon
sleep 1000
MouseMove, x, y
return
IniWriteShieldPixel:
MouseGetPos, x, y
MouseMove, 0, 0
sleep 1000
PixelGetColor, color, %x%, %y%
IniWrite, %color%, C:\ahk\config.ini, Items, shield
sleep 1000
MouseMove, x, y
return
; ------------ItemSearchHandling------------------
SearchWeaponPaperdoll:
px := round((pxl - pxu )/2+ pxu)
py := round(pyu-(pyl - pyu ))
MouseClick, %kmenuclick%, %px%, %py%, 1
sleep 300
PixelSearch oX, oY, pxu, pyu, pxl, pyl, pweapon, 1, Fast
if ErrorLevel
Gosub, SearchWeaponBackpack
return
return
SearchShieldPaperdoll:
px := round((pxl - pxu )/2+ pxu)
py := round(pyu-(pyl - pyu ))
MouseClick, %kmenuclick%, %px%, %py%, 1
sleep 300
PixelSearch, oX, oY, pxu, pyu, pxl, pyl, pshield, 1, Fast
if ErrorLevel
Gosub, SearchShieldBackpack
return
return
SearchWeaponBackpack:
bx := round((bxl - bxu )/2 + bxu)
by := round((byl - byu )/2 + byu)
MouseClick, %kmenuclick%, %bx%, %by%, 1
sleep 300
PixelSearch, oX, oY, bxu, byu, bxl, byl, pweapon, 1, Fast
if ErrorLevel
return
else
MouseClick, %kmenuclick%, %oX%, %oY%, 3
return
return
SearchShieldBackpack:
bx := round((bxl - bxu )/2 + bxu)
by := round((byl - byu )/2 + byu)
MouseClick, %kmenuclick%, %bx%, %by%, 1
sleep 300
PixelSearch, oX, oY, bxu, byu, bxl, byl, pshield, 1, Fast
if ErrorLevel
return
else
MouseClick, %kmenuclick%, %oX%, %oY%, 3
return
return
Menu:
sleep 200
send % kmenuopen
sleep 200
return
; ------------ConnectionHandling------------------
Connection_Init:
OnExit, ExitSub ; For connection cleanup purposes.
socket := ConnectToAddress(Network_Address, Network_Port)
if socket = -1 ; Connection failed (it already displayed the reason).
ExitApp
Process, Exist ; This sets ErrorLevel to this script's PID (it's done this way to support compiled scripts).
DetectHiddenWindows On
ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel)
DetectHiddenWindows Off
NotificationMsg = 0x5555 ; An arbitrary message number, but should be greater than 0x1000.
OnMessage(NotificationMsg, "ReceiveData")
FD_READ = 1 ; Received when data is available to be read.
FD_CLOSE = 32 ; Received when connection has been closed.
if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, "UInt", ScriptMainWindowId, "UInt", NotificationMsg, "Int", FD_READ|FD_CLOSE)
{
MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
ExitApp
}
return
SendviaNet:
Gui, Submit, NoHide
SendData(socket,SendText)
SentText =
return
ConnectToAddress(IPAddress, Port)
{
VarSetCapacity(wsaData, 32) ; The struct is only about 14 in size, so 32 is conservative.
result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsaData) ; Request Winsock 2.0 (0x0002)
if ErrorLevel
{
MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required.
return -1
}
if result ; Non-zero, which means it failed (most Winsock functions return 0 upon success).
{
MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
return -1
}
AF_INET = 2
SOCK_STREAM = 1
IPPROTO_TCP = 6
socket := DllCall("Ws2_32\socket", "Int", AF_INET, "Int", SOCK_STREAM, "Int", IPPROTO_TCP)
if socket = -1
{
MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
return -1
}
SizeOfSocketAddress = 16
VarSetCapacity(SocketAddress, SizeOfSocketAddress)
InsertInteger(2, SocketAddress, 0, AF_INET) ; sin_family
InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2) ; sin_port
InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), SocketAddress, 4, 4) ; sin_addr.s_addr
if DllCall("Ws2_32\connect", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress)
{
MsgBox % "connect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?"
return -1
}
return socket ; Indicate success by returning a valid socket ID rather than -1.
}
ReceiveData(wParam, lParam)
{
global ShowRecieved
global khit
global kparrydown
global kparryup
global karm
global krest
global kmove
global kmenuopen
global kmenuclose
global kmenuclick
global oShields
global pxu
global pyu
global pxl
global pyl
global bxu
global byu
global bxl
global byl
global ActionArray
global pweapon
global pshield
socket := wParam
ReceivedDataSize = 4096
Loop
{
VarSetCapacity(ReceivedData, ReceivedDataSize, 0) ; 0 for last param terminates string for use with recv().
ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", socket, "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0)
if ReceivedDataLength = 0 ; The connection was gracefully closed,
ExitApp
if ReceivedDataLength = -1
{
WinsockError := DllCall("Ws2_32\WSAGetLastError")
if WinsockError = 10035
return 1
if WinsockError <10054>> 8*(A_Index-1) & 0xFF)
}
ExitSub:
DllCall("Ws2_32\WSACleanup")
ExitApp