Valhalla Legends Forums Archive | Battle.net Bot Development | Diablo II

AuthorMessageTime
Spilled[DW]
I have a few question regarding diablo II. I want to make a Diablo II Meph Bot, but first lets work on the connection. What would be the login sequence? Then after i log in wouldn't I need a UDP winsock? So that would make a requirement of 2 Winsock's. After I do the connection, what would I do with the UDP Socket?  Doesn't Diablo II use the Huffman algorithm?

Thanks in advance!
November 17, 2005, 9:19 PM
JoeTheOdd
Logon Sequences are documented on BnetDocs.

You need to create a UDP Winsock and bind it to port 6112, I believe, You'll recieve a UDP ping, and instead of simply sending TENB (BNET backwards) like most bots do, I suggest you actually extract that from the UDP ping packet and send it then, if your going to have a UDP socket anyhow. To bind a Winsock/CSocket on a UDP port, set the property Protocol to UDP (I don't know the integer constant), and call of routine Bind(int port).

I've never done ANY in-game work whatsoever. However, I'm under the impression that its something like this.
Client: I'd like to join a game.
Server: Mmk, which one? *presents list*
Client: Uh, that one. *points at menu*
Server: Mmk. The people in that game are.. *presents another list*
Client: Thank you.
Client: *disconnect* [optional]

From there, its all over the UDP socket, I believe. Perhaps its over a TCP socket connection to the game host. Again, I've never done this.

Hope I helped.
November 17, 2005, 10:26 PM
Spilled[DW]
Yes, you have been helpful, but what I really meant is, after I have done the logon sequence with the tcp winsock. What should I do? send the join/create game over the tcp socket, then hwo would i start using the UDP socket.... basically what do i do after i have joined a channel. How would i go about creating a game and doing in-game actions. Thanks in advance!
November 18, 2005, 12:20 AM
HdxBmx27
Well I think the main thing thats screing you up is that Diablo II DOES NOT use UDP.
Diablo II plays games using the TCP/IP protocol.
I suggest you go to BnetDocs And look at the "Realm messages' And "D2GS Messages"
Packets you will be interested in:
SID_QUERYREALMS2
SID_LOGONREALMEX
MCP_JOINGAME
MCP_GAMELIST


basically:
ask for the Realm server.
Connect to the realm server with a new socket
Login to realm server
ask for game list
tell server your joing game
connect to the IP the server tells you with a new socket.

