Transport Fever 2

Transport Fever 2

Yeol's Senseless Industries 2.21a
phobos2077 16 May, 2022 @ 6:06am
Industry placement and dynamic opening/closure (Mod Idea)
I'm thinking about doing another play-through this time with a more complex industry mod. This seems like almost perfect with it's concept of eras (I don't understand why they didn't do them in the base game, if we have so many difference in vehicles and visual assets over the years).

But after previous games I came to realize I want my primary industries (such as mines and farms) to not be randomly sprinkled across the map, but be placed logically and with different "regions" to make map more thematically diverse. Now I've looked into how terrain generators work and they only allow to customize the heightmap generation and assets, not towns and industries (which seem to be hard-coded into the engine). This only leaves the option of manually (or semi-manually) creating a map of desired shape with distinct regions and placing towns and industries to make sense thematically. This is a lot of work to set up a game, but I don't know any better way...

So what this has to do with industry mods? Well, because this mod has different industries in different eras, you can't just place everything beforehand. Also this will conflict with the new dynamic closure/opening of industries from Spring Update, as the game's industry placement algorithm will ignore any "regional" logic and just place them all over the map again.

My idea how to possible solve this:

1. Prepare a map and manually place every industry of every era in high numbers (like 3-times more than you need to have 100% supply).
2. At game start, have a script that will remember locations of every industry that was placed (in the mod persistent data), then delete like 70% of them.
3. Industry closure from Spring Update will have to be disabled (or only spawning disabled, but keep closure), but instead implemented in script. So that new industries will only spawn in logical locations (from the initial list of positions). Having this done by script also allows to have "rush" periods when new eras start so that new industries appear more rapidly.

