## 📖 Introduction

The MOOSE Dual Coalition Zone Capture system is a fully-featured, balanced territorial control framework for DCS World missions. This script creates dynamic capture zones that both RED and BLUE coalitions can fight over, with automatic victory detection, tactical information displays, and comprehensive player feedback systems.

### ✨ Key Features

- Easy Configuration: Define zones with simple Lua tables - no complex coding required
- Dual Coalition Support: Both RED and BLUE can capture zones and win
- Dynamic Visual Feedback: Color-coded zone boundaries, smoke markers, and flares
- Tactical Information: Real-time unit counts and MGRS coordinates for small enemy forces
- F10 Radio Menu: Players can check status, progress, and refresh visuals
- Automatic Victory Detection: First coalition to capture all zones wins
- Flexible Initial Ownership: Set zones to start under RED, BLUE, or NEUTRAL control
- Comprehensive Logging: Detailed debug output for troubleshooting

## 📋 Requirements

### Essential Components

1. DCS World - Any recent version
2. MOOSE Framework - Latest version recommended
   - Download from: https://github.com/FlightControl-Master/MOOSE
   - You need the `Moose_.lua` file
3. This Script - `Moose_DualCoalitionZoneCapture.lua`

### Mission Prerequisites

#### ⚠️ Required Mission Elements

Your mission MUST contain the following groups (case-sensitive):

- `BLUEHQ` - A BLUE coalition ground unit group (can be a single unit)
- `REDHQ` - A RED coalition ground unit group (can be a single unit)

Why? These groups serve as command centers for the messaging system. They can be placed anywhere, even hidden or spawned late. Without them, the script will fail to initialize.

## 🚀 Quick Start Guide

Get up and running in 5 minutes:

### 1Mission Editor Setup

1. Create trigger zones at locations you want to be capturable (e.g., airbases, towns)
2. Name each zone starting with `Capture` - for example:
   - `Capture Severomorsk`
   - `Capture Murmansk`
   - `Capture Zone-1`
3. Create two ground unit groups named `BLUEHQ` and `REDHQ`

### 2Load MOOSE Framework

1. In Mission Editor → Triggers → New Trigger
2. Type: MISSION START
3. Actions → DO SCRIPT FILE → Select `Moose_.lua`

### 3Configure Zone Ownership

Open `Moose_DualCoalitionZoneCapture.lua` in a text editor and edit the `ZONE_CONFIG` section:

    local ZONE_CONFIG = {
      RED = {
        "Capture Severomorsk",
        "Capture Murmansk"
      },
      BLUE = {
        "Capture Banak"
      },
      NEUTRAL = {
        "Capture Contested Valley"
      }
    }

### 4Load the Script

1. In the same trigger, add another action
2. Actions → DO SCRIPT FILE → Select `Moose_DualCoalitionZoneCapture.lua`

#### ✅ Done!

Save your mission, start it, and the zone capture system will automatically initialize. Check the DCS.log file to verify successful zone creation.

## 📐 Detailed Setup Instructions

### Step 1: Creating Trigger Zones

#### In DCS Mission Editor:

1. Click the Trigger Zones button (or press F5)
2. Click New to create a zone
3. Set the zone type to Circular or Polygon
4. Position the zone over the area you want to be capturable
5. CRITICAL: Name the zone with any name you choose (e.g., "Capture Severomorsk")
6. Adjust the size to encompass the tactical area
7. Repeat for all capture locations

#### ⚠️ Zone Naming Rules

- Zone names in the mission editor MUST EXACTLY match the names in your Lua config
- Names are case-sensitive: `Capture Zone-1` ≠ `capture zone-1`
- Spaces matter: `Capture Zone-1` ≠ `CaptureZone-1`
- Best practice: Use the "Capture [Location]" format for clarity

### Step 2: Creating Command Centers

The script requires two "command center" groups to function:

#### BLUEHQ Setup:

1. Place any BLUE ground unit (e.g., M-1 Abrams, Infantry, HMMWV)
2. Name the GROUP (not the unit): `BLUEHQ`
3. You can make it immortal via triggers if desired
4. Location doesn't matter - can even be in an unreachable area

#### REDHQ Setup:

1. Place any RED ground unit (e.g., T-90, BTR-80, Infantry)
2. Name the GROUP: `REDHQ`
3. Same rules as BLUEHQ

#### 💡 Pro Tip: Hidden Command Centers

You can hide these units by:

- Placing them far off-map
- Setting them to "UNCONTROLLED" start state
- Using the "Late Activation" option
- Adding a trigger to activate them after mission start

They only need to exist in the mission file - they don't need to be active or visible.

### Step 3: Script Loading Order

Create a MISSION START trigger with these actions IN ORDER:

1. DO SCRIPT FILE: `Moose_.lua` (MUST be first)
2. DO SCRIPT FILE: `Moose_DualCoalitionZoneCapture.lua` (MUST be after MOOSE)
3. (Optional) Any other scripts that depend on this system

#### ❌ Common Loading Errors

