Skip to content

Economy System Reference

rayswaynl edited this page Jul 3, 2026 · 1 revision

Economy System Reference

Source-verified 2026-07-03 against origin/claude/build84-cmdcon36@a26871e85 (Build 89 / cmdcon44 source Chernarus). This is lane 320's current economy flow map. No mission source was changed for this page.

This page connects the money and supply surfaces that are spread across narrower owner pages: town income, side supply, team/player funds, AI commander treasury, upgrade purchases, bank dividends, patrol rewards, the optional funds sink and player donations into the AI commander wallet.

Use this as the current Build84 routing page before changing economy behavior. For detailed subareas, follow the owner links in Continue Reading.

Quick Map

Surface Storage Main writers Primary consumers
Side supply missionNamespace key wfbe_supply_<side> Common_ChangeSideSupply.sqf:24-26 publishes a temp PV; Server_ChangeSideSupply.sqf:1-49 validates and clamps Structures, upgrades, commander defenses, AI/base workers and supply UI
Team/player funds Group variable wfbe_funds Common_ChangeTeamFunds.sqf:1-17, connect/JIP paths and selected server reward handlers Player purchases, commander upgrades, donations and HUD/menu reads
Client cash payouts BankPayout client PVF -> WFBE_CL_FNC_ChangeClientFunds Server_BankIncome.sqf:41, Server_ProcessUpgrade.sqf:87, some reward handlers Living owning-side players only, guarded client-side by BankPayout.sqf:16-17
AI commander treasury Side-logic variable wfbe_aicom_funds ChangeAICommanderFunds.sqf:1-6, seeded in Init_Server.sqf:707-711 AI teams, production, research, supports and economy pressure tools
Upgrade state Side-logic variables wfbe_upgrades, wfbe_upgrading, wfbe_upgrading_id, wfbe_upgrading_end_time RequestUpgrade.sqf, upgradeQueue.sqf, AI_Commander.sqf and Server_ProcessUpgrade.sqf Upgrade menu/RHUD, unlock consumers and completion hooks

Current Scope

The source checkout itself was parked on another agent lane when this page was written, so all source claims were read directly from origin/claude/build84-cmdcon36@a26871e85 with git show. Paths below are relative to Missions/[55-2hc]warfarev2_073v48co.chernarus/.

Current Build84 is not the same shape as several older economy wiki notes. In particular:

  • Player upgrade purchase is now server-paid and server-validated: the client sends a 6-element request and does not deduct locally (Client/GUI/GUI_UpgradeMenu.sqf:363-380; Server/PVFunctions/RequestUpgrade.sqf:145-154).
  • Side supply has server-side payload validation and a floor-at-zero guard (Server/Functions/Server_ChangeSideSupply.sqf:9-41).
  • Three-argument side-supply reasons are preserved in the common helper (Common/Functions/Common_ChangeSideSupply.sqf:12-14).
  • Team-funds writes treat missing/non-scalar wfbe_funds as 0 instead of erasing the wallet (Common/Functions/Common_ChangeTeamFunds.sqf:8-17).
  • Donation to the AI commander is server-authoritative and no longer performs the removed optimistic client debit (Client/GUI/GUI_TransferMenu.sqf:85-91; Server/PVFunctions/RequestAIComDonate.sqf:72-78).

Town Income Tick

Server/FSM/updateresources.sqf is the per-match income loop. It reads economy mode, interval, currency mode and the income gate once at startup (:3-11), then loops over WFBE_PRESENTSIDES - [resistance] (:153). GUER/resistance is excluded from this automatic town-income/AI-commander loop.

The loop uses two separate town readers:

Function Meaning Evidence
GetTownsSupply Raw sum of owned towns' supplyValue; this is the tick basis used by updateresources.sqf Common_GetTownsSupply.sqf:1-10, called at updateresources.sqf:65
GetTownsIncome Display/income sum that applies WFBE_C_ECONOMY_INCOME_COEF when income system 3 is active Common_GetTownsIncome.sqf:1-18, client display reads it at Client_GetIncome.sqf:5

Inside the under-gate block (updateresources.sqf:78-126), the loop:

  • computes cash income from town supply (:80) and splits it by income system (:82-91);
  • credits side supply in dual-currency mode through ChangeSideSupply with empty-side stagnation enabled (:94-96);
  • pays each side team with ChangeTeamFunds (:101-112);
  • credits AI commander cash with population/time/endgame/town-leader multipliers while under the wealth cap (:22-55, :66-76, :114-115);
  • adds the AI commander stipend, again under the wealth cap (:119-123).

The over-gate branch is deliberately AI-cash-only. When town supply reaches the income gate, it keeps AI commander funds and stipend flowing but does not synthesize supply (updateresources.sqf:128-141).

Two Supply Limits

There are two similarly named supply values. Do not swap them.

