Sign in to follow this  
Followers 0
Ramm

Diablo II problem

6 posts in this topic

I have only been working with Autoit for about 3 days now. I started using it to make a AFK hammerdin for gubers. I have to setting for this bot.

1. Spinner w/merc

2. Spinner w/o merc

At first i only used one file for everything but decided it would be easier to use 3.

1. for auto it its self

2. An iniread file

3. Config.txt file

Now my problem started AFTER I added the 2 other files. At first I had it use F1, F2, F3, etc. to select skills. Well I know everyone is different so I made the config file so people could add in their own "Hot Keys" for the set skills. The problem I have is, it wont select holy shield OR Conc after it bo's.

Here is the Au3 file

CODE
opt("PixelCoordMode", 2)

opt("MouseCoordMode", 2)

opt("SendKeyDelay", 200)

#Include "IniRead.au3"

#Include "Checksums.au3"

If WinExists($D2WinName) Then

MsgBox(0, "", "Looks like a d2 window is already open! Close it before launching the bot.")

Exit

EndIf

If LaunchD2() = 0 Then

MsgBox(0, "", "Oh noes! we failed to log in! Better check the error log to find out why...")

Exit

Else

EndIf

If ($Use = 1) OR ($Use = 2) Then

ChannelJoin()

Endif

Func ChannelJoin()

opt("SendKeyDelay", 200)

MouseClick("Left", 90, 470, 1, $MenuMouseSpeed)

ScreenWait("Channel", 15000)

send("/j " & $Channel_,1)

send("{ENTER}")

EndFunc

Func LaunchD2()

