Author Topic: Mine Yield Formula  (Read 557 times)

Offline TechCor

  • Full Member
  • ***
  • Posts: 142
Mine Yield Formula
« on: December 30, 2025, 10:10:23 AM »
I couldn't find this anywhere, so I discovered this with SCIENCE!



There is a hardcoded maximum yield for each ore type:

Common Ore MaxYield = 1000
Rare Ore MaxYield = 500


Using the data from the mine yield sheet, we calculate the initial, peak, and minimum yields:

Code: [Select]
InitialYield = MaxYield * InitialYield% / 100
PeakYield = MaxYield * PeakYield% / 100
MinYield = MaxYield * MinYield% / 100

The yield formula is as follows where TrucksLoaded is the number of trucks already loaded prior to loading the current truck:

Code: [Select]
if (TrucksLoaded > MinTruck)
Yield = MinYield
else if (TrucksLoaded > PeakTruck)
Yield = PeakYield - (TrucksLoaded - PeakTruck) * (PeakYield - MinYield) / (MinTruck - PeakTruck)
else
Yield = InitialYield + TrucksLoaded * (PeakYield - InitialYield) / PeakTruck
Yield rounds down due to int truncation.


Bonuses from research are applied after calculating the yield.

Code: [Select]
Yield = Yield + Yield * Bonus% / 100

Metallogeny
20% bonus to yield for Common Ore.

Rare ore extraction
20% bonus to yield for Rare Ore.

Magma Vents do not use the mine yield sheet. Instead, the building sheet sets the production capacity.
There is no formula for Magma yield based on trucks loaded.

From the building sheet: Magma Yield = 100

Magma Purity Control
Set to 150 production capacity by the research topic found in the tech sheet.
« Last Edit: December 30, 2025, 12:27:22 PM by TechCor »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4958
Re: Mine Yield Formula
« Reply #1 on: February 27, 2026, 08:43:56 AM »
This encouraged me to turn on an old computer and copy some old files, such as the OllyDbg comments file and take a look. The relevant code is indeed documented.



Code: [Select]
0044B1C0 MOV EAX,DWORD PTR SS:[ESP+8]             ;  Function: BeaconTypes.CalculateMineYield(int barYield, int variant, int numTruckLoadsSoFar)

The code in that function matches the Yield calculation you gave based on the number of truck loads. There were only inconsequential differences. (The middle condition used `>=` instead of `>`, and it swapped the order for (minYield - peakYield) which was added instead of subtracted).



Code: [Select]
0044AF10 PUSH EBX                                 ;  Function: Unit:Mine.CalculateMineYield()

This function has the tech check to increase yield to 120%. The 120% value is a hardcoded constant, based on a flag that is checked for the increase.

It kind of looks like the same flag is checked for both common and rare ore, though there are first checks if the mine is a common or rare ore mine. I wonder if that might indicate a bug in the game where a single tech increases both, or if it's a dual purpose flag that is context dependent. I kind of suspect a bug now that I'm looking at it.

There is also a detail that if the `unitType` is `mapRareOreMine` then the `yield` is cut in half.



I haven't seen evident for hardcoded maximum yields based on what I just looked at. I kind of thought the yields were loaded directly from `MINES.TXT` based the variant and yield values, rather than using percentages. I remember there was data for 3 different variants of each yield level.