Page 1 of 1

Moving cities around

Posted: Fri Nov 23, 2018 11:38 pm
by nctrd
I got inspired by Dracula's moving castle from Castlevania, and I wonder how would the game change if there was an option to teleport a city to a whole new location (with regular restrictions, e.g. not right next to another city and not into other nation's territory).

I see that a technology, a special building or a wonder allowing it can be created using rulesets. But, what about the movement itself? It must be a feature more special than destroy-and-create city, not leave ruins behind, tile use and borders must be updated etc.
Also, the question of roads arises. With all that in mind, how can that be coded?

Re: Moving cities around

Posted: Sat Nov 24, 2018 7:49 pm
by Ignatus
As defined in common/city.h in the source, a city is just a record which among other data contains a pointer (struct tile *tile) to the tile it stands on. This field probably will cause bugs if just reassigned, so the straightforward method to reallocate a city is just destroying it in one place and creating in the another (in the reverse order), with transferring all the units, rebuilding all the improvements and setting properly production counters etc. Currently, this in general case can't be done by Lua script, but coding it on C seems rather simple (just hardly will happen soon). I have thought about flying cities; if the game will ever be rewritten in OO code, maybe it would be efficient to base a unit and a city on the same class "game piece" with some actions and properties just blocked to one or another, or not.