# How are SpawnAI Unit costs calculated?

## Recommended Posts

Hey BIS Forums,

Can anyone explain how SpawnAI unit costs are actually calculated?

I'm working on a mission using the SpawnAI modules. The SpawnAI modules have a manpower cap of 50 by default and I'd like to tweak it to spawn more/less units of different types (infantry, armor etc).

According to the MP Support Guidelines on the BIS Wiki...

• a rifleman costs about 0.5
• an AA/AT soldier about 6

The page says the values are calculated using the cost and threat values defined in the unit's config. I admit I'm not great at math, but I just don't see how they came up with 0.5 as an answer using those two values.

Example 1 - a standard NATO rifleman ("B_Soldier_F") and open up his entry in the config viewer:

```cost = 100000;
threat[] = {0.8,0.1,0.1};```

Example 2 - NATO AT Missile Specialist ("B_soldier_AT_F"):

```cost = 130000;
threat[] = {0.8,0.8,0.3};```

According to the guidelines these units should cost 0.5 and 6 respectively. Clearly I'm missing something, so can anyone tell me how unit costs are actually calculated?

##### Share on other sites

Hi Elusive,

I know this is something of a late reply but as I've been trying to locate the answer to this very same question today I thought I'd share my findings with you for future reference.

The manpower calculation is as follows:

_threat = ((((_threat select 0) + (_threat select 1) + (_threat select 2)) - 0.5) max 0.5) ^ 2;

_value = _threat * sqrt(_cost/10000 + _armor) * 0.25;
_value = _value max 0.5;
_value = [_value,0.1] call bis_fnc_roundNum;

using the _threat, _cost and _armor values from the units CfgVehicles entry. I didn't bother actually checking but I assume the roundNum function rounds the value to the nearest 0.1.

Having tested this, the cost of 6 for an AA/AT soldier appears to be incorrect (it's more like 2), and it's important to note that the module will not spawn any unit that will send it over it's manpower cap.

Hope this helps someone.

• 1
• 1

##### Share on other sites

Hey CollectiveS,

Thank you so much for sharing your findings, this is really useful stuff.