ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
198 stars 32 forks source link

Status of the project #88

Open eVen-gits opened 2 years ago

eVen-gits commented 2 years ago

Is this project still maintained?

I see it's bassed off of node-dota2, which has been deprecated.

I am currently to set up the bot, host a lobby, but I am unable to start it, as the bot doesn't connect to the game (even in broadcaster slot).

At the moment, I am looking at go-dota2, but that seems to be way more complicated (perhaps because I don't have experience with go).

So I guess my question is whether this project should still be used, or should I use something else?

rossengeorgiev commented 2 years ago

Only basic maintenance, it is not being actively developed. None of these module will let you connect the game, only create and manage lobbies.

eVen-gits commented 2 years ago

OK thanks!

I've managed to solve the problem by instead of joining the broadcaster team, I've joined the player pool team -> which disconnects the bot when it launches the game.

Now it appears that the bot does know when the game ends - once I write GG in chat and the throne explodes. The sequence of the messages is something like this:

Click to expand! [2022-07-03 12:26:52,365] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:52,365] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,365] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:52,365] DEBUG SteamClient: Multi: Decompressing payload (1266 -> 1825) [2022-07-03 12:26:52,366] DEBUG SteamClient: Incoming: | CMsgGCClient)> [2022-07-03 12:26:52,366] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,366] DEBUG SteamClient: Incoming: | CMsgGCClient)> [2022-07-03 12:26:52,366] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,366] DEBUG SteamClient: Incoming: | CMsgGCClient)> [2022-07-03 12:26:52,366] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,366] DEBUG Dota2Client: Incoming: [2022-07-03 12:26:52,367] DEBUG Dota2Client: Emit event: [2022-07-03 12:26:52,367] DEBUG Dota2Client.socache: Emit event: ('updated', ) [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2014 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2016 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2013 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2015 [2022-07-03 12:26:52,367] DEBUG Dota2Client: Emit event: 'lobby_changed' [2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: [2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: [2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: [2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: [2022-07-03 12:26:52,368] DEBUG Dota2Client.socache: Emit event: ('removed', ) [2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: 'lobby_removed' [2022-07-03 12:26:52,464] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:52,464] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,464] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:52,464] DEBUG SteamClient: Incoming: | CMsgGCClient)> [2022-07-03 12:26:52,464] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,465] DEBUG SteamClient: Incoming: | CMsgGCClient)> [2022-07-03 12:26:52,465] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,465] DEBUG Dota2Client: Incoming: [2022-07-03 12:26:52,465] DEBUG Dota2Client: Emit event: [2022-07-03 12:26:52,465] DEBUG Dota2Client.channels: Emit event: ('join_result', 'PostGame_27795233295518340', 18) [2022-07-03 12:26:52,465] DEBUG Dota2Client.channels: Emit event: 'channel_joined' [2022-07-03 12:26:52,465] DEBUG Dota2Client: Incoming: [2022-07-03 12:26:52,465] DEBUG Dota2Client: Emit event: [2022-07-03 12:26:52,466] DEBUG Dota2Client.channels: Emit event: 'members_update' [2022-07-03 12:26:52,915] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:52,916] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,916] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:52,916] DEBUG SteamClient: Incoming: | not parsed)> [2022-07-03 12:26:52,916] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,965] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:52,965] DEBUG SteamClient: Emit event: [2022-07-03 12:26:52,965] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:52,965] DEBUG SteamClient: Multi: Decompressing payload (271 -> 276) [2022-07-03 12:26:52,966] DEBUG SteamClient: Incoming: | CMsgClientPersonaState)> [2022-07-03 12:26:52,966] DEBUG SteamClient: Emit event: [2022-07-03 12:26:57,915] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:57,916] DEBUG SteamClient: Emit event: [2022-07-03 12:26:57,916] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:57,916] DEBUG SteamClient: Incoming: | not parsed)> [2022-07-03 12:26:57,916] DEBUG SteamClient: Emit event: [2022-07-03 12:26:58,015] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:26:58,016] DEBUG SteamClient: Emit event: [2022-07-03 12:26:58,016] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:26:58,016] DEBUG SteamClient: Incoming: | CMsgClientPersonaState)> [2022-07-03 12:26:58,016] DEBUG SteamClient: Emit event: [2022-07-03 12:26:59,026] DEBUG SteamClient: Outgoing: | CMsgClientHeartBeat)> [2022-07-03 12:27:08,026] DEBUG SteamClient: Outgoing: | CMsgClientHeartBeat)> [2022-07-03 12:27:17,027] DEBUG SteamClient: Outgoing: | CMsgClientHeartBeat)> [2022-07-03 12:27:18,114] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:27:18,115] DEBUG SteamClient: Emit event: [2022-07-03 12:27:18,115] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:27:18,115] DEBUG SteamClient: Incoming: | CMsgClientPersonaState)> [2022-07-03 12:27:18,115] DEBUG SteamClient: Emit event: [2022-07-03 12:27:20,419] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:27:20,419] DEBUG SteamClient: Emit event: [2022-07-03 12:27:20,419] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:27:20,419] DEBUG SteamClient: Incoming: | not parsed)> [2022-07-03 12:27:20,419] DEBUG SteamClient: Emit event: [2022-07-03 12:27:20,515] DEBUG SteamClient: Incoming: | CMsgMulti)> [2022-07-03 12:27:20,515] DEBUG SteamClient: Emit event: [2022-07-03 12:27:20,515] DEBUG SteamClient: Multi: Unpacking [2022-07-03 12:27:20,515] DEBUG SteamClient: Incoming: | CMsgClientPersonaState)> [2022-07-03 12:27:20,515] DEBUG SteamClient: Emit event:

