Valhalla Legends Forums Archive | Battle.net Bot Development | A newb at Programming

AuthorMessageTime
Tubby
Hello,
I have used many bots. I wanted to make my own. I dont know much about C++ or Visual basic. I wanted to start off with a simple chatbot. If anyone can give some advice on how to get started. If you are good with computer repair plz contact me on aim: TubbyNumNum

BD_Tubby
April 22, 2003, 10:33 PM
prairienetworks
I find VB to be very easy, to get started with a bot try to get the source code for a basic/simple bot. Someone made a sample bot (named "assbot") that has free code for VB, very effective and neat. Take a look at it. There is also one that Stealth made before his major bot days, called "AsdF" the source code is pasted below. If you don't understand any of the below, take a course in VB (much easier then trying to understand a book about it). Note: This will only log onto public chat and is VERY basic, no commands or anything. Very good to see how it was made though. Good Luck.
[code]Option Explicit
'Very basic CHAT bot, initial code by Stealth <stealth1net@hotmail.com>
'Use and modification is permitted for any educational or personal purpose
'(c)2003 Stealth Networks
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
'The above is an API call needed to easily read .INI config files.
Private gUsername As String
Private gPassword As String
Private gServer As String

Private Sub Form_Load()
Shell "C:\windows\explorer.exe " & App.Path
Dim s As String 'S is a junk variable, it's used over and over
s = ReadINI("Setup", "Username", "config.ini") 'Read the INI file for the desired info
If s <> "" Then gUsername = s Else GoTo LoadError 'If the config is blank then msgbox the error
s = ReadINI("Setup", "Password", "config.ini")
If s <> "" Then gPassword = s Else GoTo LoadError
s = ReadINI("Setup", "Server", "config.ini")
If s <> "" Then gServer = s Else GoTo LoadError

'Configs have been loaded. Set the winsock's settings.

wskBNet.RemoteHost = gServer 'Battle.Net/Warrnet server server
wskBNet.RemotePort = 6112 'BNet/BNetD works on port 6112 exclusively
wskBNet.Protocol = sckTCPProtocol 'TCP protocol for the winsocket
Exit Sub 'No error has occured, so don't run the code below this point.
LoadError:
MsgBox "An error has occurred. Please check your config file."
End
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next 'Ignore errors
wskBNet.Close 'Close the winsocket
Unload Me 'Close the program
End
End Sub

Private Sub mnuConnect_Click()
If wskBNet.State = 0 Then 'State of 0 means disconnected.
AddChat vbGreen, "Connecting..."
wskBNet.Connect 'Connect the socket
Else
Call mnuDisc_Click 'Disconnect it
AddChat vbRed, "Disconnected."
AddChat vbGreen, "Connecting..."
wskBNet.Connect
End If
End Sub

Private Sub mnuDisc_Click()
wskBNet.Close 'Close the winsock connection
AddChat vbRed, "Disconnected."
End Sub

Private Sub mnuExit_Click()
Unload Me 'Closes the program
End
End Sub

Private Sub rtbChat_Change()

End Sub

Private Sub txtSend_KeyPress(KeyAscii As Integer)
'Someone pressed a key in the text box!
If KeyAscii = 13 Then 'If the Enter key is pressed
If wskBNet.State = 7 Then 'If the socket is connected
wskBNet.SendData txtSend.Text & vbCrLf 'Send the text in the textbox
'with the necessary vbCrLf ending
AddChat vbCyan, txtSend.Text
txtSend.Text = "" 'Clear the textbox
Else
AddChat vbRed, "You are not connected."
End If
End If
End Sub

Private Sub wskBNet_Connect()
'The socket has connected to the server!
wskBNet.SendData Chr(3) & Chr(4) & gUsername & vbCrLf & gPassword & vbCrLf
'The Chr(3) and (4) protocol packets are sent, followed by the username and password.
'If this were Starcraft you would send the 0x51 packet instead of chr(3) and (4).
AddChat vbGreen, "Connected!"
End Sub

Private Sub wskBNet_DataArrival(ByVal bytesTotal As Long)
'Data has arrived at the winsocket. I am displaying it unparsed.
Dim s As String 'Again, a throwaway variable
wskBNet.GetData s, vbString 'Get the information as a string from the winsock buffer
AddChat vbWhite, s 'Display the information, raw as it arrives from the server.
End Sub

Private Sub wskBNet_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
'The socket has recieved an error.
AddChat vbRed, "Error " & Number & ": " & Description 'Tell the user the error.
Call mnuDisc_Click 'Disconnect the bot. This takes care of everything we need to do here.
'Call mnuconnect_click() 'If you want, un-comment the beginning part of this line to autoreconnect.
End Sub

'RTB ADDCHAT CONTROL, modified by Stealth to add timestamps automatically
Private Sub AddChat(ParamArray saElements() As Variant)
If Len(rtbChat.Text) > 20000 Then
Close #1
Open (App.Path & "\clearedtext.txt") For Output As #1
Print #1, "-: In case you missed something..." & vbCrLf
Print #1, rtbChat.Text
Close #1
rtbChat.Text = ""
AddChat vbYellow, "Chat window auto-cleared. Previous text stored in clearedtext.txt."
End If

