Home › Dev CE (experimental) › PlayerTreasury

Experimental: needs Dev CE (fork of the Community Extension, release zip and source). A GameCore that adds these Lua methods by calling engine functions directly. Not part of the upstream Community Extension, single-player testing only. Descriptions on these pages were written by an AI assistant from decompiled code and are marked inferred unless a test result confirms them.

PlayerTreasury

7 methods (Dev CE test build). this is found with the game's own IPlayerTreasury instance resolver (plain).

Method Signature Purpose (AI-written, inferred) Tested Engine function Current
ApplyBankruptcyPenalties PlayerTreasury:ApplyBankruptcyPenalties() If the treasury balance is negative, sets a bankruptcy flag and a deficit-driven counter, disbands units according to thresholds and sends a notification. plumbing ✓
this ✓ (oracle)
— 0x340fc0
ApplySiphonLosses PlayerTreasury:ApplySiphonLosses() → number Sums, over the player's cities, the lesser of each city's siphon amount (+0x954) and its current yield, adds it to the output value, and subtracts the amount from a per-city counter. plumbing ✓
this ✓ (oracle)
— 0x3410c0
CalculateGoldYieldExcludingTrade PlayerTreasury:CalculateGoldYieldExcludingTrade() → number Recomputes the player's gold yield, then adjusts the cached yield field by the gold value of active deal items (subtracting outgoing gold-per-turn, adding incoming) and returns the result. plumbing ✓
this ✓ (oracle)
— 0x3421d0
ChangeGoldDiplomaticDeal PlayerTreasury:ChangeGoldDiplomaticDeal(dealId: integer, dealItemId: integer, addDeal: boolean) Adds or removes a (deal id, deal item id) pair in the treasury's list of gold diplomatic deals, then recalculates gold yield excluding trade. plumbing ✓
this ✓ (oracle)
Player::Treasury::ChangeGoldDiplomaticDeal 0x343360
ChangeGoldInterestPercent PlayerTreasury:ChangeGoldInterestPercent(xPercent: number (fixed point, 1/256 steps)) Adds a signed amount to the player's gold interest percentage, clamping it to zero if it would go negative. plumbing ✓
this ✓ (oracle)
Player::Treasury::ChangeGoldInterestPercent 0x3434b0
DoTaxForGold PlayerTreasury:DoTaxForGold() Per-turn gold processing: if the capability 0x798f719c is present, computes yield, subtracts siphon losses and maintenance, changes the gold balance, and applies bankruptcy penalties and resets balance to 0 if it goes negative. plumbing ✓
this ✓ (oracle)
— 0x343780
SetGoldRateChange PlayerTreasury:SetGoldRateChange(xNewValue: number (fixed point, 1/256 steps)) Sets the treasury gold rate-change value (+0xc0 mirror) if it differs from the current one, then sends a reporting event and dispatches a signal with the player ID and current gold balance (whole units). plumbing ✓
this ✓ (oracle)
— 0x343dc0

Details

ApplyBankruptcyPenalties

Writes - Bankruptcy-related state at +0x110/+0x120 - Player units via DisbandUnit

Side effects - Disbands units - Sends a notification (hash 0x6de806ec)

Input checks: Only acts when gold is below zero; thresholds come from the global parameters.

Multiplayer: may-desync, disbands units and changes treasury state. Risk: high (Destroys units). Confidence of the reading: medium.

ApplySiphonLosses

Writes - Per-city counter at +0x9c in the city's variant map

Side effects - Edits city objects

Input checks: Only cities with a positive siphon value are processed.

Multiplayer: may-desync, edits city state. Risk: high (Modifies every affected city). Confidence of the reading: medium.

CalculateGoldYieldExcludingTrade

Writes - Cached gold-yield auto variable at +0xf8 (value at +0x108), overwritten during computation

Input checks: Skips null deal items and deals not involving this player; no other checks.

Multiplayer: may-desync, rewrites cached treasury yield variable. Risk: medium (Despite the name it mutates a cached synchronised variable and relies on deal manager state.). Confidence of the reading: medium.

ChangeGoldDiplomaticDeal

Arguments: dealId — diplomatic deal id; dealItemId — item id within the deal; addDeal — true to append the pair, false to remove all matching pairs

Writes - vector of (uint,uint) pairs in the variant map at this+0x1b0 (append or erase) - gold yield cached values (via CalculateGoldYieldExcludingTrade)

Side effects - recomputes the gold yield excluding trade, which may change displayed income

Input checks: No check for duplicates on add, so the same pair can be added repeatedly. On remove, matching pairs are erased and a missing pair is a no-op. No id validation.

Preconditions - gameplay Lua state only - must run on the game thread

Multiplayer: may-desync: replicated list change plus yield recalculation. Risk: medium (list edit with duplicates allowed; affects gold income). Confidence of the reading: medium.

Verified from the code - add path appends a pair of the two ids to the vector at this+0x1b0 - remove path compacts out all pairs equal to both ids and erases the tail - always calls CalculateGoldYieldExcludingTrade at the end

Inferred - pairs identify gold deal items counted in income - the vector append template name is mis-resolved but behaves as a push_back

Open questions - how the list is consumed when computing gold

ChangeGoldInterestPercent

Arguments: xPercent — delta to the interest percent (raw/256)

Writes - gold interest percent auto-variable at this+0xe0 (value mirrored at this+0xf0) set to old+delta, then to 0 if negative

Side effects - assigns through an FAutoVariable move-assignment; edit() used for the clamp

Input checks: No bounds on delta; negative result is clamped to 0. xPercent pointer not checked.

Preconditions - gameplay Lua state - valid Treasury object - game thread

Multiplayer: may-desync: mutates synced game state; only safe when run identically on all clients. Risk: low (simple clamped additive change). Confidence of the reading: medium.

Verified from the code - new value = value at 0xf0 plus delta, assigned to variable at 0xe0 - if value at 0xf0 is negative afterwards, edit() is called and zero is written

Inferred - the variable is the gold interest percent, from the name; the Ghidra ControlPriority template name is likely code folding of the same assignment

Open questions - whether 0xf0 is the live value or a cached copy of 0xe0

DoTaxForGold

Writes - Treasury gold balance (+0xa8) via ChangeGoldBalance/SetGoldBalance - Cached yield/maintenance variables at +0xc8 and +0x110

Side effects - ApplyBankruptcyPenalties when balance is negative

Input checks: Does nothing unless the game capability is present; no argument checks.

Multiplayer: may-desync, changes player gold and penalties. Risk: high (Mutates player gold and can trigger bankruptcy penalties.). Confidence of the reading: medium.

SetGoldRateChange

Arguments: xNewValue — New gold rate change as fixed point (compared against and copied to the stored field)

Writes - Gold rate change field at +0xb0/+0xc0

Side effects - Reporting event 0x20f2116e with player ID - Dispatches game signal at game+0x280 +0x9f0 (player, gold>>8)

Input checks: Only skips when value is unchanged; no range check; signal skipped if no current game.

Multiplayer: may-desync, writes player treasury field. Risk: medium (Writes synchronised treasury value and fires UI/event signals.). Confidence of the reading: medium.