- Script loaded before MOOSE: Will crash with "attempt to index a nil value"
- Wrong trigger type: Must be MISSION START, not TIME MORE or ONCE
- DO SCRIPT instead of DO SCRIPT FILE: Use FILE to load external Lua files

## ⚙️ Configuration Options

### Zone Ownership Configuration

Edit the `ZONE_CONFIG` table at the top of the script:

    local ZONE_CONFIG = {
      -- Zones that start under RED coalition control
      RED = {
        "Capture Severomorsk-1",
        "Capture Severomorsk-3",
        "Capture Murmansk International"
      },

      -- Zones that start under BLUE coalition control
      BLUE = {
        "Capture Banak",
        "Capture Kirkenes"
      },

      -- Zones that start neutral (empty/uncontrolled)
      NEUTRAL = {
        "Capture Contested Valley",
        "Capture No Man's Land"
      }
    }

#### ⚠️ Important: Initial Ownership vs. Unit Presence

The ownership you set here is the starting state of the zone. However:

- If you place RED units in a zone configured as BLUE, the zone will immediately flip to RED when the mission starts
- Empty zones (no units) will respect your configured ownership
- The script scans for units every 30 seconds (configurable)

Best Practice: Either start zones empty/neutral, or ensure ground units match the configured ownership.

### Advanced Settings

    local ZONE_SETTINGS = {
      guardDelay = 1,        -- Seconds before entering Guard state after capture
      scanInterval = 30,     -- How often to scan for units in zones (seconds)
      captureScore = 200     -- Points awarded for capturing a zone
    }

Setting | Default | Description
--- | --- | ---
`guardDelay` | 1 | Delay (in seconds) before a captured zone enters the "Guarded" state. Shorter = faster transitions.
`scanInterval` | 30 | How frequently the script checks for units in zones. Lower = more responsive but more CPU usage.
`captureScore` | 200 | Points awarded when a zone is captured (requires MOOSE scoring system to be active).

## 🎨 Understanding Zone States

Zones can be in one of four states, each with distinct visual indicators:

State | Color | Smoke | Description
--- | --- | --- | ---
RED Controlled | Red Border | Red Smoke | Zone is secured by RED coalition forces
BLUE Controlled | Blue Border | Blue Smoke | Zone is secured by BLUE coalition forces
Neutral/Empty | Green Border | Green Smoke | Zone is uncontrolled and can be captured by either side
Contested/Attacked | Orange Border | White Smoke | Zone is under attack - both coalitions have units present

### State Transitions

#### How Zones Change Ownership:

1. Empty → Captured: Move ground units into an empty zone
2. Captured → Attacked: Enemy forces enter a controlled zone
3. Attacked → Captured: One side eliminates all enemy forces
4. Captured → Empty: All units leave the zone
5. Captured → Guard: Zone remains secured after a brief delay

### Tactical Information Markers

Each zone displays a tactical marker with real-time information:

- Force Counts: Shows R: (RED units), B: (BLUE units)
- MGRS Coordinates: When ≤10 enemy units, shows their exact positions
- Coalition-Specific: Each side sees their enemies marked
- Auto-Refresh: Updates every 60 seconds

Example tactical marker:

    TACTICAL: Capture Severomorsk-1
    Forces: R:5 B:12
    TGTS: T-90@38U LV 12345 67890, BTR-80@38U LV 12346 67891

## 👥 Player Features

### F10 Radio Menu Commands

Players from both coalitions have access to F10 radio menu commands under "Zone Control":

Command | Description
--- | ---
Get Zone Status Report | Displays current ownership of all zones with detailed breakdown
Check Victory Progress | Shows percentage toward victory and zones remaining
Refresh Zone Colors | Manually redraws all zone boundaries (troubleshooting tool)

### Automatic Status Updates

The script provides automatic notifications:

- Every 5 minutes: Zone control report broadcast to both coalitions
- On zone capture: Both sides notified when a zone changes hands
- On zone attack: Alerts when a zone comes under attack
- At 80% victory: Warning that one side is close to winning
- On victory: Dramatic announcement with 60-second countdown

### Victory Conditions

### 🏆 How to Win

The first coalition to capture ALL zones wins the mission.

- Total zones must be controlled by one coalition
- Victory triggers a 60-second countdown
- Celebratory effects: smoke, flares, messages
- Mission ends automatically with appropriate user flag set

## 🔧 Troubleshooting

### Script Won't Load

#### ❌ Problem: "attempt to index a nil value"

Cause: MOOSE framework not loaded before this script

Solution: Ensure MOOSE is loaded FIRST in your MISSION START trigger

#### ❌ Problem: "GROUP:FindByName() returned nil"

Cause: BLUEHQ or REDHQ groups don't exist or are misnamed

Solution: Verify you have groups (not units) named exactly `BLUEHQ` and `REDHQ`

### Zones Not Working

#### ❌ Problem: "Zone 'X' not found in mission editor!"

Cause: Zone name mismatch between Lua config and mission editor

Solution:

1. Check DCS.log for the exact error message
2. Open mission editor and verify trigger zone names
3. Ensure names match EXACTLY (case-sensitive, spaces matter)
4. Update either the mission or Lua config to match

