Send units to cities


In my development version, a new comfort function has now been completed.
In the next version of the game, it will be possible to send units directly to a specific city.

This feature is also available in the original game "Colonization" and was requested by some players.
However, the integration of this function turned out to be much more difficult than expected.
If you want to send a unit to a certain city, this means that there must be a list of the cities that can be reached.

But how is this list created?

Pathfinding to all of your own cities is impossible, as it would take far too long on the Amiga.
I then asked myself how this function works in the games "Colonization" and "Civilization".

I found out that the different land areas on the map are marked as "continents". (Screenshot 1)
All contiguous land areas are one continent each.
Since land units cannot easily move over water, only cities that are on the same continent as the selected unit can be targets.
Unfortunately, I could not find out how the continents were determined in these old games. Therefore I found my own solution.

In AmiBlitz 3 there is a function called "Flood-Fill". This function colours all contiguous areas of one colour.
When creating the map in "Settle the World", each land square now gets a continent start value.
Then all the squares on the map are scanned.
If the square still has the continent start value, the function "Flood-Fill" is applied to this square and colours all squares on this continent in a one random colour. The colour number is then the new continent value.

This is done until no square has the start continent value and every land square is assigned to a continent. (Screenshot 2)
This process is repeated again for ocean fields. (Screenshot 3)

In order to obtain a list of the cities that can be reached in the game, all the player's cities must be scanned in a loop and it must be checked whether these cities are on the same continent as the selected unit.
In addition, the distance to the cities is determined by a simple distance check ("as the crow flies").
Cities that are outside the pathfinding range are not listed. (Screenshot 4)

If the player now selects one of the listed cities as a target, the pathfinding of the unit starts in order to determine a way to this city.
If the selected unit is inside a city, it is automatically moved out of the city.

This new functionality is very usefull in mid- and late-game to reduce micromanagement ;-)

Get Settle the World (Amiga)

Leave a comment

Log in with itch.io to leave a comment.