Attempting to fix water luxury clustering.

pokiehl

Moderator
Moderator
Joined
Mar 5, 2017
Messages
4,173
Hi all,

Water luxuries tend to cluster together away from the fish and crabs. I think the relevant code in ResourceGenerator.lua is this:

function ResourceGenerator:__PlaceWaterLuxury(eChosenLux, pPlot)
if (ResourceBuilder.CanHaveResource(pPlot, self.eResourceType[eChosenLux])) then
-- Randomly detetermine each plot if a water luxury is placed less likely if there are adjacent of the same type

local iBonusAdjacent = 0;

if( self.iStandardPercentage < self.iTargetPercentage) then
iBonusAdjacent = -1.5;
elseif ( self.iStandardPercentage > self.iTargetPercentage) then
iBonusAdjacent = 1;
end

local iRandom = 15 * self.iOccurencesPerFrequency + 300;

--print ("Random Frequency: " , iRandom);

local score = TerrainBuilder.GetRandomNumber(iRandom, "Resource Placement Score Adjust");
score = score / ((ResourceBuilder.GetAdjacentResourceCount(pPlot) + 1) * (3.0 + iBonusAdjacent));

if(score * self.iSeaFrequency[eChosenLux] >= 85 + 5 * self.iOccurencesPerFrequency) then
ResourceBuilder.SetResourceType(pPlot, self.eResourceType[eChosenLux], 1);
return true
end
end

return false;
end

Any idea what numbers could be modified to allow water luxuries to be placed more frequently than water bonuses?
 
I wish I knew more about map generation to help you out. :(
Also related to water luxuries, I can never get more than 3 types to appear on any map - even YnAMP's larger sizes. It's frustrating since with my enabled mods there are several I'd like to see, but almost never do. If you happen across anything useful in those regards...
 
I wish I knew more about map generation to help you out. :(
Also related to water luxuries, I can never get more than 3 types to appear on any map - even YnAMP's larger sizes. It's frustrating since with my enabled mods there are several I'd like to see, but almost never do. If you happen across anything useful in those regards...

I think I have a better idea of how to tackle this; I'll do experimenting tonight and hopefully I get results :)

As for the variety of water luxuries, I was perplexed about that issue for a while but I fixed it so that you get all possible water luxuries on any size map. I believe I incorporated this into my Truly Abundant Resources mod, so if you want to try that go for it (you don't need to use the "Truly Abundant" or "Plentiful" settings for those changes to work).

I THINK it was just a database thing but I may have altered ResourceGenerator.lua. I'll have to double check.

But either way, I'll post the code here for you and maybe upload it as a separate mod. It'll just have to be later today as I am still at work.
 
Ok, so what I used in Truly Abundant Resources to fix that is:

UPDATE Resource_SeaLuxuries SET Huge=5 WHERE MapArgument<>1;
UPDATE Resource_SeaLuxuries SET Large=5 WHERE MapArgument<>1;
UPDATE Resource_SeaLuxuries SET Standard=5 WHERE MapArgument<>1;

This will make it so that 5 distinct sea luxury resources will spawn on all map types from Standard on up. 5 accounts for pearls, whales, turtles, amber, and Sukritact's Sharks. If you use other mods that add water luxuries, then increase the number for taste.

For custom map sizes, like in my Larger Map Sizes mod or YNAMP, the ResourceGenerator defaults to the value for Huge, so no need for further compatibility. For custom map SCRIPTS, like Detailed Worlds or something, I think the generator defaults to MapArgument 2, so again, the code as written is automatically compatible.
 
Ah, awesome! :thumbsup: I had looked at that table, but wasn't sure exactly what it did. I assumed it was just a variable that increase frequency, but it's nice to know it's actually for the number of distinct sea luxuries.
5 accounts for pearls, whales, turtles, amber, and Sukritact's Sharks.
Haha, that's exactly what got me looking into this! Sharks & Turtles are an absolute necessity imo.
For custom map sizes, like in my Larger Map Sizes mod or YNAMP, the ResourceGenerator defaults to the value for Huge, so no need for further compatibility.
That's good to know. That's a question I asked Gedemon over in the YnAMP thread concerning adding larger map sizes to the table.
For custom map SCRIPTS, like Detailed Worlds or something, I think the generator defaults to MapArgument 2, so again, the code as written is automatically compatible.
I use Detailed Worlds too, so that's also good to know. What exactly does the MapArgument column define?
 
MapArgument refers to the map script (Continents, Pangaea, Island Plates, etc.). I forget which number corresponds to which vanilla script. I kept it at 0 for MapArgument1 because it was like that by default so I didn't want to rock the boat.
 
Back
Top Bottom