### Zones Not Capturing

#### ⚠️ Problem: Units in zone but ownership not changing

Possible Causes:

- Wrong unit types: Only ground units, planes, and helicopters are scanned
- Dead units: Script only counts alive units
- Scan timing: Wait 30 seconds for the next scan cycle
- Both coalitions present: Zone enters "Attacked" state, doesn't flip ownership

Solution: Eliminate all enemy forces to capture the zone

### Visual Issues

#### 💡 Problem: Zone colors wrong or not showing

Solutions:

- Use F10 → Zone Control → "Refresh Zone Colors"
- Zone colors auto-refresh every 2 minutes
- Check DCS graphics settings (markers must be enabled)
- Restart mission if issue persists

### Checking Logs

The script provides extensive logging. To view:

1. Open `DCS.log` file in your Saved Games\DCS folder
2. Search for `[CAPTURE Module]` or `[INIT]`
3. Look for initialization messages and error reports

Successful initialization looks like:

    [CAPTURE Module] [INIT] Starting zone initialization...
    [CAPTURE Module] [INIT] Creating zone: Capture Severomorsk-1 (Coalition: RED)
    [CAPTURE Module] [INIT] ✓ Zone 'Capture Severomorsk-1' initialized successfully
    [CAPTURE Module] [INIT] Zone initialization complete. Total zones created: 11

## 🔬 Advanced Customization

### Adjusting Scan Performance

If you experience performance issues with many units:

    local ZONE_SETTINGS = {
      scanInterval = 60,  -- Scan less frequently (every 60 seconds)
    }

For fast-paced action:

    local ZONE_SETTINGS = {
      scanInterval = 15,  -- Scan more frequently (every 15 seconds)
    }

### Disabling Logging

To reduce log spam, add this BEFORE loading the script:

    CAPTURE_ZONE_LOGGING = { enabled = false }

### Mission Integration

The script sets user flags on victory:

- `BLUE_VICTORY` = 1 when BLUE wins
- `RED_VICTORY` = 1 when RED wins

You can use these flags in mission triggers to:

- End the mission
- Trigger victory cutscenes
- Award points or bonuses
- Transition to next phase

### Modifying Messages

All player messages are in the event handler functions. Search for:

- `OnEnterGuarded` - Zone secured messages
- `OnEnterCaptured` - Zone captured messages
- `OnEnterAttacked` - Zone under attack messages
- `CheckVictoryCondition` - Victory messages

### Zone-Specific Behavior

To create different behaviors for specific zones, modify the event handlers to check zone names:

    local function OnEnterCaptured(ZoneCapture)
      local zoneName = ZoneCapture:GetZoneName()

      if zoneName == "Capture MainBase" then
        -- Special behavior for main base capture
        US_CC:MessageTypeToCoalition("CRITICAL: Main base captured!", MESSAGE.Type.Information)
      else
        -- Standard behavior for other zones
      end
    end

### Integration with Other Scripts

Access zone data from other scripts:

    -- Get current ownership status
    local status = GetZoneOwnershipStatus()
    -- Returns: { blue = X, red = Y, neutral = Z, total = N, zones = {...} }

    -- Broadcast status manually
    BroadcastZoneStatus()

    -- Refresh visuals manually
    RefreshAllZoneColors()

## 💡 Best Practices & Tips

#### ✅ Mission Design Tips

- Zone Size: Make zones large enough to encompass tactical areas but not so large they overlap
- Zone Placement: Position over airbases, FOBs, or strategic terrain features
- Starting Balance: Consider giving RED more zones for defensive scenarios, or split evenly for balanced play
- Ground Units: Populate zones with defending forces appropriate to difficulty level
- Respawning: Consider using MOOSE's spawn system to continuously reinforce zones
- AI Behavior: Set AI ground units to "Ground Hold" or "Ground On Road" for best results

#### 🎮 Player Experience

- Brief players on F10 radio menu commands before mission start
- Place zones at recognizable landmarks for easy navigation
- Consider adding custom mission briefing with zone locations
- Test zone sizes with different unit counts to ensure good balance
- Use neutral zones as "no man's land" for dynamic front lines

### 🚀 Quick Reference Card

Required Groups: BLUEHQ, REDHQ

Zone Naming: Must match exactly between mission and Lua

Load Order: MOOSE → This Script

Victory Condition: Capture all zones

F10 Menu: Zone Control → Status/Progress/Refresh

Log Location: Saved Games\DCS\Logs\DCS.log

## 📞 Support & Resources

### Script Author

Author: F99th-TracerFacer

Discord Community: https://discord.gg/7wBVWKK3

Join the Discord for support, updates, and discussion about this script and other DCS mission development topics.

### Additional Resources

- MOOSE Documentation: https://flightcontrol-master.github.io/MOOSE_DOCS/
- MOOSE Discord: https://discord.gg/gj68fm969S
- DCS Forums: https://forum.dcs.world

#### ✨ Version Information

Script Version: 2.0 (Dual Coalition)

Author: F99th-TracerFacer

Last Updated: October 2025

Compatibility: DCS World 2.9+, MOOSE Latest