[BNW] Add resources near city-states and players start locations

Elvalantan

Chieftain
Joined
Sep 2, 2017
Messages
3
Hi all, I created account just to ask this question so I'm quite new here. If there is somewhere a comprehensive guide or the topic was already raised - please give me the link - I couldn't find the full answer myself. I'm also looking for "simple answer" - I know C/C++ quite good and LUA is similar, but I don't know CIV functions and commands library. The exemplary script that works similary to what I need mayby could be enough but comments and functions description would be very helpful.

1. I want to add resources near initial locations of players and city states with the conditions:
a) resources have to be added after default script;
b) new resources can't overwrite old ones;
c) I want to add each type of resources separately, for example:
- at first put 2 random strategic resources at 1-5 plots distance from initial locations,
- secondly put randomly 1 luxury resource at 1-3 plots distance and 2 luxury resource at 3-5 plots distance,
- thirdly put 2 random bonus resources at 2-3 plots distance;
d) land resources can't be put on water or mountains, water resources can't be put on land etc.

2. I want to change some tundra and ice plots to plains:
a) all tundra and ice plots at 0-3 distance from initial player location;
b) all tundra and ice plots at 0-2 distance from city-states locations.

It would be great if code could be universal and would work just by copy-paste to standard map, for example "Four_Corners.lua".
 
Last edited:
Ok, I have progress, but I get one serious problem. When I use Terrain functions sick things happens. For example function below change desert plots without Features near start location (plotX, plotY) to water. What am I doing wrong?

for ix = -5, 5 do
for iy = -5, 5 do
local newX = plotX + ix;
local newY = plotY + iy;
local newPlot = Map.GetPlot(newX, newY);
local terrainType = newPlot:GetTerrainType();


if (terrainType==TerrainTypes.TERRAIN_TUNDRA or terrainType==TerrainTypes.TERRAIN_SNOW) then
newPlot:SetTerrainType(TerrainTypes.TERRAIN_PLAINS, true, true);
end


if (terrainType==TerrainTypes.TERRAIN_DESERT and newPlot:GetFeatureType()==FeatureTypes.NO_FEATURE) then
newPlot:SetTerrainType(TerrainTypes.TERRAIN_HILL, true, true);
end

end
end
 
Top Bottom