|
AutoHotkeyRestart
Automating game restarts while battling your own AI
This page deals with automating game restarts while battling your own AI. Setting up StarCraft2 machines (or Virtual Machines of course), one that will create the game that we will call host, the other that will connect to it that we will call client.
ai_dll = C:\StarCraft\AI\BroodwarBotQ\Release\HostModule.dll ; your host dll auto_menu = LAN lan_mode = Local Area Network (UDP) auto_restart = ON map = maps\BroodWar\Tournament\SC-t1maps\dragoons.scm ; the map on which you want to play
ai_dll = C:\StarCraft\AI\BroodwarBotQ\Release\ClientModule.dll ; your client dll auto_menu = LAN lan_mode = Local Area Network (UDP) auto_restart = ON map = ; auto-joins games
Setting up AutoHotkey
Sleep 6000
WinGetActiveTitle, PreviouslyActive
MouseGetPos, xpos, ypos
IfWinExist Brood War
{
WinActivate
Click 517, 426
}
IfWinExist, %PreviouslyActive%
WinActivate
MouseMove, %xpos%, %ypos%, 0This waits 6 secondes avec been called (in onEnd(bool isWinner), see next section) so that we can skip the menus and have the client joined back the game. You may need to change that for more if your network is slow.
Tuning your code
void myRestartGame()
{
/////////// Launch an AutoHotkey that will click on "OK" in 10 sec
char procName[200];
sprintf_s(procName,
"C:\\StarCraft\\AI\\BroodwarBotQ\\scripts\\startGame.exe");
// Initialize StartupInfo structure
STARTUPINFO StartupInfo;
memset(&StartupInfo, 0, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);
// This will contain the information about the newly created process
PROCESS_INFORMATION ProcessInformation;
BOOL results = CreateProcess(0,
procName, // Process and arguments
0, // Process Attributes
0, // Thread Attributes
FALSE, // Inherit Handles
0, // CreationFlags,
0, // Environment
0, // Current Directory
&StartupInfo, // StartupInfo
&ProcessInformation // Process Information
);
// Cleanup
CloseHandle(ProcessInformation.hProcess);
CloseHandle(ProcessInformation.hThread);
} | |
► Sign in to add a comment