How to edit unit stats and weapons in BAR modding

A practical walkthrough through unitdefs, weapondefs, and tweakdef loops for anyone changing unit costs, speed, or weapon behavior in Beyond All Reason.

Tags: bar modding, unitdefs, weapondefs, lua scripting, tweakdefs, game balance

Changing unit properties with unitdefs

The basic loop covers every unit in the game. You iterate through the UnitDefs table with pairs, then modify whichever property you need.

For name, ud in pairs(UnitDefs) do end walks the entire unit list. Inside that loop you can change anything defined for each unit, things like metal cost, energy cost, and movement speed.

Some unitdefs don't list every field outright. If a unit lacks a ud.metalcost entry, setting it directly will fail. You need to account for missing fields before applying changes.

Where to find the documentation

Unit property definitions live on the Spring RTS wiki under GameDev UnitDefs. Weapon-specific properties are on the GameDev WeaponDefs page. Those two pages cover almost every field you will want to tweak.

BAR has roughly 109 unit and weapon files to track when you are tracing behavior like nano constructor fire priorities between hold fire, maneuver, and roam. The nano priority widget in game gives a solid reference for how those targets get ordered.

Common tweakdef mistakes

New modders often try to set values on definitions that do not exist in the base file. When ud.metalcost is missing, you need to create it before modifying it. Same applies to energy cost and speed fields that aren't always present.

Another trap is assuming one file controls everything. Unit behavior like nano targeting spans multiple files. Finding the right one means searching through the full file list, not just the one you expect.

Tweak commands in lobby

Custom lobby tweaks let you test balance changes without rebuilding the full game package. Base64 encoded tweak strings can be shared between players for consistent custom games.

The process requires a working understanding of which unitdefs and weapondefs are being modified, and whether those changes conflict with the base game definitions.

Learning path for new modders

Start with small changes to one unit's cost or speed. Test in a real lobby before touching weapon behavior. Gradually work up to balancing multiple units across factions once the iteration patterns feel natural.

The BAR modding community responds well to clear questions with specific file references. Showing what you tried and where the error landed makes it easy for experienced modders to point you in the right direction.

Advertisement