Constant Job Current evidence
WFBE_C_MAX_ECONOMY_SUPPLY_LIMIT Real banked side-supply clamp. Server_ChangeSideSupply.sqf reads this value and clamps wfbe_supply_<side> into [0, max]. Handler reads it at Server_ChangeSideSupply.sqf:35; parameter default is 50000 in Rsc/Parameters.hpp:186-190; constants comments warn the MP parameter owns production at Init_CommonConstants.sqf:1259-1265.
WFBE_C_ECONOMY_SUPPLY_MAX_TEAM_LIMIT Income gate used by updateresources.sqf against GetTownsSupply, plus attack-wave discount reference. It is not the real banked-supply cap. Read at updateresources.sqf:11, compared at :78 and :135; comments at Init_CommonConstants.sqf:1274-1279.

The prompt still cross-references the old side-supply-underflow lane. On this checked Build84 target, the authoritative handler already floors negative results at zero (Server_ChangeSideSupply.sqf:37-41). Reopen that only with new current-source evidence.

Side Supply Path

All normal side-supply mutations should use [side, amount, reason, includeStagnation] Call ChangeSideSupply.

Common_ChangeSideSupply.sqf does not write the authoritative pool. It optionally applies the empty-side income stagnation throttle to positive deltas (:16-18), stores [_side, _amount, _reason] under wfbe_supply_temp_<side> (:24) and sends that temp variable to the server (:26).

Server_ChangeSideSupply.sqf is the authority boundary. It rejects malformed payloads, short payloads, invalid side types, side/channel mismatches and non-scalar amounts (:9-31), normalizes the reason (:33-34), clamps the result (:37-41), writes missionNamespace key wfbe_supply_<side> (:47) and broadcasts that key (:49). West, resistance and east temp channels are all registered (:53-64), but resistance still has no automatic town-income supply loop.

GetSideSupply reads the published side key and has bounded client fallback waits for west/east (Common_GetSideSupply.sqf:9-49). The resistance case returns a non-blocking 0 default because GUER is funds-only in the current economy (:50-55).

Team Funds And Cash Payouts

Team/player funds live on the group variable wfbe_funds. ChangeTeamFunds accepts [group, delta], exits on null groups, treats missing/non-scalar current funds as 0, then broadcasts the new value (Common_ChangeTeamFunds.sqf:1-17). GetTeamFunds returns 0 for null or nil (Common_GetTeamFunds.sqf:1-7).

Initial and recovered funds routes include:

  • side player groups seeded in Init_Server.sqf:815-821;
  • GUER groups seeded to 50000 in Init_Server.sqf:860-869;
  • JIP funds resend that re-broadcasts the exact existing or stored value and never adds money (RequestFundsResend.sqf:26-35, :90-109).

Bank and reward payouts use the client PVF path instead of ChangeTeamFunds directly:

  • building a Bank registers the structure and spawns WFBE_SE_FNC_BankIncome (Construction_MediumSite.sqf:135-150);
  • the bank loop pays a fixed $6000 pool every 300 seconds, skipping when the owning HQ is not deployed/alive (Server_BankIncome.sqf:20-41);
  • BankPayout.sqf exits for dead local players, then applies the amount through WFBE_CL_FNC_ChangeClientFunds (:12-19);
  • Patrol upgrade level 3 pays a one-time cash pool through BankPayout; Patrol level 4 credits side supply through ChangeSideSupply (Server_ProcessUpgrade.sqf:70-98).

Upgrade Purchases

There are four current upgrade start paths, but they converge on WFBE_SE_FNC_ProcessUpgrade for timing and completion.

Path Payment owner Evidence
Player commander direct purchase Server RequestUpgrade.sqf Client sends [side,id,currentLevel,true,player,group player] without local debit (GUI_UpgradeMenu.sqf:363-380). Server validates requester/team/side, commander ownership, enabled state, current level, max level, config shape, dependencies, funds and supply, then debits supply and commander-team funds before spawning the worker (RequestUpgrade.sqf:7-154).
Commander upgrade queue Server queue worker Every five seconds it scans the queue, skips blocked prerequisites, stops on unaffordable front entries, debits supply and team funds, then spawns ProcessUpgrade (Server/FSM/upgradeQueue.sqf:1-16, :72-108).
AI commander programmed upgrade Server AI worker Existing Server_AI_Com_Upgrade.sqf can start AI upgrades; exact branch status routes through AI Commander Autonomy Audit.
AI commander rich research sink AI_Commander.sqf supervisor While rich and not upgrading, it scans enabled upgrade rows, checks dependencies plus funds/supply, starts ProcessUpgrade, debits side supply and AI funds, and logs ECON_SINK_RESEARCH (AI_Commander.sqf:623-699).

Server_ProcessUpgrade.sqf publishes wfbe_upgrading, wfbe_upgrading_id and authoritative wfbe_upgrading_end_time (:17-27), waits on the player sync or full server sleep (:29-44), increments the upgrade level (:46-50), clears the active id/end time (:64-68) and broadcasts upgrade completion (:137-140). It does not charge resources; callers pay before entering this worker.

AI Commander Treasury

