Page 1 of 1

Ore Generation issues

Posted: Fri Mar 01, 2019 2:51 pm
by kasandraen
Hi

I'm trying to generate some ores for my mod and I'm running into some issue. I have followed the doings of other mods, but it seems they all rely on Bobs'library ore functions and even with those I cant get it to seem right.

Ingame when you reduce the frequency the ore patches grow in size instead of just becoming more rare like this example; Image
Image
Notice the vanilla ores circled arent massive

This is how this code looks;

Code: Select all

  
  name = input.name
  sharpness = 1
  richness_multiplier = 1250 * richness
  richness_base = 8 * richness
  richness_multiplier_distance_bonus = 20
  coverage = size / 600
  peaks ={{
	noise_layer = base.name,
	starting_area_weight_optimal = 1,
	starting_area_weight_range = 0,
	starting_area_weight_max_range = 2,
	noise_octaves_difference = -0.85,
	noise_persistence = 0.4
	},
	{
	noise_layer = base.name,
	noise_octaves_difference = -0.85,
	noise_persistence = 0.4
	}}
}
  

How do I correctly set the ores up to follow the generation of the vanilla ores and not explode in size like above? I heard we havnt had access to the new ore gen configs for .17 yet.

Re: Ore Generation issues

Posted: Fri Mar 01, 2019 6:04 pm
by orzelek
It's not only limited to mod ores.
I seen iron or copper do this - I think they might have underflow/overflow kind of error somewhere in the code that gets triggered when you use minimum frequency.
When I looked at how probability is defined in data stage (expression tree with 100+ elements) I did not try to look into it further :D

Re: Ore Generation issues

Posted: Fri Mar 01, 2019 6:18 pm
by kasandraen
orzelek wrote: Fri Mar 01, 2019 6:04 pm It's not only limited to mod ores.
I seen iron or copper do this - I think they might have underflow/overflow kind of error somewhere in the code that gets triggered when you use minimum frequency.
When I looked at how probability is defined in data stage (expression tree with 100+ elements) I did not try to look into it further :D
Yeah I tried that myself in hopes of figuring out where I was wrong and it just made me more confused. I tried looking at the Demo-resource-autoplace aswelll but that too weren't very concrete at what settings it wanted to be fed. The demo resources also used a function inside the Demo-resource-autoplace and I dont know how to use that function myself

Code: Select all

utoplace = resource_autoplace.resource_autoplace_settings{
      name = resource_parameters.name,
      order = resource_parameters.order,
      base_density = autoplace_parameters.base_density,
      has_starting_area_placement = true,
      resource_index = resource_autoplace.get_next_resource_index(),
      regular_rq_factor_multiplier = autoplace_parameters.regular_rq_factor_multiplier;
      starting_rq_factor_multiplier = autoplace_parameters.starting_rq_factor_multiplier;
    }
and looking at how the uraninium is setup, it too uses that function inside the Demo-....

Code: Select all

autoplace = resource_autoplace.resource_autoplace_settings{
      name = "uranium-ore",
      order = "c",
      base_density = 0.9,
      base_spots_per_km2 = 1.25,
      has_starting_area_placement = false,
      random_spot_size_minimum = 2,
      random_spot_size_maximum = 4,
      resource_index = resource_autoplace.get_next_resource_index(),
      regular_rq_factor_multiplier = 1

is there a way for me to use the resource_autoplace.resource_autoplace_settings outside of the core files? I tried including it but since it was in a different "mod" it didnt work


Edit: I tried to work my way down the tree and modifying the values that had a name

Code: Select all

	local obj = util.table.deepcopy(data.raw["resource"]["copper-ore"])
	local ap = obj.autoplace
	ap.control = base.name
	
	local settingsProb = ap.probability_expression.arguments[1].expression.arguments[1].arguments[1].arguments.basement_value.arguments[1].arguments[2].arguments[2].arguments[1].arguments[1].arguments[1].arguments[2].arguments[1].arguments[1].arguments[1].arguments[1].arguments[2]
	settingsProb.arguments[1].expression_id = "variable:control-setting:"..base.name..":frequency:multiplier"
	settingsProb.arguments[1].variable_name = "control-setting:"..base.name..":frequency:multiplier"
	settingsProb.arguments[2].expression_id = "variable:control-setting:"..base.name..":size:multiplier"
	settingsProb.arguments[2].variable_name = "control-setting:"..base.name..":size:multiplier"
	local settingsRich = ap.richness_expression.arguments[2].arguments[2]
	settingsRich.expression_id = "variable:control-setting:"..base.name..":richness:multiplier"
	
But now ingame it just replaces the copper ore so it seems just changing the name of these settings didnt fix it

Edit2:

I tried working with the vanille oregen by importing the class they used;

Code: Select all

local resource_autoplace = require("__base__/prototypes/entity/demo-resource-autoplace")

obj.autoplace = resource_autoplace.resource_autoplace_settings{
      name = base.name,
      order = "b",
      base_density = base.base_density,
      --base_spots_per_km2 = base.base_spots_per_km2,
      has_starting_area_placement = base.starting_area,
      --random_spot_size_minimum = base.random_spot_size_minimum,
      --random_spot_size_maximum = base.random_spot_size_maximum,
      resource_index = resource_autoplace.get_next_resource_index(),
      regular_rq_factor_multiplier = base.regular_rq_factor_multiplier,
	  starting_rq_factor_multiplier = (base.starting_rq_factor_multiplier or 0)
    }
with the some ores, all using the same settings as the iron does in the demo

Code: Select all

{
      base_density = 10,
      regular_rq_factor_multiplier = 1.10,
      sta
but now I am even more confuse because the spawner is being all wierd and only making mixed patches;

Image

all those highligthed ones are Gold+Coal patches, there is not a single seperate one of those, but as you can see the other ores work ish. But for some reason there is no Copper outside the spawn anymore... But if i take the slider up 1 tick in frq to 133% it starts spawning again.

Edit4: I managed to fix the the coal+gold always spawning together....but now lead and coal allways spawn together...

Edit5: I figured out why the resources spawned on top of eachother, or atleast I suspect what the issue was, inside the demo-resource they use the resource_autoplace.get_next_resource_index() to get the next index of the ore, so in vanille it would be 1(iron),2(copper),3(Coal),4(stone),5(oil) and 6(uranium). What I think is happening is that since the counter variable is a local it starts at 0 again when my mod commes and uses the same resource_autoplace.get_next_resource_index(), so that my resources get the same index and thus collide in the spawning. I fiex that by just manually setting in a new number

Code: Select all

resource_index = 20+(counter*2)
now they spawn as expected, evenly spread and not ontop of eachother