Fix resource calculation in map generator
The editor's resource value calculation logic was fixed in #21820 to match actual gameplay. The map generator logic originally copied the editor logic from EditorResourceLayer rather than ResourceLayer and associated game logic. As such, it inherited incorrect calculations. This change updates the map generator logic to match the now consistent logic in both ResourceLayer classes. Map generator resource settings are also adjusted -25% to continue roughly matching the previous resource output.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
965a490b70
commit
4a4217c3b3
@@ -1681,8 +1681,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
map.Resources.Clear();
|
||||
|
||||
// Return resource value of a given square.
|
||||
// See https://github.com/OpenRA/OpenRA/blob/9302bac6199fbc925a85fd7a08fc2ba4b9317d16/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs#L144-L166
|
||||
// https://github.com/OpenRA/OpenRA/blob/9302bac6199fbc925a85fd7a08fc2ba4b9317d16/OpenRA.Mods.Common/Traits/World/EditorResourceLayer.cs#L175-L183
|
||||
// Matches the logic in ResourceLayer trait.
|
||||
int CheckValue(CPos cpos)
|
||||
{
|
||||
if (!map.Resources.Contains(cpos))
|
||||
@@ -1690,22 +1689,24 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var resource = map.Resources[cpos].Type;
|
||||
if (resource == 0)
|
||||
return 0;
|
||||
var adjacent = 0;
|
||||
for (var y = -1; y <= 1; y++)
|
||||
for (var x = -1; x <= 1; x++)
|
||||
{
|
||||
var offsetCpos = cpos + new CVec(x, y);
|
||||
if (!map.Resources.Contains(offsetCpos))
|
||||
continue;
|
||||
if (map.Resources[offsetCpos].Type == resource)
|
||||
adjacent++;
|
||||
}
|
||||
|
||||
var resourceType = bestResource[cpos];
|
||||
var density = Math.Max(resourceType.MaxDensity * adjacent / /*maxAdjacent=*/9, 1);
|
||||
|
||||
// density + 1 to mirror a bug that got ossified due to balancing.
|
||||
return param.ResourceValues[resourceType] * (density + 1);
|
||||
var adjacent = 0;
|
||||
var directions = CVec.Directions;
|
||||
for (var i = 0; i < directions.Length; i++)
|
||||
{
|
||||
var c = cpos + directions[i];
|
||||
if (map.Resources.Contains(c) && map.Resources[c].Type == resource)
|
||||
++adjacent;
|
||||
}
|
||||
|
||||
// We need to have at least one resource in the cell.
|
||||
// HACK: we should not be lerping to 9, as maximum adjacent resources is 8.
|
||||
// HACK: it's too disruptive to fix.
|
||||
var density = Math.Max(int2.Lerp(0, resourceType.MaxDensity, adjacent, 9), 1);
|
||||
|
||||
return param.ResourceValues[resourceType] * density;
|
||||
}
|
||||
|
||||
int CheckValue3By3(CPos cpos)
|
||||
|
||||
@@ -268,7 +268,7 @@
|
||||
Label: label-cnc-map-generator-choice-resources-low
|
||||
Settings:
|
||||
SpawnResourceSpawns: 1
|
||||
ResourcesPerPlayer: 25000
|
||||
ResourcesPerPlayer: 18750
|
||||
ResourceSpawnWeights:
|
||||
split2: 1
|
||||
split3: 1
|
||||
@@ -278,7 +278,7 @@
|
||||
Label: label-cnc-map-generator-choice-resources-medium
|
||||
Settings:
|
||||
SpawnResourceSpawns: 2
|
||||
ResourcesPerPlayer: 50000
|
||||
ResourcesPerPlayer: 37500
|
||||
ResourceSpawnWeights:
|
||||
split2: 95
|
||||
split3: 95
|
||||
@@ -289,7 +289,7 @@
|
||||
Label: label-cnc-map-generator-choice-resources-high
|
||||
Settings:
|
||||
SpawnResourceSpawns: 3
|
||||
ResourcesPerPlayer: 75000
|
||||
ResourcesPerPlayer: 56250
|
||||
ResourceSpawnWeights:
|
||||
split2: 9
|
||||
split3: 9
|
||||
@@ -300,7 +300,7 @@
|
||||
Label: label-cnc-map-generator-choice-resources-very-high
|
||||
Settings:
|
||||
SpawnResourceSpawns: 4
|
||||
ResourcesPerPlayer: 100000
|
||||
ResourcesPerPlayer: 75000
|
||||
ResourceSpawnWeights:
|
||||
split2: 8
|
||||
split3: 8
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
Label: label-ra-map-generator-choice-resources-low
|
||||
Settings:
|
||||
SpawnResourceSpawns: 2
|
||||
ResourcesPerPlayer: 25000
|
||||
ResourcesPerPlayer: 18750
|
||||
ResourceSpawnWeights:
|
||||
mine: 1
|
||||
MaximumExpansionResourceSpawns: 3
|
||||
@@ -304,7 +304,7 @@
|
||||
Label: label-ra-map-generator-choice-resources-medium
|
||||
Settings:
|
||||
SpawnResourceSpawns: 3
|
||||
ResourcesPerPlayer: 50000
|
||||
ResourcesPerPlayer: 37500
|
||||
ResourceSpawnWeights:
|
||||
mine: 95
|
||||
gmine: 5
|
||||
@@ -314,7 +314,7 @@
|
||||
Label: label-ra-map-generator-choice-resources-high
|
||||
Settings:
|
||||
SpawnResourceSpawns: 3
|
||||
ResourcesPerPlayer: 75000
|
||||
ResourcesPerPlayer: 56250
|
||||
ResourceSpawnWeights:
|
||||
mine: 9
|
||||
gmine: 1
|
||||
@@ -324,7 +324,7 @@
|
||||
Label: label-ra-map-generator-choice-resources-very-high
|
||||
Settings:
|
||||
SpawnResourceSpawns: 4
|
||||
ResourcesPerPlayer: 100000
|
||||
ResourcesPerPlayer: 75000
|
||||
ResourceSpawnWeights:
|
||||
mine: 8
|
||||
gmine: 2
|
||||
|
||||
Reference in New Issue
Block a user