Systems architecture51 files · 11K LOC
Contracts
A group-based contracts, quests, and server-events economy — five contract types and nine world-altering events, built on a polymorphic factory and a state machine.
- Enforce Script
- RPC opcodes
- State machine
- Factory pattern
- JSON persistence
In game
What it does
Contracts gives groups a reason to leave base. They accept jobs from in-world contract boards — capture, defense, delivery, scavenger, assassination — complete objectives to earn tokens, then spend those tokens to trigger server-wide events: a bounty, a heli crash, a zombie surge, an EMP, a comms blackout, a weather shift, and more. It's a full economy loop that lets players bend the world.
Engineering
How it's built
- Polymorphic base-class + factory pattern: ContractBase / ServerEventBase abstract classes with ContractFactory / ServerEventFactory; each subclass overrides OnStart / UpdateContract / CheckCompletion / OnComplete.
- A contract state machine (AVAILABLE → ACTIVE → COMPLETED / FAILED) with pause support, driven by a ContractManager singleton on a 1 Hz tick.
- ~60 namespaced RPC opcodes offset from a hex base (0x434F4E00 = 'CON') to avoid collisions with other mods — a hand-rolled message-ID enum with a clean client-side dispatch switch.
- Authoritative server state with full-sync reconciliation RPCs so late-joining clients receive consistent contract, marker, and blackout state.
- A token economy with difficulty and group-size reward multipliers, inventory-overflow fallback (stack, then spill to ground), and versioned JSON persistence (GroupTokenManager).