Home › Dev CE (experimental) › PlayerResources
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.
PlayerResources
26 methods (Dev CE test build). this is found with the game's own IPlayerResources instance resolver (virtual).
| Method |
Signature |
Purpose (AI-written, inferred) |
Tested |
Engine function |
Current |
| CalculateExcessLuxuries |
PlayerResources:CalculateExcessLuxuries() → number |
Sums (amount - 1) over accessible luxury resources for which the player has more than one available. |
plumbing ✓ |
— |
0x31e650 |
| ChangeBannedResource |
PlayerResources:ChangeBannedResource(eResource: integer, iDelta: integer) |
Adds a delta to the per-resource banned counter for this player, so the resource can be disabled for them. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeBannedResource |
0x31e700 |
| ChangeExtraAccumulationModifier |
PlayerResources:ChangeExtraAccumulationModifier(eResource: integer, iDelta: integer) |
Adds a delta to a per-resource extra accumulation modifier for the player. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeExtraAccumulationModifier |
0x31e740 |
| ChangeExtraAmenitiesPerOwnedBonusResource ✓ |
PlayerResources:ChangeExtraAmenitiesPerOwnedBonusResource(iChange: integer) |
Adds to the extra amenities granted per owned bonus resource, then re-runs luxury allocation so cities update. |
plumbing ✓ effect ✓ (GetAmenities, GetAmenitiesFromLuxuries) |
Player::Resources::ChangeExtraAmenitiesPerOwnedBonusResource |
0x31e780 |
| ChangeExtraAmenitiesPerOwnedLuxuryResource ✓ |
PlayerResources:ChangeExtraAmenitiesPerOwnedLuxuryResource(iChange: integer) |
Adds to the extra amenities granted per owned luxury resource, then re-runs luxury allocation so cities update. |
plumbing ✓ effect ✓ (GetFaithYield, GetScienceYield, GetGoldYield, GetCultureYield) |
Player::Resources::ChangeExtraAmenitiesPerOwnedLuxuryResource |
0x31e7c0 |
| ChangeFreeResourcesExtracted |
PlayerResources:ChangeFreeResourcesExtracted(resource: integer, amount: integer) |
Adds an amount to the count of free (extra) extracted resources for a given resource type. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeFreeResourcesExtracted |
0x31e810 |
| ChangeImportResourceExtracted |
PlayerResources:ChangeImportResourceExtracted(resource: integer, amount: integer) |
Adds a delta to the count of an imported resource that has been extracted, indexed through the resource definition. |
plumbing ✓ |
Player::Resources::ChangeImportResourceExtracted |
0x31e870 |
| ChangeNoCapResource |
PlayerResources:ChangeNoCapResource(eResource: integer, iDelta: integer) |
Adds a delta to a per-resource counter that exempts that resource from the stockpile cap. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeNoCapResource |
0x31e8d0 |
| ChangePowerResourceDemandPerTurn |
PlayerResources:ChangePowerResourceDemandPerTurn(resource: integer, iDelta: integer) |
Adds iDelta (as fixed point, x256) to the power demand per turn of the resource; out-of-range indices go to a fallback counter. |
plumbing ✓ |
— |
0x31e910 |
| ChangeReservedResourceAmount |
PlayerResources:ChangeReservedResourceAmount(eResource: integer, iDelta: integer) |
Adds a signed delta to the amount of a resource reserved for the player, clamping at zero. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeReservedResourceAmount |
0x31e960 |
| ChangeResourceStockpileCapModifier |
PlayerResources:ChangeResourceStockpileCapModifier(eResource: integer, iDelta: integer) |
Adds a game-speed-adjusted delta to the per-resource stockpile cap modifier. |
plumbing ✓ ran ±1, reversible ✓, no visible effect |
Player::Resources::ChangeResourceStockpileCapModifier |
0x31eb10 |
| CheckNotifications |
PlayerResources:CheckNotifications() |
Loops over resource definitions whose consumption/government entry has a flag set; if the stockpile-related counter is below the projected amount plus unit demand, fires the Lua hook AdvisorNegativeResourceRate with player id and resource. |
plumbing ✓ |
— |
0x31eb90 |
| DoTurnActivate |
PlayerResources:DoTurnActivate() |
Start-of-turn step: accumulates resources, allocates luxuries to cities, then recomputes national park amenities for the owning player. |
plumbing ✓ |
— |
0x31f520 |
| DoTurnDeactivate |
PlayerResources:DoTurnDeactivate() |
End-of-turn step: for each qualifying resource, if the stockpile (minus reserved amount) exceeds the stockpile cap, reduces it down to the cap. |
plumbing ✓ |
— |
0x31f560 |
| DoTurnResourceMaintenance |
PlayerResources:DoTurnResourceMaintenance() |
Resets a per-resource index list at offset 0x1a0, pays resource maintenance costs, then supplements city power with resources. |
plumbing ✓ |
— |
0x31f670 |
| EndExportResource |
PlayerResources:EndExportResource(resource: integer, amount: integer) |
Ends an export of a resource: moves the given amount from category 2 back to category 0 of the resource amounts. |
plumbing ✓ |
— |
0x31f6b0 |
| GetAvailableResourceAmount |
PlayerResources:GetAvailableResourceAmount(resource: integer, bSubtractReserved: boolean) → number |
Returns the amount of a resource available to the player, optionally subtracting the reserved amount, plus a second per-resource value. |
plumbing ✓ |
— |
0x31f820 |
| GetFreeResourcesExtracted |
PlayerResources:GetFreeResourcesExtracted(resource: integer) → number |
Returns the free-resources-extracted count for a resource from an array at this+0x2e0, or 0 for the invalid type -1. |
plumbing ✓ |
— |
0x31fe60 |
| GetNumOwnedLuxuries |
PlayerResources:GetNumOwnedLuxuries() → number |
Counts luxury resources (class hash match) whose owned amount, minus the reserved amount, is positive. |
plumbing ✓ |
— |
0x31ff10 |
| GetResourceImportedExtracted |
PlayerResources:GetResourceImportedExtracted(resource: integer) → number |
Returns the imported-extracted count for a resource from an array at this+0x2b0, or 0 for -1. |
plumbing ✓ |
— |
0x3204f0 |
| GetResourceStockpileCap |
PlayerResources:GetResourceStockpileCap(eResource: integer) → number |
Returns the stockpile cap for a resource: the consumption/government base value adjusted for game speed plus a per-resource bonus at this+0x340; 0 if no entry. |
plumbing ✓ |
— |
0x320560 |
| GetUnitResourceDemandPerTurn |
PlayerResources:GetUnitResourceDemandPerTurn(resource: integer) → number |
Returns per-turn resource demand of units for a resource as a fixed-point value from an array in the player unit object, 0 if invalid. |
plumbing ✓ |
— |
0x320ba0 |
| IncrementAccumulatedResources |
PlayerResources:IncrementAccumulatedResources() |
Resets a per-resource list at this+0x140, then adds imported and free-extracted amounts to resource stockpiles and processes city plots; decompilation is truncated in the second half. |
plumbing ✓ |
— |
0x320ec0 |
| IsNoCapResource |
PlayerResources:IsNoCapResource(eResource: integer) → number |
Returns 1 if the resource is flagged as no-cap (array entry at this+0x258 is greater than 0), else 0. |
plumbing ✓ |
— |
0x321580 |
| RevealResourceOnVisibleTiles |
PlayerResources:RevealResourceOnVisibleTiles(resource: integer) |
Private helper: when a player gains the ability to see a resource, scans all plots, marks that resource revealed, refreshes visibility, adds extractable amounts and notifies the player. |
plumbing ✓ |
Player::Resources::RevealResourceOnVisibleTiles |
0x322f00 |
| SetFreeResourceVisibility |
PlayerResources:SetFreeResourceVisibility(resource: integer) |
Marks a resource as visible in a flag array at this+0x90 (if not already), dispatches a game signal, and reveals the resource on visible tiles. |
plumbing ✓ |
— |
0x323190 |
Details
CalculateExcessLuxuries
Input checks: No inputs.
Multiplayer: read-only: pure getter. Risk: low (pure getter). Confidence of the reading: high.
ChangeBannedResource
Arguments: eResource — resource index; iDelta — amount added to the counter
Writes
- per-resource int array in the variant map at this+0x220 (banned count)
Side effects
- editing the variant map marks the game state changed
Input checks: Silently ignores indices below 0 or at/above the array size at this+0x240. Counter can go negative.
Preconditions
- gameplay Lua state only
- must run on the game thread
Multiplayer: may-desync: direct replicated state write. Risk: low (bounds checked, simple counter). Confidence of the reading: high.
Verified from the code
- bounds check against this+0x240
- edits array at this+0x220 and adds iDelta
Inferred
- nonzero counter means banned
Open questions
- how the banned state is consumed
ChangeExtraAccumulationModifier
Arguments: eResource — resource index; iDelta — amount added
Writes
- per-resource int array in the variant map at this+0x300
Side effects
- editing the variant map marks the game state changed
Input checks: Only rejects index -1. No upper bound check: an out-of-range resource index writes outside the array (crash or corruption risk).
Preconditions
- gameplay Lua state only
- valid resource index
Multiplayer: may-desync: direct replicated state write. Risk: medium (no upper bound check on resource index). Confidence of the reading: medium.
Verified from the code
- returns when resource is 0xffffffff
- adds iDelta to element at this+0x300 array, no size check
Inferred
- the modifier is a stockpile accumulation rate bonus
Open questions
- whether the array is always sized to the resource count
ChangeExtraAmenitiesPerOwnedBonusResource
Arguments: iChange — amount added to the setting
Writes
- int auto-variable at this+0xd0 (current value at this+0xe0 plus change)
Side effects
- calls AllocateLuxuries, which redistributes luxury amenities to cities
Input checks: None; any delta is accepted.
Preconditions
- gameplay Lua state only
- must run on the game thread
Multiplayer: may-desync: state change plus amenity reallocation; must run identically everywhere. Risk: low (simple counter plus recompute). Confidence of the reading: high.
Verified from the code
- stores this+0xe0 + iChange into the auto-variable at this+0xd0
- calls AllocateLuxuries afterwards
Inferred
- bonus resources here mean the resource class named in the function
ChangeExtraAmenitiesPerOwnedLuxuryResource
Arguments: iChange — amount added to the setting
Writes
- int auto-variable at this+0xb8 (current value at this+0xc8 plus change)
Side effects
- calls AllocateLuxuries, which redistributes luxury amenities to cities
Input checks: None; any delta is accepted.
Preconditions
- gameplay Lua state only
- must run on the game thread
Multiplayer: may-desync: state change plus amenity reallocation; must run identically everywhere. Risk: low (simple counter plus recompute). Confidence of the reading: high.
Verified from the code
- stores this+0xc8 + iChange into the auto-variable at this+0xb8
- calls AllocateLuxuries afterwards
ChangeFreeResourcesExtracted
Arguments: resource — resource type; amount — delta to add
Writes
- int array element at this+0x2d0 indexed by resource definition index
Side effects
- none beyond the array edit
Input checks: returns silently for resource -1; if the definition is not found the index becomes -1 (0xffffffff) and the write goes to an out-of-range element (crash/corruption risk)
Preconditions
- valid resource id
- gameplay thread
Multiplayer: safe-deterministic. Risk: medium (unchecked fallback index on unknown resource). Confidence of the reading: high.
Verified from the code
- skips when resource == -1
- uses Find on resource definitions, index taken from field +0x14, -1 if not found
- adds amount to array at +0x2d0 with no bounds check
Inferred
- count feeds into the player's resource stockpile
Open questions
- whether stockpile/yield gets recomputed by caller
ChangeImportResourceExtracted
Arguments: resource — resource index; amount — amount added
Writes
- per-resource int array in the variant map at this+0x2a0, indexed by a field at definition+0x14
Side effects
- editing the variant map marks the game state changed
Input checks: Ignores resource -1. If the definition is not found, the index becomes 0xffffffff and the write goes to an out-of-range slot (crash or corruption risk). No upper bound check.
Preconditions
- gameplay Lua state only
- valid resource index
Multiplayer: may-desync: direct replicated state write. Risk: high (unchecked index when definition lookup fails). Confidence of the reading: medium.
Verified from the code
- looks up resource definition, uses uint at +0x14 as array index, or 0xffffffff when not found
- adds amount to array element at this+0x2a0 with no bounds check
Inferred
- field at definition+0x14 is probably a dense index of stockpile-capable resources
- the Find symbol is labelled HeroClass but takes the resource collection, a mis-resolved name
Open questions
- what the field at +0x14 really is and its value range
ChangeNoCapResource
Arguments: eResource — resource index; iDelta — amount added
Writes
- per-resource int array in the variant map at this+0x248 (no-cap count)
Side effects
- editing the variant map marks the game state changed
Input checks: Silently ignores indices below 0 or at/above the size at this+0x268. Counter can go negative.
Preconditions
- gameplay Lua state only
- must run on the game thread
Multiplayer: may-desync: direct replicated state write. Risk: low (bounds checked simple counter). Confidence of the reading: medium.
Verified from the code
- bounds check against this+0x268
- adds iDelta to array at this+0x248
Inferred
- nonzero counter means no cap; meaning inferred from the name
Open questions
- where the counter is consumed
ChangePowerResourceDemandPerTurn
Arguments: resource — Resource type index; iDelta — Change in demand per turn (whole units)
Writes
- Power resource demand vector (offset 0x1a0)
Input checks: Bounds-checks resource; out of range adds to fallback field.
Multiplayer: may-desync. Risk: medium (writes synced resource data). Confidence of the reading: medium.
ChangeReservedResourceAmount
Arguments: eResource — resource type; iDelta — signed change
Writes
- reserved resource int array at this+0x1f8 (entry for eResource, min 0)
Input checks: Silent return when resource index <0 or >= count at +0x218.
Preconditions
- game thread
Multiplayer: may-desync: synced array. Risk: low (bounds-checked clamped counter). Confidence of the reading: high.
Verified from the code
- bounds check
- adds delta then clamps negatives to 0
- no event or signal
Inferred
- bounds count is the resource definition count
ChangeResourceStockpileCapModifier
Arguments: eResource — resource index; iDelta — amount before game-speed scaling
Writes
- per-resource int array in the variant map at this+0x330 (cap modifier)
Side effects
- editing the variant map marks the game state changed
Input checks: Ignores resource -1 and any index outside the resource definitions list or with a null definition slot, silently.
Preconditions
- gameplay Lua state only
- valid resource index
Multiplayer: may-desync: direct replicated state write, delta scaled by game speed. Risk: low (validated index against definitions). Confidence of the reading: high.
Verified from the code
- checks index against definitions vector size and non-null entry
- delta passes through Economic::AdjustForGameSpeed before being added at this+0x330
Inferred
- modifier is added to the base stockpile cap
Open questions
- whether the array is always sized to the definition count
CheckNotifications
Side effects
- Calls Lua hook AdvisorNegativeResourceRate(playerID, resourceType)
Input checks: Bounds-checks resource index against arrays; no external input.
Multiplayer: read-only on game state; only fires a UI advisor hook. Risk: low (Only calls a Lua hook, no state writes seen). Confidence of the reading: medium.
DoTurnActivate
Writes
- Accumulated resource stockpiles (via IncrementAccumulatedResources)
- Luxury allocation (via AllocateLuxuries)
- National park amenities for the player
Side effects
- Edits Game::NationalParks
Input checks: None; no parameters.
Multiplayer: may-desync, turn processing mutates synchronised state. Risk: medium (Calling it out of turn double-counts resources). Confidence of the reading: high.
DoTurnDeactivate
Writes
- Resource stockpile amounts (via ChangeResourceAmount)
Input checks: Checks resource index range; skips resources whose consumption entry flag is unset.
Multiplayer: may-desync, modifies player stockpiles. Risk: medium (Modifies player resource stockpiles). Confidence of the reading: medium.
DoTurnResourceMaintenance
Writes
- Per-resource list at this+0x1a0 (reset)
- Resource stockpiles (via PayResourceMaintenanceCosts)
- City power (via SupplementCityPowerWithResources)
Input checks: None; no parameters.
Multiplayer: may-desync, turn-processing writes to player/city state. Risk: high (Turn-processing writes to synchronised state). Confidence of the reading: medium.
EndExportResource
Arguments: resource — resource type affected; amount — quantity moved back from category 2 to category 0
Writes
- Resource amounts (category 2 decreased, category 0 increased by amount)
Input checks: No checks here; ChangeResourceAmount does any range checking.
Multiplayer: may-desync, edits player resource totals. Risk: medium (Edits player resource totals). Confidence of the reading: medium.
GetAvailableResourceAmount
Arguments: resource — resource type index; bSubtractReserved — if true, subtract the reserved amount from the base count
Input checks: Range-checks resource index against the definition count; returns 0 if invalid.
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: medium.
GetFreeResourcesExtracted
Arguments: resource — resource type, -1 means none
Input checks: Rejects -1; the definition lookup result is only partly checked.
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: medium.
GetNumOwnedLuxuries
Input checks: Range-checks resource index; no parameters.
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: high.
GetResourceImportedExtracted
Arguments: resource — resource type, -1 means none
Input checks: Rejects -1 only.
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: medium.
GetResourceStockpileCap
Arguments: eResource — resource type, -1 returns 0
Input checks: Rejects -1; if the definition is missing it dereferences a null-based pointer (not checked).
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: medium.
GetUnitResourceDemandPerTurn
Arguments: resource — resource type index (inferred)
Input checks: Checks -1, definition count and array size; returns 0 otherwise.
Multiplayer: read-only getter. Risk: low (Pure getter (decompiler shows the return-slot and param mismatched)). Confidence of the reading: medium.
IncrementAccumulatedResources
Writes
- Per-resource list at this+0x140
- Resource stockpile amounts
Side effects
- Reporting event block 0x1153df52 begin/end/send
Input checks: Checks flags and -1 resource index; decompilation truncated so later checks unknown.
Multiplayer: may-desync, mutates stockpiles and sends events. Risk: high (Mutates synchronised stockpiles and sends events). Confidence of the reading: low.
IsNoCapResource
Arguments: eResource — resource type index
Input checks: Checks index within 0 and array size.
Multiplayer: read-only getter. Risk: low (Pure getter). Confidence of the reading: high.
RevealResourceOnVisibleTiles
Arguments: resource — resource to reveal
Writes
- resource revealed state per plot via the resource builder
- player visibility on those plots
- player resource amount via ChangeResourceAmount
Side effects
- Map::Resource::Builder::UpdateRevealedAt per matching plot
- RefreshVisibility on visible/explored plots
- dispatches a game signal (+0x12a8) with player, resource, plot
- sends a notification (type 0x36460f2d) for plots owned by the player
Input checks: No explicit validation of the resource id; unmatched plots are skipped.
Preconditions
- gameplay state
- valid owner
Multiplayer: may-desync: map visibility and resource changes. Risk: medium (Full map scan changing visibility and amounts). Confidence of the reading: medium.
Verified from the code
- loops all plots
- matches plot resource type to param
- calls UpdateRevealedAt for matches
- notification only when plot owner equals this player
Inferred
- plots not currently visible or explored are skipped before refresh
- Change amount uses plot resource count
Open questions
- meaning of RevealedState values 1 and 2 passed to RefreshVisibility
SetFreeResourceVisibility
Arguments: resource — resource type to reveal
Writes
- Free-resource visibility flag array at this+0x90
Side effects
- Dispatches a game signal with the player and resource
- Calls RevealResourceOnVisibleTiles
Input checks: Checks index in range and flag not yet set; ignores otherwise.
Multiplayer: may-desync, writes synchronised visibility state. Risk: medium (Writes synchronised visibility state). Confidence of the reading: medium.