AI-Powered NPCs in Arma Reforger: When Game Characters Think for Real
ยท7 min read
๐ŸŽฎ

AI-Powered NPCs in Arma Reforger: When Game Characters Think for Real

What happens when you connect Arma Reforger NPCs to actual AI models? They stop following scripts and start making decisions. Flanking, retreating, negotiating, lying. Here's how ANT makes it possible.

gamingNPCsArma ReforgerAI agents

Every NPC you've ever met in a game is an actor reading a script. They patrol a route. They aggro when you get close. They say the same three lines. They die in the same predictable way. Even in Arma Reforger โ€” one of the most realistic military simulators ever made โ€” the AI follows decision trees. Sophisticated ones, sure. But trees nonetheless.

Now imagine this: an Arma Reforger mod where every NPC squad leader has access to a language model. Not a chatbot bolted on top โ€” an actual reasoning engine that receives the tactical situation as structured data and returns decisions. The squad leader assesses terrain, evaluates threats, considers ammo status, and decides whether to push, flank, hold, or retreat. Not because a behavior tree told it to. Because it thought about it.

How It Works

The mod sends a structured prompt to ANT on every decision tick โ€” every few seconds, or when a significant event occurs (contact, casualty, objective change). The prompt contains the NPC's current state as structured data:

json
{
  "role": "squad_leader",
  "squad_size": 6,
  "casualties": 1,
  "ammo_status": "low",
  "position": "tree_line_north",
  "known_enemies": [
    {"type": "infantry", "count": 4, "bearing": 210, "range": 150, "in_cover": true}
  ],
  "terrain": "open_field_south, forest_north, buildings_east",
  "objective": "secure_village",
  "morale": 0.7,
  "time_of_day": "dusk",
  "weather": "rain",
  "orders_from_command": "advance_when_ready"
}

ANT routes this to a fast, cheap model (ant:fast for routine decisions, ant:reasoning for complex tactical situations) and gets back a structured decision:

json
{
  "action": "flank_east",
  "reasoning": "Enemy is dug in facing south. Direct assault across open ground with low ammo is suicide. Buildings east provide covered approach. Use rain and fading light as concealment.",
  "fireteam_alpha": "suppress_from_treeline",
  "fireteam_bravo": "move_through_buildings_to_east_flank",
  "priority": "conserve_ammo_suppress_only",
  "fallback_trigger": "if_bravo_takes_contact_before_reaching_buildings",
  "fallback_action": "smoke_and_withdraw_north"
}

The mod parses this JSON and translates it into Arma Reforger AI commands. Fireteam Alpha suppresses. Bravo moves. If things go wrong, they have a fallback plan. The NPC didn't follow a script โ€” it made a tactical decision based on the actual situation.

Why ANT, Not a Direct API

A game mod can't afford GPT-5 pricing for every NPC decision. A 40-player server with 200 AI-controlled NPCs making decisions every 5 seconds = 2,400 requests per minute. At GPT-5 rates, that's $50+/hour. Nobody is paying that to play Arma.

ANT solves this with intelligent routing. Most NPC decisions are routine โ€” patrol, hold position, follow squad leader. These go to ant:fast or ant:free (Llama, Gemma) at near-zero cost. Only genuinely complex tactical decisions โ€” ambush planning, retreat coordination, surrender negotiations โ€” escalate to reasoning models. The result: 95% of decisions cost fractions of a cent, and the 5% that matter get frontier-grade intelligence.

  • โ€ขRoutine patrol decision โ†’ ant:free (Llama 8B) โ†’ $0.00 โ†’ 200ms
  • โ€ขEnemy spotted, simple engagement โ†’ ant:fast (GPT-4.1 mini) โ†’ $0.001 โ†’ 300ms
  • โ€ขComplex flanking maneuver โ†’ ant:coder (structured output) โ†’ $0.005 โ†’ 800ms
  • โ€ขSurrender negotiation with player โ†’ ant:reasoning (o4-mini) โ†’ $0.02 โ†’ 2s
  • โ€ขFull battle plan for 3 squads โ†’ ant:best (Claude Opus) โ†’ $0.10 โ†’ 5s

