# How can I obtain in-game data from Warcraft 3 from an external process?

I am implementing a behavior algorithm and would like to test it with my lovely Warcraft III game to watch how it will fight against real players.

The problem I'm having is that I don't know how to obtain information about in-game state (units, structures, environment, etc.) from the running WC3 game. My algorithm needs access to the hard drive and possibly distributed computing, that's why JASS (WC3's editor language) isn't appropriate; I need to run my algorithm from a separate process.

Direct3D hooking is an approach, but it wasn't done for WC3 yet and a significant drawback of that approach would be the inability to watch how the AI performs online, since it uses the viewport to issue commands.

How I read in-game data from WC3 in a different process in a fastest and easiest way?

Precisely what I need for Warcraft 3 exists for Starcraft: BWAPI.

• Why not try starcraft instead? There's bwapi which is much better for trying out AI. – congusbongus Aug 22 '14 at 0:33
• I really like WarcraftIII - spent ~3 years playing it 7 years ago but still couldn't reach even a "semi pro" and would like to see how my programming incarnation will beat everyone to the pieces :) . BTW, if to implement AI within Starcraft2 using common way, you won't be able put him playing against real players within Battle.Net's ranked system. – Slav Aug 22 '14 at 0:48
• I think @William 'MindWorX' Mariager was working on a WC3 hooking project that might be useful to you, hopefully he sees this. – Josh Aug 22 '14 at 0:50
• Thank you! Nice wit. Waiting for it and putting slight initiation also ... ;) – Slav Aug 22 '14 at 1:10

I see basically two ways you could solve this, but in both cases you'll need to utilize my SharpCraft project, which is a C# powerered way of injecting functionality into Warcraft III made by me, with research from a bunch of other people. Do note that the readme is outdated, but I'll do my best to help you out with the current release.

## Use JASS

This way you have easy access to the full JASS API, which allows you to fetch everything easily. What you do here is add some custom natives to the JASS API that help bridge the gap between JASS and your application. This could be natives that write to the hard disk or natives that send messages to your application.

## Use C#

This approach has the advantage that you can keep it in all C#, which is much more versatile than JASS, but you can't use natives that use strings. You have full access to the JASS API from C#, so you'll not lose out on any features.

There's a plugin included in the pack that shows the XML structure for plugins. To use the library, you add a reference to SharpCraft.dll, and then create a class that implements the FullPluginBase class. From there you have access to the different parts of the API.

public class MyPlugin : FullPluginBase
{
public override void Initialize()
{
// This is a pretty cheap way to get into any map without the map needing to be coded for it.
Script.PostMain = this.Script_PostMain;
}

private void Script_PostMain()
{
// Create a JASS trigger.
var trigger = JassTrigger.Create();
// Make the trigger run every .01 seconds, repeatedly.
trigger.RegisterTimerEvent(0.01f, true);
// Make the trigger call our Tick function when triggered.
}

private void Tick(JassTrigger trigger)
{
// Do the stuff you want to do, using the JASS API or .NET API.
}
}


I hope this gives you an idea of how to use it.

• Omg, I definitely cannot google properly - was looking for any hacks for 2 days and dig down all the existing hacks/hooks etc. and didn't found your vast, structured project with "Warcraft 3" preamble ... – Slav Aug 22 '14 at 9:58
• Having information out of project's README file, it's clear that it will solve most problems, but please could give a short resume about the following issues: a) can AI be run at Blizzard's official map (which you cannot change with WorldEditor); b) can AI be run transparently for WC3, so the game will think it's an ordinary player and let AI play at Battle.NET against real players? – Slav Aug 22 '14 at 10:04
• Sounds like this is suddenly a gray area, asking people to help you violate the game's user agreement. – Evan Aug 22 '14 at 15:58
• As it is, SharpCraft can do all you're asking, issue units around, analyze the environment, log data, etc., except for doing it in official games. This is a conscious choice on my behalf, to avoid people using the project for cheating. – William Mariager Aug 23 '14 at 10:47
• The simplest would be to just create something that takes control of player 2 and then have your testers play as player 1. Then the map doesn't matter, as you just use SharpCraft to inject into all maps the way I've shown. – William Mariager Aug 23 '14 at 13:11