# Farm Manager - Tribal Wars 2 Farmbot

This bot farms barbarian villages in Tribal Wars 2.
It automatically detects barbarian villages, available troops and configured army presets to attack.

## Features

### Easy to Configure

• Automatically reads the required information from the game: Locations of farms, available units, army presets, current attacks per village, etc.
• Use the in-game army presets to configure which villages should attack and which units to use.

### Efficient

• Supports multiple army presets per village to make the best use of your troops.
• Takes into account the limit of 50 attacks per village.
• Fast enough to send 800 attacks per hour.
• Option to avoid barbarian villages under a certain amount of points.
• Avoid having your troops die at remaining walls: Option to avoid barbarian villages with specific coordinates.

### Safe

• Supports random breaks between farming cycles.
• Uses a normal web browser to interact with the game server for maximum security.
• Stops the farming when the configured time limit is met to avoid perpetual activity on your account.

## Starting the Farmbot

This video shows the process of starting the farmbot and setting up your Tribal Wars 2 account:

To start the farmbot, download the executable file from https://botengine.blob.core.windows.net/blob-library/by-name/tribal-wars-2-farmbot-2020-05-07.exe and then run it.

The first time you start the bot, it will download a web browser component. This can take some time, depending on your internet connection.

When the browser download is finished, the bot opens a ‘chromium’ web browser window, which is a variant of googles chrome web browser. In the Windows taskbar, it appears with an icon that is a blueish version of the google chrome logo:

In the browser window opened by the bot, navigate to the Tribal Wars 2 website and log in to your world so that you see your villages.

Then the browsers address bar will probably show an URL like https://es.tribalwars2.com/game.php?world=es77&character_id=12345

Now the bot will probably display a message like this:

Found no army presets matching the filter ‘farm’.

Or, in case your account has no army presets configured at all, it shows this message:

Did not find any army presets. Maybe loading is not completed yet.

In any case, we need to configure at least one army preset before the bot can start farming.

### Configuring Army Presets

The bot only uses an army preset if it matches the following three criteria:

• The preset name contains the string ‘farm’.
• The preset is enabled for the currently selected village.
• The village has enough units available for the preset.

If multiple army presets match these criteria, it uses the first one by alphabetical order.

If no army preset matches this filter, it switches to the next village.

You can use the in-game user interface to configure an army preset and enable it for villages:

Besides the army presets, no configuration is required.

The bot searches for barbarian villages and then attacks them using the matching presets. You can also see it jumping to the barbarian villages on the map.

In the console window, you can read about the number of sent attacks and what the bot is currently doing:

[...]
Sent 129 attacks in this session, 129 in the current cycle.
Checked 1413 coordinates and found 364 villages, 129 of wich are barbarian villages.
Found 3 own villages.

Current activity:
+ Currently selected village is 871 (482|523 'Segundo pueblo de skal'. Last update 6 s ago. 537 available units. 11 outgoing commands.)
++ Best matching army preset for this village is 'farm beta'.
+++ Farm at 567|524.
++++ Send attack using preset 'Farm 1'.
[...]


When all your villages are out of units or at the attack limit, the bot stops with this message:

Finish session because I finished all 1 configured farm cycles.

## Getting Help

When asking for help with the bot, include the complete text from the console window or a screenshot. Make sure screenshots are well readable. Don’t try to insert a screenshot directly into the forum, as it will be compressed and unreadable. When posting on the forum, you can link screenshots hosted at other sites like Github or imgur.

## Configuration Settings

All settings are optional; you only need them in case the defaults don’t fit your use-case.

• ‘number-of-farm-cycles’ : Number of farm cycles before the bot stops. The default is only one (1) cycle.
• ‘break-duration’ : Duration of breaks between farm cycles, in minutes. You can also specify a range like 60-120. It will then pick a random value in this range.
• ‘farm-barb-min-points’: Minimum points of barbarian villages to attack.
• ‘farm-barb-max-distance’: Maximum distance of barbarian villages to attack.
• ‘farm-avoid-coordinates’: List of village coordinates to avoid when farming. Here is an example with two coordinates: ‘567|456 413|593’

To configure settings, open the configuration page at https://catalog.botengine.org/64AAE01CE30C88F2973264AC3F357943F3D640472E4A2DE64155016B4F83A498 in a web browser.

On this page, scroll down to the button Configure app.

Click this button to navigate into the configuration interface:

Here we have multiple input fields, but to use any of the bot settings mentioned above, we only need the input field right of the --app-settings label.

Here is an example of app-settings for three farm cycles with breaks of 20 to 40 minutes in between:

number-of-farm-cycles = 3, break-duration = 20 - 40


