Valhalla Legends Forums Archive | Battle.net Bot Development | Please Slain my idea into prespective

AuthorMessageTime
Ringo
This is REALLY hard to explain, so i will try and be as clear as i can.
Im looking for ideas on why it will/wont work etc.

Anyway, i had the idea of running a single TCP connection to battle.net on a Broodwar client, but having a total of 8 UDP sockets, all bound to different ports.
The first socket would be the "master" socket, witch hosted the game and waited for me and 7 other people to join (making 9 i know).
But when i join on the "bot master's" account, the hostbot sections me into a differnt "room" to any other players who may join.
The host wouldnt notify any other players who joined that i was there, but would notify me they joined via one of its other sockets, and tell "me" that the player is useing that address.
So when a random player joins, the host would tell all the other random players that they have joined (in the main game room) and tell me (in the sectioned game room) that the player is useing the ip and port of one of its other sockets.
Then anything the reall players did in the reall "room", would be fawarded to me via one of the bots other sockets, and everything i did in the "fake room", would be fawarded to all the reall players as a action from the hostbot.

So in effect, once ingame, "me" will be playing souly with bots witch fawarded the reall players packets to "me", and ONE of the sockets fawarding "me" the other players data, would then make the host faward the data sent by "me" to all the reall players as if it was its own.

THis would mean, with in reassion, that the bots could give me the other players vision, filter out any "out of range" clicks that would look like a map hack, tell you whats going on so u dont have to keep checking manualy, do unit and base production why you are busy microing, what ever, the possibilitys are almost endless.

Diogram:
[code]
Host______________________tmp2____Me
|||||||       \ \ \ \ \ \      /
|||||||        \ \ \ \ \ tmp3__\
|||||||         \ \ \ \ tmp4___/
|||||||          \ \ \ tmp5____\
|||||||           \ \ tmp6_____/
|||||||            \ tmp7______\
|||||||___2         tmp8_______/
||||||__\_3
|||||___/_4
||||____\_5
|||_____/_6
||______\_7
|_______/_8
[/code]


