TownEffects
Moderator: OpenTTD Developers
TownEffects
Hi,
I've a question, sorry if it look stupid, I could not get clear answer from wiki or GS api
What are TownEffects ?
I suppose it's the effect a given cargo provides to a town,
for example, Good cargo in temperate provides TE_PASSENGERS, TE_MAIL, TE_GOODS and TE_FOOD effects.
But what does it means : "goods provide Food effect to town" ?
What usage ottd can makes of that ? probably growing town ?
I don't see the internal behind : Good cargo provide 4 different effects here, do all these 4 effects behave the same ? maybe with a different rate ? if yes, can we know each rate ?
I'm a little bit in the dark with the concept of TownEffect, it would be helpfull if someone could explain,
Thank you.
I've a question, sorry if it look stupid, I could not get clear answer from wiki or GS api
What are TownEffects ?
I suppose it's the effect a given cargo provides to a town,
for example, Good cargo in temperate provides TE_PASSENGERS, TE_MAIL, TE_GOODS and TE_FOOD effects.
But what does it means : "goods provide Food effect to town" ?
What usage ottd can makes of that ? probably growing town ?
I don't see the internal behind : Good cargo provide 4 different effects here, do all these 4 effects behave the same ? maybe with a different rate ? if yes, can we know each rate ?
I'm a little bit in the dark with the concept of TownEffect, it would be helpfull if someone could explain,
Thank you.
Re: TownEffects
It help you determine what the cargo does :
If a newGRF provide a new cargo : says "Beef". What you're AI will do with "Beef" now ?
Beef with town effect as "TE_FOOD" will allow your AI to treat "Beef" as food. So your AI now knows town "can" accept it (so your AI will search a station in a town to drop beef".
As another example : providing "Football supporters" with effect "TE_PASSENGERS", you're AI can send them in town or platform, but if you want make a town grow, better gives them to a town and not to a platform.
It's good to note that until we have "TE_DUMB" you cannot see any "PSG Fooball supporters" cargo.
look at http://wiki.openttd.org/Towns#Climate-R ... own_Growth
edit: seeing frosch comment, i see i gave you AI pov, and you were seeking GS, sorry
If a newGRF provide a new cargo : says "Beef". What you're AI will do with "Beef" now ?
Beef with town effect as "TE_FOOD" will allow your AI to treat "Beef" as food. So your AI now knows town "can" accept it (so your AI will search a station in a town to drop beef".
As another example : providing "Football supporters" with effect "TE_PASSENGERS", you're AI can send them in town or platform, but if you want make a town grow, better gives them to a town and not to a platform.
It's good to note that until we have "TE_DUMB" you cannot see any "PSG Fooball supporters" cargo.
look at http://wiki.openttd.org/Towns#Climate-R ... own_Growth
edit: seeing frosch comment, i see i gave you AI pov, and you were seeking GS, sorry

Last edited by krinn on 12 Nov 2013 15:01, edited 1 time in total.
Re: TownEffects
For scripts the relevant functions which deal with town effects are:
Sorry, if this is confusing you even more
- GS/AITown::GetLastMonthReceived
- GS/AITown::GetCargoGoal
- GSTown::SetCargoCoal
- GameScripts can set growth conditions depending on the amount of TownEffect being delivered.
- When not using GameScripts, the default arctic and tropic climate require food and water effects for growth.
- NewGRF define which cargos supply a certain TownEffect, which can include an efficiency-factor. (n units of cargo A may supply more of a town effect than n units of a different cargo B)
Sorry, if this is confusing you even more

⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: TownEffects
Thank you,
Statements :
S1: cargo can have zero to many town_effect.
S2: every cargo that can be delivered to a town have at least one town_effect.
S3: every cargo that have (at least one) town_effect can be delivered to a town.
S4: when a cargo is delivered to a town, the delivered quantity is splitted to each cargo town_effect
S5: town_effect is took into account for town growing process. For this, each town_effect have a factor. (F_TEpass, F_TEmail, F_TEgood,F_TEwater, F_TEfood)
S6: Factors and cargo acceptance can be changed by newGRF (like TTRS for example, that allow FOOD to be accepted by town)
S7: Cargo town_effect can be changed by newGRF (like FIRS for example, it changes GOOD town_effect to TE_Food and TE_Water only)
S8: in temperate (without any newGRF) town can only accept PASS, MAIL, GOOD and VALU cargo
S9: in temperate GOOD delivering does ont make town to grow. (I don't know for VALU)
S10: with statements S8+S9+S5 it imply that Factor F_TEgood=0 (in temperate mode, without any newGRF)
Now it brings to me one question :
Do we have an api (or another way) to get these in game towneffect factors ? (I mean the one modified by newGRF)
Let's check if I understood correctly, here are statments of what I understood. Please let me know if I'm wrong :frosch wrote:Sorry, if this is confusing you even more
Statements :
S1: cargo can have zero to many town_effect.
S2: every cargo that can be delivered to a town have at least one town_effect.
S3: every cargo that have (at least one) town_effect can be delivered to a town.
S4: when a cargo is delivered to a town, the delivered quantity is splitted to each cargo town_effect
S5: town_effect is took into account for town growing process. For this, each town_effect have a factor. (F_TEpass, F_TEmail, F_TEgood,F_TEwater, F_TEfood)
S6: Factors and cargo acceptance can be changed by newGRF (like TTRS for example, that allow FOOD to be accepted by town)
S7: Cargo town_effect can be changed by newGRF (like FIRS for example, it changes GOOD town_effect to TE_Food and TE_Water only)
S8: in temperate (without any newGRF) town can only accept PASS, MAIL, GOOD and VALU cargo
S9: in temperate GOOD delivering does ont make town to grow. (I don't know for VALU)
S10: with statements S8+S9+S5 it imply that Factor F_TEgood=0 (in temperate mode, without any newGRF)
Now it brings to me one question :
Do we have an api (or another way) to get these in game towneffect factors ? (I mean the one modified by newGRF)
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: TownEffects
A town is a rather abstract concept or a meta-object and cannot accept anything on its own. A town consists of houses and industries within its influence area. And it will note which cargos are accepted by each of the individual entities in its influence area. Each house and industry decides on its own what it accepts or not. And it will only report accepted quantities to the local authority (aka town) for statistics reasons.fabca2 wrote:Thank you,Let's check if I understood correctly, here are statments of what I understood. Please let me know if I'm wrong :frosch wrote:Sorry, if this is confusing you even more
Statements :
S1: cargo can have zero to many town_effect.
S2: every cargo that can be delivered to a town have at least one town_effect.
S3: every cargo that have (at least one) town_effect can be delivered to a town.
S4: when a cargo is delivered to a town, the delivered quantity is splitted to each cargo town_effect
S5: town_effect is took into account for town growing process. For this, each town_effect have a factor. (F_TEpass, F_TEmail, F_TEgood,F_TEwater, F_TEfood)
S6: Factors and cargo acceptance can be changed by newGRF (like TTRS for example, that allow FOOD to be accepted by town)
S7: Cargo town_effect can be changed by newGRF (like FIRS for example, it changes GOOD town_effect to TE_Food and TE_Water only)
S8: in temperate (without any newGRF) town can only accept PASS, MAIL, GOOD and VALU cargo
S9: in temperate GOOD delivering does ont make town to grow. (I don't know for VALU)
S10: with statements S8+S9+S5 it imply that Factor F_TEgood=0 (in temperate mode, without any newGRF)
Now it brings to me one question :
Do we have an api (or another way) to get these in game towneffect factors ? (I mean the one modified by newGRF)
S2 doesn't make sense as a town itself doesn't accept anything. A cargo can be accepted and have no effect other than giving you money. For instance coal.
S3 is undetermined. It requires a house or industry accepting the cargo which is not necessarily guaranteed
S8 doesn't make sense for the same reason as S2 but isn't wrong either. Those are the goods accepted by town houses and town industries (banks) in temperate climate w/o any NewGRFs.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: TownEffects
A cargo can have zero or one town effect.fabca2 wrote:S1: cargo can have zero to many town_effect.
Cargos with and without town effect can be delivered to both industries or houses. There are no implications between any of these properties.S2: every cargo that can be delivered to a town have at least one town_effect.
Delivering to a town means delivering to a house or a industry of that town. This is the case for all cargos.S3: every cargo that have (at least one) town_effect can be delivered to a town.
Yes. TownEffectAmount = sum_{cargo} EffectFactor_{cargo} * CargoAmount_{cargo}S4: when a cargo is delivered to a town, the delivered quantity is splitted to each cargo town_effect
Usually the amount delivered does not affect the speed of growth. Only whether the town growth.S5: town_effect is took into account for town growing process. For this, each town_effect have a factor. (F_TEpass, F_TEmail, F_TEgood,F_TEwater, F_TEfood)
GameScripts may set certain monthly amounts as precondition for growth. For default climates without GameScript this amount is 1 per month.
Yes. But industry acceptance also counts.S6: Factors and cargo acceptance can be changed by newGRF (like TTRS for example, that allow FOOD to be accepted by town)
Yes.S7: Cargo town_effect can be changed by newGRF (like FIRS for example, it changes GOOD town_effect to TE_Food and TE_Water only)
VALU has no town effect by default.S8: in temperate (without any newGRF) town can only accept PASS, MAIL, GOOD and VALU cargo
In temperate no cargos are required for town growth. Cargos have town effects, but the town effects have no effect on the town by default. These restrictions only exist in arctic above snowline, and in tropic desert, or when using a GameScript.S9: in temperate GOOD delivering does ont make town to grow. (I don't know for VALU)
Do we have an api (or another way) to get these in game towneffect factors ? (I mean the one modified by newGRF)
- AI/GSTownEffectList gives you a list of all potentially existing town effect (which is a superset of the town effects that actually exist).
- AI/GSCargo::GetTownEffect tells you the town effect a cargo has, resp. whether it has any.
- AI/GSTown::GetCargoGoal tells you how much of a certain town effect is required for growth.
- There is currently no API to tell you how much town effect a certain cargo actually supplies. So, you only have a qualitative information, no quantity.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: TownEffects
You can determine a list of all cargos X1..Xn that supply cargo effect Y. You can then use GSCargoMonitor to detect how much cargo supply there is for cargo X1..Xn if you for any reason need to detect the supply of cargo for some town effect. However, you still need to have your own idea on how much each town effect should affect the town.
Usually, if you only want "deliver at least Z of some cargo effect" to grow town, a GS will not need to track the delivery amounts. Only use the GS API to set the growth limits. However, if you want to implement stock piles etc. then you will need track delivery using GSCargoMonitor.
Usually, if you only want "deliver at least Z of some cargo effect" to grow town, a GS will not need to track the delivery amounts. Only use the GS API to set the growth limits. However, if you want to implement stock piles etc. then you will need track delivery using GSCargoMonitor.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: TownEffects
Thank you,
That's incredible to see how far from reality I was !
It makes about 9 years I play ottd... and most of my statements were wrong !
I feel ashamed
in fact, this returns the amount of cargo delivered to houses and industries within influence area of the town.
In fact I want to handle myself (maybe stockpiling...), and then I use GSCargoMonitor. But I've doubt about how to correctly make town growing,
shall I use GSTown.SetGrowthRate or GSTown.ExpandTown ?
I started to use GSTown.SetGrowthRate with a number of days (for example 10), but then when I need to stop growing, I tried value 365 * 1000 as I could see in other scripts, but it remains "every 10 days" instead of "not growing".
Do you have a link that explain best practices for script-driven town growing ?
wow, I got 3 ottd dev replies in a raw !
by the way : thank you for what you do on that game !
edit : removed stupid question
That's incredible to see how far from reality I was !
It makes about 9 years I play ottd... and most of my statements were wrong !
I feel ashamed

That was one of the base of my mistake, thank you !frosch wrote:A cargo can have zero or one town effect.fabca2 wrote:S1: cargo can have zero to many town_effect.
But when I play (temperate without any newgrf) I can see "town is growing every 15 days" and later "every 7 days" and then "every 5 days" while delivering more and more passengers. that's what I felt. that's what I called the speed of growth, it's maybe inappropriate.frosch wrote:Usually the amount delivered does not affect the speed of growth. Only whether the town growth.
GameScripts may set certain monthly amounts as precondition for growth. For default climates without GameScript this amount is 1 per month.
That's right, I was fooled by the name of the function I use to monitor cargo delivering :planetmaker wrote:A town is a rather abstract concept or a meta-object and cannot accept anything on its own. A town consists of houses and industries within its influence area.
Code: Select all
GSCargoMonitor.GetTownDeliveryAmount(company_id, cargo_id, town_id, true);
Yes, and I tried already to use Goals, which is very nice (because it take into account displaying of the goal progress in town windows), but it was for testing purpose.Zuu wrote:Only use the GS API to set the growth limits.
In fact I want to handle myself (maybe stockpiling...), and then I use GSCargoMonitor. But I've doubt about how to correctly make town growing,
shall I use GSTown.SetGrowthRate or GSTown.ExpandTown ?
I started to use GSTown.SetGrowthRate with a number of days (for example 10), but then when I need to stop growing, I tried value 365 * 1000 as I could see in other scripts, but it remains "every 10 days" instead of "not growing".
Do you have a link that explain best practices for script-driven town growing ?
wow, I got 3 ottd dev replies in a raw !
by the way : thank you for what you do on that game !
edit : removed stupid question
Last edited by fabca2 on 14 Nov 2013 06:36, edited 1 time in total.
Re: TownEffects
365 * 1000 = 365 000, which overflows the maximum. In the API docs there is now a documented max value of 30 000 days.
If you got the 365 000 value from Neighbours are important, that is an error in my script that frosch noticed and will be corrected in its next release.
If you want to support both 1.3 and trunk, use 30 000 days as 'infinity', that is 8 years. Or, if you only care about trunk, use the new special value for infinity GSTown.TOWN_GROWTH_NONE. Or use TOWN_GROWTH_NONE when available:
If you got the 365 000 value from Neighbours are important, that is an error in my script that frosch noticed and will be corrected in its next release.
If you want to support both 1.3 and trunk, use 30 000 days as 'infinity', that is 8 years. Or, if you only care about trunk, use the new special value for infinity GSTown.TOWN_GROWTH_NONE. Or use TOWN_GROWTH_NONE when available:
Code: Select all
local infinity = "TOWN_GROWTH_NONE" in GSTown ? GSTown.TOWN_GROWTH_NONE : 30000;
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: TownEffects
you rocks !
thanks.
thanks.
Who is online
Users browsing this forum: No registered users and 19 guests