Jacob Schmidt 8117e6ffa6 feat(economy): Enhance economy system with service charges and medical billing
- Expanded README.md to detail economy addon functionalities including refueling, medical services, and service charges.
- Updated XEH_PREP.hpp to include initSEconomyStore preparation.
- Modified XEH_postInit.sqf to ensure MEconomyStore initializes only if not nil.
- Adjusted XEH_preInit.sqf to initialize SEconomyStore correctly.
- Updated config.cpp to include forge_server_common as a required addon.
- Enhanced fnc_initFEconomyStore.sqf to manage fuel refueling sessions and organization charges.
- Improved fnc_initMEconomyStore.sqf to handle medical billing and fallback to organization funds.
- Created fnc_initSEconomyStore.sqf for organization-funded service charges and repairs.
- Updated org.rs and org.rs service layer to support member debt recording and organization fund charging.
- Added ECONOMY_USAGE_GUIDE.md for comprehensive documentation on economy functionalities.
- Updated MODULE_REFERENCE.md and README.md to include links to the new economy guide.
2026-04-18 13:37:09 -05:00

3.6 KiB

Forge Server Economy

Overview

The economy addon contains server-side systems for world economic interactions that are still implemented in SQF. It owns Arma-world behavior such as active refueling sessions, medical spawn occupancy, respawn placement, and death inventory handling.

Current stores cover fuel tracking, medical service behavior, and service charges such as repairs.

Dependencies

  • forge_server_main
  • forge_server_common for logging, formatting, and player lookup
  • forge_server_bank for player-funded medical billing
  • forge_server_org for extension-backed organization hot-cache charges
  • forge_client_actor and forge_client_notifications for response RPCs

Main Components

  • fnc_initFEconomyStore.sqf tracks active refueling sessions, calculates fuel totals, charges the player's organization through OrgStore, syncs the org patch, and rolls fuel back to the starting level when organization funds cannot cover the refuel.
  • fnc_initMEconomyStore.sqf manages medical spawn occupancy, healing charges, respawn placement, death inventory handling, and body-bag transfer. Medical charges use player bank/cash first, then organization funds with repayable member debt only when the player cannot cover the service.
  • fnc_initSEconomyStore.sqf handles organization-funded service charges and repairs. Repairs only apply after the organization charge succeeds. The shared org-charge helper can also record member debt for medical fallback.

Event Surface

The addon registers CBA server events for fuel start/tick/stop, repair service, player killed, player respawn, and healing. Medical store initialization runs after post-init to discover configured medical spawn objects.

Repair service requests use:

[QEGVAR(economy,RepairService), [_target, _unit, _cost]] call CBA_fnc_serverEvent;

_cost is optional. Passing -1 uses the configured service repair cost.

Billing Rules

Economy does not own durable money state. It coordinates Arma-world effects after the relevant hot-cache charge succeeds.

Fuel and repair services are organization-funded:

  1. Resolve the player's organization from actor state.
  2. Ensure the player is a member of that organization hot record.
  3. Call OrgStore chargeCheckout with source = "org_funds", commit = true, and member service charging enabled.
  4. Send the returned organization patch to online members.
  5. If the charge fails, do not complete the service. Refueling rolls the target back to its starting fuel level; repairs are not applied.

Medical services are player-funded first:

  1. Load the player's bank hot state.
  2. Charge the player's bank balance when it can cover the medical bill.
  3. Otherwise charge the player's cash when it can cover the bill.
  4. If neither personal balance can cover the bill, charge organization funds and record the same amount as a debt on the player's organization credit line.
  5. If personal billing is unavailable, or both personal and organization funds fail, do not complete the heal.

The organization fallback reduces org funds immediately and adds the medical cost to the player's credit-line balance due. Repayment uses the normal bank credit-line repayment flow, which moves player bank funds back into the organization treasury.

This keeps money mutation rules in the extension-backed organization service and bank service while leaving world interactions in SQF.

Notes

Fuel, medical, and service world behavior should stay server-authoritative because it mutates inventory, vehicles, and respawn state. Money mutations should continue to use extension-backed bank and organization hot state.