Ideas?
November 15, 2005, 9:14 AM
Arta
[quote author=Ringo link=topic=13246.msg134037#msg134037 date=1132046092]
THis would mean, with in reassion, that the bots could give me the other players vision, filter out any "out of range" clicks that would look like a map hack, tell you whats going on so u dont have to keep checking manualy, do unit and base production why you are busy microing, what ever, the possibilitys are almost endless.
[/quote]

You can do that without going to all that trouble. Just hook the game's message processing routines. Or am I missing something?
November 15, 2005, 11:31 AM
Ringo
[quote author=Arta[vL] link=topic=13246.msg134041#msg134041 date=1132054280]
You can do that without going to all that trouble. Just hook the game's message processing routines. Or am I missing something?
[/quote]
I can get a handle to the window, but anything else and i wouldnt have a clue where to start :D
Would that require reverseing the binary files?
November 15, 2005, 11:51 AM
Arta
Yes, but in order to do anything meaningful you'd have to do that anyway - otherwise you wouldn't know what the UDP messages do.
November 15, 2005, 5:31 PM
Myndfyr
So this is like a proxy for Battle.net games?
November 15, 2005, 6:07 PM
QwertyMonster
Would this actually work? I mainly understand what he is saying, for people who dont:

He wants to play vs bots in other words? Please correct me if im wrong.

And in order to play vs the bots, he is going to make the "real players" packets, which are then sent to him, then sent to the bots making them "be real"? I THINK thats the basic idea of it, like i said.. please correct me if im wrong!
November 15, 2005, 7:15 PM
Ringo
[quote author=Arta[vL] link=topic=13246.msg134067#msg134067 date=1132075906]
Yes, but in order to do anything meaningful you'd have to do that anyway - otherwise you wouldn't know what the UDP messages do.
[/quote]
The packets wont be a problem, as i know what 90% of them do already, im more worryed about other problems witch would result in it not working :)


[quote author=MyndFyre link=topic=13246.msg134069#msg134069 date=1132078024]
So this is like a proxy for Battle.net games?
[/quote]
Sort of.
The host socket would be acting like a proxy, in the sence that it will be fawarding all the game data to me via the correct sockets.
So each game beat, my SC would send its data payload to all the tmp sockets, witch the host socket would then hold and send to each reall player when the main game beat goes off.
And when the reall players transmit there data payloads to the host socket, the tmp sockets hold each players payload and transmit it to my sc when the next game beat goes off.
So the players i see in my game are controlled by the reall players witch cant see me, but i can see them through the bots sockets, giving the bot VIP access :)
(thats if it worked)

[quote author=QwertyMonster link=topic=13246.msg134077#msg134077 date=1132082110]
And in order to play vs the bots, he is going to make the "real players" packets, which are then sent to him, then sent to the bots making them "be real"? I THINK thats the basic idea of it, like i said.. please correct me if im wrong!
[/quote]
err, somthing like that :P
November 15, 2005, 7:52 PM
Kp
In theory, it should work.  But like Arta, I think you're going to a lot more trouble and bandwidth than this requires.  Also, you won't be able to have the other players share vision with you or anything like that.  As soon as you do, your game goes out of sync with theirs and you drop.  Of course, your proxy will need to do quite a bit of NAT too. :)
November 16, 2005, 12:28 AM
MesiaH
hrm.. didn't think about the NAT thing.. ouch..
November 16, 2005, 6:14 AM
Ringo
[quote author=Kp link=topic=13246.msg134140#msg134140 date=1132100905]
In theory, it should work.  But like Arta, I think you're going to a lot more trouble and bandwidth than this requires.  Also, you won't be able to have the other players share vision with you or anything like that.  As soon as you do, your game goes out of sync with theirs and you drop.  Of course, your proxy will need to do quite a bit of NAT too. :)
[/quote]
Hm, the host socket would handle any sync problems with the reall players, and the tmp sockets would handle there own sync issues with SC, so all that gets crossed over is data payloads.
That way when it comes to adding/removing packets in the cross over, its just a case of adding or removing the extra data in the payload, before it gets sent by the host or tmp sockets.
Other than useing 3x more bandwith than normal, could that effectively work?

I did a quick test with my bot, making it give my SC vision, but it kinda went messed up, and SC thought my bot had unallied its self :P (replay here)


And i dont think NAT will be a issue, because all clients other than the real players (witch are on other address) will be ran from one PC, so each would be bound to there own port, so there shouldnt ever be a mix up over what socket recvs from who, and if there was, it could easyly be handled by the bot via the senders port.
But then again, i dont know alot at all about NAT, other than you mean traffic across the network/network-ips etc?
November 16, 2005, 8:49 AM
Kp
Starcraft passes the in_addr of other players to you when you join.  The bot will need to NAT that so that new players don't talk directly to you.
November 17, 2005, 4:29 AM
Ringo
Im still not 100% sure what you mean by NAT it. :(
At the moment im useing this kind of thing and havent had any send/recv direction problems as yet*
[code]
Public Type sockaddr_in
    sin_family       As Integer
    sin_port         As Integer
    sin_addr         As Long
    sin_zero(1 To 8) As Byte
End Type

Public Type SCPLAYERS
    Addr         As sockaddr_in
    Address      As String
    Port         As Long
    Index        As Integer 'Player ID
    SentOS(2)    As Long
    Sent(2)      As Long
    Recv(2)      As Long
    Account      As String
    StatString   As String
    RoomSlot     As UDPROOMSLOTS
    Race         As SCRACES
    Data(2, 100) As String
    ect ect...
End Type

Public Sub UDP_S_0_0x06(S As SCPLAYERS, ByVal ToPID As Integer)
    If S.Account = SC(ToPID).Account Then Exit Sub
    If Db.Cmd0 = True Then
        ShowChat vbWhite, "Sent Cmd 0 0x06 About Player " & _
                          S.Account & " to " & _
                          SC(ToPID).Account & "    " & _
                          SC(ToPID).Sent(0) + 1 & "/" & _
                          SC(ToPID).Recv(0)
    End If
    Dim IsHost As Byte
    If S.Addr.sin_addr = &H0 Then
        IsHost = &H1
    Else
        IsHost = &H0
    End If
    Dim B As New clsBuffer
    With B
        .InsertDWORD &H32 'urg
        .InsertDWORD S.Index
        .InsertDWORD IsHost
        .InsertDWORD &H0
        .InsertDWORD GameBeats + 2
        .InsertWORD S.Addr.sin_family
        .InsertWORD S.Addr.sin_port
        .InsertDWORD S.Addr.sin_addr
        .InsertBYTE S.Addr.sin_zero '()
        .InsertSTRING S.Account, Chr(0)
        .InsertSTRING S.StatString, Chr(0)
        .InsertHEADER &H6, UDPG_HEADER, SC(ToPID).Sent(0), SC(ToPID).Recv(0), 0, 0, True
        .StoreData 0, SC(ToPID).Index, SC(ToPID).Sent(0), SC(ToPID).SentOS(0)
        .SendPacket sckUDP, SC(ToPID).Address, SC(ToPID).Port
    End With
End Sub
[/code]
Im guessing it has somthing to do with sin_family? because at the moment, im setting the bot's sin_family to 0 (AF_UNSPEC) and joining players sin_family to 2 (AF_INET).
I was going to set the sockaddr.sin_port to the tmp sockets localport when it came to sending the data to SC, where as all other players would get sent the reall sockaddr for the player.
Also im filling the Addr type on join hail, for future checks on the address and port, to make sure each players ID matchs that of there join IP and port.
Altho i havent really tested this a great deal, would this generaly be ok/work for this kinda thing, or am i missing somthing?

Thanks

[edit]: fixed typos
November 17, 2005, 1:10 PM
Kp
[quote author=Ringo link=topic=13246.msg134363#msg134363 date=1132233046][edit]: fixed typos[/quote]

You missed quite a few.
November 18, 2005, 2:58 AM
Ringo
[quote author=Kp link=topic=13246.msg134435#msg134435 date=1132282737]
[quote author=Ringo link=topic=13246.msg134363#msg134363 date=1132233046][edit]: fixed typos[/quote]

You missed quite a few.
[/quote]
Forgetting the typo's for a second :), im not on a network, does that count for anything?
My address for each would for example be like so:
84.9.75.30:6112 - Starcraft
84.9.75.30:6113 - Host
84.9.75.30:6114 - tmp2
84.9.75.30:6115 - tmp3
84.9.75.30:6116 - tmp4
84.9.75.30:6117 - tmp5
84.9.75.30:6118 - tmp6
84.9.75.30:6119 - tmp7
84.9.75.30:6120 - tmp8
November 18, 2005, 3:34 AM
FrOzeN
Shouldn't it only be ports 6112-6119? Not 6120?
November 18, 2005, 3:42 AM
Ringo
Well, one socket would have to use 6120 :P
SC would be talking with the 7 tmp sockets, and the host would be talking to the 7 reall players.
It all depends what ports are avalible when i bind() them all
November 18, 2005, 3:48 AM
Kp
[quote author=Ringo link=topic=13246.msg134455#msg134455 date=1132285711]what ports are avalible when i bind() them all[/quote]

"... one bot to rule them all, and in the darkness bind() them."
November 18, 2005, 5:35 AM
Explicit[nK]
[quote author=Kp link=topic=13246.msg134477#msg134477 date=1132292151]
[quote author=Ringo link=topic=13246.msg134455#msg134455 date=1132285711]what ports are avalible when i bind() them all[/quote]

"... one bot to rule them all, and in the darkness bind() them."
[/quote]

What the hell? lol
November 18, 2005, 5:55 AM
Ringo
uh, im getting confused, i suck at this :(
I genealy find a free port like so:

[code]
Dim i as integer
for i = sockets.lbound to sockets.ubound
    BNCS_BIND(Sockets(i), 6112 + i)
next i


Public Sub BNCS_BIND(SOCK As Winsock, Optional PortRange As Long = 6112)
    Dim MyIP As String
    Dim FreePort As Long
    Bnet.BNCSIP = GFini("Setup", "BNET Address")
    Bnet.BNCSPort = CLng(GFini("Setup", "BNET Port"))
    MyIP = SOCK.LocalIP 'my internet IP (if accessable)
    FreePort = PortRange
    Bnet.UDPStamp = &H0
    Do Until FreeBind(SOCK, FreePort) = True
        FreePort = FreePort + 1
    Loop
    SOCK.RemoteHost = Bnet.BNCSIP
    SOCK.RemotePort = Bnet.BNCSPort
End Sub

Public Function FreeBind(SOCK As Winsock, ByVal PortRange As Long) As Boolean
    On Error GoTo NextPORT
    With SOCK
        .Close
        .Bind PortRange, .LocalIP
    End With
    FreeBind = True
    Exit Function
NextPORT:
    If Err.Number = 10048 Then
        FreeBind = False
    Else
        FreeBind = True
        Call ShowChat(vbRed, "[UDP] Bind Error:" & Err.Number & " Unable to bind " & Err.Description)
    End If
End Function
[/code]
November 18, 2005, 6:15 AM
LockesRabb
Lol... Ringo, when Kp said what he said, he was quoting from the 'Lord of the Rings' movies. Amusing reference. :) It wasn't related to what you were saying, he was just being amusing by playing with the word bind() when you mentioned that word :P
November 20, 2005, 6:12 AM
Ringo
Heh, I thought he was under the impression i was binding them in the darkness/blind :P
Its all constructive comments, witch is what i wanted tho :)
Kp knows alot more about this kinda stuff than me :P
November 20, 2005, 8:41 AM
Kp
[quote author=Kyro link=topic=13246.msg134760#msg134760 date=1132467161]he was just being amusing by playing with the word bind() when you mentioned that word :P[/quote]

Actually, bind() alone wouldn't have been enough to merit the joke.  But when it was "bind() them all", it seemed appropriate.
November 20, 2005, 5:58 PM

Search