BAR modding: epic unit properties and the limits of tweakdefs

Epic units like the Raptor Queen push the boundaries of what can be modified through lobby tweaks. Some properties live too far up the code stack for tweakdefs to reach.

Tags: BAR modding, raptors, epic units, unitdefs_post, luarules limits

Bulk property injection on specific units

The pattern used for epic raptor units defines a property table and applies it selectively:

local a = {
  health = 1275000,
  repairable = false,
  canbehealed = false,
  buildtime = 9999999,
  autoheal = 2,
  canSelfRepair = false
}

for b, c in pairs(UnitDefs) do
  if b == "raptor_queen_epic" then
    for d, e in pairs(a) do
      c[d] = e
    end
  end
end

This is cleaner than individual property assignments because the property table is defined once and then applied. The difference between the base file version and the epic version — health from 1.25M to 1.275M, buildtime from 1.5M to 9.99M, autoheal from 90 to 2 — shows exactly which properties changed without needing to track assignments line by line.

When tweakdefs cannot reach

Some game properties live in luarules rather than in unit definitions — scavenger spawn delays, grace periods, and spawn logic fall into this category. If a value is defined in scav_spawn_defs.lua or similar luarules config, tweakdefs and tweakunits cannot modify it. These values are read by the game rules during runtime, not from the lobby's tweak data. The only way to change them is through a full mod that replaces the luarules files, which cannot be shared via lobby base64 strings.

Finding property definitions in the codebase

When searching for how a specific property works, start at the unitdefs_post.lua file in the BAR GitHub repository. This is where post-processing of unit definitions happens — properties that are computed rather than explicitly set. Health bar visibility, for example, is controlled through a chain of computed values that trace back through the post-processing logic. Following the code path from the property name through the post-processor is the most reliable way to answer questions about why a property behaves unexpectedly.

Creed of champions

Deep code exploration takes patience. Players willing to read through the BAR source code to understand mechanics bring knowledge back to everyone. Creed of Champions includes people who learn the engine inside out and share what they find. Competitive play, zero team-blame.

[Crd] Training sessions, team gameplay, even some non-BAR stuff. Large cross section of abilities, time zones, and game mode interests.