Understanding BAR unit ranges and unit command hooks for modders

New BAR modders often trip over two fundamentals. First, units do not have range. Weapons have range. Second, the command hook system uses callins that gate what units are allowed to do. Both concepts matter whether you are restricting factories or building custom game modes.

Tags: beyond all reason, modding, weapon ranges, unitdefs, allowcommand, callins, lua scripting

Range lives on the weapon, not the unit

A common mistake when modifying units is trying to change range on the unit definition itself. Range belongs to the weapon definition. If a unit has three weapons, it has three separate range values. The effective firing distance depends on which weapon is active.

When you modify unit reach, edit the weapondefs files. Change the range parameter there. The unit inherits whatever range its equipped weapons define.

Restricting shipyards and factory outputs

Custom scenarios often require restricting specific factory types. Shipyard restrictions work by targeting movement class categories. The factory arrays list shipyard and lab identifiers for each faction. Removing entries from these arrays prevents those factories from building certain unit classes.

Common targets include corsy, armsy, armalab, coralab, and others. The pattern covers all standard factory types across Arm, Core, and Legion factions.

The AllowCommand callin workflow

The engine fires AllowCommand when any unit receives a command. The hook runs before the command enters the queue. Return true to allow it, false to block it.

A typical workflow looks like this:

Understanding this flow helps when designing custom game modes or restricting unit behaviors in special scenarios.

Practical modding advice

The BAR modding community helps newcomers who ask specific questions. Share what you are trying to do, show your code, and expect direct feedback. The fastest way to learn is reading existing implementations and adapting them.

Structured play benefits everyone

Whether running custom scenarios or standard ranked matches, clear rules and good communication improve the experience. Groups like Creed of Champions apply this same principle to organized play. Teams that coordinate properly and share knowledge perform better and have more fun doing it.

[Crd] One of the few places where you can for sure coordinate with people in matches with a good supportive attitude. Everybody tends to be understanding and constructive.