1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Why not try starcraft instead? There's bwapi which is much better for trying out AI. \$\endgroup\$ – congusbongus Aug 22 '14 at 0:33
  • \$\begingroup\$ 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. \$\endgroup\$ – Slav Aug 22 '14 at 0:48
  • 1
    \$\begingroup\$ I think @William 'MindWorX' Mariager was working on a WC3 hooking project that might be useful to you, hopefully he sees this. \$\endgroup\$ – Josh Aug 22 '14 at 0:50
  • \$\begingroup\$ Thank you! Nice wit. Waiting for it and putting slight initiation also ... ;) \$\endgroup\$ – Slav Aug 22 '14 at 1:10
4
\$\begingroup\$

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.
        trigger.AddAction(new DelegateAction(this.Tick));
    }

    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.

\$\endgroup\$
  • \$\begingroup\$ 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 ... \$\endgroup\$ – Slav Aug 22 '14 at 9:58
  • \$\begingroup\$ 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? \$\endgroup\$ – Slav Aug 22 '14 at 10:04
  • \$\begingroup\$ Sounds like this is suddenly a gray area, asking people to help you violate the game's user agreement. \$\endgroup\$ – Evan Aug 22 '14 at 15:58
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – William Mariager Aug 23 '14 at 10:47
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – William Mariager Aug 23 '14 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.