• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to interface with WC3 for automation?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

I would to be able to send chat commands in WC3 using a script.

I'm tempted just to go blind and use something like Java.robot, and model all the possible states from my knowledge of battle.net's UI, keeping track of each state so the robot can do what I need to do.

The downside is ofc I can't use my machine while the robot does its thing.

Clearly this isn't how hosting bots work though--they somehow (magically?) have access to WC3's actual states and even the game state (they know if you left by defeat or just rage quit).
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Hostbots replace a normal client, so they dont work on top of a normal game instance but just use the battlenet protocols to communicate with battlenet as if they were normal wc3 clients.

I dont know what ur trying to do, if you want to write your own spambot take a look at this:
https://bnetdocs.org/

You can also read through the sources of other bots, Ghost++ and AuraBot ...
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Hostbots replace a normal client, so they dont work on top of a normal game instance but just use the battlenet protocols to communicate with battlenet as if they were normal wc3 clients
This is not entirely true.

Host robots replace the standard host that clients use if they create a game. This is a layer present even in singe player (yes you can crash it causing you to "you have been disconnected" when testing a WE map offline) that is responsible for synchronizing clients and managing commands.

You can run a host robot and join it with a client on the same system. This is done by simply publishing the game on local LAN as well and joining via that. When you join no battlenet data is transmitted, which is how you can spoof your name since your client is responsible for declaring what name it is when joining.

This is also why the idea of a "host player" is all fantasy since clients do not host. With standard hosting there is a forced relationship of 1 client always managing the host server as well but as robots show this need not be the case so all clients are actually identical to each other.

BattleNet is mostly used as an advertisement server for host lobbies. It keeps track of game names, map details and the host IP address so that the details can be forwarded to the client without creating a direct connection to the host. Basically it is a coordination server.

The exception is with melee games where BattleNet itself acts as the host server to prevent cheating. This is why melee players never ran into issues joining games through NATs.

In StarCraft II all games (arcade, custom and melee) are run with hosts managed by BattleNet. This has considerable advantages such as automatic replay and match logs, no NAT hosting issues, good QoS but also some problems such as limited bank synchronization rates and potential traffic problems with too many synchronized commands. Only campaign and map testing/offline play is done via a private host server in SC2.

Clearly this isn't how hosting bots work though--they somehow (magically?) have access to WC3's actual states and even the game state (they know if you left by defeat or just rage quit).
The host server keeps tracks of all in game commands and event messages and is responsible for making synchronization decisions. It does not have any idea of the deterministic state, it only knows what clients send it about the state. Since a replay file is nothing more than a dump of all this detail that runs through the host it can generate replay files. Also since none of the deterministic state is involved host servers are considerably more light weight than the game client so even an old computer should be able to manage several as long as network resources are sufficient (most of the limits with host robots are network resources).

The easiest way to force a client to send a chat command is to perform a man in the middle style hacking trick. The idea is that you have a packet insertion point (via proxy or anything that works) that allows you to insert custom packets that contain commands for your chat message (looks like a valid WC3 packet) along with the usual WC3 traffic. Since WC3 uses TCP a proxy would be easiest where the return pipe is directly connected but transmit pipe scans for command frames and then can queue chat command frames into the stream. From WC3 client point of view it will send and receive data as normal but the host server will receive additional command frames with chat messages and things that will then be synchronized between all clients.

It should be noted that this goes against the terms of use of WC3 as you are now manipulating its generated traffic. As such it is possible it will get your CD KEY banned from online use. Chances of this happening for custom games is probably quite slim (they are dominated by robots now) but it will certainly be a huge risk I recommend against for melee use.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Is the number of bots you can make determined by the number of CDKeys you have? So for every bot on battle.net, it uses a unique CD key?

I was hoping for a library I could import in Python that provides a high level API / interface for doing this, e.g. like win32api which provides an interface for interacting with Windows OS in Python.

This is because I have 0 knowledge about anything to do with networks or internet communication.

Thanks Muzzel for the links and thanks DSG for the explanation. I will need some time to digest them given my aforementioned background.

AuraBot source is in some kind of C I think? I suppose I could try calling its functions in Python once I get familiar with it.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Is the number of bots you can make determined by the number of CDKeys you have? So for every bot on battle.net, it uses a unique CD key?
The number of CDkeys purely determines the number of games listed in the lobby as each requires an account logged into battlenet. The number of parallel sessions is entirely dependant on the resources available to you. After a lobby starts (no longer in custom game list) another lobby can be created using the same account.

Obviously there is no such restriction for LAN which is why VPNs are flooded with robot games.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
AuraBot is in C++, its a fork of the very popular Ghost++ with reduced functionality (ghost has lots of unrequired functions that complete bloat the bot) and efficiency in mind. If you want to read bot code i suggest you read the AuraBot sources as they are much smaller and cleaner than the Ghosts.
 
Status
Not open for further replies.
Top