Automating Tedious Tome Farming In Lost Ark

Cheesy automation for farming low-level collection quests with simple programming. I don’t play Lost Ark anymore, but this post has been on my TODO for quite a while.

Automating the Grind

There’s an MMORPG game called Lost Ark. It has a problem in that simple (Tome) collection quests involve grinding for a handful of hours. We’re talking about 5+ hours of mindless grinding per region – and there are quite a few regions.

There are various ways around this, such as purchasing these items from the game’s auction house. Although, I don’t want to spend too much gold doing that. Another option is to automate the tedious farming. Of course, this article exists because I decided to do the latter.

Option 1: Some Kind of Bot System

The game has a bot problem, where large groups of bots swarm the game, farm gold, blatantly teleport and wallhack, and tank the in-game economy. I’m not trying to do anything like this; I’m just trying to get past the unnecessarily tedious parts with my one character. So we’ll nix this consideration.

Option 2: Input Simulator

The other option would be to have an input simulator. But how would I simulate complex-enough input to perform the tasks I need of running around and killing enemies all day?

Luckily,

  • The areas I’m farming have incredibly weak enemies.
  • My character class has homing weapons.

So, the situation is pretty simple. All I need to do is stand still in the middle of enemy spawning grounds and automate attack commands every so often. The automation doesn’t need to be smart because my homing attacks have autonomy.

Simple Windows Automation

There are several ways we can go about this. Some devs may favor a Python package that simulates input. There’s also the option of using a full-blown automation tool. But I just made a simple program in C/C++.
In the end, a Python solution would call compiled code that invokes the same native OS functions. So, beyond personal programming preferences, it’s same-same.

For Windows applications, often an easy way to manipulate GUI applications is to find the application’s HWND, and make a (console) program that publishes (keydown) messages to it. But this doesn’t always work for games. Often games won’t check keydown messages, but use a separate API to query input states.

The function I used to emulate input into Lost Ark was SendInput().

#include <iostream>
#include <Windows.h>
#include <vector>

int main()
{
    std::cout << "Starting inputter program\n";


    // Sleep for a short while to allow the user to move keyboard
    // focus to the target application.
    Sleep(2000);

    // The keys we want to press.
    std::vector<char> keys = {'F', 'R', 'E'};
    
    int i = 0;
    while(true)
    {
        char key = keys[i % keys.size()];
        ++i;

        INPUT input;
        // Setup the key press
        input.ki.wVk        = key;
        input.ki.wScan      = 0;
        input.ki.time       = 0;
        input.ki.dwExtraInfo= NULL;
        input.type          = INPUT_KEYBOARD;

        // Execute the key press
        input.ki.dwFlags = 0; // Keydown
        SendInput(1, &input, sizeof(INPUT));
        //
        Sleep(2000);
        //
        // Execute the key release
        input.ki.dwFlags = KEYEVENTF_KEYUP;
        Sleep(2000);
        SendInput(1, &input, sizeof(INPUT));
    }
    return 0;
}

The simple program simulates pressing and releasing a key, then another, then another, etc. A short video below, but nothing to write home about; it’s pretty much like watching paint dry.

I cycle between 3 keys,

  • F key – Place a turret that attacks enemies.
  • R key – Paint a location to drop a tactical nuke. This isn’t a homing weapon, but it has a large blast radius. So I leave the mouse cursor over an enemy spawning location.
  • E key – Create an energy orb that moves towards nearby enemies.

The program requires keyboard focus. While I could also program a mouse motion to click the app automatically or possibly find Lost Ark’s HWND and use a Window API function to activate the game and give it keyboard focus, I manually click the app myself. Not a big deal. Also, because it requires keyboard focus, it pretty much hogs the computer while it’s running. This is also fine; I can start it up and let the game run overnight while I ZzZzZz.

Results

When using this program, I leave it overnight while getting some sleep. In the morning, ~8 hours later, I verify that I haven’t been reported/banned. I doubt that would ever happen, but it’s always in my mind as a non-zero possibility. I then check if I have all the necessary collection items. If I’m missing a stray thing or two, I buy the last of what I need from an auction.