Fantastical

resorcerer

Chieftain
Joined
Apr 3, 2013
Messages
85
I remade the fantasy map script using Voronoi diagrams (inspired by Amit Patel's Realm of the Mad God procedural map). Everything being made of polygons means the same map can be rendered at different resolutions--larger maps will look very different than smaller maps because they are the same.

I also decided, like an old man building model trains, that I needed my own custom river generation. It creates wacky, convoluted rivers that if you're looking for watersheds will seem like Escher. Especially on larger maps (more details make it).

Another effect of the polygonal structure is that unlike the previous script which drew everything hex by hex, the continents can have unique shapes without being wispy and snakey, and have bulk without becoming round blobs.

There is strict control over how how many deep oceans there are. There is some concern for gameplay.

And an option to sprinkle fallout around the map, like good cheer.

It can give add old road networks connecting city ruins to the map.

Lua File

GitHub Repository

Steam Workshop
 

Attachments

  • fantastical-ingame.jpg
    fantastical-ingame.jpg
    236.6 KB · Views: 1,292
  • fantastical-worldbuilder.jpg
    fantastical-worldbuilder.jpg
    462.5 KB · Views: 1,396
  • fantastical-realmrealism-worldbuilder.jpg
    fantastical-realmrealism-worldbuilder.jpg
    412.4 KB · Views: 1,110
really nice.
I like the maps layout a lot.

anyway i have a bug (using BNW)
if I enable climate logic, all oceans are filled with ice.
 
Do I need an extra mod to make it work?
I ask because I subscribed to it on Steam and cannot find it ingame.
 
i used this fantasy-dev it made a map of nothing but water and i instantly lost
 
mcguffin: thanks for the report. it should be fixed now.

Shaitan051: if you're using the steam workshop, you need to enable it in Mods before it will show up

bladex: weird. if it's still happening and you have logging enabled, could you send the Lua.log ?

In case anyone's interested, I did find out how to add roads. It has to be done outside of the map script, and as far as I know it has to be within a mod :-(. Right now I'm doing it this way: The map script creates a database table with DB.Query and inserts all the road locations into it. Another lua file reads the database and does plot:SetRouteType() at the road locations. The really weird part about trying to test the roads is, even if you're revealed the whole map using the debug panel or the Reseed mod, you can't see the roads until your units have actually revealed them.

If anyone knows how to get the other lua file to run without being a part of a mod, tell me?
 
Seriously, it's probably just an include you could add to your mapscript that would allow it to place roads. Your best bet is going to be to search the source for which modules are required in order to place them and then find an existing include in one of the game's .lua files that activates the tools you need within your mapscript.

It may require you to do a chain of searches as most of the Lua functions are just wrappers that map to a C function with a slightly different name. Alternatively you could just try poking in includes until you find the right one.
 
I'm an idiot--it turns out setting a plot's RouteType just has to be done in AddGoodies()
 
Hi, instead of the old one I'm going to use a modified version of this map script in my mod, if you have nothing against it (sorry for a delayed reaction for this new version, I was busy with other aspects of my mod). Although I miss some options from the old version, like the land to ocean ratio and region size. Would it be possible to bring them back?

Btw I changed the formula that determines the aspect ratio for Realm maps. It uses exponential distribution instead of linear, which I think is better - it has the same chance to generate an aspect ratio between 1:2 and 1, and between 1 and 2:1.

Code:
local grid_width = mCeil (mSqrt (grid_area) * math.pow (2, mRandom() - 0.5))
 
Wow, this makes a fun map -- very nice!

I did notice one minor glitch, though. Look at the Korean Warrior in the attached screenshot. He appears to be standing on a mountain, but a mouse-over says he's in a flat desert tile. Weird.

 
It's probably just the seam of the map and nothing to do with the map script.

Maps that wrap and have land at the point where the map wraps commonly have graphical glitches like false mountains and dry rivers.

I think it's quite an achievement, this map script, I like it. A problem that I have is that I hardly get any tundra, especially unforested tundra is next to non-existent. I see it in the screenshots in the first post, but I'm not getting that.
If there is some setting in the map script that I can alter to get more tundra I would like to know about it!
 
I noticed a serious problem with this map script - sometimes the custom options get messed up and the map looks different than it should. I will try to find the source of the problem myself, but I'm not sure if I manage to do it.
 
I found it. It's not your fault, it's a bug in the game - it just doesn't work properly when there are more than 9 map options. It sounds strange, but it seems only the first digit of the option number is checked. So if you have 12 options, and in the advanced setup you change option 1, and leave the default values of options 10, 11 and 12, then options 10, 11 and 12 are assigned the same values as you assigned to option 1. I'm just going to delete the options that are not relevant to my mod, but I don't know any good solution if you want to keep more than 9 options... :(

Edit: How to reproduce the bug:

1. Select Single Player -> Set Up Game.
2. Go to the advanced setup.
3. If you already have selected this map script, then select another one, and select this one again (so all options go back to the default values).
4. Change Word Wrap (option 1) to Realm (Does Not Wrap). Don't touch any other options.
5. Notice the state of options 10-12: Fallout: None, Ancient Roads: Few, Resources: Standard (Resources are actually the last option, they appear at the top because of SortIndex).
6. Start a game.
7. Go back to the main menu.
8. Go to Single Player -> Set Up Game -> Advanced Setup again.
9. Notice that Fallout has changed to Post-Apocalyptic.
10. Change Word Wrap to Globe again and start a game.
11. Go back to the main menu and to the advanced setup one more time.
12. Notice that Fallout is None again, Ancient Roads are None, and Resources are Sparse.
 
PawelS, thanks for the research! I forgot how many map options I have, but I have to remove some :-(

Oh, also PawelS, it wouldn't be too hard to resurrect region size. Would just need to change
Code:
a.polygonCount = 140 -- how many polygons (map scale)
and possibly
Code:
a.subPolygonCount = 1700 -- how many subpolygons
which means that the OptionsDictionary would contain something like
Code:
{ name = "Map Scale", sortpriority = 12, keys = { "polygonCount", "subPolygonCount" }, default = 2,
	values = {
			[1] = { name = "Small", values = {200, 2200} },
			[2] = { name = "Medium", values = {140, 1700} },
			[3] = { name = "Large", values = {100, 1200} },
		}
	},

Another odd map option bug is, if you're testing scripts in World Builder, the first time you click "Generate", it will ignore the map options you input, and use I don't even know what. Possibly this is also caused by too many map options.

Optional, that's just because I haven't updated the screenshots here in a while. I've since changed the way the climate works. The problem is that the calculations that produce terrain and feature types from temperature and rainfall are extremely delicate, and I accidentally erred on the side of too much forest on tundra (I had not enough too many times).

It's so delicate because I wanted to have a wide range of climate options without having to individually input the proportions of terrain and features for each one, and at the same time have roughly the same proportions whether the map is latitude-based ("climate realism") or not. So both are based on latitude, but in the nonrealistic map, the latitudes are not really latitudes because they're randomly distributed. To get the kind of varation I wanted, rainfall is a sine wave along the laitude, and temperature is linear along latitude. I tell you all this because, of course, the world must know my private suffering! And er, maybe because someone has a better idea.

Attached is a screenshot of the madness I was submerged in some months ago. It's a Lua Love script just to help me visualize what I was doing, and also it did some primitive optimization based on the parameters I wanted. The x axis is temperature, the y axis is rainfall. The red dotted line is where latitude falls. Yes, the climate is also voronoi-based :p

PS reply is very late, I hadn't checked this forum in a while
 

Attachments

  • climate_optimize_madness.png
    climate_optimize_madness.png
    84.3 KB · Views: 284
Thanks for the reply! I experimented with the polygon and subpolygon count and the results are interesting indeed, I think I will make it a little higher in the mod's version of the script, or add a map option that changes it.

Is there a way to control the land/sea ratio?

(The amount of tundra is good for me, I generate maps with the "land at the poles" option enabled, and it generates a good (but not too big) amount of snow and tundra, including tundra without forest.)
 
ocean/land ratio can't be controlled precisely. it's really just these three numbers:

Code:
a.oceanNumber = 2 -- how many large ocean basins
	a.majorContinentNumber = 1 -- how many large continents per astronomy basin
	a.islandRatio = 0.5 -- what part of the continent polygons are taken up by 1-3 polygon continents

all three produce more watery maps with higher numbers. the more deep oceans required, the less room there is for land to fit between them. the more continents and islands, the more channels of ocean must seperate the continents and islands.

oceanNumber can be set to -1 to create an all-land map (with a few small lakes), and to 0 to have no deep ocean rifts that seperate groups of continents (allowing room for much more land).
 
ugh, the only way i can think to get 9 options (currently there are 11) is to consolidate world wrap, land at poles, and climate realism into some monstrous amalgam
 
It's even worse: unless you made changes lately, you have 12 options - the standard Resources option counts too.

Edit: another possibility would be fixing the bug, but I suppose it's hiding somewhere in the DLL source code (probably CvPreGame.cpp), so it would require a custom DLL.

Edit2: I think I found it. Here:

Code:
bool GetMapOption(const char* szOptionName, int& iValue)
{
	for(std::vector<CustomOption>::const_iterator it = s_MapOptions.begin();
	        it != s_MapOptions.end(); ++it)
	{
		size_t bytes = 0;
		const char* szCurrentOptionName = (*it).GetName(bytes);
		if(strncmp(szCurrentOptionName, szOptionName, bytes) == 0)
		{
			iValue = (*it).GetValue();
			return true;
		}
	}

The 'strncmp' function compares two strings, but only to the extent of a limited number of characters - the 'bytes' variable, which seems to represent the length of one of the strings. The option "names" are actually their numbers stored as text strings - see Civ5UserHistoryDatabase.db, AdvancedSettings_MapOptions table (it gains content after you change a map option to a non-default value and start a game), or Civ5DebugDatabase.db, MapScriptOptions table, where it's called OptionID. So if the first digit of the two options is the same, the compare can return a success. The options are numbered from 1, so 10 will have the same first digit as 1 - that's why only 9 options will work properly.

To fix it, I think strncmp should be replaced with strcmp, which compares entire strings regardless of their length. It takes only 2 arguments, so the bytes argument should be removed. I assume both arguments are proper null-terminated strings, if not then it needs a different solution.

I already reported this bug in the bug reports forum, now I will add a link to this additional information.
 
Thanks PawelS. I'm hesitant to wade into DLL patching, but on the other hand might be less effort than getting rid of three map options. Have you tried your fix?
 
No, I haven't got into DLL compiling yet, as in the current phase of development my mod uses the standard DLL. Perhaps you can ask whoward69 or the community patch team to include the fix in their versions of the DLL.
 
ah, good tip. i'm not sure how many people, especially those using the steam workshop, will know about the community patch.

okay it's fixed. there are only nine map options. i had to sacrifice fine-tuning the number of roads. the first option, "World Type" is hideous (it has 12 choices), but it all works.

Code:
{ name = "World Type", keys = { "wrapX", "inlandSeasMax", "useMapLatitudes", "polarMaxLandRatio", "ancientCitiesCount" }, default = 1,
	values = {
			[1] = { name = "Globe (Wraps East-West)", values = {true, 2, false, 0.15, 0} },
			[2] = { name = "Realm (Does Not Wrap)", values = {false, 1, false, 0.15, 0} },
			[3] = { name = "Realistic Globe", values = {true, 2, true, 0.15, 0} },
			[4] = { name = "Realistic Realm", values = {false, 1, true, 0.15, 0} },
			[5] = { name = "Globe w/o Polar Land", values = {true, 2, false, 0.0, 0} },
			[6] = { name = "Realistic Globe w/o Polar Land", values = {true, 2, true, 0.0, 0} },
			[7] = { name = "Globe w/ Old Roads", values = {true, 2, false, 0.15, 4} },
			[8] = { name = "Realm w/ Old Roads", values = {false, 1, false, 0.15, 4} },
			[9] = { name = "Realistic Globe w/ Old Roads", values = {true, 2, true, 0.15, 4} },
			[10] = { name = "Realistic Realm w/ Old Roads", values = {false, 1, true, 0.15, 4} },
			[11] = { name = "Globe w/o Polar Land w/ Old Roads", values = {true, 2, false, 0.0, 4} },
			[12] = { name = "Realistic Globe w/o Polar Land w/ Old Roads", values = {true, 2, true, 0.0, 4} },
		}
	},
 
Top Bottom