Of course this is just a draft idea and can be refined further. For example, I think allowing player to place his own industries is logical (as long as their costs aren't too low), but this should be limited to secondary industries only. Or the locations of primary industries should be restricted to certain zones manually placed when creating map.

If the idea is solid and I find an easy way to implement it, I may be able to do it as separate mod that will work with base game as well as Senseless Industries.

What do you think?
Last edited by phobos2077; 16 May, 2022 @ 6:10am
< >
Showing 1-15 of 16 comments
GordonDry 16 May, 2022 @ 6:49am 
Just my two cents - what is missing in the game core for a better implementation of that feature:
About 2 years ago or so I opened a "feature request" to the UG devs anywhere - could have been here on Steam or on transportfever.net - that the map generator could have underground resource areas like many other games also have - for decades.
Those may be paintable with a brush.
This would mean not everywhere is coal, or iron ore, or even stone.
A mod dev could add more areas, like clay, limestone etc.

If this would exist, the map generator could/should only place a coal mine where coal is etc.
This way the cluttering of industries at absurd places would stop.

And the player should have to look where a coal mine could be placed - even without sending out geologists like in "Settlers" :steammocking:
Last edited by GordonDry; 16 May, 2022 @ 6:49am
phobos2077 16 May, 2022 @ 6:56am 
Resource areas are absolutely possible to implement via mod. Just not with game-generated maps. There's a cool feature in Map Editor - you can generate map without towns and industries (only terrain and assets). That's what I'm planning to use. Then a special "resource zone" asset could be placed that would allow to build given type of industry only in this area (you can restrict building to zones no problem). This same zone could be used in custom industry placement script.
GordonDry 16 May, 2022 @ 7:02am 
Nice.
As you're already here, @phobos2077:
I have another thing that I "demanded" from UG some time ago - a better terrain paint brush filter.
Actually brushes are only to be filtered by slope, positive or negative logic.
What is missing badly is a filter by altitude, simply as that.

It is such a boring and dumb work to paint mountain tops properly.

Is a filter like this also possible with modding?
Last edited by GordonDry; 16 May, 2022 @ 7:03am
phobos2077 16 May, 2022 @ 8:18am 
Originally posted by GordonDry:
a better terrain paint brush filter.
I don't know, you can study game resources to see if this is something that's Lua-configurable.

Regarding built-in industry opening/closure, also see this analysis: https://steamhost.cn/steamcommunity_com/workshop/discussions/18446744073709551615/4997318143963632130/?appid=1066780
Last edited by phobos2077; 16 May, 2022 @ 8:18am
Yeol  [developer] 16 May, 2022 @ 9:02am 
About pre-placements of industries, PMV has solved this in a particular way. It might interest you to check it out.

https://www.transportfever.net/index.php?thread/14523-logistische-herausforderung-logistic-challenge/&postID=374282#post374282
Last edited by Yeol; 16 May, 2022 @ 9:03am
phobos2077 16 May, 2022 @ 9:50am 
Originally posted by Yeol:
About pre-placements of industries, PMV has solved this in a particular way. It might interest you to check it out.

https://www.transportfever.net/index.php?thread/14523-logistische-herausforderung-logistic-challenge/&postID=374282#post374282

My idea is much smaller in scope. I just want to solve one issue of more "lore-friendly" and varied placement of industries when using industry spawn/closure.

Additional optional goals for the mod:

- Dynamically spawn/close towns. I want to enhance the feeling of industrialization and growth over the decades. Starting with small number of towns that you can realistically connect in early game, then remove cities that you neglected and add more.

- Make industry spawn/closure more dynamic. When new era is arrived, make sure these new industries are spawned faster. Historically, when new big industry is invented, it expands very quickly to the point of bubble, then collapses back into it's balanced state.

- (optionally) Add challenge to player by sometimes closing even connected industries or disrupting output, etc.

Overall by having complete control over how, when and where industries are spawned you can make gameplay more varied.

I'm not yet sure if I would do it as an addon for Senseless Industries (since it introduces industry eras), or make it vanilla-compatible.
Yeol  [developer] 16 May, 2022 @ 11:40am 
You are free to use parts or the whole of Senseless Industries to make something better/bigger. If you succeed, we all win. I made Senseless Industries, because I totally dislike the puzzle game concept the developers made of the industries. It was a big step backwards from TpF1. So, Senseless is at your disposal in whatever way you like, to make something better. I do not have the knowledge or skills to do it.
phobos2077 16 May, 2022 @ 11:49am 
Originally posted by Yeol:
You are free to use parts or the whole of Senseless Industries to make something better/bigger. If you succeed, we all win. I made Senseless Industries, because I totally dislike the puzzle game concept the developers made of the industries. It was a big step backwards from TpF1. So, Senseless is at your disposal in whatever way you like, to make something better. I do not have the knowledge or skills to do it.

Exactly the kind of attitude I like and try to follow myself in regards to modding! Thanks.

Btw, just tested your mod with above-maximum chances of industry closures - I think it can actually make your mod better because of new industries will appear with higher chance. So a tiny mod that can partially achieve the goal of more rapid industry era change. If only you could dynamically change game config parameters...
phobos2077 21 May, 2022 @ 8:14am 
Made this little mod that can be used with Senseless Industries as a crude way to speed up industry era transitions by increasing spawning/closure rates. Industries will still close indiscriminately so you'll get a lot of annoying notifications... Also it will be harder to plan ahead. So this is a hack at best.

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2810826371
phobos2077 23 May, 2022 @ 9:06am 
So I tested some stuff and so far it seems what I want to implement is possible:

- Industries created via BuildProposal command work just like game-spawned industries. They can be connected to cities via ConnectTownsAndIndustries command. They can be removed via built-in industry closure (along with roads connecting them to towns).

- I could also remove industries no problem via the same command. The only problem is that in this case roads connecting industry to the city will remain. This can probably be addressed with more code, but it's extra work.

- I could create a custom notification window with any content. The only issue so far is that I couldn't find how to interact with built-in Popup Manager so that custom notifications stack properly with built-in notifications.

- I can draw polygon zones for player (circles) and prevent him from building certain industries at certain zones.


So what remains to do:

- Create a custom "industry zone" construction that can be placed during map creation with a parameter to specify category and radius.

- Distribute all industries between these categories (like separate category for every type of ore, one for all farms, one for all processing industries, one for distribution centers to make sure they're closer to towns)

- Write script that will partly replicate built-in industry spawn logic: calculate the target number of industries total and per type (according to placementParams), get all existing industries, find an industry type that's lacking the most, then take all "zone" constructions of compatible category and try to place a new industry inside it's radius.

- Create custom notification that new industry is available and try to integrate it with built-in notifications.

- Test it. Figure out if it will perform on maps with lots of industries (especially road connections). Figure out if I can use built-in industry closure logic or replace it as well.
Last edited by phobos2077; 23 May, 2022 @ 9:20am
phobos2077 26 May, 2022 @ 7:15am 
I have some good news. It took a bit of work but the main feature I wanted (industry clusters) seems to be working, even better than I hoped:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918376
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918333
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918345
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812920531

Industry clusters are special type of industry that you place in map editor (or during game) that doesn't do anything on it's own, but you can set a radius and category of industries to spawn inside it.

Once in a while, a script will find all industries and clusters on map. Then try to replicate vanilla industry distribution like this:

1. Calculate total desired number of industries by multiplying terrain size in square km to industry density target set in basic game settings.
2. Using placementParams.initWeight of industries, calculate target number of every industry and difference to target (how much industries of this type are missing).
3. Industry types with highest difference are selected first, then one with the lowest buildOrder is selected to spawn next.

Industries are names similarly to vanilla - closest town is found and multiple industries of the same type will be denoted with a number.

Now the best part - it seems if you set game.config.economy.industryDevelopment.spawnIndustries to true, then creating industry via scripts for some weird reason shows "Industry founded" notification! Seems like some code gets confused and thinks it was spawned by the game. Unexpected but very desirable behavior!!! (I set probability exponent to 0, and hope that the built-in spawn will never happen)

Finally, I call connectTownsAndIndustries on the closest town and it seems to work most of the time connecting the industry just like the built-in spawning would do.

That is the minimum viable mod that I wanted in the beginning. I'd use the built-in industry closure for now, maybe it will be enough. Considering how spawn logic works, in case of Senseless, new era industries should spawn very quickly as target year is reached - as soon as some industry is closed.

I think I might post this as an experimental mod after some polishing.
GordonDry 26 May, 2022 @ 12:09pm 
Sounds good.
Can a script get the slope and altitude values within an area to avoid building at the steepest spot? Perhaps only in map editor and create a blacklist of coordinates within an area for later use?
phobos2077 26 May, 2022 @ 12:59pm 
Originally posted by GordonDry:
Sounds good.
Can a script get the slope and altitude values within an area to avoid building at the steepest spot? Perhaps only in map editor and create a blacklist of coordinates within an area for later use?

Yes, and it's already done, but in a very simple way. I take 5 points (center and 4 corners of box with a diagonal of 300m) and check the difference between lowest and highest points. Seems to work.

The only problem is if you place clusters of a certain category covering mountains or water, you can get in situation where the script can't spawn any industry of this type and will get stuck. (it selects a random point and checks if it's valid, and has 10 attempts to do so before failing). Shouldn't be an issue though if you place enough clusters on the map, so that's up to the player (map creator).
Last edited by phobos2077; 26 May, 2022 @ 1:00pm
Piranha 16 Oct, 2024 @ 2:14am 
Originally posted by phobos2077:
I have some good news. It took a bit of work but the main feature I wanted (industry clusters) seems to be working, even better than I hoped:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918376
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918333
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812918345
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2812920531

Industry clusters are special type of industry that you place in map editor (or during game) that doesn't do anything on it's own, but you can set a radius and category of industries to spawn inside it.

Once in a while, a script will find all industries and clusters on map. Then try to replicate vanilla industry distribution like this:

1. Calculate total desired number of industries by multiplying terrain size in square km to industry density target set in basic game settings.
2. Using placementParams.initWeight of industries, calculate target number of every industry and difference to target (how much industries of this type are missing).
3. Industry types with highest difference are selected first, then one with the lowest buildOrder is selected to spawn next.

Industries are names similarly to vanilla - closest town is found and multiple industries of the same type will be denoted with a number.

Now the best part - it seems if you set game.config.economy.industryDevelopment.spawnIndustries to true, then creating industry via scripts for some weird reason shows "Industry founded" notification! Seems like some code gets confused and thinks it was spawned by the game. Unexpected but very desirable behavior!!! (I set probability exponent to 0, and hope that the built-in spawn will never happen)

Finally, I call connectTownsAndIndustries on the closest town and it seems to work most of the time connecting the industry just like the built-in spawning would do.

That is the minimum viable mod that I wanted in the beginning. I'd use the built-in industry closure for now, maybe it will be enough. Considering how spawn logic works, in case of Senseless, new era industries should spawn very quickly as target year is reached - as soon as some industry is closed.

I think I might post this as an experimental mod after some polishing.
I looked at your workshop items and i couldn't find this mod. This looks excellent as I'm trying to find a mod that spawns manufactured goods industries in / very close to cities and not so far away without having to manually move everything
phobos2077 16 Oct, 2024 @ 2:31am 
My interest in the game dried up before I could finish this mod. Maybe I will revisit the idea later if no one beats me with another mod solving the same problem.
< >
Showing 1-15 of 16 comments
Per page: 1530 50