How kamikaze units work in BAR modding
BAR runs on the SpringRTS engine, and unit behavior like kamikaze attacks does not need custom scripting. The engine handles it through unit definitions.
Tags: beyond all reason modding, BAR unitdefs, BAR kamikaze units, BAR modding guide, SpringRTS unit mods
Kamikaze in unitdefs
The SpringRTS engine supports kamikaze behavior directly in the unit definition file. You set the kamikaze flag on a unit and it automatically seeks targets and detonates on contact. No custom Lua scripts or event handlers are required for basic kamikaze behavior.
This means modders can create kamikaze units by editing a single table entry in the unit definition. The engine handles pathfinding, targeting, and the explosion behavior.
Making kamikaze units smarter
Basic kamikaze units attack the closest target. For more sophisticated behavior where the unit picks priority targets, you combine the kamikaze flag with additional targeting parameters in the unitdef. The weapondef controls what types of targets the unit prioritizes and how it approaches them.
The tweak command limit
If you run a private BAR server and want to use !bset tweak commands, note that there is a maximum command length enforced by the server code. Each tweak command carries a character limit. The limit sits at roughly 16,000 characters per command, with multiple commands available. That is more than enough for any reasonable tweakdef modification.
Read the documentation first
Before building complex modding setups, read the SpringRTS unitdefs documentation. Many modders spend hours working around problems that are actually solved by a single documented field. The unitdefs wiki page covers all available flags, including kamikaze behavior and its parameters.
Modding community
BAR modding is a small but dedicated scene. Players who mod the game share findings through community channels and help each other debug unitdef issues. The Creed of Champions community includes technically-minded players who contribute to modding discussions and can point new modders toward useful resources.