Skip to content

Getting Started

Leo edited this page Mar 26, 2022 · 7 revisions

This guide will get a user from zero to having Intercept up and working within their Arma 3 development environment

Requirements:

  • Arma 3 is installed
  • Latest version of CBA is installed and enabled as a mod CBA releases can be found here
  • A working knowledge of C++
  • Knowledge of how to install and activate non-workshop mods in Arma 3
  • Disabled Battleye Anti-Cheat because it would block your non-whitelisted plugin.

Outcome:

  • Intercept Host mod installed
  • Visual Studio 2017 project environment configured to build an Intercept client
  • Minimal mod created for Intercept host to find and load sample client
  • Sample plugin built and installed

Install Visual Studio 2017

You can find the downloads for the free community edition here.
Note: Ensure C++ Visual Studio modules are installed.

Install Arma 3 Tools

Note: You may use some other PBO packer. In which case you won't need the Arma 3 Tools.

To install this via Steam, go to the Library drop-down, click tools. In the list, select and download Arma 3 Tools. This is necessary to build the mod to allow the Intercept host to find our client.

Download and Install the Latest Release of Intercept

Building from source

If you would prefer to install from source, please see Building and installing Intercept from source and follow the build guide there. How to do this will not be covered here.

Download the latest release and Install it

You can download the last released version of the library, which can be found here (You want the intercept_host file).

Alternatively you can retrieve the latest build from master branch here

NOTE: currently downloading the latest build from master branch is recommended as the releases are lagging a behind a bit

You then install it like any other Arma mod by moving the @intercept directory to your Arma directory.

Creating the Visual Studio 2017 Project

First download the Project template by either downloading the packed release from here or by cloning the intercept-plugin-template repository.

Note: The repository contains git submodules. Depending on your Git client you might need to take additional steps to download the submodules.

Now open Visual Studio. From the Menu on the top left select File->Open->CMake project. In the opened Dialog navigate to the template project you just downloaded and open the CMakeLists.txt in the main directory.

Visual Studio will now have opened the Project and you should be able to already build the Template. You might now want to open the CMakeLists.txt inside the project and edit the project Name.

You can also use the Visual Studio file browser to navigate to addons/main/config.cpp. This is the config for your PBO that will take care of loading your Plugin. Modify the marked lines to your liking.

Developing and Installing a Sample Client

Note: This section assumes a basic knowledge of C++ syntax.

We will make a client which spawns a new OPFOR unit, disables the AI, and has it follow the player around. This will demonstrate various operations, and the threading model.

Inside main.cpp add the following code:

using namespace intercept;

// Our custom function, instructing our follower unit to move to a location near the player every second
void follow_player(object follower) {
    while (true) {
        //New scope to allow the thread_lock to lock and release each cycle
        {
            // Blocks the renderer to allow the SQF engine to execute
            client::invoker_lock thread_lock;

            // Get the player object and store it
            auto player = sqf::player();

            // Get the position of the player, returned as a Vector3 in PositionAGLS format
            auto player_pos = sqf::get_pos(player);

            // Calculate a new position near the player for our follower to move to
            vector3 target_pos(player_pos.x + 5, player_pos.y + 3, player_pos.z);

            // Move our follower
            sqf::move_to(follower, target_pos);

        } // thread_lock leaves scope and releases its lock

        // Wait one second
        Sleep(1000);
    }
}

// This function is exported and is called by the host at the end of mission initialization.
void intercept::post_init() {
    // Get the player object and store it
    auto player = sqf::player();
    // Get the position of the player, returned as a Vector3 in PositionAGLS format
    auto player_pos = sqf::get_pos(player);

    // Calculate a new position near the player for our follower to spawn at
    vector3 follower_start_pos(player_pos.x + 5, player_pos.y + 3, player_pos.z);

    // Make a new group so that we can make a new unit
    auto follower_group = sqf::create_group(sqf::east());

    // Make our new unit
    auto follower_unit = sqf::create_unit(follower_group, "O_G_Soldier_F", follower_start_pos);

    // Stop our new friend from shooting at us or cowering in fear
    sqf::disable_ai(follower_unit, sqf::ai_behaviour_types::TARGET);
    sqf::disable_ai(follower_unit, sqf::ai_behaviour_types::AUTOTARGET);
    sqf::disable_ai(follower_unit, sqf::ai_behaviour_types::AUTOCOMBAT);
    sqf::disable_ai(follower_unit, sqf::ai_behaviour_types::CHECKVISIBLE);

    // The doStop SQF function allows him to move independently from his group
    sqf::do_stop(follower_unit);

    // Make a new thread
    std::thread follower_thread(follow_player, follower_unit);

    // Allow that thread to execute independent of the Arma 3 thread
    follower_thread.detach();
}

Now select the appropriate build type on the top left to the green play button. If you run 64-bit Arma you want to choose x64 here. Otherwise you choose x86.

Next Build the plugin. intercept-plugin-template/build/winXX directory.

Next, Open a new File Explorer window:

  1. Navigate to your Arma 3 installation folder
  2. In the root of your Arma 3 installation folder (where the arma3.exe exists), create a new folder
  3. Name the new folder @intercept-plugin-template
  4. Create a intercept and a addons folder inside it
  5. move the compiled .dll file of your plugin into the intercept folder.

Your Intercept plugin is now ready. Next we need the PBO that tells Intercept to actually load your plugin.

Create the Intercept Client Addon

In order for the Intercept host to find our sample client, we must create a mod which will point to the DLL we've just installed.

To build the mod:

  1. Open Arma 3 Tools Addon Builder
  2. In the "Addon Source Directory" field, press the "..." to the right
  3. Navigate to the intercept-plugin-template/addons/main folder and select it
  4. In the "Destination directory or filename" field select the @intercept-plugin-template/addons folder that you previously created
  5. Click the Pack button at the bottom right

We have built and installed the minimal client extension mod.

Testing

  1. Start Arma 3 and open the EDEN editor
  2. Load into the Virtual Reality map
  3. Place a playable BLUFOR unit down
  4. Start the map in single player mode

You should notice the new unit that has spawned, and it should move along with with you as if it were in formation with you

Happy Intercepting!