distance of new cities from old

Post Reply
dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

distance of new cities from old

Post by dejvid2 » Sun Oct 14, 2018 5:23 pm

I want to increase the distance that a settler has to be from the existing cities before a city can be founded.

My aim is to discourage the AI from building cities and so the cities that are in play are the historical ones in their historical location as specified by the scenario.

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: distance of new cities from old

Post by Cablenexus » Sun Oct 14, 2018 9:20 pm

dejvid2 wrote:
Sun Oct 14, 2018 5:23 pm
I want to increase the distance that a settler has to be from the existing cities before a city can be founded.

My aim is to discourage the AI from building cities and so the cities that are in play are the historical ones in their historical location as specified by the scenario.

First of all, I don't think you can set this is scenario or mod.ag directly.

You need to make a MOD with a new script file: Msgs.cs and eventually Units.cs.

I'm not a scripter myself, but I like to experiment a bit. For a real solution wait for Pavel, at least before you publish it.
USE AT YOUR OWN RISK


You should create a MOD with your own Msgs.cs script file where you change:

private MsgResult CanBuildTown(Unit unit, Position position)

Within:

MOD_MOVE_4 (in Msgs.cs script), which is actually the "build" command for towns.

Change:

else if (State.Chart.GetUnitsCloseToPosition(position, 1).GetUnitsByUnitClass(UNIT_CLASS.CITY).Count > 0)

To:

else if (State.Chart.GetUnitsCloseToPosition(position, 2).GetUnitsByUnitClass(UNIT_CLASS.CITY).Count > 0)

So it will check for two tiles away instead of one. Otherwise you will get message "cannot build here".

This is not bound specifically to the Settler, but to all units who can build cities.
If you really want to have this rule for the settler only you should make a complete new movetype with this rule and give only the settler this movetype (ability).


I'm not sure if it is enough to achieve what you want, but a good start I think. I tested it and it worked for me.


You probably also want to make use of more tiles around existing cities (for yield for example). You can do that as well:

I find a way to set the surrounding occupied tiles per city size in script file.
Again USE AT YOUR OWN RISK, I'm not exactly sure what all is bounded to the occupied neighbourhood positions. I think it's more then the "yielding" alone.

In the script you add a public class for cities. (public class Static Unit inluding all content must be there as well).

(see original Units.CS file to copy the whole Staticunit and City public class in the Scripts folder of the Ancient Rome mod).

So your script file looks like this:

//css_reference Shared.dll;
//css_reference Kernel.dll;
//css_reference Resource.dll;
using System;
using System.Drawing;
using System.Collections.Generic;
using Aggressors.Units;
using Aggressors.StateClasses;
using Aggressors.Msgs;
using Aggressors.Msgs.Moves;
using Aggressors;
using Aggressors.Reports;


- public class StaticUnit ...

- public class City ...

Within the public class cities find the:

private PositionCollection

For every city size (>3 for example) you can now set the neighbourhood range.

For example

If the city is smaller then 3, occupy type is a cross type (one square N, E, S and W) and one square range.
If change 1 to 3 for example and CROSS to SQUARE you will get a 3 range square.

(unit.Position, 0, 1, OCCUPY_TYPE.CROSS)


to

(unit.Position, 0, 3, OCCUPY_TYPE.SQUARE)

Will result in:
range.jpg
range.jpg (319.43 KiB) Viewed 1105 times

Be also aware this only works for newly created cities in your scenario. The already placed ones keeps the same value.

dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

Re: distance of new cities from old

Post by dejvid2 » Mon Oct 15, 2018 9:01 am

Thanks for a very complete reply. I did wonder if there was a simple way to do this. It seems not but going thru this will teach me a lot about scripting etc.
Thank you.

(And the big USE AT YOUR OWN RISK duly noted)

pavelk
Kubat Software
Kubat Software
Posts: 2445
Joined: Mon May 16, 2016 4:27 pm

Re: distance of new cities from old

Post by pavelk » Mon Oct 15, 2018 4:07 pm

Hi dejvid2,
Cablenexus was pretty much right in those answers.
dejvid2 wrote:
Sun Oct 14, 2018 5:23 pm
My aim is to discourage the AI from building cities and so the cities that are in play are the historical ones in their historical location as specified by the scenario.
I am not sure I understand what you mean by "cities that are in play are the historical ones in their historical location as specified by the scenario."
Can you please explain it a bit more?

dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

Re: distance of new cities from old

Post by dejvid2 » Mon Oct 15, 2018 5:02 pm