If Run($D2PathName & "\" & $D2Executable & " " & $Paramaters,$D2PathName) = 0 Then

Return 0

Else

EndIf

WinWaitActive($D2WinName)

For $kuk = 1 to 1000

$WINsize = WinGetPos($D2WinName)

if ($WINsize[2] > 800) then

exitloop

else

sleep(100)

endif

Next

WinMove($D2WinName, "", 0, 0)

MouseClick("Left", 100, 100, 1, $MenuMouseSpeed)

If ScreenWait("TitleScreen", 15000) = 0 Then Return 0

MouseClick("Left", 394, 353, 1, $MenuMouseSpeed)

If ScreenWait("LoginScreen", 20000) = 0 Then Return 0

MouseClickDrag("Left", 477, 336, 300, 336, $MenuMouseSpeed)

Sleep($MenuStaticDelay)

Send($A,1)

Sleep($MenuStaticDelay)

Send("{TAB}")

Sleep($MenuStaticDelay)

Send($P,1)

Sleep($MenuStaticDelay)

MouseClick("Left", 395, 470, 1, $MenuMouseSpeed)

If ScreenWait("CharacterSelect", 20000) = 0 Then Return 0

$Xclix = 0

$Yclix = 0

If $CharSlot = 1 Then

$Xclix = 180

$Yclix = 130

ElseIf $CharSlot = 2 Then

$Xclix = 450

$Yclix = 130

ElseIf $CharSlot = 3 Then

$Xclix = 180

$Yclix = 225

ElseIf $CharSlot = 4 Then

$Xclix = 450

$Yclix = 225

ElseIf $CharSlot = 5 Then

$Xclix = 171

$Yclix = 318

ElseIf $CharSlot = 6 Then

$Xclix = 447

$Yclix = 315

ElseIf $CharSlot = 7 Then

$Xclix = 180

$Yclix = 410

ElseIf $CharSlot = 8 Then

$Xclix = 458

$Yclix = 406

Else

MsgBox(0, "", "You must pick a character slot! 1-8")

EXIT(0)

EndIf

MouseClick("Left", $Xclix, $Yclix, 1, $MenuMouseSpeed)

Sleep($MenuStaticDelay)

MouseClick("Left", 692, 557, 1, $MenuMouseSpeed)

If ScreenWait("Lobby", 20000) = 0 Then Return 0

Return 1

EndFunc

Func CreateGame()

For $Retry = 0 to 4

;If ScreenCheck("Lobby") = 0 Then

If (IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasDeadStatus", "1")) = 1 Then

LogEvent(0, "Bot Died. Stopping due to that...")

EXIT(0)

EndIf

If (IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasHostiled", "1")) = 1 Then

IniWrite(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasHostiled", "0")

$RunCount = Random(1, 5000, 1)

EndIf

$RunCount = $RunCount+$Retry

LogEvent(0, "Attempting to create the game " & $GameName & $RunCount & " This is attempt number " & $Retry)

if ScreenCheck("Channel") = 1 Then

ChannelMSG(StringReplace ( $NGMSG, "_GN_", $GameName & $RunCount))

endif

MouseClick("Left", 590, 462, 1, $MenuMouseSpeed)

If ScreenWait("CreateButton", 15000) = 0 Then

MouseClick("Left", 712, 461, 1, $MenuMouseSpeed)

Sleep(2000)

ContinueLoop

EndIf

Send($GameName & $RunCount)

Sleep(200)

If $GamePassLength = 1 Then

Send("{TAB}")

Send($RunCount)

ElseIf $GamePassLength = 9 Then

Sleep(10)

ElseIf $GamePassLength > 1 Then

Send("{TAB}")

For $lll = 1 to $GamePassLength

Send(Random(1, 9, 1))

Next

else

Send("{TAB}")

Send($GamePassLength)

EndIf

MouseClick("Left", 676, 418, 1, $MenuMouseSpeed)

If ScreenWait("GameJoin", 15000) = 0 Then

If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 0 Then

LogEvent(1, "Game create screen not detected after 5 seconds... will retry the game join.")

MouseClick("Left", 711, 461, 1, $MenuMouseSpeed)

ContinueLoop

EndIf

EndIf

Local $Timeout = TimerInit()

While ScreenCheck("GameJoin") = 1

If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 0 Then

If TimerDiff($Timeout) > 30000 Then

LogEvent(1, "Looks like we got stuck on the game create screen for over 30 seconds...")

Return 0

EndIf

EndIF

Sleep(500)

WEnd

If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 1 Then

IniWrite(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0")

Return 1

Endif

If (ScreenCheck("Lobby")+ScreenCheck("Channel")) = 1 Then

LogEvent(1, "Failed to Join! Bnet needs to fix their damn servers!!! Lets just retry...")

ContinueLoop

ElseIf ScreenCheck("GUIBar") = 1 Then

LogEvent(0, "Successfully joined the game after " & Round((TimerDiff($Timeout)/1000), 2) & " seconds.")

Return 1

Elseif IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 1 Then

Return 1

Else

LogEvent(1, "Hmm, looks like we got lost somewhere while attempting to create a game...")

Return 0

EndIf

Next

LogEvent(1, "Failed to create a game after 5 retries.")

Return 0

EndFunc

Func ScreenWait($ScreenName, $Timeout)

Local $Checksum[5]

Local $Sum

$Checksum = Eval($ScreenName)

$Time = TimerInit()

Do

Sleep(200)

$Sum = PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4])

If $Sum = $Checksum[0] Then Return 1

Until TimerDiff($Time) > $Timeout

LogEvent(1, $Sum & " does not match the expected the checksum of " & $Checksum[0] & " for the menu " & $ScreenName & " at coordinates (" & $Checksum[1] & " ," & $Checksum[2] & " ," & $Checksum[3] & " ," & $Checksum[4] & ") and timed out after " & $TimeOut & " milliseconds.")

Return 0

EndFunc

Func ScreenCheck($ScreenName)

Local $Checksum[5]

$Checksum = Eval($ScreenName)

;LogEvent(1, PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4]) & " is checksum for: " & $ScreenName)

If PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4]) = $Checksum[0] Then

Return 1

Else

Return 0

EndIf

EndFunc

$time = 0