That should get you started,
~-~(HDX)~-~
November 18, 2005, 1:12 AM
Ringo
D2GS Logon sequance:
[color=yellow]C > S Connect()[/color]
[color=blue]S > C Accept()[/color]
[color=blue]S > C 0xAF[/color] (Compressed)  --  AF 01
[color=yellow]C > S 0x68[/color] (Login Data)
[color=yellow]C > S 0x6D[/color] (Optional ping at this stage)
[color=blue]S > C 0x01[/color]
[color=blue]S > C 0x00[/color]
If Failed: [color=red]S > C 0xB3[/color]
If Passed: [color=blue]S > C 0x02[/color]
[color=yellow]C > S 0x6B[/color]
[color=blue]S > C Game Data
~~~~
~~~~
~~~~
[/color]
November 18, 2005, 2:21 AM
JJBot
I think Ringo has pretty much summed it up. HdxBmx27 was right when he said Diablo II does not use UDP. Good luck with your Diablo bot.
November 18, 2005, 7:01 AM
programming-design
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?
November 20, 2005, 1:48 AM
UserLoser.
[quote author=programming-design link=topic=13270.msg134725#msg134725 date=1132451280]
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?
[/quote]

No, Starcraft uses UDP
November 20, 2005, 5:26 AM
JoeTheOdd
[quote author=UserLoser link=topic=13270.msg134753#msg134753 date=1132464366]
[quote author=programming-design link=topic=13270.msg134725#msg134725 date=1132451280]
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?
[/quote]

No, Starcraft uses UDP
[/quote]

That's what he said.
November 20, 2005, 5:41 AM
UserLoser.
[quote author=Joe link=topic=13270.msg134756#msg134756 date=1132465299]
[quote author=UserLoser link=topic=13270.msg134753#msg134753 date=1132464366]
[quote author=programming-design link=topic=13270.msg134725#msg134725 date=1132451280]
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?
[/quote]

No, Starcraft uses UDP
[/quote]

That's what he said.
[/quote]

Oops, perhaps I should have read that slower
November 20, 2005, 6:38 PM
Spilled[DW]
[quote author=Ringo link=topic=13270.msg134432#msg134432 date=1132280488]
D2GS Logon sequance:
[color=yellow]C > S Connect()[/color]
[color=blue]S > C Accept()[/color]
[color=blue]S > C 0xAF[/color] (Compressed)  --  AF 01
[color=yellow]C > S 0x68[/color] (Login Data)
[color=yellow]C > S 0x6D[/color] (Optional ping at this stage)
[color=blue]S > C 0x01[/color]
[color=blue]S > C 0x00[/color]
If Failed: [color=red]S > C 0xB3[/color]
If Passed: [color=blue]S > C 0x02[/color]
[color=yellow]C > S 0x6B[/color]
[color=blue]S > C Game Data
~~~~
~~~~
~~~~
[/color]
[/quote]

Compressed how? Huffman algorithm?

And another question i have is, When i connect to battle.net and query the realm list. Would i disconnect from battle.net and connect to the realm server? or would i need seperate winsocks? Finally, When i connect to the realm server and get the game list. Do i need a 3rd winsock to connect to the game? or disconnect from realm then connect to the game?

Thanks in advance
November 21, 2005, 5:34 PM
Ringo
[quote author=Spilled[DW] link=topic=13270.msg134908#msg134908 date=1132594493]
Compressed how? Huffman algorithm?
[/quote]
ye, i wrote a quick VB6 example to use the D2GS.dll here witch might be worth checking out.
Or the source code witch Brand.X wrote here

[quote]
And another question i have is, When i connect to battle.net and query the realm list. Would i disconnect from battle.net and connect to the realm server? or would i need seperate winsocks? Finally, When i connect to the realm server and get the game list. Do i need a 3rd winsock to connect to the game? or disconnect from realm then connect to the game?

Thanks in advance
[/quote]

Hmm, it would be better to have 3 TCP sockets, 1 for BNCS, 1 for the realm and 1 for D2GS
When you query the realm list and get the realm address, keep the connection live with battle.net and logon the realm.
Then when you request to create or join a game and the realm sends you the D2Gs IP, port, hash and token, you then start connecting to it with the D2GS socket.
I normaly disconnect the realm socket when the d2gs socket accepts, and when it comes to leaving a D2Gs game, i query the realm list, and logon the realm like normal (so your back where you started)
But you should always have a live connection to BNCS.

Hope this helps
November 21, 2005, 6:02 PM
LivedKrad
[quote author=Spilled[DW] link=topic=13270.msg134908#msg134908 date=1132594493]
Compressed how? Huffman algorithm?

And another question i have is, When i connect to battle.net and query the realm list. Would i disconnect from battle.net and connect to the realm server? or would i need seperate winsocks? Finally, When i connect to the realm server and get the game list. Do i need a 3rd winsock to connect to the game? or disconnect from realm then connect to the game?

Thanks in advance
[/quote]

When I work with D2GS, I never disconnect from the Realm server. If I have a separate TCP socket managing the realm data, I find that the speed decrease from having an extra socket is made up for by the fact that I do not have to requery the Realm server after disconnecting from the D2GS.

Additionally, as Ringo said, Diablo II uses a compression scheme much to the liking of the Huffman algorithm. All packets received from the server (D2GS) are compressed in this manner, whereas the packets sent to the server are not compressed. Ringo gave the general login sequenced used and I believe Joe (I don't feel like scrolling down) linked you to the login sequence page. I'm not entirely sure the logon sequence that I have there is up-to-date, however I'm fairly sure that the packets involved in the logon sequence are correctly added. If you have any further inquiries, I'd be glad to help.
November 21, 2005, 9:12 PM

Search