1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Worlds Unlimited (formerly 'Large World Fits All')

Discussion in 'Civ5 - Map Scripts' started by skweetis, Nov 9, 2010.

  1. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Removed files from library, as I have more recently discovered, odd numbers in Map Height will cause problems for the AI and other Game logic. Because of the method I was using to produce random map sizes, odd numbers were 50% possible. I have been using what little time I have to learn more about modding and scripting for Civ5 and work on improving the designs as I learn the limitations of the game and mod tools. However, the current state of the game makes it difficult to test since there are still many issues with the core game. I really like Civ5, and the potential it has, so I'll be back when things are more stable.

    Cheers, and my apologies if my maps interfered with you game experience.
     
  2. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,153
    Location:
    France
    that's a good idea !

    I'll certainly have to try it :D
     
  3. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Saved for Future use....
     
  4. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Still trying to figure out whats going on here. It seems that Random Map Size just picks whatever you last selected from the list that wasn't Random Map Size!??!

    I'll look at it tomorrow with a fresh pair of eyes. If anyone else notices this with regards to Random Map Size and my script, I would like to know!

    I seem to produce the same results with Terra or Lakes in Vanilla single player.

    Cheers!
     
  5. ColBashar

    ColBashar Chieftain

    Joined:
    Nov 3, 2010
    Messages:
    32
    Hi Skweetis.

    I can't unpackage the mod so, until CivFanatics approves your upload, would it be troublesome to attach the script files to this thread? Then I can take a look at it and see if I can offer any suggestions as to what's going on.

    --TG
     
  6. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    For some reason I didn't notice your post before, Gedemon, I hope you enjoy it!

    And thanks for the offer ColBashar. Take a look in either lakes or terra, I used the GetMapInitData() function thats there, the only difference is that I set it so that the grid size only returned 104, 64 regardless of what is selected. It works fine, and does what I expected for the Map Size that is chosen.

    I have put in a bit of time now on testing the Random Map Size selection in game setup and it isn't working correctly (at least not here it isn't!), it just picks whatever size was last selected.
    I submitted a ticket and posted on the CIV5 forum... we'll see what happens. There is no way around it, unless someone can tell me how to override the number of Civs and City States directly from the map script... my code logic is pretty rusty, and with a newborn in the house, I can't devote the time to troubleshoot it that I would like to. I'll have to wait for Firaxis to correct it.

    If anyone is interested, here's the steps to reproduce the bug in Vanilla Single Player:

    1. Select any Civ and Map Type
    2. Select a Map Size that is NOT Random Map Size
    3. Do not start the game, instead, go back to Map Size and select Random Map Size
    4. Press Start

    Whatever you chose before you selected Random Map Size will always be the map size that is generated (Easiest way to check without having to use dev mode, is to select Menu at the top right when the world is loaded, at the bottom of the Menu Popup you will see what size was selected)

    Rinse and repeat, for a not so random experience!
     
  7. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
  8. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Download is available in the first post.
     
  9. ColBashar

    ColBashar Chieftain

    Joined:
    Nov 3, 2010
    Messages:
    32
    Hi Skweetis,

    I've made a script I think you might like. Or at least want to take a look at. It borrows the same basic concept from your script except that the scaling is much more exact and will accommodate any number of civilisations and city states the user selects.

    Obviously the bugged Random Map selection is still a problem. Since I don't see any immediate means of adding or removing civilisations at the script level then the alternative is to make map dimensions variable. So I've also included in this script the means to select the minimum and maximum map size you'd like to compete on. Not ideal but might be appealing nonetheless. Note that this method makes it impossible to tell the actual map dimensions until you've explored it, even by pressing ESC to bring up the menu.

    I have left all of the standard options in for the sake of broad appeal. I appreciate that you like mountains, fact is that I like them, too, but my philosophy when developing for the public is to include the widest functionality that is practical to implement without sacrificing the map's core concept. That way you don't wind up with several individual scripts for different flavours, and it becomes easier to implement changes and fixes across the board. Though I think that will be mitigated some as the community matures to develop include files that can be shared between maps.

    BTW, congratulations on the newborn!

    --TG

    edit: (2010-11-13)
    I'm including a script snippet from the attached map showing how I scaled landmass to player count, for anyone who is interested in applying a similar concept to their own scripts.

    Code:
    --water_percent variable will be determined by scaling the area of
    --  land required by players to the total area of the map.
    
    -- Retrieve dimensions from map
    local iW, iH = Map.GetGridSize();
    
    -- Collect the number of active players and city states, borrowed from MapmakerUtilities.lua
    local iNumCivs, iNumCityStates = 0, 0;
    for i = 0, GameDefines.MAX_MAJOR_CIVS - 1 do
    	local player = Players[i];
    	if player:IsEverAlive() then
    		iNumCivs = iNumCivs + 1;
    	end
    end
    for i = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS - 1 do
    	local player = Players[i];
    	if player:IsEverAlive() then
    		iNumCityStates = iNumCityStates + 1;
    	end
    end
    
    -- Set the number of tiles reserved for land according to the number of players and city states present
    local land_total = iNumCivs * 215 + iNumCityStates * 25;
    
    -- Modify land ammount according to user-selected sea level
    land_total = land_total * (1.5 - sea_level * .25);
    
    -- Scale water percent accordingly
    water_percent = 100 - land_total / (iW * iH) * 100;	
    
    -- Clamp value so that there is always at least a minimum amount of land or ocean coverage
    --  This should prevent the game from hanging when faced with extreme values
    water_percent = math.clamp(water_percent, 10, 95);
     

    Attached Files:

  10. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    That's awesome ColBashar, thanks!

    I've actually gone through and revamped all the code yesterday, enabled options and calibrated sea_level with a little more fidelity to number of civs for exactly the reason you mentioned, which is widening the functionality so users could do what they want.

    This was really just bashed together for my own use, hence the lack of user options. It has been a really long time since I sat down and did any coding (I love designing, enjoy programming as a hobby since commodore64 days), and I had this design for a mod I have been wanting to do since BTS but wasn't sure if I still had it in me to code the thing. Took a bit to coax all that mess of code out me, but it's all coming back to me, slowly...:)

    I just threw it out there to see if anyone was interested in the concept before I went to the trouble of making it more usable for others, and my wife told me to! I was actually pleasantly surprised with even the modest number of downloads and ratings it has gotten, so I've been diligently revamping the whole thing (plus it was a mess to look at when I was trying to see if it was my code that was buggering up the Random Map Size thing.....)

    Anyway, sorry for the babble.... I'll download and take a look at what you have, I'm very interested to see, I learn best by reverse engineering other people's work! And thanks for the congrats, he's sleeping nearby to the steady click of daddy's fingers on the keyboard!

    If you're curious, here is what my script looks like now... there's lot yet I would like to do, but gives an idea of where I'm heading.

    Code:
    ------------------------------------------------------------------------------
    --	FILE:	LWFA-Redux_EXPERIMENTAL.lua 
    --	BUILD:  X1
    --	AUTHOR: Jamie 'Skweetis' M. (jm)
    --	ABOUT:	Total overhaul of my 'LargeWorldFitsAll' script, allowing for more
    --			user choice as to how the world is generated.  Blah blah blah...
    --			(refer to design journal p.73, make it readable!)
    --
    ------------------------------------------------------------------------------
    -- TODO: 
    --  < > Keep documenting! I know you hate it, but you know it's indespensible!
    --  < > come up with map name, based on addon module theme...
    --	< >	Consider keeping override sea_level option, for greater end-user
    --		customisablility, somebody may want to override.  Need to make sure 
    --		we add selection for Use Game Start Map Size.
    --	< > Restore world_age, but rename to mountain height or something, the 
    --		idea of age does not fit with add-on mod theme.  
    --	< > Set all option defaults to Random, the main idea is unpredictability.		
    ------------------------------------------------------------------------------
    -- CHANGES:
    --
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
    -- Lua scripts to include so we can call the functions in them, without having
    -- to rewrite them
    -- UPDATES:
    include("MapGenerator");
    include("FractalWorld");
    include("FeatureGenerator");
    include("TerrainGenerator");
    
    ------------------------------------------------------------------------------
    -- Create our own Custom Options, make sure to add to GetMapScriptInfo()
    -- UPDATES:
    player_start_option = {
    	Name = "Player Starts",
    	Values = {
    		"Old World",
    		"Continental",
    		"Anywhere",
    		"Random",
    	},
    	DefaultValue = 4,
    	SortPriority = 0,
    };
    
    -- FOR DEBUG IN MAP BUILDER ONLY
    override_map_size = {
    	Name = "Override Map Size",
    	Values = {
    		"Huge: 12 on 128x80",
    		"Large: 10 on 104x64",
    		"Standard: 8 on 80x52",
    		"Small: 6 on 66x42",
    		"Tiny: 4 on 56x36",
    		"Duel: 2 on 40x24",
    		"Random Map Size",
    	},
    	DefaultValue = 3, -- make default "Standard: 8 on 80x52"
    	SortPriority = 1,
    };
    -- FOR DEBUG IN MAP BUILDER ONLY
    
    ------------------------------------------------------------------------------
    -- Gets the options available at Game Setup
    -- UPDATES: 
    function GetMapScriptInfo()
    	local world_age, temperature, rainfall, sea_level, resources = GetCoreMapOptions()
    	return {
    		Name = "Eternal Arena - X1",
    		Description = "An unpredictable but natural looking 94x58 tile world that uses Map Size to determine Total Land Plots.",
    		IsAdvancedMap = false, 
    		SupportsMultiplayer = false,
    		IconIndex = 1,
    	CustomOptions = {
    		--[[ world_age ]]-- Add back in after Total Land Area calibration work completed.
    		temperature, -- 1
    		rainfall, -- 2
    		sea_level, -- 3 
    		resources, -- 4
    		player_start_option, -- 5
    		override_map_size, -- 6 this is for WorldBuilder Debug, ***DEPRECATE AT RELEASE***
    		},
    	};
    end
    ------------------------------------------------------------------------------
    -- Resets map grid sizes and/or world wrap
    -- UPDATES: X1, 
    function GetMapInitData(worldSize)
    --[[ 
    NOTES:
    I borrowed this function from Firaxis' Terra.lua.  Useful for overriding
    default map grid sizes without having to actually mod any files.
    
    CHANGES:
    X1: Return Fixed size between Standard and Large (92x58).
    
    ]]--
    	local worldsizes = {
    		[GameInfo.Worlds.WORLDSIZE_DUEL.ID] = {92, 58}, --{40, 24}, 
    		[GameInfo.Worlds.WORLDSIZE_TINY.ID] = {92, 58}, --{56, 36},
    		[GameInfo.Worlds.WORLDSIZE_SMALL.ID] = {92, 58}, --{66, 42},
    		[GameInfo.Worlds.WORLDSIZE_STANDARD.ID] = {92, 58}, --{80, 52},
    		[GameInfo.Worlds.WORLDSIZE_LARGE.ID] = {92, 58}, --{104, 64},
    		[GameInfo.Worlds.WORLDSIZE_HUGE.ID] = {92, 58}, --{128, 80}
    		}
    	local grid_size = worldsizes[worldSize];
    	
    	local world = GameInfo.Worlds[worldSize];
    	--------------------------------------------------------------------------
    	-- BLOCK START
    	-- TEST: override GameInfo.Worlds.<WorldSize>.<DefaultPlayers>/<DefaultMinorCivs>?  See CIV5Worlds.xml
    
    	-- 
    	-- BLOCK END
    	--------------------------------------------------------------------------
    	if(world ~= nil) then
    	return {
    		Width = grid_size[1],
    		Height = grid_size[2],
    		WrapX = true,		
    	};      
         end
    end
    ------------------------------------------------------------------------------
    -- This is based on Bob Thomas' (Sirian of Firaxis) custom Fractal Method
    -- from Continents.lua.  ***Play around later with renaming***
    -- UPDATES: X1,
    ContinentsFractalWorld = {}; -- this sets the name of custom function? - jm
    
    function ContinentsFractalWorld.Create(fracXExp, fracYExp)
    --[[
    NOTES:
    I believe this creates the Map grid, filling it with ocean plots, and returns
    it for use with the Generate PlotTypes custom method.  I likely could alter 
    map grid size in here, no?
    CHANGES:
    nil
    ]]--
    	local gridWidth, gridHeight = Map.GetGridSize();
    	
    	local data = {
    		InitFractal = FractalWorld.InitFractal,
    		ShiftPlotTypes = FractalWorld.ShiftPlotTypes,
    		ShiftPlotTypesBy = FractalWorld.ShiftPlotTypesBy,
    		DetermineXShift = FractalWorld.DetermineXShift,
    		DetermineYShift = FractalWorld.DetermineYShift,
    		GenerateCenterRift = FractalWorld.GenerateCenterRift,
    		GeneratePlotTypes = ContinentsFractalWorld.GeneratePlotTypes,	-- Custom method
    		
    		iFlags = Map.GetFractalFlags(),
    		
    		fracXExp = fracXExp,
    		fracYExp = fracYExp,
    		
    		iNumPlotsX = gridWidth,
    		iNumPlotsY = gridHeight,
    		plotTypes = table.fill(PlotTypes.PLOT_OCEAN, gridWidth * gridHeight)
    	};
    		
    	return data;
    end	
    ------------------------------------------------------------------------------
    -- This must be where the custom fractal plot method gets applied, after the 
    -- map dimensions are laid with ocean plots in ContinentsFractalWorld.Create()
    -- UPDATES: X1
    function ContinentsFractalWorld:GeneratePlotTypes(args)
    --[[
    NOTES:
    Still going to use the Fixed Map method, and adjust Sea_Level to match +/-
    for number of civilizations.  The difference from LargeWorldFitsAll_v3 will
    be that the variation is much tighter to maintain optimum balance, so we need
    to:
    	1...find out the AVERAGE number of land tiles generated by default MAP GRID 
    		SIZE. We will then use this to make sure land area is consistent with 
    		NORMAL sea level for the DEFAULT MAP GRID SIZES. We will then +/- that
    		percentage to randomise low/arid||normal||high/lush for that number 
    		of Civs.
    CHANGES:
    X1: 'sea_level_<1...6>' percentages equal to 'landmass_<DUEL2...HUGE12>' 
    ]]--
    	if(args == nil) then args = {}; end
    	
    -- sea_level defaults in Continents.lua were low=67, normal= 72, high=76
    -- now is 1 to 6 or lowest percent to highest.Percentages below are 
    -- calibrated to Total Number Land Plots generated for equivalent MapSize 
    -- from Firaxis' Pangaea.lua.
    -- EternalArena.lua is half way between Default Standard and Large Size Maps
    -- at 94X54 generating a total of 5076 Total Plots.
    -- so the ratio of sea to land will be different (ie, not always Pangaea at
    -- Larger Size.) Calibration values range from +/- 30 to 100 tiles from
    -- Duel to Huge respectively.  These assume Normal Sea Levels in all cases.
    	local sea_level_HUGE12 = 41; --X1: Calibration HUGE12 = 3000 Total Land Tiles
    	local sea_level_LARGE10 = 61; --X1: Calibration LARGE10 = 2000 Total Land Tiles
    	local sea_level_STANDARD8 = 75; --X1: Calibration STANDARD8 = 1250 Total Land Tiles
    	local sea_level_SMALL6 = 83; --X1: Calibration SMALL6 = 850 Total Land Tiles
    	local sea_level_TINY4 = 88; --X1: Calibration TINY4 = 600 Total Land Tiles
    	local sea_level_DUEL2 = 94; --X1: Calibration DUEL2 = 300 Total Land Tiles
    	
    	local sea_level_low = -2;
    	local sea_level_normal = 0;
    	local sea_level_high = 2;
    
    	local world_age_adjustment = 5;
    	
    	local extra_mountains = 0; --what does this do?
    	local grain_amount = 3;	--need to learn more about grains
    	local adjust_plates = 1.5; --set to default value for New in Continents.lua
    	local shift_plot_types = true;
    	local tectonic_islands = false; --whatdoes this do?
    	local hills_ridge_flags = self.iFlags; --what is this for?
    	local peaks_ridge_flags = self.iFlags; --what is this for?
    	local has_center_rift = false; --looks better if it happens naturally.
    	
    	--------------------------------------------------------------------------
    	-- BLOCK START
    	-- 
    
    	-- 
    	-- BLOCK END
    	--------------------------------------------------------------------------
    
    	--------------------------------------------------------------------------
    	-- BLOCK START
    	-- This block of code sets up sea level based on option selected at 
    	-- GameSetup, uses that sea level to +/- the sea_level based
    	-- on the number of Civs for the map size option that was selected
    	
    	-- Get GameOption sea_level, we will use later to vary the percentage a little
    	local sea_level_option = Map.GetCustomOption(3)
    	print("Sea Level option: ", sea_level_option); --DEBUG
    	if sea_level_option == 4 then --sea level selected is Random
    		sea_level_option = 1 + Map.Rand(3, "Random Sea Level - Lua");
    	end
    
    	--Get map size chosen at GameSetup
    	local WorldSizeTypes = {}; --create the container
    	for row in GameInfo.Worlds() do
    		WorldSizeTypes[row.Type] = row.ID;
    	end
    	local sizekey = Map.GetWorldSize();
    	
    	-- Sea Level by Map Size Num Civs
    	local sizevalues = {
    		[WorldSizeTypes.WORLDSIZE_DUEL]     = 6,
    		[WorldSizeTypes.WORLDSIZE_TINY]     = 5,
    		[WorldSizeTypes.WORLDSIZE_SMALL]    = 4,
    		[WorldSizeTypes.WORLDSIZE_STANDARD] = 3,
    		[WorldSizeTypes.WORLDSIZE_LARGE]    = 2,
    		[WorldSizeTypes.WORLDSIZE_HUGE]		= 1,
    	};
    	
    	local pregame_size = sizevalues[sizekey] or 3;
    	
    	--DEBUG MAPSIZE OVERRIDE FOR WORLDBUILDER
    	local override_mapsize_option = Map.GetCustomOption(6) --override is debug for worldbuilder
    	print("- override_mapsize_option is: ", override_mapsize_option); --DEBUG
    
    	if override_mapsize_option == 7 then 
    	   override_mapsize_option = 1 + Map.Rand(6, "Random WorldSize Sea Level Override - Lua");
    	end
    
    	print("- PreGame world size was: ", pregame_size);
    	pregame_size = override_mapsize_option;
    	print("- PreGame world size is now: ", pregame_size);
    	--DEBUG MAPSIZE
    	
    	local water_percent = sea_level_STANDARD8; -- init to Standard size, just in case
    	--set map generation values, depending on Map Size (From Pregame)
    	if pregame_size == 6 then 
    		water_percent = sea_level_DUEL2;
    	elseif pregame_size == 5 then 
    		water_percent = sea_level_TINY4;
    	elseif pregame_size == 4 then 
    		water_percent = sea_level_SMALL6;
    	elseif pregame_size == 3 then 
    		water_percent = sea_level_STANDARD8;
    	elseif pregame_size == 2 then 
    		water_percent = sea_level_LARGE10;
    	else --only option left is 1, so it must be...
    	    water_percent = sea_level_HUGE12;
    	end
    	
    
    	-- now apply sea_level_option (+/-) from user selection to water_percent:	
    	if sea_level_option == 1 then --------- Low Sea Level, %--
    		water_percent = water_percent + sea_level_low;
    	elseif sea_level_option == 3 then ----- High Sea Level, %++
    		water_percent = water_percent + sea_level_high;
    	else	------------------------------- Normal Sea Level, %+-
    	    water_percent = water_percent + sea_level_normal; 
    	end
    
    	-- BLOCK END
    	--------------------------------------------------------------------------
    	
    	--------------------------------------------------------------------------
    	-- FROM Continents.lua --
    	-- borrowed these because I really like the way sirian's new (3Bill)
    	-- mountain ranges look.  No need to reinvent the wheel. Original Code has 
    	-- been modified or deleted to suit my purposes.
    	-- -- -- 
    	-- Comments below this are not by Skweets unless marked '-jm' --
    	world_age = 1;
    	-- Apply adjustment to hills and peaks settings.
    	local hillsBottom1 = 28 - world_age_adjustment;
    	local hillsTop1 = 28 + world_age_adjustment;
    	local hillsBottom2 = 72 - world_age_adjustment;
    	local hillsTop2 = 72 + world_age_adjustment;
    	local hillsClumps = 1 + world_age_adjustment;
    	local hillsNearMountains = 91 - (world_age_adjustment * 2) - extra_mountains;
    	local mountains = 97 - world_age_adjustment - extra_mountains;
    
    	local grain = 4; 
    	local numPlates = 18;
    
    	-- Add in any plate count modifications passed in from the map script. 
    	-- Think about possibly randomising the number of plates between 18 24 for variety? --jm
    	numPlates = numPlates * adjust_plates;  --with current settings will result in 24 total plates -jm
    
    	-- Generate continental fractal layer and examine the largest landmass.
    	local iWaterThreshold, 
    		  biggest_area, 
    		  iNumTotalLandTiles, 
    		  iNumBiggestAreaTiles, 
    		  iBiggestID;
    	local grain_dice = Map.Rand(7, "Continental Grain roll - LUA Continents");
    	if grain_dice < 4 then
    		grain_dice = 2;
    	else
    		grain_dice = 1;
    	end
    
    	self:InitFractal{continent_grain = grain_dice}; 
    		
    	iWaterThreshold = self.continentsFrac:GetHeight(water_percent);
    	
    	-- START BLOCK INFO: this gets the total number of land tiles on the map. useful... -jm	
    	iNumTotalLandTiles = 0;
    	for x = 0, self.iNumPlotsX - 1 do
    		for y = 0, self.iNumPlotsY - 1 do
    			local i = y * self.iNumPlotsX + x;
    			local val = self.continentsFrac:GetHeight(x, y);
    			if(val <= iWaterThreshold) then
    				self.plotTypes[i] = PlotTypes.PLOT_OCEAN;
    			else
    				self.plotTypes[i] = PlotTypes.PLOT_LAND;
    				iNumTotalLandTiles = iNumTotalLandTiles + 1;
    			end
    		end
    	end
    	-- END BLOCK INFO -jm
    
    	self:ShiftPlotTypes();
    
    	SetPlotTypes(self.plotTypes);
    	Map.RecalculateAreas();
    		
    	biggest_area = Map.FindBiggestArea(false); 
    	iNumBiggestAreaTiles = biggest_area:GetNumTiles(); 
    	iBiggestID = biggest_area:GetID();  
    		
    		--[[BEGIN Printout for DEBUG use only ]]--
    		print("-"); print("--- Continents landmass generation, Attempt#", iAttempts, "---");
    		print("- This attempt successful: ", done);
    		print("- Total Land Plots in world:", iNumTotalLandTiles);  
    		print("- Land Plots belonging to biggest landmass:", iNumBiggestAreaTiles);
    		print("- Continent Grain for this attempt: ", grain_dice);
    		print("- Rift Grain for this attempt: ", rift_dice);
    		print("- Water Percent for this attempt: ", water_percent);
    		print("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
    		print("."); 
    		--[[ END Printout for DEBUG use only ]]--
    		
    	-- Generate fractals to govern hills and mountains
    	self.hillsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, grain, self.iFlags, self.fracXExp, self.fracYExp);
    	self.mountainsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, grain, self.iFlags, self.fracXExp, self.fracYExp);
    	self.hillsFrac:BuildRidges(numPlates, hills_ridge_flags, 1, 2);
    	self.mountainsFrac:BuildRidges((numPlates * 2) / 3, peaks_ridge_flags, 6, 1);
    	-- Get height values
    	local iHillsBottom1 = self.hillsFrac:GetHeight(hillsBottom1);
    	local iHillsTop1 = self.hillsFrac:GetHeight(hillsTop1);
    	local iHillsBottom2 = self.hillsFrac:GetHeight(hillsBottom2);
    	local iHillsTop2 = self.hillsFrac:GetHeight(hillsTop2);
    	local iHillsClumps = self.mountainsFrac:GetHeight(hillsClumps);
    	local iHillsNearMountains = self.mountainsFrac:GetHeight(hillsNearMountains);
    	local iMountainThreshold = self.mountainsFrac:GetHeight(mountains);
    	local iPassThreshold = self.hillsFrac:GetHeight(hillsNearMountains);
    	
    	-- Set Hills and Mountains
    	for x = 0, self.iNumPlotsX - 1 do
    		for y = 0, self.iNumPlotsY - 1 do
    			local plot = Map.GetPlot(x, y);
    			local mountainVal = self.mountainsFrac:GetHeight(x, y);
    			local hillVal = self.hillsFrac:GetHeight(x, y);
    	
    			if plot:GetPlotType() ~= PlotTypes.PLOT_OCEAN then
    				if (mountainVal >= iMountainThreshold) then
    					if (hillVal >= iPassThreshold) then -- Mountain Pass though the ridgeline
    						plot:SetPlotType(PlotTypes.PLOT_HILLS, false, false);
    					else -- Mountain
    						plot:SetPlotType(PlotTypes.PLOT_MOUNTAIN, false, false);
    					end
    				elseif (mountainVal >= iHillsNearMountains) then
    					plot:SetPlotType(PlotTypes.PLOT_HILLS, false, false);
    				elseif ((hillVal >= iHillsBottom1 and hillVal <= iHillsTop1) or (hillVal >= iHillsBottom2 and hillVal <= iHillsTop2)) then
    					plot:SetPlotType(PlotTypes.PLOT_HILLS, false, false);
    				end
    			end
    		end
    	end
    end
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
    function GeneratePlotTypes()
    	-- Customized plot generation to ensure avoiding "near Pangaea" conditions.
    	print("Generating Plot Types (Lua Continents) ...");
    	
    	local fractal_world = ContinentsFractalWorld.Create();
    	fractal_world:GeneratePlotTypes();
    	
    	GenerateCoasts();
    end
    ------------------------------------------------------------------------------
    function GenerateTerrain()
    	print("Generating Terrain (Lua Continents) ...");
    	
    	-- Get Temperature setting input by user.
    	local temp_option = Map.GetCustomOption(1)
    	if temp_option == 4 then
    		temp_option = 1 + Map.Rand(3, "Random Temperature - Lua");
    	end
    	
    	--------------------------------------------------------------------------
    	-- START BLOCK: 
    	-- overriding Defaults in TerrainGenerator.lua by sending as ARGS.
    	-- I'm sure there is a better way to do this, but I don't have time to 
    	-- muck around with it.
    	-- **** THIS NEEDS TO BE LOOKED AT A LITTLE MORE ****
    
    	local DesertPercent = 32;  
    	local PlainsPercent = 50;	
    	local SnowLatitude  = 0.75;
    	local TundraLatitude = 0.6;
    	local GrassLatitude = 0.1;
    	local DesertBottomLatitude = 0.2;
    	local DesertTopLatitude = 0.5;
    
    	if temp_option == 1 then -- COLD 
    		DesertPercent = DesertPercent + 12; 
    		PlainsPercent =  PlainsPercent + 10;
    		SnowLatitude  = SnowLatitude - 0.2;
    		TundraLatitude = TundraLatitude - 0.2;
    		GrassLatitude = GrassLatitude - 0.05;
    		DesertBottomLatitude = DesertBottomLatitude - 0.05;
    		DesertTopLatitude = DesertTopLatitude - 0.2; 
    	elseif temp_option == 3 then -- HOT
    		DesertPercent = DesertPercent + 12;
    		GrassLatitude = GrassLatitude + 0.05;
    		DesertBottomLatitude = DesertBottomLatitude + 0.1;
    	else --must be 2 then...
    		SnowLatitude = SnowLatitude - 0.1;
    		TundraLatitude = TundraLatitude - 0.1;
    		DesertTopLatitude = DesertTopLatitude - 0.1;
    	end
    
    	local args = {
    		temperature = temp_option, 
    		iDesertPercent = DesertPercent,
    		iPlainsPercent =  PlainsPercent,
    		fSnowLatitude  = SnowLatitude,
    		fTundraLatitude = TundraLatitude,
    		fGrassLatitude = GrassLatitude,
    		fDesertBottomLatitude = DesertBottomLatitude,
    		fDesertTopLatitude = DesertTopLatitude
    		};
    	
    	-- END BLOCK
    	--------------------------------------------------------------------------
    	
    	local terraingen = TerrainGenerator.Create(args);
    
    	terrainTypes = terraingen:GenerateTerrain();
    	
    	SetTerrainTypes(terrainTypes);
    end
    ------------------------------------------------------------------------------
    function AddFeatures()
    	print("Adding Features (Lua Continents) ...");
    	
    	local rain = Map.GetCustomOption(2)
    	if rain == 4 then
    		rain = 1 + Map.Rand(3, "Random Rainfall - Lua");
    	end
    
    	local args = {rainfall = rain, clump_grain = 4}; --X1: passed clump_grain value to override default in 
    	local featuregen = FeatureGenerator.Create(args);
    
    	featuregen:AddFeatures();
    
    end
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
    function StartPlotSystem()
    	-- Get Resources setting input by user.
    	local res = Map.GetCustomOption(4)
    	if res == 6 then
    		res = 1 + Map.Rand(3, "Random Resources Option - Lua");
    	end
    
    	print("Creating start plot database.");
    	local start_plot_database = AssignStartingPlots.Create()
    	
    	print("Dividing the map in to Regions.");
    	-- Regional Division Method = how the start positions are distributed
    	local starts = Map.GetCustomOption(5)
    	if starts == 4 then --Player start selection was Random
    		starts = 1 + Map.Rand(3, "Roll Random Division Method - JC Lua");
    	end
    	
    	local args = {
    		method = starts, 
    		resources = res,
    		};
    	start_plot_database:GenerateRegions(args)
    
    	print("Choosing start locations for civilizations.");
    	start_plot_database:ChooseLocations()
    	
    	print("Normalizing start locations and assigning them to Players.");
    	start_plot_database:BalanceAndAssign()
    
    	print("Placing Natural Wonders.");
    	start_plot_database:PlaceNaturalWonders()
    
    	print("Placing Resources and City States.");
    	start_plot_database:PlaceResourcesAndCityStates()
    end
    ------------------------------------------------------------------------------
    
     
  11. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Just took a look, I really like your method of reserving land tiles to numcivs and states... that is much tidier (and likely more balanced) than mine... plus it wouldn't have to be tweaked if I can actually find out how to change number of players at map generation, from what is in pregame.

    And I really like your min/max workaround for the dimensions, opened up a few concepts for me!

    and much more elegant approach than mine! You have inspired me good sir!

    Cheers!
     
  12. civ5crazy

    civ5crazy Chieftain

    Joined:
    Sep 21, 2010
    Messages:
    33
    Location:
    Edmond, OK
    skweetis awesome map bud I love it and play it all the time now thanks and I hope it gets even better thanks again.
     
  13. ColBashar

    ColBashar Chieftain

    Joined:
    Nov 3, 2010
    Messages:
    32
    <salute> Happy to help.

    Well the whole idea here is scalability. By procedurally determining values rather than using hard numbers, you make the script able to more easily adapt to different conditions. For instance, instead of a "Large World Fits All" map, perhaps somebody wants to play on a "Huge World Fits All" map. This goes hand in hand with what I was saying earlier about developing for the widest functionality while adhering to the core concept. The main difference between your script and mine, disregarding our individual approaches to writing, is that mine applied the core concept of scaling landmass to player counts to each map size rather than just committing to one.

    Anyway, IsAdvancedMap determines where the user will be able to select the map. If true, then the map can only be accessed from the Advanced menu when setting up a new game. Otherwise it's additionally listed with the default array of maps, including Continents and Pangaea etc on the "simple" setup screen.

    Fractal grain is a measure of a fractal's fidelity. Fractals, by nature, produce cloud-like images if you were to convert them to a bitmap. A high grain will produce a "pitted" look with significant variations from tile to tile while a low grain will produce a very smooth transition. So choose the former where you want a scattered effect and the former for a clumped effect. Regrettably, the existing fractal generator only accepts whole numbers for this value.

    Fractals aren't the only tool Firaxis provides to simulate organic terrain, though. There's now a method to generate maps based on a Voronoi diagram. I've seen it primarily in the tectonics map. I don't use it, myself, though I think it has a finer level of control than fiddling around with the fractals.

    As for manipulating player information at runtime, I'm pretty certain it's possible but I don't know how to do it or if the documentation is available to show how it is done exactly. Perhaps Sirian could chime in here and point us in the right direction. <s> A possible shortcut, though, would be to add a function to randomly cull various civs. Given the map script already does this to city states it can't find homes for, applying that to civs seems to me a possibility.

    To be honest I'm not wholly certain it's a good idea to be messing around with player settings, first because it would be very rude to randomly drop somebody in multiplayer, and also because many players like to have fine control in choosing their enemies. That said, it would be very interesting if, say, you could script a shortcut that would give preference to Civs corresponding to various artsets or historical time periods.

    It's interesting that the default civ count to land ratio is not linear from map size to map size on the default Continents script. Standard map size is the most claustrophobic while each map size larger and smaller from it becomes progressively less so. For the values in my script I just took the average of the bunch. My guess, though, is that this has to do with the relationship between map size and fractal granularity. The smaller the map, the more "inaccurate" the fractal becomes because its nuances can not be adequately represented by a smaller resolution.

    Anyway, keep working on the map! And don't be shy about digging deep in to the script. Once you get comfortable with the way Sirian's set things up and understand how and why his methods work, odds are you'll wipe the whole thing and build something new from scratch. That's not a poke at Sirian, just that once you get past the intimidation factor I suspect you'll have an itch to try whole new approaches.

    --TG
     
  14. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Civ5Crazy: Thanks for taking the time to let me know! I'm really pleased you enjoy it!

    ColBashar: Thanks for the info, you have saved me many hours of playtesting to answer the questions that came up as I dissected continents! I suspect that why the land area scales up is in compensation for city states being double number of civs (each map size is +50% total number of players of the previous size), to keep city states from being dropped.

    I'm currently looking at including a mod that adds Random Players checkbox option to the Advanced menu, I think I have an idea how to do it without much fuss.

    Baby calls, I'll provide more details when I can. Thanks again ColBashar!

    Cheers!
     
  15. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Just got a chance finally to read your post in detail Ty (can I call you Ty?)

    Your feedback and input has been invaluable, I can't say it enough. I have basically got to that point now, where I need to just rebuild it from the ground up... I used some spare time to make some changes to the design, mostly to give the user's the option to choose their own world.

    I'm leaving the development of this script as is, and I'll support it as far as bugs are concerned. This has evolved into a whole new project that needs to be its own, and I'm eager to use the new stuff I've learned!

    ColBashar, if it's okay with you, I'd like to integrate a few if not all of the concepts and ideas you've provided (with full credit of course! :)) Also, if you're okay with it, would you mind if I PM you for advice or questions that may arise during this development, you obviously have a much clearer understanding of Civ map scripting, and it would really be appreciated!

    Cheers!

    Once I have the new concept laid out and organised, I'll start up a new project thread with the details. If anyone who has used this version and has anything they'd like to see changed or added, now's the time!

    (Am I at 30 posts yet? lol)
     
  16. ColBashar

    ColBashar Chieftain

    Joined:
    Nov 3, 2010
    Messages:
    32
    Sounds neat. I look forward to seeing what you're working on now, particularly with regard to handling player information. I hope this doesn't mean you're going to leave LWFA an orphan, though. Will you be releasing a more polished version or is your new project going to supersede it entirely?

    And, sure, you can borrow any of my script if you think it would help. I believe the better we can write these scripts, the better off the community will be as a whole. Please feel free if you ever have the desire to critique my own work.

    A final point on documentation. I admit that I'm not the most disciplined in this area but it's a good idea to document your work regardless of whether or not anybody else is going to see it. No only does this reinforce the habit but should you set your project aside for a few months and then come back to it, chances are you'll be just as lost as a person looking at it for the first time. I kinda, sorta learned that one from experience.

    --TG

    aside: To my surprise, Mozilla's spellcheck plug-in actually accepts "kinda" and "sorta" as words.
     
  17. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    same concept, more polished and refined, with more flexibility for the user. Its being built on the same principle, from the ground up.

    I'm leaving this one up, as it would be redundant to update it with what I have in the works, and somebody may still want this one. It's easier to start from scratch then try and Frankenstein all that code together and still make sense of it.

    I understand infinitely more now about map scripting and lua than I did when I made this one, and even the other I showed. Plus there are the add-on ideas I hope I can make time for, I'd like to lay the foundations for in the new version.

    I'm anticipating having something to show by next week (or by the time I hit 30 posts and don't have to wait for approval of my uploads ;) ).

    Cross those fingers!

    PS - maybe I'll save the forum the clutter and just rename and edit this thread, and include link to what would then become the 'old version'......so much to think about and do, so little time!
     
  18. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Oh yeah and as for the random number of players, Im trying to sneak in a method into GetMapInfo() to update values stored in pregame.cpp (been trying to collect hints from the UI for advanced setup, see the button that controls the Add a player?), before the map is launched, since this section is read at map selection to get the options info right? It's gotta be possible somehow, no? I'm going to play with it. Haven't had a chance for a few days to sit down and work on it. I hope to tonight...

    Maybe you will beat me to it?

    Cheers, and thanks!
     
  19. ColBashar

    ColBashar Chieftain

    Joined:
    Nov 3, 2010
    Messages:
    32
    Well, I've been focusing purely on Rhineland. Don't like having buggy code up for long. Now that I've dealt with that I'll be focusing on all the things I didn't focus on while I was focusing on Rhineland. And then if there's any time left over I hope to take a look at working on a gameplay mod for the game. So I'm very interested in seeing what you've gleaned. <s>

    As for the thread, if the old map script is different in some way that is novel, then I think it should stand on its own right. On the other hand, if the new map does everything the old one did, even if the script is completely different, then it is probably worth consolidating. I'll probably kill my Scaled Continents script once I see the new version of your own.

    Not that it matters much at this point, since as of this writing you're three posts away from the 30 threshold, but I'm wondering why you haven't been taking advantage of the option to add attachments to posts? I found that an excellent means of publishing files without having to go through administration. Moreover it is very convenient to move and replace files through post editing. Just curious.
     
  20. skweetis

    skweetis Chieftain

    Joined:
    Mar 14, 2008
    Messages:
    58
    Location:
    Canada
    Lol, cause I didn't Know that could be done! Well, that would have worked better than me posting every thought and looking like a rambling idiot!

    Cheers! Learn something new everyday!

    You're right, I'll just consolidate them. The main point of the script is the same, land area scaled to number of players, but with much more flexibility. If I can't find another way to randomise the players, well Firaxis will likely fix the Random Map Size issue, and I can just use my original method.
     

Share This Page