Skip to content

Commit 46308ed

Browse files
committed
Merge remote-tracking branch 'rrdm/master'
2 parents 8c29cfc + 612df00 commit 46308ed

9 files changed

Lines changed: 686 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Resource Richness Distance Multiplier
2+
3+
You're almost done mining your starting iron ore patch. You need to expand.
4+
Lucky you, right next door there is an iron ore field huge enough to support your base for the rest of your life as well as that of your grandchildren.
5+
6+
This mod adds a bit of control on just how much richer the resource patches outside the starting area are.
7+
It does not alter the placement of ores from vanilla. As such, the map preview still works.
8+
9+
If you need more control, you should stick to good ol' [RSO](https://mods.factorio.com/mod/rso-mod).
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
local resource_autoplace_settings = require('lualib.resource-autoplace').resource_autoplace_settings
2+
3+
-- default values as of 1.0.0
4+
data.raw.resource['iron-ore'].autoplace = resource_autoplace_settings({
5+
name = 'iron-ore',
6+
order = 'b',
7+
base_density = 10,
8+
has_starting_area_placement = true,
9+
regular_rq_factor_multiplier = 1.10,
10+
starting_rq_factor_multiplier = 1.5,
11+
candidate_spot_count = 22,
12+
})
13+
data.raw.resource['copper-ore'].autoplace = resource_autoplace_settings({
14+
name = 'copper-ore',
15+
order = 'b',
16+
base_density = 8,
17+
has_starting_area_placement = true,
18+
regular_rq_factor_multiplier = 1.10,
19+
starting_rq_factor_multiplier = 1.2,
20+
candidate_spot_count = 22,
21+
})
22+
data.raw.resource['coal'].autoplace = resource_autoplace_settings({
23+
name = 'coal',
24+
order = 'b',
25+
base_density = 8,
26+
has_starting_area_placement = true,
27+
regular_rq_factor_multiplier = 1.0,
28+
starting_rq_factor_multiplier = 1.1,
29+
})
30+
data.raw.resource['stone'].autoplace = resource_autoplace_settings({
31+
name = 'stone',
32+
order = 'b',
33+
base_density = 4,
34+
has_starting_area_placement = true,
35+
regular_rq_factor_multiplier = 1.0,
36+
starting_rq_factor_multiplier = 1.1,
37+
})
38+
39+
data.raw.resource['uranium-ore'].autoplace = resource_autoplace_settings({
40+
name = "uranium-ore",
41+
order = "c",
42+
base_density = 0.9,
43+
base_spots_per_km2 = 1.25,
44+
has_starting_area_placement = false,
45+
random_spot_size_minimum = 2,
46+
random_spot_size_maximum = 4,
47+
regular_rq_factor_multiplier = 1
48+
})
49+
50+
data.raw.resource['crude-oil'].autoplace = resource_autoplace_settings({
51+
name = "crude-oil",
52+
order = "c",
53+
base_density = 8.2,
54+
base_spots_per_km2 = 1.8,
55+
random_probability = 1/48,
56+
random_spot_size_minimum = 1,
57+
random_spot_size_maximum = 1,
58+
additional_richness = 220000,
59+
has_starting_area_placement = false,
60+
regular_rq_factor_multiplier = 1
61+
})
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Resources
2+
3+
- data/core/lualib/resource-autoplace.lua
4+
- https://github.com/wube/factorio-data/blob/2b18d0a/core/lualib/resource-autoplace.lua
5+
- https://lua-api.factorio.com/1.0.0/Concepts.html#AutoplaceSpecification
6+
7+
# Notes on how stuff works
8+
9+
```
10+
return
11+
{
12+
initialize_patch_set = initialize_patch_set,
13+
resource_autoplace_settings = resource_autoplace_settings
14+
}
15+
```
16+
17+
`initialize_patch_set` defines spots that resources can spawn on.
18+
If omitted, it doesn't initially change anything it seems.
19+
20+
However, if the `probability_expression` is changesd, the probability applies to the entire map instead of just some
21+
blobs.
22+
23+
---
24+
25+
```
26+
local ret =
27+
{
28+
order = order,
29+
control = autoplace_control_name,
30+
probability_expression = probability_expression,
31+
richness_expression = probability_expression * 100 -- noise.random(800) + 400
32+
}
33+
```
34+
35+
`probability_expression` is a value between 0 and 1, indicating the chance that a particular tile will have a resource
36+
to begin with. If the chance is not actually 0 or 1, but something in between, resources patches will have empty tiles
37+
scatted across them.
38+
39+
`richness_expression` returns the exact amount of ore for a particular tile. Though I'm not sure how exactly this
40+
converts to yielding resources, e.g. oil patches.
41+
- tne(10000) -> 3%
42+
- tne(100000) -> 33%
43+
- tne(1000000) -> 333%
44+
45+
Note that this value must be at least 2. The tile won't spawn if it has a richness of less than that.
46+
Though it will still show up on the preview for map generation if the value is greater than 0.
47+
Floating point numbers are floored.
48+
49+
Both these values must be noise expressions, a regular number is not enough. You can use the `tne()` that is used in
50+
this file to convert numbers "To Noise Expression"s.
51+
52+
`noise.delimit_procedure(expression)` doesn't really do anything.
53+
It only causes outputs by `dump_expression(expression)` to be trimmed as not to clutter the output with a wall of math.
54+
55+
---
56+
57+
```
58+
{
59+
type = "function-application",
60+
function_name = "random-penalty",
61+
arguments =
62+
{
63+
source = tne(10),
64+
x = noise.var("x"),
65+
y = noise.var("y"),
66+
amplitude = tne(8)
67+
}
68+
}
69+
```
70+
71+
`source` is the base value.
72+
73+
`amplitude` is the maximum deviation from that base value.
74+
In the above example, the effective value is in the range 2..10
75+
76+
---
77+
78+
```
79+
{
80+
type = "function-application",
81+
function_name = "spot-noise",
82+
arguments =
83+
{
84+
x = noise.var("x"),
85+
y = noise.var("y"),
86+
seed0 = noise.var("map_seed"),
87+
seed1 = tne(seed1+1),
88+
density_expression = litexp(1000), -- litexp(starting_density * starting_modulation_richness),
89+
spot_quantity_expression = litexp(starting_area_spot_quantity),
90+
spot_radius_expression = litexp(starting_rq_factor * starting_area_spot_quantity ^ (onethird)),
91+
spot_favorability_expression = litexp(
92+
starting_feasibility_richness * 2 -
93+
1 * distance / starting_resource_placement_radius +
94+
noise.random(0.5)
95+
),
96+
basement_value = basement_value,
97+
maximum_spot_basement_radius = tne(128) -- does making this huge make a difference?
98+
}
99+
}
100+
```
101+
102+
`density_expression` seems to practically determine the max distance at which a resource can spawn.
103+
104+
# Variables
105+
106+
The returned expressions can contain variables that will be replaced somewhere in the C++ core I assume.
107+
These can be included by calling `noise.var("variableName")`.
108+
109+
Known variables:
110+
- `x`: X coordinate in tiles on the map
111+
- `y`: Y coordinate in tiles on the map
112+
- `distance`: Distance in tiles from the center of the map
113+
- `elevation`: Height of a specific tile
114+
- `map_seed`: Seed of the map
115+
- `regular-resource-patch-set-count`: ???
116+
- `starting-resource-patch-set-count`: ???
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "resource-richness-distance-multiplier",
3+
"version": "1.0.0",
4+
"title": "Resource Richness Distance Multiplier",
5+
"author": "desto",
6+
"homepage": "https://github.com/desto-git/factorio-rrdm",
7+
"description": "Adjust the richness of resource patches outside the starting area.",
8+
"dependencies": ["base"],
9+
"factorio_version": "1.0"
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[mod-setting-name]
2+
resource-richness-distance-multiplier-regular-patch-multiplier=Basismultiplikator
3+
resource-richness-distance-multiplier-distance-multiplier=Distanzmultiplikator
4+
5+
[mod-setting-description]
6+
resource-richness-distance-multiplier-regular-patch-multiplier=Multipliziere die Menge von regulären Erzfeldern (außerhalb des Startbereichs) mit diesem Wert.\n0.1 entspricht in etwa der Menge von Feldern im Anfangsbereich.
7+
resource-richness-distance-multiplier-distance-multiplier=Addiere <diesen Wert> * <Entfernung zur Kartenmitte> zur Menge von Ressourcen.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[mod-setting-name]
2+
resource-richness-distance-multiplier-regular-patch-multiplier=Base multiplier
3+
resource-richness-distance-multiplier-distance-multiplier=Distance multiplier
4+
5+
[mod-setting-description]
6+
resource-richness-distance-multiplier-regular-patch-multiplier=Multiply the richness of regular resource patches (outside starting area) by this amount.\n0.1 is about the same as the starting area patches.
7+
resource-richness-distance-multiplier-distance-multiplier=Add <this value> * <distance from map center> to the richness of resources.

0 commit comments

Comments
 (0)