[BNW] Can I restrict cities on small islands

yepzer

Chieftain
Joined
Jan 12, 2006
Messages
39
Location
Denmark
I'm pretty tired of the AI spawning cities on 1 and 2 tile islands, I'm considering how to put a mod together to restrict this. Having done some mods already I'm familier with corners of the API and XML - but I struggle putting the pieces together.

1. Detecting if the unit is on a 1-2 tile island. Is there a way to do this already? The Wiki is a bit thin on explaining Areas and other terrain functions.
Alternatively I would expand the map database initially, and after map creation iterate all plots and count neighbor water tiles. Perhaps ring two too.

2. At runtime suppress that settlers and other units can found cities. I find no clear path in the wiki for this though. Perhaps I need to suppress some vanilla code either by replacing vanilla lua files or expand the DLL?

What have I missed? Are there any hints you can give? thank you
 
If you're using my DLL (or a version of it), there is a
GameEvents.PlayerCanFoundCity.Add(function(iPlayer, iPlotX, iPlotY) return true end)
event
 
Thank you for your quick reply - and DLL work. I can build from that - will revert when I have more to share
 
If you're using my DLL (or a version of it), there is a
GameEvents.PlayerCanFoundCity.Add(function(iPlayer, iPlotX, iPlotY) return true end)
event
So finally time for some coding.

I have a mod dependency for both G&K, BNW and Various Mod Components [ICON_FLOWER] 105, but I cant seem to get the added function to fire.
in the end of my mod lua file I have this - as I would usually have
GameEvents.PlayerCanFoundCity.Add(onCanFoundCity)​
the function "onCanFoundCity" starts like this
function onCanFoundCity(iPlayer,iPlotX,iPlotY)​
print("CanFoundCity: ")​
but nothing is printet from that function into the log when I build cities.

nothing happens when I have this Add-statement instead. (I would expect not being able to build cities...?)
GameEvents.PlayerCanFoundCity.Add(function(iPlayer, iPlotX, iPlotY) return false end)​
full code here. What have I missed - it seems straight forward similar to eg Global - Coastal Waters Only
 
Just to help out the next modder on expanding on the "Various Mod Components" - many of the functions needs to be enabled in CustomModOptions.xml. See the OG post
 
Back
Top Bottom