Global $Paused

HotKeySet("=", "hammers")

HotKeySet("{PGUP}", "nomerc")

HotKeySet("{PGDN}", "merc")

HotKeySet("{END}", "TogglePause")

HotKeySet("{HOME}", "Terminate")

While 1

Sleep(100)

WEnd

WinMove("Diablo II", "", 0,0)

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

send("=")

WEnd

EndFunc

Func Terminate()

Exit 0

EndFunc

Func Hammers()

Send("{SHIFTDOWN}")

Sleep(30)

MouseClick("left")

Sleep(30)

Send("{SHIFTUP}")

endfunc

Func nomerc()

Send($Tele)

MouseClick("right", 120,225)

Sleep(380)

MouseClick("right", 120,225)

Sleep(380)

MouseClick("right", 120,225)

Sleep(380)

MouseClick("right", 165,315)

Sleep(1000)

Send("{w}")

Sleep(500)

Send($Bc)

MouseClick("Right")

Sleep(500)

Send($Bo)

MouseClick("Right")

Sleep(1000)

Send("{W}")

Sleep(1000)

Send($HS)

MouseClick("Right")

Sleep(1000)

Send($Conc)

Sleep(500)

Send("{ENTER}")

Sleep(500)

Send("k")

Sleep(500)

Send("{ENTER}")

Sleep(200)

Do

Send("{SHIFTDOWN}")

Sleep(30)

MouseClick("left")

Sleep(30)

Send("{SHIFTUP}")

$time = $time + 1

Until $time = 1000

Sleep(1000)

Send($Tele)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 628,313)

Sleep(5000)

Send("{PGUP}")

EndFunc

Func merc()

Send($Tele)

#tele to corner

MouseClick("right", 130,175)

Sleep(380)

MouseClick("right", 130,175)

Sleep(380)

MouseClick("right", 130,175)

Sleep(380)

#walks up

MouseClick("Left", 450,100)

Sleep(500)

#walks right/up

MouseClick("Left", 460,200)

Sleep(1200)

#walks left/down

MouseClick("Left", 100,300)

Sleep(400)

#walks down

MouseClick("Left", 270,420)

Sleep(500)

#walks to tree

Sleep(800)

MouseClick("Left", 315,558)

Sleep(1000)

Send("{w}")

Sleep(500)

Send($Bc)

MouseClick("Right")

Sleep(500)

Send($Bo)

MouseClick("Right")

Sleep(1000)

Send("{W}")

Sleep(1000)

Send($HS)

MouseClick("Right")

Sleep(1000)

Send($Conc)

Sleep(500)

Send("{ENTER}")

Sleep(500)

Send("k")

Sleep(500)

Send("{ENTER}")

Sleep(200)

Do

Send("{SHIFTDOWN}")

Sleep(30)

MouseClick("left")

Sleep(30)

Send("{SHIFTUP}")

$time = $time + 1

Until $time = 1000

Sleep(1000)

Send($Tele)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 685,395)

Sleep(380)

MouseClick("right", 628,313)

Sleep(5000)

Send("{PGDN}")

EndFunc

while 1

hotkeyset("=","Hammers")

wend

Here is my iniread file

CODE
;Settings

$D2PathName = IniRead(@ScriptDir & "\Config.ini", "Settings", "D2PathName", "")

$D2Executable = IniRead(@ScriptDir & "\Config.ini", "Settings", "D2Executable", "")

$D2WinName = IniRead(@ScriptDir & "\Config.ini", "Settings", "D2WinName", "")

$Paramaters = IniRead(@ScriptDir & "\Config.ini", "Settings", "Paramaters", "")

$A = IniRead(@ScriptDir & "\Config.ini", "Settings", "Account", "")

$P = IniRead(@ScriptDir & "\Config.ini", "Settings", "Password", "")

$CharSlot = IniRead(@ScriptDir & "\Config.ini", "Settings", "CharSlot", "")

;Hot Keys

