Resource Spawner Overhaul

by orzelek

Overhauls resource spawning system.

13 days ago
0.14 - 1.1

g Deadlock Compatiblity

2 years ago

If possible, could support for Deadlock's Industrial Revolution Tin (as well as Krastorio's Rich Rock) be added? Many thanks.

2 years ago
(updated 2 years ago)

I'll talk with Deadlock - I need to see what resources are there and find out if he wants to prep the config.
I havr new config from Krastor in a thread from yesterday - I'll add it along with the IR one soon.

2 years ago
(updated 2 years ago)

Tin ore spawns as often and as large as iron does but less dense (7 on the vanilla scheme as opposed to iron's 10).

Gold ore spawns almost identically to vanilla uranium ore.

Iron ore should not spawn in starting areas, nor should gold, but tin does.

Don't know if RSO touches trees, but there's an additional resource from rubber trees, don't ask me how it works, that bit of mapgen is black magic as far as I'm concerned, I just threw numbers at it for six hours until it did what I wanted.

Let me know if you need anything else. Or look at code/terrain/terrain-ores.lua in the mod.

2 years ago

Thanks for the info.
I'm not touching trees either.. and I should drop the iron from starting area then? That'll be interesting.

2 years ago

It wouldn't necessarily "break" anything if iron was in the starting area, but it would be an annoyance for the player and confusing. Iron smelting is the first green science research, so it's supposed to be further out than copper and tin.

2 years ago

And you can get trains without iron?
Because with RSO if I drop it outside starting area then trains are a necessity.

2 years ago
(updated 2 years ago)

No. Train infrastructure is based on iron. It's cheaper than in vanilla because it's mostly based on iron rather than steel, but you need the iron.

In my playthroughs, with vanilla's idea of what the starting area is like on default settings, one of two things happened. Either the nearest iron ore patch was just about near enough to run a belt without that being too annoying; or if it was too far, IR provides a very early, very cheap car substitute (the monowheel) which is used to gather stuff. I would then set up a bootstrap iron outpost to get my first iron ingots and kickstart trains with that.

2 years ago

We might try to start with no iron in starting area and see how it goes. With increased distances in RSO it might prove problematic.

2 years ago
(updated 2 years ago)

I'm happy for you to use your judgement, you know RSO. I used it a lot in 0.15-0.16 days but have lost touch with it.

2 years ago

I've released new version and for now iron is off the starting area.
There is a bit of a conflict with Krastorio on gold ore since both mods have it and Krastorio is more generaous with spawning. For now if Krastorio is present it will use more generous version.

It would be good if you could take a look and see how it plays without iron in starting area. If you are lucky you will get iron in about 1k tiles range, if not then search area might be larger. (Or if starting area size is increased)

2 years ago

That sounds right for Krastorio - I don't know it very well but I think gold is a bit more important for K.

Will definitely test it out. Need to start a new game and wanted a rail world type thing anyway.

Thanks for doing this.

2 years ago

Hi, have not had any time for playing to be honest (sad face) but have received positive feedback about RSO's settings for IR. The challenge to break into iron seems appreciated so far.

2 years ago

Thats good to know :)

1 year, 8 months ago
(updated 1 year, 8 months ago)

Hi, I am looking at releasing an overhaul of IR after Factorio 1.1 drops.

There have been some changes to ore resources. However they are not final yet.

In terms of the existing RSO config, in plain English, tin ore is fractionally less common than it used to be (it should show up about 7/8ths the frequency of copper), and gold ore is a bit more common.

However there are three new ore patches. They are variants of coal, iron ore and copper ore. They have a tiny probability of dropping various gems in addition to the 1 ore item. That probability is still TBD but at the moment we're talking at least four zeroes after the decimal point. They are the only way of getting those gems so at the moment RSO 6.1.4 breaks IR 2.0.0's progression.

I had a look at the existing RSO config file for IR but to be honest I wasn't sure where to start with multiple item drops.

The good news is that IR will be providing a file that returns a data table filled with useful info about ore fields. You could dynamically read the bonus probability drops from there. That means that if I change them later to be more generous, you don't have to lift an additional finger. If you have some scheme for converting vanilla properties like base_density etc to RSO properties, they are all in the table as well. You can get the whole table like so:

local IR_orefields = require("__IndustrialRevolution__/code/data/orefields")

Sorry for the hassle.

1 year, 8 months ago
(updated 1 year, 8 months ago)

Or does none of that matter? Does RSO just use the existing resource entity? If so then I guess you don't need to worry about the additional drops.

The three new patches are named "iron-gem-ore", "copper-gem-ore" and "coal-gem-ore". They all have the same size/frequency properties. They are between 200-300% the size of a uranium patch but with only 70% of the spot frequency of uranium and about 55% of the density.

1 year, 8 months ago

Drops etc don't matter at all.
Only thing that matters is that it's a separate ore type. RSO doesn't interact with ores after spawning in any way.

When you have new IR ready I'll update the config - or you can edit it with new ores and modifications you mentioned and post it on forums.

1 year, 8 months ago
(updated 1 year, 8 months ago)

Man, vanilla resource_autoplace is a nightmare.

