skip to Main Content

Modify Frontiers at Runtime

WMSK includes a new API for transfering a region from country B to another country A modifying both country frontiers at runtime. This could be seen as if country A conquered part or all country B (remember: a country can have more than one land region – for example, a country with a mainland and 2 islands will have 3 regions in total).

The list of regions of a country can be obtained through the regions list of the country object. The main region of a country is defined by the biggest region and is identified by the mainRegionIndex of the country object. So country.regions[country.mainRegionIndex] would return the reference to the main land region for the country.

For example, to transfer the main region of Portugal to Spain you could do:

Country portugal = map.GetCountry(“Portugal”);

Region portugalMainRegion = portugal.regions[portugal.mainRegionindex];

int spainCountryIndex = map.GetCountryIndex(“Spain”);

map.CountryTransferCountryRegion(spainCountryIndex, portugalMainRegion);


Check demo scene 102 for an example of how to grow an empire using this API.

Provinces can also be merged at runtime. Check demo scene 103 for an example. A province can also be converted to an independent country using ProvinceToCountry method.


It’s important to note that the above API is experimental and currently shows some important limitations:

  • It’s quite slow with high definition frontiers, specially with bigger countries, like Canada or Russia.

  • It has only been tested with country low resolution frontiers.

These limitations derive from the fact that automating boolean operations on complex polygons result in a extremmely difficult task so it’s not 100% reliable. We provide this new API in beta – after extensive tests we find that this API could be useful as is with the world map provided considering the above limitations but again you should make your own tests if you modify the map.

The API includes 3 methods that are more robust albeit a bit slower (CountrySetProvinces, CountryAddProvinces, CountryRemoveProvinces). These method work great if you work with both countries and provinces and want to redistribute or change the ownership of certain provinces without incurring in the complex polygon substraction operations. Please check the API section for more details about these 3 methods.

Back To Top