Jump to content

Script To Attack


bvr
 Share

Recommended Posts

Hello, I'm finding it very difficult to write an attack function for my "bot." Their are different skills I can use on my character. We can make our character change skills by "hotkey", like F1, F2, F3, ect... To cast a spell on a monster, we must have the skill we want, then we right click on the monster and it attacks. Now, here is the kind of script I need. I want, in my config, to be able to control which hotkey to use, which mouse button to use, right or left, how many times to cast that spell, and a delay between each cast. If anyone can help me with this, please do! Its hard for me, I tried many times.

Link to comment
Share on other sites

Hello, I'm finding it very difficult to write an attack function for my "bot." Their are different skills I can use on my character. We can make our character change skills by "hotkey", like F1, F2, F3, ect... To cast a spell on a monster, we must have the skill we want, then we right click on the monster and it attacks. Now, here is the kind of script I need. I want, in my config, to be able to control which hotkey to use, which mouse button to use, right or left, how many times to  cast that spell, and a delay between each cast. If anyone can help me with this, please do! Its hard for me, I tried many times.

<{POST_SNAPBACK}>

this would actually be a pretty easy script to make..but nobody here is going to make it for you...you can use ...MouseMove,Sleep function for the delay and HotKeySet

look in the helpfile. you can do it

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

  • Moderators

Actually, you would get some help, but ... why don't you show what you've done so far, then explain how you would like to do more and where.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

here is what I had, which it just does 2 spells then stops and goes to the next function which is game exit.