The relevant bit, I guess, is this line: [2022-07-03 12:26:52,465] DEBUG Dota2Client.channels: Emit event: ('join_result', 'PostGame_27795233295518340', 18)

Unfortunately, it doesn't seem that I can hook onto this event this way: self.dota.on('join_result', self.on_join_result), as the function doesn't seem to reach a breakpoint. Additionally, I am not sure what the number is - it's not the match ID. Is there a way to convert this?

Sorry if this is offtopic, but I don't know where else to ask. Still, thank you for your swift and understanding reply.

rossengeorgiev commented 2 years ago

That is the post match chat channel, everyone gets joined to it after the match. You should be looking at:

[2022-07-03 12:26:52,367] DEBUG Dota2Client.socache: Emit event: ('updated', <ESOType.CSODOTALobby: 2004>)
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2014
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2016
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2013
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2015
[2022-07-03 12:26:52,367] DEBUG Dota2Client: Emit event: 'lobby_changed'
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: <ESOMsg.CacheUnsubscribed: 25>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: <ESOMsg.CacheUnsubscribed: 25>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081>
[2022-07-03 12:26:52,368] DEBUG Dota2Client.socache: Emit event: ('removed', <ESOType.CSODOTALobby: 2004>)
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: 'lobby_removed'

Lobby change indicates that the lobby socache object has been updated, like with the match result. Followed by <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081> which indicates match end, not sure what the message contains. The lobby socache object gets removed as you are no longer in a lobby.

I wonder what the unsupported socache types are, these are new and need to be implemented.

eVen-gits commented 2 years ago

Hm, I am trying to get this going, but with no success.

How can I look at a message? It appears that I can only register callbacks to events (such as lobby_new or lobby_changed). I am doing this in such manner (short snippet):

    def on_dota_ready(self):
        print('{}: Dota ready!'.format(self.username))
        if self.dota.lobby:
            self.dota.leave_practice_lobby()
            self.dota.wait_event('lobby_removed')

        #Register callbacks
        self.dota.on('lobby_new', self.on_lobby_new)

    def on_lobby_new(self, CSODOTALobby:ESOType.CSODOTALobby):
        result = self.dota.join_practice_lobby(
            CSODOTALobby.lobby_id,
            password=CSODOTALobby.pass_key
        )
        #result = self.dota.join_practice_lobby_broadcast_channel() #Fails to launch game because bot doesn't connect
        result = self.dota.join_practice_lobby_team(1, DOTA_GC_TEAM.PLAYER_POOL)

How do I make a callback or how do I look at the messages you suggested? Sorry if these are basic questions, but I can't find anything regarding this in the docs.

Philaeux commented 1 year ago

To subscribe to a message, use the "dota.on" decorator or the callback subscribe method "on".

# Subscribing to a callback
dota.on('lobby_changed', game_update)

# Using feature code
dota.on(dota2.features.Lobby.EVENT_LOBBY_CHANGED, game_update)

# using Message code
dota.on(EDOTAGCMsg.EMsgGCMatchmakingStatsResponse, stat_response)

# using decorator version
@dota.on('lobby_changed')
def game_update(self, message):
   # Here message.state can be 
   # 0: in lobby
   # 1: in-game (loading)
   # 2: in game
   # 3: post-game
   # if 3, message.match_outcome == 2 if radiant win, or 3 if dire win
   pass

ISSUE STATUS: CLOSED TAG: HOWTO

vilad86 commented 8 months ago

That is the post match chat channel, everyone gets joined to it after the match. You should be looking at:

[2022-07-03 12:26:52,367] DEBUG Dota2Client.socache: Emit event: ('updated', <ESOType.CSODOTALobby: 2004>)
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2014
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2016
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2013
[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2015
[2022-07-03 12:26:52,367] DEBUG Dota2Client: Emit event: 'lobby_changed'
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: <ESOMsg.CacheUnsubscribed: 25>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: <ESOMsg.CacheUnsubscribed: 25>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Incoming: <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081>
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081>
[2022-07-03 12:26:52,368] DEBUG Dota2Client.socache: Emit event: ('removed', <ESOType.CSODOTALobby: 2004>)
[2022-07-03 12:26:52,368] DEBUG Dota2Client: Emit event: 'lobby_removed'

Lobby change indicates that the lobby socache object has been updated, like with the match result. Followed by <EDOTAGCMsg.EMsgGCToClientMatchSignedOut: 8081> which indicates match end, not sure what the message contains. The lobby socache object gets removed as you are no longer in a lobby.

I wonder what the unsupported socache types are, these are new and need to be implemented.

Hi

[2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2014 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2016 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2013 [2022-07-03 12:26:52,367] ERROR Dota2Client.socache: Unsupported type: 2015

How to disable these messages?

Philaeux commented 8 months ago

I don't think the project is updated at the moment: protobuff are not synced with retail. Also the lib is using ValvePython/steam which is not updated and got a breaking change too.