Managing cloaked unit energy reserves with BAR widgets
Keeping cloaked units from decloaking when energy dips low requires tracking total cloak cost against available energy reserves across all team units.
Tags: beyond all reason, widgets, cloak, energy management, lua, modding, unitdefs
The cloaking energy problem
Cloaked units decloak when team energy drops below what cloak drain requires. A widget can monitor this by summing the cloak cost of all cloaked units and comparing against current energy reserves every second.
Efficient unit scanning
Using Spring.GetTeamUnits returns only your team's units. Using broader calls like Spring.GetAllUnits pulls allied and enemy units as well, which wastes processing and returns units you cannot control anyway. Stick to team-scoped calls when managing your own units.
Pausing builder tasks
Issuing a wait command to builders pauses their work without canceling it. This frees up energy for cloaked units during crunch moments. Builders resume their previous tasks when the wait command clears.
Checking command options
When intercepting build queue commands, checking cmdOpts.shift tells you whether the player queued the command or issued it immediately. The pattern is just not cmdOpts.shift to detect a direct command without shift-queue.
Creed of champions
Smart resource management separates good players from great ones. Creed of Champions welcomes players who think strategically about every aspect of the game, from macro builds to widget customization.
[Crd] Creed of Champions is a great place to learn and play BAR in a friendly atmosphere. Training sessions, team gameplay, even some non-BAR stuff. Large cross section of abilities, time zones, and game mode interests.