Modifying unit definitions in Beyond All Reason requires the right hook pattern. Here is how to gate your changes behind lobby options so mods work cleanly in every game mode.
PrebakeUnitDefs is a hook function that fires before unit definitions are finalized by the Spring engine. It is the standard way for modders to adjust unit stats like build cost, health, damage, or weapon parameters without editing core game files.
Every mod that changes unit behavior should use this hook. Direct edits to unit definition files get wiped on game updates, while PrebakeUnitDefs patches apply cleanly every time the game loads.
The single most important rule for unit tweaking mods is to gate every change behind a lobby option check. Without this, your code runs unconditionally and can break games where the mod option was never selected.
The pattern is straightforward. Wrap all modifications inside a conditional that checks Spring.GetModOptions for your specific toggle. If the option is not active, the function returns immediately and nothing changes.
if not Spring.GetModOptions().my_mod_rebalance then
return
end
This ensures your unit changes only apply when a host explicitly enables them in the lobby, keeping games predictable for players who do not want the modded behavior.
To modify a single unit, access it through the UnitDefNames table. For example, adjusting the build cost of a specific unit requires one line inside your gated block.
You can stack as many unit changes as needed inside the same PrebakeUnitDefs function. Common tweaks include build time adjustments, weapon damage multipliers, health and armor changes, and movement speed modifications.
A frequent question is how to handle units that carry more than one weapon. Each weapon on a unit has its own entry in the weapons table. You need to identify which weapon slot to modify by index or by weapon definition name.
Multiplier modoptions follow the same pattern as individual stat changes. Set a scalar value in the lobby options table, then multiply your target stat by that value inside the PrebakeUnitDefs function. This lets hosts fine-tune balance without touching code.
Once your tweak file is complete, package it as a standard BAR sdz archive so other players can drop it into their mods folder. The modoptions.lua file defines the lobby toggle, your script applies the changes, and the sdz archive bundles everything together.
Include instructions in the mod metadata about which lobby option to enable. Players need to know that the tweak only works when the corresponding option is turned on in the match setup screen.
Good modding requires the same patience and attention to detail as good gameplay. If you want a community that values steady progress and helps each other learn, Creed of Champions welcomes players who care about doing things right.
[Crd] The first and only community I have seen that actually holds up to its values. I have honestly not had a single bad experience here.
Competitive play. Zero team-blame. Join a place where improvement is the goal and respect is the baseline.