FF SUITEArma 3 addons

Capacitors, safe windows, trips, supply edges

Transfer power internals

The Outpost/Theta capacitor switch as a reusable service: a charge window with a safe RUN band, a trip threshold, server-authoritative supply and physical or scripted controls.

FF_Utils 6 related functions

1. Registering a site

// server
["campPower", myGenerator, myTransferPanel, createHashMapFromArray [
    ["title", "Camp transfer panel"],
    ["limits", [0.1, 0.65, 0.9, 0.98]],
    ["range", 3]
]] call FF_utils_fnc_powerRegister;
["campPower", true] call FF_utils_fnc_powerSetInput;

Registration is refused for missing objects, invalid callback types, a duplicate ID, a transfer object already owned by another site, or more than 64 sites. One source may feed several independent transfer objects. Newly registered input is disabled until explicitly enabled, so a battery installation or mission script keeps control of when power exists. The service never consumes inventory and never starts a generator engine.

2. The charge window

limits is [charge per second, safe RUN minimum, safe RUN maximum, trip threshold]. The default reproduces Outpost [0.1, 0.65, 0.9, 0.98]; Theta uses [0.025, 0.82, 0.845, 0.91]. Rate is bounded 0.001–1, safe thresholds 0–0.999, and trip must be at least 0.001 above the safe maximum and at most 1. Invalid values fall back to defaults and bounds keep the safe window below the trip threshold.

ActionResult
InspectUpstream input, lever, stored charge, trip, downstream supply and the safe window.
OFFDischarges and clears the trip latch, even with no upstream input.
CHARGERaises stored energy.
RUNConnects only inside the inclusive safe window; early or late RUN latches a trip.

A source must be physically alive, enabled and permitted by its input callback. Charging through the trip threshold latches a trip. Losing input immediately discharges and disconnects supply, and restoring input never silently reconnects an uncharged RUN selector. No ordinary player action can enable the upstream source by itself.

3. Callbacks

KeyArgumentsResult
input[siteID, source, transfer]true when additional upstream conditions permit power; default true
canOperate[player, siteID, operation]true when that player may inspect or operate; default true
onSupply[siteID, connected, state, source, transfer]Notification on the initial level and on supply edges

Callbacks are local server code and are never sent to clients. onSupply is also published as the server-local CBA event FF_utils_powerSupplyChanged with the same arguments — that is the extension point for driving downstream services, such as enabling a registered UAV with droneAssign or gating a solar array.

4. Authority and state

The server owns per-site records. Player requests validate network owner, live body, distance, on-foot and conscious state, the access callback and the registration generation. Queued handling re-checks physical conditions and generation, so an old action can never mutate a replacement registered under the same ID. Only known lever operations are accepted, at most one request per site per 0.1 s. Elapsed charge time is advanced before a request applies, so concurrent requests cannot overwrite newer ticks.

  • FF_utils_powerSites — [ID, generation, transfer, title, limits, range].
  • FF_utils_powerState on the transfer object — [generation, inputPresent, [lever, charge, trip, connected]]; match the generation before trusting a snapshot.
  • Meter snapshots are quantized and limited to 5 Hz; lever, input, trip and supply edges publish immediately.
  • One 0.1 s server worker serves every site; one local client worker maintains only registered actions.

5. Physical props

Optional mappings: animations (exactly three nonempty source names for lever, charge meter and input meter) and lampSelection (texture index, -1 disables texture work). Only map sources and selections that exist on your model. Lamp states are red trip, green safe/connected, orange charging and transparent offline. Original animation phases and textures are captured and restored on unregister; the site owns those fields exclusively until release.

6. Battery transactions

A battery-fed site turns one activation into exactly one item transaction. The panel asks first, the server reserves, and only then does the owning client remove the item.

StepFunctionWhat it guarantees
ReservepowerBatteryRequest(player, site, generation) One authenticated transaction per player and site, bound to the current generation.
ConsumepowerBatteryConsume(player, transaction, class) The item is removed on the player's owner and the reservation is acknowledged.
CommitpowerBatteryFinish(player, transaction, removed, owner) Supplies the site when the removal is confirmed; a changed or replaced site ends the transaction.
RefundpowerBatteryRefund Returns the item when the site could not accept the charge.
AckpowerBatteryAck Local feedback for the requesting client only.

Because the reservation is server-owned, two simultaneous attempts at the same site cannot spend the same battery, and a stale panel cannot finish a transaction that was already refunded.

7. Release and validation

Unregister removes the site, restores mapped props, broadcasts disconnection, removes its local actions and emits a final false supply notification. Deleted source or transfer objects unregister automatically; destroyed but retained props stay registered offline so a mission can repair them. Removing the last site removes the workers, and mission end releases everything.

For restrictive CfgRemoteExec policies allow FF_utils_fnc_powerRequest on the server and FF_utils_fnc_powerClientEnable / FF_utils_fnc_powerReply on clients.

Verified offline: the actual limit/state helpers and all nine source Theta switch cases, plus Outpost charging, immutable prior state, supply loss without reconnection, bounds and malformed-state reset. Not verified: model animations and textures, request races, JIP/respawn, deletion and unregister, callback-driven services.

Related functions

↑ Back to top