|
Getting All Around the Game
By now it should be clear that there are many places we can look around for interesting data in or near the game client. And there are even more places to mess around with these data. You can do this by sending information to the game client through the user interface (we’ll call this going over the game). You can do this by getting inside the game and looking around in memory (we’ll call this getting in the game). You can do this by getting between the game and the lower-level services it needs, such as video drivers (we’ll call this getting under the game). And you can even do this by sitting on the network between the game client and its server (we’ll call this standing way outside the game).
Here we go.
Going Over the Game: Controlling the User Interface
Elsewhere in the book, we present a very simple farming game bot that works by interacting with an MMO client interface. This is an extremely common technique and is thus worth another quick look.
The basic idea for getting over the game is to send events to the game client as if the events themselves were coming from the PC. That is, you can send messages to the client that look to it like normal keystrokes, mouse events, or other game-specific messages. This type of utility is sometimes called a macro. There are many macro programs available that can post mouse and keyboard events to the screen. Instead of showing you other people’s macro programs, we show you how to write your own. What follows are some easy examples to get you started.
Controlling Keystrokes
The first example involves sending keyboard events to the game client just as if we were typing directly on the keyboard. This is important since this can be used to move your game character, click on hotkeys for actions and events, and even type into a chat window.
Here is a snippet of source code that posts a keystroke to the computer. This is handled globally and will post the keystroke regardless of which window is in the foreground or which application is running. This technique is commonly used by macro programs. Many game hacking and macro scripts use basic keyboard and mouse events to interact with the game client. The side effect of using this technique is that you can’t use the computer for anything else while you are doing your botting because this technique basically takes over the user interface while it runs.
DWORD PostKeystroke(
BYTE theScanCode,
DWORD theTime)
{
keybd_event(
theScanCode,
MapVirtualKey(theScanCode, 0), 0, 0);
Sleep(theTime);
keybd_event(
theScanCode,
MapVirtualKey(theScanCode, 0), 0 |
†††††††††††††††††††††KEYEVENTF_KEYUP, 0);
return 0;
}
This code snippet uses the API call keybd_event( ). This call takes the virtual scan code for the key you want to press. This is not the same thing as the ASCII code. The character you want to press needs to be mapped to its respective scan code before you use this API function.
Using Magic Key Sequences
WoW has a character class known as Paladin—quite possibly one of the most difficult classes to play in the game.3 The key to playing this class is the proper ordering of actions to maximize damage or to preserve mana (an in-game energy rating of sorts). The game offers hotkeys that can be linked to actions for your character. So, one kind of macro might be designed to execute a series of actions to maximize the effectiveness of the Paladin character. Such a sequence might go like this:
F1 key: cast spell Sanctity Aura—increases Holy Damage
F2 key: cast spell Seal of Holy Might
F3 key: cast spell Judgement
F4 key: cast spell Seal of Command
F5 key: cast spell Hammer of Justice
F6 key: cast spell Crusader Strike
There are a total of six key bindings set up. Now, using these keys in the correct order and timing could result in the following:
Begin fighting . . .
F1—F2—F3—F4
Wait 15 seconds while fighting
F5—F3—F4
Continue fight for 15 more seconds, if target still alive, then
F5—F3—F4
Repeat above as timers allow
Obviously, that’s a lot of keystrokes. At the time of this writing, this sequence would first cast a Sanctity Aura, increasing damage output. Then, the Seal of Holy Might is cast, which is then immediately Judged—effectively placing a curse that makes your opponent take extra damage for a period of time. Next, a Seal of Command is cast, and fighting continues. This spell causes even more damage, and then a Hammer of Justice stuns the target opponent. Next, another Judgment causes a burst of damage that is enhanced by the fact that the opponent is also stunned. The character repeats this sequence as long as the fight is on.
Variations of these kinds of techniques abound, but this gives you an idea of the kind of analysis you can perform up front to engineer your macro for maximum effectiveness. Your mileage may vary.
|