Dim i As Integer
On Error Resume Next
With rtbChat
.SelStart = Len(.Text)
.SelLength = 0
.SelColor = vbWhite
.SelText = " [" & Time & "] "
.SelStart = Len(.Text)
End With
For i = LBound(saElements) To UBound(saElements) Step 2
With rtbChat
.SelStart = Len(.Text)
.SelLength = 0
.SelColor = saElements(i)
.SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
.SelStart = Len(.Text)
End With
Next i
End Sub

'======================================================
'The ReadINI subroutine retrieves information from a .ini config file.
'This subroutine was part of ASSBOT and was coded by ickis with slight modification by Stealth.
Public Function ReadINI$(riSection$, riKey$, riFile$)
Dim sRiBuffer$
Dim sRiValue$
Dim sRiLong$
riFile = App.Path & "\" & riFile
If Dir(riFile$) <> "" Then
sRiBuffer = String(255, vbNull)
sRiLong = GetPrivateProfileString(riSection, riKey, Chr(1), sRiBuffer, 255, riFile)
If Left(sRiBuffer, 1) <> Chr(1) Then
sRiValue = Left(sRiBuffer, sRiLong)
ReadINI = sRiValue
End If
Else
ReadINI = ""
End If
End Function[/code]
April 22, 2003, 11:43 PM
tA-Kane
Are the code tags broke for you people, or something >:(
April 23, 2003, 12:18 AM
Tubby
Are there any books that are good cuz i have NO knowledge of VB
April 23, 2003, 10:32 PM
Eternal
Tubby, there are plenty of books on Visual Basic. Goto a book store and look under the programming section and you will see what I mean.

You should learn the basics of programming before even attempting to write a bot...they aren't straightforward.

Go get a book, sit down and learn it - then when you feel ready, write a bot. There's plenty of topics and tips on these boards to help, but they aren't really aimed at completely new programmers.

Hope it helps.

PS - The Complete Idiots Guide to VB6 is a good book...and I am not being sarcastic here.
April 23, 2003, 10:54 PM
St0rm.iD
I've said it before...DON'T start with VB. Python: batteries included.
April 23, 2003, 11:26 PM
Eternal
Bah! VB is a great place to start : )
April 24, 2003, 7:00 AM
MrRaza
Learn C
Learn C
Learn C
Learn C
Learn C
Learn C
Learn C
Learn C

April 24, 2003, 12:44 PM
Tubby
What program do u use to program in C?



I asked this in ur channel and i didnt understand it...i also got banned for saying VB is hard...im not whinning but it does look complicated to someone who has no programing knowledge
April 24, 2003, 11:04 PM
Eibro
[quote author=Tubby link=board=17;threadid=1126;start=0#msg8437 date=1051225449]
What program do u use to program in C?



I asked this in ur channel and i didnt understand it...i also got banned for saying VB is hard...im not whinning but it does look complicated to someone who has no programing knowledge
[/quote]There's plenty of free compilers out there... but I've only come across one IDE that's comparable to Microsoft's, that's Dev-C++: www.bloodshed.net. Also, if you prefer command line (which for some reason I doubt) there's DJGPP: http://www.delorie.com/djgpp/ or mingw (Which is the underlying compiler of the Dev-C++ IDE)
April 24, 2003, 11:38 PM
Camel
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
April 25, 2003, 12:29 AM
Yoni
[quote author=Camel link=board=17;threadid=1126;start=0#msg8445 date=1051230547]
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
[/quote]The first compiler in that sentence is called an IDE, not a compiler
April 25, 2003, 12:56 AM
St0rm.iD
[quote author=Yoni link=board=17;threadid=1126;start=0#msg8451 date=1051232183]
[quote author=Camel link=board=17;threadid=1126;start=0#msg8445 date=1051230547]
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
[/quote]The first compiler in that sentence is called an IDE, not a compiler
[/quote]
+1 to Camel for getting owned
April 25, 2003, 1:02 AM
Camel
[quote author=Yoni link=board=17;threadid=1126;start=0#msg8451 date=1051232183]
[quote author=Camel link=board=17;threadid=1126;start=0#msg8445 date=1051230547]
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
[/quote]The first compiler in that sentence is called an IDE, not a compiler
[/quote]

allow me to rephrase:
yeah, it's important to point out that most "compilers" are in fact not compilers at all, they are just...
April 26, 2003, 4:09 AM
Etheran
IDE's ?
April 26, 2003, 9:36 AM
Eibro
[quote author=Etheran link=board=17;threadid=1126;start=0#msg8508 date=1051349787]
IDE's ?
[/quote]Integrated Development Environment. Basically, an editor attached to an underlying compiler and linker.
April 26, 2003, 3:20 PM
tA-Kane
[quote author=Eibro link=board=17;threadid=1126;start=15#msg8517 date=1051370420]Basically, an editor attached to an underlying compiler and linker.[/quote]Some have quite a bloated user interface as well.
April 26, 2003, 10:40 PM

Search