• Welcome to Valhalla Legends Archive.
 

Diablo II

Started by Spilled, November 17, 2005, 03:19 PM

Previous topic - Next topic

Spilled

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!

Joe[x86]

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.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Spilled

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!

Hdx

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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Ringo

D2GS Logon sequance:
C > S Connect()
S > C Accept()
S > C 0xAF (Compressed)  --  AF 01
C > S 0x68 (Login Data)
C > S 0x6D (Optional ping at this stage)
S > C 0x01
S > C 0x00
If Failed: S > C 0xB3
If Passed: S > C 0x02
C > S 0x6B
S > C Game Data
~~~~
~~~~
~~~~

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.
Quote from: Spilled[DW] on November 17, 2005, 03:19 PM
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?
::)

programming-design

I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?

UserLoser.

Quote from: programming-design on November 19, 2005, 07:48 PM
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?

No, Starcraft uses UDP

Joe[x86]

Quote from: UserLoser on November 19, 2005, 11:26 PM
Quote from: programming-design on November 19, 2005, 07:48 PM
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?

No, Starcraft uses UDP

That's what he said.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

UserLoser.

Quote from: Joe on November 19, 2005, 11:41 PM
Quote from: UserLoser on November 19, 2005, 11:26 PM
Quote from: programming-design on November 19, 2005, 07:48 PM
I think the reason he thought Diablo II uses UDP is because doesn't SC use UDP?

No, Starcraft uses UDP

That's what he said.

Oops, perhaps I should have read that slower

Spilled

#10
Quote from: Ringo on November 17, 2005, 08:21 PM
D2GS Logon sequance:
C > S Connect()
S > C Accept()
S > C 0xAF (Compressed)  --  AF 01
C > S 0x68 (Login Data)
C > S 0x6D (Optional ping at this stage)
S > C 0x01
S > C 0x00
If Failed: S > C 0xB3
If Passed: S > C 0x02
C > S 0x6B
S > C Game Data
~~~~
~~~~
~~~~


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

Ringo

Quote from: Spilled[DW] on November 21, 2005, 11:34 AM
Compressed how? Huffman algorithm?
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

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

LivedKrad

Quote from: Spilled[DW] on November 21, 2005, 11:34 AM
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

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.