Starcraft II: Lost Viking “macro” for mac
Posted: June 2nd, 2011 | Author: chmullig | Filed under: Gaming | Tags: gaming, programming, starcraft 2, starcraft II | 1 Comment »So Stracraft II is a fantastic game, and includes achievements. I’ve turned into a bit of a SC2 achievement whore (Currently: 3350). I long ago completed every achievement in the single player campaign except 4: The Lost Viking. It’s a stupid arcade game within the game! It doesn’t matter at all! Yet I was tantalizingly close to 100%, so finally I decided to tackle it.
First, you can read all sorts of strategies. Basically they come down to this: immediately get 2 side missiles, then get 2 drones. Whenever you loose a drone, replace it first chance you get. Then everything else should be bombs. (Any drop goes through a sequence, so wait until it’s the one you want). Use bombs liberally to prevent death and loss of drones. They make you invincible for a few seconds, in addition to clearly crap away. You’ll have basically all the bombs you need. Press space as fast as you can to shoot faster.
So it’s mostly a question of staying alive, and keeping your drones alive. Except for the bosses/mini bosses there’s not a ton of strategy. After a few attempts yesterday I beat it once, then hit 245k points, then 279k points (getting Silver). That only left gold (500k points), and I didn’t have the energy. However I knew there was a macro on the Windows side to hit space for you. In that case all you’d have to do is navigate around, which isn’t too hard. A few attempts to track one down on the Mac failed. Mac OS X is nice, but it definitely lacks some of the rom emulation tools so popular on Windows. I wanted an OS X program to simply pres the space bar over and over and over again forever, quickly, while not interfering with the rest of the system. It was useless if I couldn’t
However I figured there must be a better option, perhaps Objective-C? My Obj-C is super rusty, but I stumbled across a StackOverflow hint suggesting how easy it would be to do in plain C. Here’s the C program I wrote that uses CG Quartz Events to simulate pressing the space bar every .05 seconds (In retrospect that’s probably way faster than it needs, could probably easily be .1 seconds).
#include <stdio.h> #include <ApplicationServices/ApplicationServices.h> #include <unistd.h> int main (int argc, const char * argv[]) { CGEventRef spaceDown = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)49, true); CGEventRef spaceUp = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)49, false); int sleepTime = 50000; printf("Pressing space every %d microseconds\n", sleepTime); sleep(2); while (1) { CGEventPost(kCGHIDEventTap, spaceDown); CGEventPost(kCGHIDEventTap, spaceUp); usleep(sleepTime); } CFRelease(spaceDown); CFRelease(spaceUp); return 0; } |
It can be copied to a file like “cstroker.c” and compiled with this gcc command (you may need to install Xcode if you don’t already have it) from Terminal.app:
gcc -o cstroker cstroker.c -O -Wall -framework ApplicationServices
You then execute it by simply calling ./cstroker
Update: Because some folks asked I’ve uploaded the binary. Might work for you, in which case you can skip the gcc compilation.
1 Comment »