Use the button Download script with this command line to run the app to download a script to run the bot with the entered settings.

When you have applied settings for multiple farm cycles, the bot displays this message during the breaks between farm cycles:

Next farm cycle starts in 17 minutes. Last cycle completed 16 minutes ago.

## Pricing and Online Bot Sessions

You can test the bot for free. When you want the bot to run more than 15 minutes per session, use an online-bot session as explained at https://github.com/Viir/bots/blob/master/guide/how-to-run-a-bot.md#online-bot-sessions

### How can I make the bot remember the locations of the barbarian villages?

To make it remember the farm locations, configure more farm cycles. The bot remembers all those coordinates within the same session, so it can reuse this knowledge, starting with the second farm cycle. It sends only one attack per target per farm cycle, so the remembering does not affect the first farm cycle. If you don’t use any configuration, the bot only performs one farm cycle and then stops.

### How much time does this bot need to send all attacks on my account?

Sending one attack takes less than four seconds. The bot can cover 800 farms per hour. The first farm cycle per session is a special case: For the first cycle, it needs additional time to find the farm villages. The game limits us to 50 concurrent attacks per village, and the bot switches to the next village when the currently selected village hits that limit. One farm cycle is complete when all your villages are at the limit, either because of the attack limit or because no matching units are remaining.

I tried evrything cant get it to work do i need to copy/paste this in the botengine.exe ? or in command prompt because it can never find anything or the bot just closes and nothing happends

C:\path\to\the\BotEngine.exe  run-bot  "https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot"


Copy the command into the Command Prompt app. Will look like in this screenshot:

Thx after 2 hours i got it working

Sorry to read it took so long for you. I recommend anyone who gets stuck for more than ten minutes to report their problem.

@Viir you could provide a .bat for people who struggle with the cmd thingy?

a universal batch file wouldn’t work as everyone will have stored the botengine files in different locations on their computer.

im trying to figure out how to run this bot online but i keep getting a message 'this app cant be executed

i typed this in command prompt botengine run-bot MY SESSION KEY “https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot” i dont get what im doing wrong ?

How? What does this mean? How does that work?

Where do you get this error message from?

What command did you use before it stopped working? for example in this case:

What was the last change before it stopped working?

it never worked i cant get it to work i did like the online bot guide said i made a online session key then i type the following in command prom

then it just says this app can’t be executed on your pc

@Random12 you don’t need an online session key. No key is required to run the bot.

In the screenshot you linked, I see the following error message, after an attempt to use the botengine command:

Toegang geweigerd

As far as I understand, it translates roughly to ‘Access denied’. Not sure what could caus this, but in any case, you probably can avoid this by specifiying the complete path to the BotEngine.exe file, with a command like this:

C:\path\to\the\BotEngine.exe  run-bot  "https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot"


Yes this works C:\Users\Tjebbe\Downloads\2020-01-24.botengine-console\BotEngine.exe run-bot “https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot” but thats not online session after 15 mins it stops i cant seems to figure out how to make that bot online im very bad with this stuff

To start an online bot session, change the command to add the --key-to-start-online-session option between then run-bot part and the bot source. So you go from

C:\Users\Tjebbe\Downloads\2020-01-24.botengine-console\BotEngine.exe run-bot "https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot"


To:

C:\Users\Tjebbe\Downloads\2020-01-24.botengine-console\BotEngine.exe  run-bot  --key-to-start-online-session=your-personal-key-here  "https://github.com/Viir/bots/tree/42b11c257f99c61538b7060ea1a4fd4f7d40f0eb/implement/applications/tribal-wars-2/tribal-wars-2-farmbot"


hmm when i type

like u said im getting this now

sorry im a total nub as this sort of stuff xd

Kann ich diesen Bot öfters als nur einmal laufen lassen? Nach einem Durchlauf stoppt der Bot und schließt die Konsole automatisch. Wenn ja wie mache ich es

@Random12, I see I should have given some more details about how to compose the command. In the example I posted, you will need to replace the part your-personal-key-here with the key that you can make visible by clicking the Show key button after logging in at https://app.botengine.org/
I could not post this final step in public because this key is personal and should not be shared in public. In case the instructions above are not clear, I can send you a private message with the command composed accordingly.

finally its working thx dude ! now i can enjoy tw again haha

Hallo Harkum, ich habe eine Version erstellt die das farmen widerholt. Du kannst diese so starten:

botengine  run-bot  "https://github.com/Viir/bots/tree/5e082111848380c9362a93a6a20a169d514f63c6/implement/applications/tribal-wars-2/tribal-wars-2-farmbot"

1 Like