• 📚 Admin Project Update: I've added a major feature to PictureBooks.io called Avatar Studio! You can now upload photos to instantly turn your kids (and pets! 🐶) into illustrated characters that star in their own stories. Give it a try and let me know what you think!

[BNW] Can I restrict cities on small islands

yepzer

Chieftain
Joined
Jan 12, 2006
Messages
41
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
 
There is a bug though. Consistently when starting a Earth map, or similar with fixed maps. The whole game aborts after game setup. Generated maps works fine.

For testing purposes I have made a mod consisting only of one xml file below and a prereq of Various Mod Components (the steam version by zai4z, v106).
Code:
<GameData>
  <CustomModOptions>
      <Update>
          <Where Name="EVENTS_CITY_FOUNDING"/>
          <Set Value="1"/>
      </Update>
  </CustomModOptions>
</GameData>

It seems to me there is a bug in VMC somewhere for this outcome. I can see that the flag is set in CustomMods.log both for crashed and OK games.
The lua log though shows a different pattern:
- After logging InstalledPanel - OK games start Map Script.
- After logging InstalledPanel - crash games have a few lines WorldBuilderMapLoader (adding ressources), then ends.

Can it be reproduced by others?
 
Back
Top Bottom