What Changes in Gameplay

When NPCs can actually think, everything changes:

  • โ€ขEnemies don't just rush you โ€” they evaluate whether rushing is smart given their numbers, ammo, and terrain
  • โ€ขWounded squads retreat and regroup instead of fighting to the last man
  • โ€ขNPCs use the environment โ€” smoke, buildings, darkness, weather โ€” as tactical advantages
  • โ€ขSquad leaders adapt to your tactics โ€” if you keep flanking left, they start covering their left
  • โ€ขNPCs can negotiate โ€” surrender, demand your surrender, offer to trade prisoners
  • โ€ขCivilians react realistically to combat โ€” hiding, fleeing, seeking help, sometimes lying about enemy positions
  • โ€ขEnemy commanders make strategic decisions โ€” reinforcing weak points, abandoning lost positions, setting up ambushes on your expected route

Real Example: Free Model, Real Decision

Here's an actual response from ant:free (Gemma 27B โ€” zero cost) given a tactical situation with grid coordinates:

json
// Prompt: "Alpha Squad (6 soldiers, 1 wounded) at grid 045,082.
// 4 enemy at 043,079 (stone wall), 2 more at 046,078 (building).
// Objective: secure village at 044,077. Dusk, rain. Reinforcements in 15min."

// Response from ant:free (Gemma 27B, $0.00):
{
  "orders": [
    {
      "type": "movement",
      "target": "044,078",
      "formation": "wedge",
      "speed": "fast",
      "reasoning": "Flank enemy at 046,078. Utilize dusk for concealment.",
      "soldiers": "All except wounded"
    },
    {
      "type": "engagement",
      "target": "046,078",
      "priority": "high",
      "ammo_threshold": "20%",
      "reasoning": "Neutralize immediate threat to village approach."
    }
  ],
  "wounded_soldier": "Remains at 045,082, radio for evac on reinforcement arrival",
  "reinforcements_ETA": "15 minutes"
}

That's a free model making a flanking decision with real grid coordinates, ammo conservation logic, and wounded soldier management. Not scripted. Not random. Reasoned.

How to Implement: Arma Reforger (Enfusion)

Arma Reforger uses the Enfusion engine with EnScript. Here's how to connect an NPC's decision loop to ANT:

c
// EnScript โ€” Arma Reforger NPC AI Decision Loop
class AntAIDecision
{
    static string ANT_URL = "https://antbase.ai/v1/chat/completions";
    static string ANT_KEY = "your-ant-api-key";

    // Called every decision tick (every 3-5 seconds)
    static void RequestDecision(AIAgent agent, string sitrep)
    {
        RestContext ctx = GetGame().GetRestApi().GetContext(ANT_URL);
        ctx.SetHeader("Authorization", "Bearer " + ANT_KEY);
        ctx.SetHeader("Content-Type", "application/json");

        string body = "{" +
            "\"model\": \"ant:fast\"," +
            "\"messages\": [" +
                "{\"role\": \"system\", \"content\": \"You are an NPC squad leader. Respond JSON.\"}," +
                "{\"role\": \"user\", \"content\": \"" + sitrep + "\"}" +
            "]," +
            "\"max_tokens\": 300" +
        "}";

        ctx.POST(new RestCallback(), body);
        // Parse JSON response โ†’ execute orders via AIAgent API
    }
}

How to Implement: Unreal Engine (C++)

cpp
// Unreal Engine โ€” HTTP request to ANT for NPC decision
#include "HttpModule.h"
#include "Json.h"

