{"record":{"id":"41264cc785114b72","repo":"OpenRA/OpenRA","slug":"dangerscanradius-must-be-greater-than-zero","errorCode":null,"errorMessage":"DangerScanRadius must be greater than zero.","messagePattern":"DangerScanRadius must be greater than zero\\.","errorType":"validation","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs","lineNumber":101,"sourceCode":"\n\t\t[Desc(\"Radius in cells that squads should scan for danger around their position to make flee decisions.\")]\n\t\tpublic readonly int DangerScanRadius = 10;\n\n\t\t[Desc(\"Radius in cells that attack squads should scan for enemies around their position when trying to attack.\")]\n\t\tpublic readonly int AttackScanRadius = 12;\n\n\t\t[Desc(\"Radius in cells that protecting squads should scan for enemies around their position.\")]\n\t\tpublic readonly int ProtectionScanRadius = 8;\n\n\t\t[Desc(\"Enemy target types to never target.\")]\n\t\tpublic readonly BitSet<TargetableType> IgnoredEnemyTargetTypes = default;\n\n\t\tpublic override void RulesetLoaded(Ruleset rules, ActorInfo ai)\n\t\t{\n\t\t\tbase.RulesetLoaded(rules, ai);\n\n\t\t\tif (DangerScanRadius <= 0)\n\t\t\t\tthrow new YamlException(\"DangerScanRadius must be greater than zero.\");\n\t\t}\n\n\t\tpublic override object Create(ActorInitializer init) { return new SquadManagerBotModule(init.Self, this); }\n\t}\n\n\tpublic class SquadManagerBotModule : ConditionalTrait<SquadManagerBotModuleInfo>,\n\t\tIBotEnabled, IBotTick, IBotRespondToAttack, IBotPositionsUpdated, IGameSaveTraitData, INotifyActorDisposing\n\t{\n\t\tpublic CPos GetRandomBaseCenter()\n\t\t{\n\t\t\tvar randomConstructionYard = constructionYardBuildings.Actors\n\t\t\t\t.Where(a => a.Owner == Player)\n\t\t\t\t.RandomOrDefault(World.LocalRandom);\n\n\t\t\treturn randomConstructionYard?.Location ?? initialBaseCenter;\n\t\t}\n\n\t\tconst int MaxRespondToAttackCooldown = 30;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/OpenRA/OpenRA/blob/a520984d91eda9de48a62b1d15c1e3bad0d4fb1a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs#L83-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set DangerScanRadius to a positive integer (e.g., the default 8) in the SquadManagerBotModule yaml.","If the intent was to disable protection scanning, remove SquadManagerBotModule or pick the appropriate squad-type configuration rather than zeroing the radius.","Validate all numeric AI fields against their stated units (cells, ticks) when tuning."],"exampleFix":"// before\nSquadManagerBotModule:\n\tDangerScanRadius: 0\n// after\nSquadManagerBotModule:\n\tDangerScanRadius: 8","handlingStrategy":"validation","validationCode":"var info = (SquadManagerBotModuleInfo)actorInfo;\nif (info.DangerScanRadius <= 0)\n    throw new ConfigException($\"{actorInfo.Name}: DangerScanRadius must be > 0\");","typeGuard":null,"tryCatchPattern":"try { RulesetLoader.Load(modData, map); }\ncatch (YamlException ex) { Log.ModError(ex.Message); }","preventionTips":["Lint all numeric AI fields against documented bounds.","Never use 0 to 'disable' a radius-based AI field; remove the trait instead."],"tags":["openra","yaml","trait","bot-ai","ruleset-validation"],"backgroundTag":null,"analyzedSha":"a520984d91eda9de48a62b1d15c1e3bad0d4fb1a","analyzedAt":"2026-08-13T15:30:14.787Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}