Func D2Attack()
SendHotKey($Attack1)
MouseClick("right", 583, 90, 4, 5)
Sleep(200)
SendHotKey($Attack2)
MouseClick("right", 526, 150, 5, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
EndFunc

~edit, I explained above what I wanted it to do. Its easier to do it in the code, rather than make it more functionable in the config. But I want it to be user friendly.

Edited by bmroyer
Link to comment
Share on other sites

here is what I had, which it just does 2 spells then stops and goes to the next function which is game exit.

Func D2Attack()
SendHotKey($Attack1)
MouseClick("right", 583, 90, 4, 5)
Sleep(200)
SendHotKey($Attack2)
MouseClick("right", 526, 150, 5, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
EndFunc

~edit, I explained above what I wanted it to do. Its easier to do it in the code, rather than make it more functionable in the config. But I want it to be user friendly.

<{POST_SNAPBACK}>

can you post some more of the script..

or try labeling them attack1 2 3 4 5?

Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

  • Moderators

That really doesn't help as B3TA_SCR1PT3R says... I don't know the game, but ... if you show everything you've done... maybe it would be easier to help out a bit.

Are there certain control id buttons / text boxes etc... or certain pixel colors that show up when you need to cast a spell. "Need it to be user friendly", is this for you specifically?

I think they still spell CONTROL like that... not like CONTorL ... OOPS :whistle:

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Full code

;---General Declares----
$D2Path = IniRead("Settings.ini", "General", "D2Path", "")
$D2Exe = IniRead("Settings.ini", "General", "D2Exe", "")
$D2Parameters = IniRead("Settings.ini", "General", "D2Parameters", "")
$Difficulty = IniRead("Settings.ini", "General", "Difficulty", "")
$Account = IniRead("Settings.ini", "General", "Account", "")
$Password = IniRead("Settings.ini", "General", "Password", "")
$CharPosition = IniRead("Settings.ini", "General", "CharPosition", "")
$Teleport = IniRead("Settings.ini", "General", "Teleport", "")
$Attack1 = IniRead("Settings.ini", "General", "Attack1", "")
$Attack2 = IniRead("Settings.ini", "General", "Attack2", "")

;----Delays----
$D2LoadWait = IniRead("Settings.ini", "Delays", "D2Start", "8000")
$D2ActivateWin = IniRead("Settings.ini", "Delays", "D2ActivateWin", "5000")
$D2Login = IniRead("Settings.ini", "Delays", "D2Login", "5000")
$D2CharSelect = IniRead("Settings.ini", "Delays", "D2CharSelect", "5000")
$D2MouseClick = IniRead("Settings.ini", "Delays", "D2MouseClick", "400")
$D2MoveWindow = IniRead("Settings.ini", "Delays", "D2MoveWindow", "1000")
$D2CreateGame = IniRead("Settings.ini", "Delays", "D2CreateGame", "7500")
$D2GetCorpse = IniRead("Settings.ini", "Delays", "D2GetCorpse", "1500")
$D2Running = IniRead("Settings.ini", "Delays", "D2Running", "2000")
$D2EnterPortal = IniRead("Settings.ini", "Delays", "D2EnterPortal", "2500")
$D2PickUpItems = IniRead("Settings.ini", "Delays", "D2PickUpItems", "4000")
$D2ExitGame = IniRead("Settings.ini", "Delays", "D2ExitGame", "4000")

D2Start()
D2Activate()
D2Login()
D2CharPicker()
D2GameMaker()
D2PortalRunner()
D2PindleKiller()
D2Attack()
;D2Pickup()
D2Exit()
;D2Close()

;----Loading Diablo II----
Func D2Start()
Run($D2Path & '\' & $D2Exe & ' ' & $d2parameters, $D2Path )
    WinWait ( 'Diablo II' )
    WinActivate ( 'Diablo II' )
      Sleep ( 500 )
    WinMove ( 'Diablo II', '', 0, 0 )
      Sleep ($D2LoadWait)
EndFunc

;----D2 Activate----
Func D2Activate()
WinActivate("Diablo II")
WinMove("Diablo II", "", 0, 0)
EndFunc

;----Login----
Func D2Login()
Send("{TAB}")
Sleep(500)
Send($Account)
Sleep(500)
Send("{TAB}")
Sleep(500)
Send($password)
Sleep(500)
Send("{ENTER}")
Sleep($D2Login)
EndFunc

;----Select Character----
Func D2CharPicker()
Select
Case $CharPosition = 1
    Send("{ENTER}")

Case $CharPosition = 2
    Send("{RIGHT}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)

Case $CharPosition = 3
    Send("{DOWN}")
    Sleep(250)
    Send("{Enter}")
    Sleep($D2CharSelect)

Case $CharPosition = 4
    Send("{DOWN}")
    Sleep(250)
    Send("{RIGHT}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)

Case $CharPosition = 5
    Send("{DOWN}")
    Sleep(250)
    Send("{DOWN}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)

Case $CharPosition = 6
    Send("{DOWN}")
    Sleep(250)
    Send("{Down}")
    Sleep(250)
    Send("{Right}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)

Case $CharPosition = 7
    Send("{DOWN}")
    Sleep(250)
    Send("{DOWN}")
    Sleep(250)
    Send("{DOWN}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)

Case $CharPosition = 8
    Send("{Down}")
    Sleep(250)
    Send("{Down}")
    Sleep(250)
    Send("{Down}")
    Sleep(250)
    Send("{RIGHT}")
    Sleep(250)
    Send("{ENTER}")
    Sleep($D2CharSelect)
EndSelect
EndFunc

;----Difficulty Select----
Func Difficulty()
Select
Case $Difficulty = 1
    MouseMove(441, 403)
    Sleep(250)
    MouseClick("left")
    Sleep(250)

Case $Difficulty = 2
    MouseMove(566, 404)
    Sleep(250)
    MouseClick("left")
    Sleep(250)

Case $Difficulty = 3
    MouseMove(709, 404)
    Sleep(250)
    MouseClick("left")
    Sleep(250)
EndSelect
EndFunc

;----Game Maker----
Func D2GameMaker()
MouseClick("left", 593, 490)
Sleep(1000)
$name = Random(1000, 999999)
Send($name)
Sleep(1000)
Send("{TAB}")
Sleep(250)
$name = Random(1000, 999999)
Send($name)
Sleep(1000)
Difficulty()
Sleep(250)
Send("{ENTER}")
Sleep($D2CreateGame)
EndFunc

Opt("MouseCoordMode", 0)

;----D2Portal Runner----
Func D2PortalRunner()
Sleep(10000)
MouseClick("left", 137, 407, 1,  5)
Sleep(5000)
MouseClick("left", 135, 399, 1, 5)
Sleep(5000)
MouseClick("left", 224, 387, 1, 5)
Sleep(5000)
MouseClick("left", 139, 429, 1, 5)
Sleep(5000)
MouseClick("left", 424, 418, 1, 5)
Sleep(5000)
MouseClick("left", 177, 412, 1, 5)
Sleep(5000)
MouseClick("left", 22, 388, 1, 5)
Sleep(5000)
MouseClick("left", 94, 146, 1, 5)
Sleep(5000)
MouseClick("left", 239, 199, 1, 5)
Sleep(1000)
EndFunc

;----Sends A SkillKey----
Func SendHotKey($hotkey)
If (StringLeft($hotkey, 1) = "F") AND (StringLen($hotkey) > 1) Then
    Send("{" & $hotkey & "}")
ElseIf ($hotkey = "NULL") Then
;don't send a hotkey
Else
    Send($hotkey)
EndIf
EndFunc

Opt("MouseCoordMode", 0)

;----Go And Kill Pindleskin----
Func D2PindleKiller()
SendHotKey($Teleport)
Sleep(500)
MouseClick("right", 367, 71, 1, 5)
Sleep(500)
MouseClick("right", 582, 88, 1, 5)
Sleep(500)
MouseClick("right", 599, 127, 1, 5)
Sleep(500)
MouseClick("right", 567, 65, 1, 5)
Sleep(500)
MouseClick("right", 458, 173, 1, 5)
Sleep(500)
EndFunc

Opt("MouseCoordMode", 0)

;----Attack----
Func D2Attack()
SendHotKey($Attack1)
MouseClick("right", 583, 90, 4, 5)
Sleep(200)
SendHotKey($Attack2)
MouseClick("right", 526, 150, 5, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
SendHotKey($Attack1)
MouseClick("right", 550, 146, 6, 5)
Sleep(200)
EndFunc 



;----Exit Game----
Func D2Exit()
Send("{ESC}")
Sleep(200)
Send("{UP}")
Sleep(200)
Send("{ENTER}")
Sleep(2000)
EndFunc

;----Closes Diablo Window----
;Func D2Close()
;CloseProcess("Diablo II.exe")
;CloseProcess("D2Loader.exe")
;CloseProcess("Game.exe")
;CloseWindow("Diablo II", "")
;CloseWindow("D2Loader", "")
;CloseWindow("Game", "")
;CloseWindow("Diablo II Exception", "")
;CloseWindow("Diablo II Error", "")
;CloseWindow("Loader Error!", "")
;CloseWindow("D2Loader Error!", "")
;CloseWindow("D2Loader Exception", "")
;CloseWindow("D2Loader Error", "")
;CloseWindow("Hey guys", "")
;CloseWindow("Microsoft Visual C++ Debug Library", "")
;CloseWindow("End Program - " & $d2wintitle, "")
;CloseWindow($d2WinTitle, "")
;CloseProcess($d2WinTitle)
;CloseWindow($d2exe, "")
;CloseProcess($d2exe)
;CloseWindow("D2stats", "")
;CloseWindow("D2stats.exe", "")
;Sleep($delay)
;EndFunc

if it has a ; before it, I am not using that function yet, and not sure if it works yet.

Link to comment
Share on other sites

  • Moderators

I'm sure it's an option in his GUI that's not listed B3TA. Nice to see no z's in your post :whistle:

bmroyer, I've read some of your other post... You know/Knew C++?

Anyway... besides a few misplaced items... (You only need to include the Opt("MouseCoordMode", 0) once at the very top of your script if your always going to be clicking in that window)

It doesn't say much as to How and or When you would like to do Spells / MouseClicks / MouseMoves etc...

I guess not being a D2 gamming enthusiast, I'm not going to be much help if you don't have a Control ID (as explained above) that pop's up or a PixelColor that does when it's time to do a spell or make an action.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...