void UAntNPCComponent::RequestTacticalDecision(const FString& Sitrep)
{
    auto Request = FHttpModule::Get().CreateRequest();
    Request->SetURL("https://antbase.ai/v1/chat/completions");
    Request->SetVerb("POST");
    Request->SetHeader("Authorization", "Bearer your-ant-api-key");
    Request->SetHeader("Content-Type", "application/json");

    TSharedPtr<FJsonObject> Body = MakeShareable(new FJsonObject);
    Body->SetStringField("model", "ant:fast");
    // ... build messages array with sitrep ...

    Request->OnProcessRequestComplete().BindUObject(
        this, &UAntNPCComponent::OnDecisionReceived);
    Request->ProcessRequest();
}

void UAntNPCComponent::OnDecisionReceived(
    FHttpRequestPtr Request, FHttpResponsePtr Response, bool bSuccess)
{
    // Parse JSON โ†’ execute movement/engagement orders via AI controller
}

How to Implement: Unity (C#)

csharp
// Unity โ€” NPC decision via ANT API
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class AntNPCBrain : MonoBehaviour
{
    const string ANT_URL = "https://antbase.ai/v1/chat/completions";
    const string ANT_KEY = "your-ant-api-key";

    public IEnumerator RequestDecision(string sitrep)
    {
        var body = JsonUtility.ToJson(new {
            model = "ant:fast",
            messages = new[] {
                new { role = "system", content = "NPC squad leader. Respond JSON." },
                new { role = "user", content = sitrep }
            },
            max_tokens = 300
        });

        var request = new UnityWebRequest(ANT_URL, "POST");
        request.SetRequestHeader("Authorization", "Bearer " + ANT_KEY);
        request.SetRequestHeader("Content-Type", "application/json");
        request.uploadHandler = new UploadHandlerRaw(
            System.Text.Encoding.UTF8.GetBytes(body));
        request.downloadHandler = new DownloadHandlerBuffer();

        yield return request.SendWebRequest();

        if (request.result == UnityWebRequest.Result.Success)
        {
            var decision = JsonUtility.FromJson<NPCDecision>(
                request.downloadHandler.text);
            ExecuteOrders(decision);
        }
    }
}

The Cost at Scale

A typical Arma Reforger server with 200 AI NPCs and ANT routing:

  • โ€ข200 NPCs ร— 12 decisions/minute ร— 60 min = 144,000 requests/hour
  • โ€ข90% routine (ant:free): 129,600 ร— $0.00 = $0.00
  • โ€ข8% tactical (ant:fast): 11,520 ร— $0.001 = $11.52
  • โ€ข2% complex (ant:reasoning): 2,880 ร— $0.02 = $57.60
  • โ€ขTotal: ~$69/hour for 200 superhuman NPCs
  • โ€ขOr ~$0.35/hour per NPC
  • โ€ขA 4-hour session costs ~$276 โ€” split across 40 players = $6.90/player

That's less than a movie ticket for an evening of playing against AI that actually thinks. And with ANT's routing, the cost drops as cheaper models improve โ€” which they do every month.

Beyond Arma: Every Game

This isn't limited to Arma Reforger. Any game with NPCs can benefit. RPGs where every shopkeeper has a personality and remembers what you said. Strategy games where the AI opponent actually strategizes. Horror games where the stalker learns your patterns. Open-world games where every NPC has goals, relationships, and opinions โ€” not just canned dialogue.

ANT makes this economically viable because it routes each decision to the right model. A shopkeeper saying "welcome" doesn't need GPT-5. A villain planning how to trap you across three acts does. One API, automatic model selection, cost stays manageable.

Try It

If you're a game developer or modder, ANT gives you an OpenAI-compatible API with 20,000+ models. Call it from any game engine โ€” Enfusion (Arma), Unreal, Unity, Godot. Use ant:fast for real-time NPC decisions, ant:reasoning for complex planning, ant:free for testing. $5 free credits to start.

Try ANT routing today

Drop-in OpenAI-compatible API. Change your base URL and every request gets intelligent routing across 30+ providers.