pavelk wrote:
Mon Oct 15, 2018 4:07 pm
Hi dejvid2,
Cablenexus was pretty much right in those answers.
dejvid2 wrote:
Sun Oct 14, 2018 5:23 pm
My aim is to discourage the AI from building cities and so the cities that are in play are the historical ones in their historical location as specified by the scenario.
I am not sure I understand what you mean by "cities that are in play are the historical ones in their historical location as specified by the scenario."
Can you please explain it a bit more?
The standard scenario has a lot of space so that players (human or ai) can build new cities. Because the ai first off takes cities from a list specific to the region, the ai often build cities with names that actually belonged to a city historically in the same are but often not. I have seen Mantinea being built on the Danube for example. (The ai is also very helpful in choosing the name of a city that has been destroyed nearby where that has happened.)

One solution is to create a scenario where the cities are so crowded that there isn't much space for new cities but some areas just were very sparse on cities.
Hence I would like to have a way of ensuring that the ai leaves empty areas that way or just builds the odd city here and there.

Okay that's the why - Cablenexus had given me the pointer as to how. Now all I have to do is understand scripting.

Cablenexus
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1680
Joined: Mon Jan 04, 2016 7:09 pm

Re: distance of new cities from old

Post by Cablenexus » Mon Oct 15, 2018 5:50 pm

dejvid2 wrote:
Mon Oct 15, 2018 5:02 pm
pavelk wrote:
Mon Oct 15, 2018 4:07 pm
Hi dejvid2,
Cablenexus was pretty much right in those answers.
dejvid2 wrote:
Sun Oct 14, 2018 5:23 pm
My aim is to discourage the AI from building cities and so the cities that are in play are the historical ones in their historical location as specified by the scenario.
I am not sure I understand what you mean by "cities that are in play are the historical ones in their historical location as specified by the scenario."
Can you please explain it a bit more?
The standard scenario has a lot of space so that players (human or ai) can build new cities. Because the ai first off takes cities from a list specific to the region, the ai often build cities with names that actually belonged to a city historically in the same are but often not. I have seen Mantinea being built on the Danube for example. (The ai is also very helpful in choosing the name of a city that has been destroyed nearby where that has happened.)

One solution is to create a scenario where the cities are so crowded that there isn't much space for new cities but some areas just were very sparse on cities.
Hence I would like to have a way of ensuring that the ai leaves empty areas that way or just builds the odd city here and there.

Okay that's the why - Cablenexus had given me the pointer as to how. Now all I have to do is understand scripting.
Take a look in the scenario.ag file of the original Ancient Med. scenario to get an idea how the citynames are setup:

<unitNames>
<unitNames>
<UnitNameMemento name="Baelo Claudia" positionRange="1" modelIds="1">
<position x="7" y="20" />
</UnitNameMemento>

You could create your own scenario and setup the positions you want to use for specific citynames and also assign a positionrange.

If you add to the list a series of names not bound to any coordination I think they will be used in advance for non coordinated citynames.

The positions you find ingame editor mode (Alt-A) by mouse over any tile.

You can play around with the terrain to prevent certain cities build in certain places (mountains etc) and you can play with resources etc, but that is all just balancing etc.

If you really want to change the distance respected towards other cities you should write a script, the bove post should be a good guideline if following step by step.

I use Visual Studio (free edition) and it can open the XML and script files. If any question feel free to ask.

dejvid2
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat Nov 04, 2017 2:50 pm

Re: distance of new cities from old

Post by dejvid2 » Tue Oct 16, 2018 9:46 am

Cablenexus wrote:
Mon Oct 15, 2018 5:50 pm
Take a look in the scenario.ag file of the original Ancient Med. scenario to get an idea how the citynames are setup:

<unitNames>
<unitNames>
<UnitNameMemento name="Baelo Claudia" positionRange="1" modelIds="1">
<position x="7" y="20" />
</UnitNameMemento>

In the short term, this is going to the most useful. (I assume that this is how the program remembers where destroyed cities were and enables them to be refounded).


I'll come back to the other options when I have got my head round scripting.


Thanks for the help

pavelk
Kubat Software
Kubat Software
Posts: 2445
Joined: Mon May 16, 2016 4:27 pm

Re: distance of new cities from old

Post by pavelk » Tue Oct 16, 2018 10:20 am

dejvid2 wrote:
Tue Oct 16, 2018 9:46 am
I assume that this is how the program remembers where destroyed cities were and enables them to be refounded.
This is actually not the functionality enabling it. It is based on "history" of the game. The list in unitNames is a list of suggested names if there is new city build and when there weren't any cities around yet in game.

Post Reply

Return to “Aggressors Modding”