How to influence city growth?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

How to influence city growth?

Post by Erato »

Hey!

I'm currently working on a building set and I was wondering how I could make it so certain types of towns or cities need different types of cargo to grow, and if it is possible to influence the speed of this growth, but I cannot find anything in the NML documentation.

For instance, how could I make it such that a city would require goods to grow if the population is bigger than 10.000?

Thanks in advance!
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
jfs
Tycoon
Tycoon
Posts: 1763
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: How to influence city growth?

Post by jfs »

Restrictions like "require goods to grow if the population is bigger than 10.000" can only be implemented via a game script.
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: How to influence city growth?

Post by Andrew350 »

EDIT: jfs posted while I was writing, and what he said is generally true, but as long as ALL houses are defined as I wrote below it can still work :)

As far as I know there's no way to change the speed of town growth, at least when it comes to the number of new houses OpenTTD builds over time, as that is hardcoded. You can, however, alter it slightly by imposing "rules" for your houses by restricting the conditions in which they will be built by using the construction_check callback. This particular callback can be abused a lot to influence how, when, and what type of buildings will appear depending on the variables you feed it.

Using your example, you could define a house using the construction_check callback to disallow construction above 10,000 population unless goods are delivered nearby, maybe something like this:

Code: Select all

switch (FEAT_HOUSES, SELF, switch_goods_check, cargo_accepted_nearby_last_month(GOOD, 0, 0)) {
	1: 1;
	0;
}
switch (FEAT_HOUSES, PARENT, switch_pop_check, population) {
	0..9999: 1;
	switch_goods_check;
}
...
...
graphics {
		construction_check:  switch_pop_check;
	}
Notice the PARENT scope of that first switch which opens up some new town variables such as population ;) Of course this is a basic example and there is tons of stuff you can do, for example by utilizing the protection callback to stop certain buildings from being destroyed or checking for similar buildings nearby using the same_class_count_town and similar variables to create a sort of "neighborhood" effect.

You can make it as simple or complicated as you wish but OpenTTD growth mechanics will always apply, so you may need to get...creative to work around it a little bit if that's not desired ;) I've only done a little bit of town growth stuff in Wasteland, but if you have any specific questions I'll gladly try to help where I can :)
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: How to influence city growth?

Post by Erato »

Thanks for the help. I think I'll go with making a Gamescript. It seems more appropriate for what I want to achieve. Thanks anyway.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 22 guests