Lord Yanaek
Emperor
- Joined
- Aug 15, 2003
- Messages
- 1,662
Anybody figured how the quantity of strategic resources is calculated? In the database i found a Resource_QuantityTypes table with the following entries.
ResourceType|Quantity
RESOURCE_FIRAXITE|2
RESOURCE_FIRAXITE|3
RESOURCE_FLOAT_STONE|2
RESOURCE_FLOAT_STONE|3
RESOURCE_PETROLEUM|2
RESOURCE_PETROLEUM|4
RESOURCE_TITANIUM|2
RESOURCE_TITANIUM|4
RESOURCE_XENOMASS|2
RESOURCE_XENOMASS|3But the actual resource quantities vary much more than this. I thought it might be multiplied by something in worlds table to account for bigger or smaller worlds but i didn't found anything. Nothing in defines either.
They didn't hard-code THIS did they
EDIT : got it (sort of). It's controlled by SpawnStrategicResourcePlotBonus.lua
Now, if anyone can explain the weird math used by this code to have anything from 2 to 10 floatstone with a database value of 2 or 3 
RESOURCE_FIRAXITE|2
RESOURCE_FIRAXITE|3
RESOURCE_FLOAT_STONE|2
RESOURCE_FLOAT_STONE|3
RESOURCE_PETROLEUM|2
RESOURCE_PETROLEUM|4
RESOURCE_TITANIUM|2
RESOURCE_TITANIUM|4
RESOURCE_XENOMASS|2
RESOURCE_XENOMASS|3
They didn't hard-code THIS did they

EDIT : got it (sort of). It's controlled by SpawnStrategicResourcePlotBonus.lua
Code:
-- Choose an amount
local amount = 1;
local quantityDeck = {};
for resourceQuantityInfo in GameInfo.Resource_QuantityTypes("ResourceType = \"" .. resourceInfo.Type .. "\"") do
table.insert(quantityDeck, resourceQuantityInfo.Quantity);
end
if (#quantityDeck > 0) then
roll = Game.Rand(#quantityDeck, "Choosing how much of the resource to spawn from plot bonus") + 1;
amount = quantityDeck[roll];
end
