> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-advanced-gang/playing/territory.md).

# Territory, lookout and bell

Camp territory in CAS Advanced Gang System: when rival riders contest a camp, when it clears, the Lookout Post, the Alarm Bell and what a contest is worth.

A camp holds the ground inside its **influence radius**: 220 m around the leader's tent by default (`Config.DefaultInfluence`). The server watches it every few seconds.

## When a camp is contested

Once `minRaiders` riders from other gangs (2 by default) are inside the radius at the same time, the camp is **contested**:

* every member on the server is told, with the gang that has the most riders inside,
* the record notes who rode in,
* the Camp tab shows it and names that gang,
* the Alarm Bell rings, if one stands,
* with `lockStores` on, the stash and the treasury refuse withdrawals until the ground is clear. Deposits still go in.

{% hint style="info" %}
Riders with no gang never count. Someone passing through isn't a raid.
{% endhint %}

## When it clears

The ground isn't called clear the moment the last rival steps out. It takes `clearSeconds` (60) with nobody from another gang inside, so a camp can't flicker between held and contested while someone rides the edge.

When it clears, members are told and the camp's **contests held** count goes up by one. That count is the `contestsHeld` challenge for [camp tiers](/script-documentation/cas-advanced-gang/playing/upgrades.md).

## The lookout

A standing **Lookout Post** (tier II) watches the trail. When riders from another gang come within 400 m of a post (`Config.Lookout.range`), every member on the server is told how far from camp they are, which direction they're coming from and which gang they ride for. That happens before they reach camp ground.

* The Camp tab shows **Riders on the trail** with a count.
* The record notes each sighting.
* After a warning, the lookout stays quiet until the trail has been empty for 3 minutes (`quietSeconds`), so a rider on the edge of range can't cause a stream of warnings.
* While the camp is contested the lookout says nothing, because the contest has already told everyone.

A camp can have two posts. Place them toward the trails riders come in on.

## The alarm bell

The **Alarm Bell** (tier V) is rung by holding the prompt at it.

* Every member on the server hears the toll wherever they are, and gets a notice naming who rang it.
* The camp is marked on their map for 2 minutes (`markSeconds`).
* Anyone else within 150 m hears it from the bell.
* The record notes who rang it.
* One ring per minute per gang (`cooldownSeconds`). A rider who rings too soon is told how long is left.

With `ringOnContest` on, the bell also rings by itself when the camp becomes contested.

## What a contest is worth

Nothing is taken away automatically. What a contest means on your server, a raid, a war score or a capture, is up to your own scripts. They read it through the `GetGangContest` export:

```lua
local contest = exports["cas-advanced-gang"]:GetGangContest(gangId)
-- { by = 'The Del Lobos', raiders = 3, defenders = 1, since = <unix time> }, or nil
```

See [Exports](/script-documentation/cas-advanced-gang/developers/exports.md#getgangcontest) and [Territory settings](/script-documentation/cas-advanced-gang/configuration/territory.md).