I'm not happy with the way this gems thing is working out. I'm trying an alternative approach which doesn't autoplace the gem ores but uses on_chunk_generated to sprinkle normal ore patches with an alternative resource. How would that fit in with RSO? Do events respect dependency order?

Edited to add: so far what I've done seems to work with RSO just fine, IR's on_chunk_generated is picking up RSO's ore placements, so this looks OK. I will put in a hidden dependency on RSO to make sure.

1 year, 8 months ago

It will work until it won't.
The main reason being RSO being a tad naughty and generating ores outside of chunk that is being generated also. For big patches it will be pretty obvious.
If you have a method that does the work I can call it with area that contains the ore patch.

Alternatively I can spawn ore in different way in RSO - there is a bit more options in RSO then in vanilla when it comes to ore spawns.

1 year, 8 months ago

So if I expose a function which takes {surface, chunk_position, area} as options, RSO could run it on any and all chunks it generates ores in? That would be ideal. Then I can tweak later if necessary without hassling you again. I guess in that situation I would not run it at all if RSO is loaded but leave it to RSO?

IR already wraps up functions into tables you can get with a require so it would be as simple as doing something like:

local IR = require("__IndustrialRevolution__/code/functions/functions-control") IR.replace_chunk_ores(surface,chunk_position,area)

1 year, 8 months ago
(updated 1 year, 8 months ago)

That would work.
Main problem might be me trying to figure out what to send you as chunk_position and area.

RSO keeps internally rectangle that is effectively bounding box of resource patch. Would that work?
I have it used as here:
local function roundRect( rect )
rect.xmin = round( rect.xmin )
rect.xmax = round( rect.xmax )
rect.ymin = round( rect.ymin )
rect.ymax = round( rect.ymax )
I could also pass ore name that is spawned so that you could decide quickly if there is a work to be done or not.

Actually maybe I'd do the reverse.
I would generate custom event from RSO when ore patch is spawned with rectangle as above and ore name. That way any other mod could also use it.
It might get a bit more tricky for oil like resources but not much of added work.

1 year, 8 months ago
(updated 1 year, 8 months ago)

At the moment (still being worked on but this is the general idea) those three parameters are based on what on_chunk_generated returns, so it's the surface, the chunk position (i.e. corner coordinates divided by 32), and the bounding box of the chunk (event.surface, event.position and event.area). I only use the chunk position to make a kind of 8x8 chunk "checkerboard" so that approximately half of the ore patches don't get any / much gems sprinkled into them (even in those chunks that are allowed, only about 1/100 resources are replaced with a gem variant so if a patch straddles a chunk boundary it doesn't really matter).

But the latter idea (custom RSO event) would certainly be very useful for all mods. It might even save you a fair bit of future work ... That way I could catch your event and run it on the whole multichunk patch instead of using the default chunk-based approach when it's vanilla autoplace. That would be super-easy to deal with and I guess other mod authors might appreciate it too.

Think about it, there is no rush at my end, what I'm getting with RSO right now is OK - at the moment I guess I might be missing parts of some chunks but this is a very rare resource anyway and technically you only need 1 gem of each type to kickstart a synthesis process so it's not critical.

I don't have any liquid patch type resources so not bothered - I guess for those you could do a second kind of event which passes on the individual blobs? Dunno.

1 year, 8 months ago

Considering that my modding is currently rather below active I'll leave it as is for now and we'll see how it works.
Main issues might be visible in areas where RSO will fail on collision checks and move the whole ore patch chunk in some direction. That would just mean that that ore patch will be gem-less.

1 year, 8 months ago

OK, let's see how it goes. I can always do some other kind of hacky tweak like boost the individual resource drops if there turn out to be too few RSO patches with any gems in, etc. But so far what I'm seeing looks OK at worst.

1 year, 8 months ago
(updated 1 year, 8 months ago)

At the worst case you'd need to peek on neighbouring chunks when RSO is around. Unless someone a tad eager buffs size of ore patches to max - it gets hardcore then with patches spawning really big areas and also bugging out a bit even.
I was actually planning to scale down base game size factor a bit to make it less severe. RSO is more abotu dense patches then huge ones.

1 year, 7 months ago
(updated 1 year, 7 months ago)

IR2 is out. If you want you could adjust the existing tin ore so that it produces similar sized patches to vanilla copper but with 7/8ths the density, and adjust gold ore so that patches are about as 120% frequent as vanilla uranium, sized the same as uranium, and 110% as dense as uranium. That said I don't think the existing settings are far off that, perhaps just too much tin.

With the on_chunk_generated thing, it looks OK. I guess it might technically be breaking if people crank up ore patch sizes very high and it's spilling to multiple adjacent chunks. But given that my existing method breaks the surface up into a checkerboard anyway, and it also avoids the edges of patches where resource count is low, it's not impossible for a big vanilla-generated patch to have sprinkles of gems down one side but not the other, so it doesn't essentially look any different. I guess we could revisit it if people start moaning but whatevs. On top of all that you technically only need a handful of gems before you can start synthesising them in the late game, so as long as every map has a minimum of 1 of each type then it's all doable.


1 year, 7 months ago

Is IR2 as separate mod name?
I'll adjust the config and post it searching for new mod id if so.

1 year, 7 months ago

No, it's the same as before - IndustrialRevolution.

Cheers and have a good break.

New response