OpenRA/OpenRA · error · YamlException

DangerScanRadius must be greater than zero.

Error message

DangerScanRadius must be greater than zero.

What it means

SquadManagerBotModuleInfo.RulesetLoaded (SquadManagerBotModule.cs:101) rejects DangerScanRadius <= 0. The radius (in cells) controls how far a protecting AI squad looks around its position for enemies; a non-positive value would make the scan meaningless, so the engine refuses to load the bot config.

Source

Thrown at OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs:101

		[Desc("Radius in cells that squads should scan for danger around their position to make flee decisions.")]
		public readonly int DangerScanRadius = 10;

		[Desc("Radius in cells that attack squads should scan for enemies around their position when trying to attack.")]
		public readonly int AttackScanRadius = 12;

		[Desc("Radius in cells that protecting squads should scan for enemies around their position.")]
		public readonly int ProtectionScanRadius = 8;

		[Desc("Enemy target types to never target.")]
		public readonly BitSet<TargetableType> IgnoredEnemyTargetTypes = default;

		public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
		{
			base.RulesetLoaded(rules, ai);

			if (DangerScanRadius <= 0)
				throw new YamlException("DangerScanRadius must be greater than zero.");
		}

		public override object Create(ActorInitializer init) { return new SquadManagerBotModule(init.Self, this); }
	}

	public class SquadManagerBotModule : ConditionalTrait<SquadManagerBotModuleInfo>,
		IBotEnabled, IBotTick, IBotRespondToAttack, IBotPositionsUpdated, IGameSaveTraitData, INotifyActorDisposing
	{
		public CPos GetRandomBaseCenter()
		{
			var randomConstructionYard = constructionYardBuildings.Actors
				.Where(a => a.Owner == Player)
				.RandomOrDefault(World.LocalRandom);

			return randomConstructionYard?.Location ?? initialBaseCenter;
		}

		const int MaxRespondToAttackCooldown = 30;

View on GitHub (pinned to a520984d91)

Solutions

  1. Set DangerScanRadius to a positive integer (e.g., the default 8) in the SquadManagerBotModule yaml.
  2. If the intent was to disable protection scanning, remove SquadManagerBotModule or pick the appropriate squad-type configuration rather than zeroing the radius.
  3. Validate all numeric AI fields against their stated units (cells, ticks) when tuning.

Example fix

// before
SquadManagerBotModule:
	DangerScanRadius: 0
// after
SquadManagerBotModule:
	DangerScanRadius: 8
Defensive patterns

Strategy: validation

Validate before calling

var info = (SquadManagerBotModuleInfo)actorInfo;
if (info.DangerScanRadius <= 0)
    throw new ConfigException($"{actorInfo.Name}: DangerScanRadius must be > 0");

Try / catch

try { RulesetLoader.Load(modData, map); }
catch (YamlException ex) { Log.ModError(ex.Message); }

Prevention

When it happens

Trigger: A bot module yaml sets DangerScanRadius to 0 or a negative number. The field defaults to 8, so you only hit this by explicitly writing an invalid value.

Common situations: Tuning the AI and setting radius to 0 to 'disable' scanning (not supported — use a different mechanism); negative value from a templating/macro mistake; copy-pasting a config that used a placeholder.

Related errors


AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13). Data as JSON: /api/errors/41264cc785114b72. Report an issue: GitHub.