The AI commander treasury is separate from every player/team wallet. It is stored as wfbe_aicom_funds on the side logic, seeded from WFBE_C_AI_COMMANDER_START_FUNDS (200000) during side init (Init_Server.sqf:707-711; constants at Init_CommonConstants.sqf:1252-1253). GetAICommanderFunds is a direct side-logic read (Server_GetAICommanderFunds.sqf:1). ChangeAICommanderFunds adds a delta and broadcasts only when WFBE_C_AICOM_PUBLIC_STATE_SYNC > 0 (Server_ChangeAICommanderFunds.sqf:1-6; default-off constant at Init_CommonConstants.sqf:253).

Current inflows include town income and stipend from updateresources.sqf, donation credits, wildcard/kill/support-specific credits, and startup seed. Current outflows include AI team founding/production, AI research, support launches and the optional funds sink.

The default-off funds sink is hooked from the income loop (updateresources.sqf:144-150) and compiled at server init (Init_Server.sqf:41-42). When enabled, AI_Commander_FundsSink.sqf exits unless the side is AI-commanded and above threshold (:30-50), arms reinforcement/veteran pressure flags (:52-62), drains a clamped fraction of the over-threshold surplus (:64-74) and emits an AICOMSTAT confirmation (:76-78). Defaults are ENABLE=0, THRESHOLD=1000000, DRAIN_PCT=0.25, DRAIN_MAX=120000 (Init_CommonConstants.sqf:619-629).

Donation Path

The live donate-to-AI-commander flow starts in the Transfer menu. When the AI commander row is selected, the client sends RequestAIComDonate and does not perform a local debit (GUI_TransferMenu.sqf:85-91).

RequestAIComDonate.sqf validates non-null donor/team/amount (:31-38), positive amount (:39-42), side logic (:48-52), absence of a human commander (:54-62) and sufficient donor team funds (:64-70). On success it debits the donor team with ChangeTeamFunds, credits the AI side with ChangeAICommanderFunds, confirms to the donor, broadcasts the side message and writes an AICOMSTAT donation line (:72-94).

Adjacent donation PRs #203 and #395 are donation-specific review lanes. Check them before touching this handler, but do not treat them as owners of this page.

Constants To Check First

Constant Current checked value / role
WFBE_C_ECONOMY_CURRENCY_SYSTEM Default 0: funds plus supply (Init_CommonConstants.sqf:1230-1231; parameter at Rsc/Parameters.hpp:149-153).
WFBE_C_ECONOMY_INCOME_INTERVAL Default 60 seconds (Init_CommonConstants.sqf:1254; parameter values at Rsc/Parameters.hpp:155-160).
WFBE_C_ECONOMY_INCOME_SYSTEM Default 3, commander split system (Init_CommonConstants.sqf:1255).
WFBE_C_ECONOMY_INCOME_COEF 14, cash multiplier for income system 3 (Init_CommonConstants.sqf:1268).
WFBE_C_ECONOMY_SUPPLY_INCOME_MULT 1.0, side-wide supply income multiplier (Init_CommonConstants.sqf:1269).
WFBE_C_FIX_INCOME_SYSTEM4_DISPLAY 0; when enabled, Client_GetIncome.sqf displays the server's income-system-4 1.5 multiplier (Init_CommonConstants.sqf:1267; Client_GetIncome.sqf:21-30).
WFBE_C_MAX_ECONOMY_SUPPLY_LIMIT Live banked side-supply cap; MP parameter default 50000 (Rsc/Parameters.hpp:186-190).
WFBE_C_ECONOMY_SUPPLY_MAX_TEAM_LIMIT Income gate / attack-wave reference, not the side-supply cap (Init_CommonConstants.sqf:1274-1279).
WFBE_C_AI_COMMANDER_START_FUNDS 200000, AI treasury seed (Init_CommonConstants.sqf:1252-1253).
WFBE_C_PATROL_T3_CASH / WFBE_C_PATROL_T4_SUPPLY 8000 cash pool and 1500 side-supply reward on Patrol upgrade tier completions (Init_CommonConstants.sqf:390-391).
WFBE_C_AICOM_FUNDS_SINK_* Default-off funds sink knobs (Init_CommonConstants.sqf:619-629).

Current Risk Routing

Topic Current Build84 reading Route
Side-supply underflow Current handler floors at 0 and caps at WFBE_C_MAX_ECONOMY_SUPPLY_LIMIT. Do not reopen lane 74 on this ref without new evidence; see Economy Authority First Cut.
Donation double-debit Current client avoids optimistic debit and server performs both sides of the transfer. Check PR #203/#395 and RequestAIComDonate.sqf before changing donation behavior.
Income-system-4 display Runtime server applies 1.5; display mirrors it only when WFBE_C_FIX_INCOME_SYSTEM4_DISPLAY > 0. Economy, Towns And Supply, Resource Income Tick Distribution Engine.
GUER economy Resistance has team funds and special paths, but is excluded from the automatic town-income/AI-commander loop. GUER Insurgent Player Economy, Resistance Supply Scaffold.
AI commander hoarding Wealth cap and optional funds sink are present; sink is dark by default. AI Commander Treasury Fund Accessors, AI Commander Execution Loop Reference.

Continue Reading

Sidebar

Clone this wiki locally