$HolyShield = IniRead(@ScriptDir & "\Config.ini", "Hot Keys", "HolyShield", "")

$Conc = IniRead(@ScriptDir & "\Config.ini", "Hot Keys", "Conc", "")

$Tele = IniRead(@ScriptDir & "\Config.ini", "Hot Keys", "Tele", "")

$Bc = IniRead(@ScriptDir & "\Config.ini", "Hot Keys", "Bc", "")

$Bo = IniRead(@ScriptDir & "\Config.ini", "Hot Keys", "Bo", "")

;Delays

$MenuMouseSpeed = IniRead(@ScriptDir & "\Config.ini", "Delays", "MenuMouseSpeed", "")

$GameCreateDelay = IniRead(@ScriptDir & "\Config.ini", "Delays", "GameCreateDelay", "")

$MenuStaticDelay = IniRead(@ScriptDir & "\Config.ini", "Delays", "MenuStaticDelay", "")

;Channel

$Use=IniRead(@ScriptDir & "\Config.ini", "Channel", "Use", "0")

$Channel_=IniRead(@ScriptDir & "\Config.ini", "Channel", "Channel", "0")

And here is my config

CODE
[settings]

D2PathName =C:\Program Files\Diablo II

D2Executable =Game.exe

Account=XXXXXXX

Password=XXXXXX

CharSlot=1

D2WinName = Diablo II

Paramaters = -w -lq -direct -txt -title "Diablo II"

[Hot Keys]

HolyShield=F1

Conc=F2

Tele=F3

Bc=F6

Bo=F7

[Delays]

MenuMouseSpeed = 3

GameCreateDelay = 4

MenuStaticDelay = 200

[Channel]

Use=1

Channel=XXXXXX

Any help would be appreciative.

Share this post


Link to post
Share on other sites



Sending F1-F12 is as followed and as stated in the help file:

Send('{F3}')oÝ÷ ÚÊØ^­ÈZ­è§ø¥zÚ,¢g­)à)r^oÝ÷ Úíç(uçè®Ç§v)ඤ{+hjëh×6; ...
Send("w")
Sleep(500)
Send('{' & $Bc & '}')
MouseClick("Right")
Sleep(500)
Send('{' & $Bo & '}')
; ...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This is not good...

While 1
    HotKeySet("=", "Hammers")
WEnd

... not good at all!!

8)

BTW... Welcome to the Autoit Forums.... 8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sending F1-F12 is as followed and as stated in the help file:

Send('{F3}')
Send("w")
Sleep(500)
Send('{' & $Bc & '}')
MouseClick("Right")
Sleep(500)
Send('{' & $Bo & '}')
; ...oÝ÷ Ûú®¢×ØZ7öYm¯(­¢ëZØhÂ+p¢¹,«¨µéÚ

... not good at all!!

8)

BTW... Welcome to the Autoit Forums.... 8)

Why is this not good? And as for the rest of it, does it look ok...ish? :)

First of all, try to write your own scripts, at least then you will know what going on. For example, do you even know why your including the "Checksums.au3"....

I never said I wrote all of it. I used bits and pieces from other scripts. Is that not how we learn new language? Edited by Ramm

Share this post


Link to post
Share on other sites

Sending F1-F12 is as followed and as stated in the help file:

Send('{F3}')oÝ÷ ÚÊØ^­ÈZ­è§ø¥zÚ,¢g­)à)r^oÝ÷ Úíç(uçè®Ç§v)ඤ{+hjëh×6; ...
Send("w")
Sleep(500)
Send('{' & $Bc & '}')
MouseClick("Right")
Sleep(500)
Send('{' & $Bo & '}')
; ...
I tried all 3 options and all seem to work fine except one single skill, holy shield ($HS), it does not matter what F function I put, it won't cast it.

Also, is there a way to get this NOT to take control of your mouse? Or any way to compensate for any lag that may occour or should i just set my delays to be longer?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0