------------------------------------------------------------------------------
-- FILE: PlayEuropeAgain.Lua
-- Hormigas
-- Imported to Civ VI by Gedemon (2016)
------------------------------------------------------------------------------
include "MapEnums"
include "MapUtilities"
include "MountainsCliffs"
include "RiversLakes"
include "FeatureGenerator"
include "TerrainGenerator"
include "NaturalWonderGenerator"
include "ResourceGenerator"
include "AssignStartingPlots"
local mapName = MapConfiguration.GetValue("MapName")
print("Loading "..tostring(mapName).." script")
local g_iW = 135
local g_iH = 81
local g_iFlags = {}
local g_continentsFrac = nil
------------------------------------------------------------------------------
-- The application side will call GetMapScriptInfo directly to request
-- information about the map script.
-------------------------------------------------------------------------------
function GetMapInitData(worldSize)
return {
Width = g_iW,
Height = g_iH,
WrapX = false,
WrapY = false,
};
end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
function GenerateMap()
print("Calling Map Generator");
-- Everything has been moved to the modded AssignStartingPlots in the "override" folder, search for "YnAMP" string in that file
GenerateImportedMap(GetMap(), ImportCiv6Map(), GetNaturalWonders(), g_iW, g_iH)
end
function GetNaturalWonders()
--[[local NaturalWonders = {}
NaturalWonders[GameInfo.Features["FEATURE_CLIFFS_DOVER"].Index] = { X = 30, Y = 59} -- 2 plots, hills on coast, 1st plot is WEST
NaturalWonders[GameInfo.Features["FEATURE_DEAD_SEA"].Index] = { X = 83, Y = 10} -- 2 plots, flat desert surrounded by desert, 1st plot is SOUTHWEST
if GameInfo.Features["FEATURE_EYJAFJALLAJOKULL"] then -- Vikings DLC is loaded
NaturalWonders[GameInfo.Features["FEATURE_EYJAFJALLAJOKULL"].Index] = { X = 12, Y = 88} -- 2 plots EAST-WEST, flat tundra/plains without features, 1st plot is WEST (YOSEMITE rule)
NaturalWonders[GameInfo.Features["FEATURE_LYSEFJORDEN"].Index] = { X = 43, Y = 72} -- 3 plots, , flat grass near coast, 1st plot is EAST
NaturalWonders[GameInfo.Features["FEATURE_GIANTS_CAUSEWAY"].Index] = { X = 23, Y = 71} -- 2 plots, one on coastal land and one in water, 1st plot is land, SOUTHEAST
end
return NaturalWonders]]
end
function ImportCiv6Map(MapToConvert, g_iW, g_iH, bDoTerrains, bImportRivers, bImportFeatures, bImportResources, bImportContinents)
print("Importing Civ6 Map ( Terrain = "..tostring(bDoTerrains)..", Rivers = "..tostring(bImportRivers)..", Features = "..tostring(bImportFeatures)..", Resources = "..tostring(bImportResources)..", Continents = "..tostring(bImportContinents)..")")
local count = 0
bOutput = false
for i = 0, (g_iW * g_iH) - 1, 1 do
plot = Map.GetPlotByIndex(i)
if bOutput then
print("----------")
print("Convert plot at "..plot:GetX()..","..plot:GetY())
end
-- Map Data
-- MapToConvert[x][y] = {civ6TerrainType, civ6FeatureType, civ6ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ6ResourceType, num} }
local civ6TerrainType = MapToConvert[plot:GetX()][plot:GetY()][1]
local civ6FeatureType = MapToConvert[plot:GetX()][plot:GetY()][2]
local civ6ContinentType = MapToConvert[plot:GetX()][plot:GetY()][3]
local Rivers = MapToConvert[plot:GetX()][plot:GetY()][4] -- = {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}
local resource = MapToConvert[plot:GetX()][plot:GetY()][5] -- = {Civ6ResourceType, num}
local Cliffs = MapToConvert[plot:GetX()][plot:GetY()][6] -- {IsNEOfCliff,IsWOfCliff,IsNWOfCliff}
-- Set terrain type
if bDoTerrains then
if bOutput then print(" - Set Terrain Type = "..tostring(GameInfo.Terrains[civ6TerrainType].TerrainType)) end
count = count + 1
TerrainBuilder.SetTerrainType(plot, civ6TerrainType)
end
-- Set Rivers
if bImportRivers then
if Rivers[1][1] == 1 then -- IsNEOfRiver
TerrainBuilder.SetNEOfRiver(plot, true, Rivers[1][2])
if bOutput then print(" - Set is NE of River, flow = "..tostring(Rivers[1][2])) end
end
if Rivers[2][1] == 1 then -- IsWOfRiver
TerrainBuilder.SetWOfRiver(plot, true, Rivers[2][2])
if bOutput then print(" - Set is W of River, flow = "..tostring(Rivers[2][2])) end
end
if Rivers[3][1] == 1 then -- IsNWOfRiver
TerrainBuilder.SetNWOfRiver(plot, true, Rivers[3][2])
if bOutput then print(" - Set is NW of River, flow = "..tostring(Rivers[3][2])) end
end
end
-- Set Features
if bImportFeatures then
if civ6FeatureType ~= g_FEATURE_NONE and civ6FeatureType < GameInfo.Features["FEATURE_BARRIER_REEF"].Index then -- Do not import Natural Wonder here !
if bOutput then print(" - Set Feature Type = "..tostring(GameInfo.Features[civ6FeatureType].FeatureType)) end
TerrainBuilder.SetFeatureType(plot, civ6FeatureType)
end
end
-- Set Continent
if bImportContinents then
if civ6ContinentType ~= -1 then
if bOutput then print(" - Set Continent Type = "..tostring(GameInfo.Continents[civ6ContinentType].ContinentType)) end
TerrainBuilder.SetContinentType(plot, civ6ContinentType)
end
end
-- Set Resources
if bImportResources and not plot:IsNaturalWonder() then
if resource[1] ~= -1 then
if bOutput then print(" - Set Resource Type = "..tostring(GameInfo.Resources[resource[1]].ResourceType)) end
--ResourceBuilder.SetResourceType(plot, ResourceCiv5toCiv6[resource[1]], resource[2]) -- maybe an option to import number of resources on one plot even if civ6 use 1 ?
ResourceBuilder.SetResourceType(plot, resource[1], 1)
end
end
-- Set Cliffs
if Cliffs then
if Cliffs[1] == 1 then -- IsNEOfCliff
TerrainBuilder.SetNEOfCliff(plot, true)
if bOutput then print(" - Set is NE of Cliff") end
end
if Cliffs[2] == 1 then -- IsWOfCliff
TerrainBuilder.SetWOfCliff(plot, true)
if bOutput then print(" - Set is W of Cliff") end
end
if Cliffs[3] == 1 then -- IsNWOfCliff
TerrainBuilder.SetNWOfCliff(plot, true)
if bOutput then print(" - Set is NW of Cliff") end
end
end
end
print("Placed terrain on "..tostring(count) .. " tiles")
end
function GetMap()
local MapToConvert = {}
for i = 0, g_iW - 1, 1 do
MapToConvert[i] = {}
end
-- Map Data (from Civ6 WB)
-- MapToConvert[x][y] = {civ6TerrainType, civ6FeatureTypes, civ6ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ6ResourceType, num}, {IsNEOfCliff, IsWOfCliff, IsNWOfCliff} }
MapToConvert[0][0]={3,3,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[1][0]={3,3,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[2][0]={3,-1,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[3][0]={3,-1,42,{{0,-1},{0,-1},{0,-1}},{9,1},{0,0,0}}
MapToConvert[4][0]={3,3,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[5][0]={3,3,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[6][0]={4,3,42,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MapToConvert[131][80]={16,-1,-1,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[132][80]={16,-1,-1,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[133][80]={16,-1,-1,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
MapToConvert[134][80]={16,-1,-1,{{0,-1},{0,-1},{0,-1}},{-1,1},{0,0,0}}
return MapToConvert
end