Transport Fever 2

Transport Fever 2

Create your own game world!
Give your game a personal touch and change it to your liking. Create, share and install mods. Customize the game with new landscapes, vehicles, stations, assets and more.
phobos2077 7 16 May, 2022 @ 8:10am
Analysis of new game.config.economy.industryDevelopment
So I did some testing in order to find how I can use these engine features for desired effect for my next game.

Let's start with the target density settings:
game.config.locations = { town = { maxNumberPerArea = 0.2, -- km^(-2) allowInRoughTerrain = false }, industry = { absoluteMinimum = 5, maxNumberPerArea = 0.8, -- km^(-2) targetMaxNumberPerArea = 0.8, -- km^(-2) }, makeInitialStreets = true -- default true, false experimental }

maxNumberPerArea seems to be applied when generating map. So a mod changing this in runFn can possibly allow to have densities beyond what map generation settings allow (e.g. density lower than Low).

targetMaxNumberPerArea control target for spawning of new industries. So if it's value is higher than maxNumberPerArea at the start of the game, industries will try to spawn immediately.


game.config.economy = { industryDevelopment = { spawnTargetTimeSpan = 50 * 365.25 * 2000, spawnProbabilityExponent = 3.0, spawnIndustries = false, closureCountdownTimeSpan = 730.5 * 2000, closureProbability = 1, }, townDevelopment = { cargoNeedsPerTown = 2, } }

spawnTargetTimeSpan - this seems to be the expected timespan in calendar-agnostic years (I will refer to it as game years) when the target density of industries is reached

spawnProbabilityExponent - this I haven't figured out yet. From the name I can speculate that there's a non-linear function of spawn probability that depends on how far is current density from the target density, and this exponent probably controls the curvature of this function.

spawnIndustries - this is self-explanatory

closureCountdownTimeSpan - also self-explanatory, this controls the countdown timer you see over expiring industry

closureProbability - this one is interesting. In advanced settings, highest value ("Very Often") corresponds to 4. But that does it mean? 4% of what? So I tested a bunch of values and it seems like it can go as far as 1000%. At these values you'll see industries closing on mass.


Important observations:
- Industry spawn starts immediately when you start a game (if starting density is lower than target density).
- Industry closure starts exactly 10 game years from game start. This is weird. I couldn't find any way to configure this delay.
< >
Showing 1-5 of 5 comments
matthias.guertler  [developer] 5 16 May, 2022 @ 8:38am 
Your observations and descriptions sound fine. A very short summary is included in the wiki too:
https://www.transportfever2.com/wiki/doku.php?id=modding:baseconfig

- spawnProbabilityExponent: Indeed it is a non linear function for the spawn propability and this property is the exponent.

- closureProbability: It is a non-unit factor in the calculation of the closure propability.

The industry closure starting 10 (calendar speed 1) years after game start is a side effect of the rule that an industry is considered as abandoned when there was no interaction for the last 10 years. If the game has just started, the difference is smaller than 10 years. Consider it as some kind of spawn protection :D
phobos2077 7 16 May, 2022 @ 8:57am 
Originally posted by matthias.guertler:
Your observations and descriptions sound fine. A very short summary is included in the wiki too:
https://www.transportfever2.com/wiki/doku.php?id=modding:baseconfig

- spawnProbabilityExponent: Indeed it is a non linear function for the spawn propability and this property is the exponent.

- closureProbability: It is a non-unit factor in the calculation of the closure propability.

The industry closure starting 10 (calendar speed 1) years after game start is a side effect of the rule that an industry is considered as abandoned when there was no interaction for the last 10 years. If the game has just started, the difference is smaller than 10 years. Consider it as some kind of spawn protection :D

Wow, thanks. I forgot to check for wiki. Good job keeping the docs updated, it's very useful for modders!

However, it seems this feature is implemented completely in-engine and there's no way to interact with it from scripts as far as I can see. So I can't check for industry "closure progress" nor initiate or stop closure manually (maybe game.interface.upgradeConstruction will stop it?).

I'm thinking about implementing an alternative closure/spawn system as a mod, and having ability to reuse some parts of base system would help. Such as displaying progress bar above industries, showing warning in Industry Statistics window and Industry window and connecting industries (there is a "connectTownsAndIndustries" command but I'm not sure it can connect individual industries, need to test).

It's not a deal breaker though, as long as I can completely disable this mechanic and replace with a scripted one.
matthias.guertler  [developer] 5 16 May, 2022 @ 9:08am 
Thanks for the heads up, indeed the current status regarding closure of industry is not fetchable from the scripting api at the moment. I took a note regarding that issue.
phobos2077 7 16 May, 2022 @ 9:27am 
Originally posted by matthias.guertler:
Thanks for the heads up, indeed the current status regarding closure of industry is not fetchable from the scripting api at the moment. I took a note regarding that issue.

Can I kindly ask to take a look at this thread: https://steamhost.cn/steamcommunity_com/groups/transportfever2_mac_vulkan/discussions/2/3266807987611732916/

One of the most important things missing from modding API is the ability to override ticket price calculation. I see many veteran players talk about it when discussing economy modding.

In the perfect world, I would liked to see modding API being expanded to allow to modify as much as possible during the game, including resources (api.res.***) data, entity component data, etc. But I understand it's a lot of extra work. But there are some small things than can open big possibilities for modding. Ticket prices, I believe, is one of such things. Another is allowing to override industries shipping amounts. This would open road to AI competition and station rating system similar to Transport Tycoon series.
phobos2077 7 16 May, 2022 @ 1:38pm 
Some more observations:

- If you disable industry spawning and set closureProbability high enough, at some point you WILL end up with no industries on the map! (except player-owned)

- Industry spawn takes into account which industries are already on the map. So if you place enough forests (for example) then additional forests will never spawn. There seems to be some kind of algorithm that calculates relative % of every type of industry that has to be present on the map. All types of industries spawn with this target percentage in mind. The total target number of industries is based on target density per sq. km as specified in game config.
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: 16 May, 2022 @ 8:10am
Posts: 5