Page 1 of 7

Improved Town Industries

Posted: 16 Jul 2020 03:48
by 2TallTyler
recycling_center.PNG
recycling_center.PNG (878.15 KiB) Viewed 99859 times
Improved Town Layouts now has a little brother available on BaNaNaS, this time adding new behaviors to vanilla-inspired industries!

Improved Town Industries

Features
  • Simple cargos accepted by multiple industries, designed for asymmetric Cargodist
  • Processing industries spawn near towns
  • Most industries accept and create passengers as workers
  • Industries have realistic invention dates for gameplay as early as 1700
  • Adds Waste & Recycling chain (requires Improved Town Layouts)
  • Adds Nuclear Energy Chain (optional)
  • Includes object tiles for visually expanding industries
Notes
  • Designed for Temperate climate only
  • Uses only base game sprites, so visually compatible with any base graphics set including original TTD, OpenGFX, aBase, zBase, and NightGFX.
  • Requires OpenTTD version 1.10.0, JGR version 0.34, or better.
  • Requires NewGRF vehicles which support additional cargos
You can see the industry and cargo chart and read the full list of features here, check out the changelog, or adapt my code for your project via GitHub.

Please let me know any suggestions or bugs in this thread. :)

Re: Improved Town Industries

Posted: 16 Jul 2020 07:46
by mak
Tried starting new games in 1920,1930, 1940, 1950. with no other GRF's than this one (after trying with my normal collection) and cannot get Coal Mines to appear.
Do get 'flag' at the beginning saying no suitable sites.
Running JGR 0.35.0

Re: Improved Town Industries

Posted: 16 Jul 2020 13:07
by 2TallTyler
Is your world extremely flat? Coal mines must be built at elevation 4 or higher. If that’s the case I may need to add a parameter to disable the requirement, otherwise something else could be wrong.

Re: Improved Town Industries

Posted: 16 Jul 2020 13:34
by madrito
Great parts :bow:
Not much is grf with application of the base graphics

Re: Improved Town Industries

Posted: 16 Jul 2020 13:37
by mak
2TallTyler wrote: 16 Jul 2020 13:07 Is your world extremely flat? Coal mines must be built at elevation 2 or higher. If that’s the case I may need to add a parameter to disable the requirement, otherwise something else could be wrong.
Yes, changed to flat and all is well. Thank you

Re: Improved Town Industries

Posted: 16 Jul 2020 13:38
by madrito
Sorry for the English as if what :mrgreen:

Re: Improved Town Industries

Posted: 16 Jul 2020 16:52
by 2TallTyler
Time to fix some embarrassing bugs caused by my woefully inadequate pre-launch testing! Thanks to James103 on GitHub for the descriptive bug reports.

1.0.1 is now live on BaNaNaS.
  • Add: Parameter to enable elevation requirements for Coal Mine, Farm, and Oil Wells (fixes #1)
  • Change: Use Default TTD strings for industry names where possible to utilize base game translations. Exceptions:
    • Nearby station names must use literal strings
    • Power Plant and Logging Camp strings don't exist in OpenTTD (they are called "Power Station" and "Lumber Mill")
  • Fix: Industries can be funded as intended (fixes #3)
  • Fix: Remove industry limit when using funding "Many random industries" in Scenario Editor (fixes #3)
  • Fix: Secondary industries can be funded when "Generate primary only" parameter is enabled (fixes #4)
  • Fix: Oil Refinery no longer needs to be near water when funding "Many random industries" in Scenario Editor
And a quick addition in 1.0.2, hopefully the last for a while.
  • Add: Parameter to require oil refineries to generate near water

Re: Improved Town Industries

Posted: 16 Jul 2020 23:58
by Zydlar
Hey,

Thanks for this grf. Have been playing it for the past day. What great time for me to reinstall OpenTTD and get back into it :D.

The first map I generated (start 1850) I had no issues with it, but since trying to start a map post 1900, I am getting a similar error to the poster above me except with Power Plants, indicating there is no suitable places for them.

I have tried playing with my map parameters but can find no combination that works (other than changing the date back). Are you able to shed some light on what requirements the Power Plants have for generation.

Many Thanks,

Re: Improved Town Industries

Posted: 17 Jul 2020 02:55
by 2TallTyler
Power Plants are introduced in 1882 and need a town of population 500 or greater. Are you using a house replacement set? I have no trouble with town populations using either default houses or Improved Town Layouts, but if you're having trouble with another I can find a solution.

Re: Improved Town Industries

Posted: 17 Jul 2020 11:56
by Zydlar
Thanks for the response..... sooooo after looking through the advanced settings I found that I had the setting number of towns to cities set to 0 instead of the default 1 in 4.

This meant that the map was generating with no towns/cities above 500 pop and causing the error.

Thanks for helping resolve this!

Re: Improved Town Industries

Posted: 18 Jul 2020 20:35
by Tsylatac
The "Food Destination" setting doesn't behave as expected (or at least, as I expected :P ). When set to "Processed to Goods at Factory" the Farm still only produces Food. The setting adds the Factory as a destination, but Food can still be delivered to houses that accept it. It looks like Grain and Livestock are still included (they show up under Industry Chains and Cargo Payment Rates), but they aren't produced or accepted anywhere. (I get that this is necessary pre-1850 when there are no Factories, I just expected all 3 cargos to be produced - grain and livestock needing processing, fruits and veggies as "Food" ready for the market.) Valuables are similarly listed despite there being no Banks.

Other than that, I'm looking forward to playing around with this and Improved Town Layouts :D

Re: Improved Town Industries

Posted: 18 Jul 2020 22:15
by 2TallTyler
Tsylatac wrote: 18 Jul 2020 20:35 The "Food Destination" setting doesn't behave as expected (or at least, as I expected :P ). When set to "Processed to Goods at Factory" the Farm still only produces Food. The setting adds the Factory as a destination, but Food can still be delivered to houses that accept it.
This is working as designed, but I designed it poorly. :)

In keeping with the (somewhat experimental) philosophy* of using generic cargos routed by Cargodist to generic industries, rather than specific cargos routed to a corresponding industry, the next update will remove this setting and Factories will always accept Food. If a house set also accepts Food, great. This matches your example of grain and livestock needing processing while fruit and veggies are delivered directly to markets.

*(For example, Chemicals produced by the Oil Refinery can go to the Factory as plastic or the Paper Mill as the various industrial chemicals used to break down wood pulp. I'm also considering adding Chemicals acceptance to Farms as fertilizer.)
Tsylatac wrote: 18 Jul 2020 20:35 It looks like Grain and Livestock are still included (they show up under Industry Chains and Cargo Payment Rates), but they aren't produced or accepted anywhere. Valuables are similarly listed despite there being no Banks.
Yep, that's a bug. I didn't think to disable the base game cargos which aren't in use, forgetting that they'd still show up in the UI. I will fix this in the next update.

Thanks for the comments! Feedback like this is very useful for refining ideas and solutions. :)

Re: Improved Town Industries

Posted: 19 Jul 2020 00:07
by 2TallTyler
I've done some cleanup and minor changes for 1.1.0. Not savegame-compatible due to removing parameters, but there's no pressing need to upgrade.
  • Add: Farms accept Chemicals as fertilizer
  • Add: Loading ITI on a map smaller than 256x256 now gives a fatal error rather than breaking without notice, since industries won't generate below this size
  • Change: Factory always accepts Food
  • Change: Rewrite parameter description for elevation requirement
  • Fix: Disable all default cargos and define from scratch
  • Remove: Parameter to change Factory acceptance of Food. Factory now always accepts Food.
  • Remove: Parameter to disable extractive industry clustering
    • Map size check already handles this well; no need for confusion
  • Remove: Parameter to require oil refineries to generate near water
    • Simplification of an unneccesary parameter. This requirement is already disabled in Scenario Editor and funded industries, so its only use is for industries created during world generation or during a game.

Re: Improved Town Industries

Posted: 19 Jul 2020 20:31
by 2TallTyler
Never again will I complain about games released with silly bugs and fixed later. :twisted:

1.2.0
  • Fix: Override special flags for Oil Wells to allow production increases and build past 1950
  • Fix: Redefine cargo IDs for proper ordering in the Cargo Flow Legend
  • Fix: "Map too small" error triggers properly on rectangular maps
Not savegame compatible due to the cargo ID re-sort.

Re: Improved Town Industries

Posted: 20 Jul 2020 04:09
by Captain_Pronin
Do the industries change appearance with time period, is that a programmable behavior for a newgrf?

Re: Improved Town Industries

Posted: 20 Jul 2020 04:50
by 2TallTyler
Captain_Pronin wrote: 20 Jul 2020 04:09 Do the industries change appearance with time period, is that a programmable behavior for a newgrf?
No, not in this set. Coding this is technically possible (my initial idea would be to use sprite animations) but the base graphics set doesn't include enough sprites to make any meaningful changes over time. The only exception is the Power Plant, which is introduced in 1882 and includes several tile layouts for variety*. Of these, it won't use layouts which include a hyperboloid cooling tower before said tower was patented in 1918.

Here are the industry invention dates:
  • Always: Farm, Coal Mine, Logging Camp
  • 1800: Factory
  • 1856: Iron Mine and Steel Mill
  • 1882: Power Plant
  • 1885: Paper Mill
  • 1900: Oil Wells and Oil Refinery
* Speaking of variety, I never got around to adding alternate tile layouts for the Coal Mine, Logging Camp, Oil Refinery, Paper Mill, or Steel Mill. The industry set includes decorative objects for most of the tiles, so if anyone wants to mock up some alternate designs and post screenshots, I'd appreciate any design ideas!

Re: Improved Town Industries

Posted: 20 Jul 2020 08:29
by Limyx826
I'm thinking forking 600mm narrow gauge to match this NewGRF but this is the first time I'm doing something of this so help please?

Re: Improved Town Industries

Posted: 20 Jul 2020 12:56
by supermop
Not sure if this is a known issue, but i started a game to test this out, and 3-years in, i still have zero industries:
No industry.PNG
(81.65 KiB) Not downloaded yet

Re: Improved Town Industries

Posted: 20 Jul 2020 16:21
by 2TallTyler
Limyx826 wrote: 20 Jul 2020 08:29 I'm thinking forking 600mm narrow gauge to match this NewGRF but this is the first time I'm doing something of this so help please?
I don't understand what you mean. That train set should be fully compatible and able to carry all the cargos used by this industry set. Or did you mean something else?
supermop wrote: 20 Jul 2020 12:56 Not sure if this is a known issue, but i started a game to test this out, and 3-years in, i still have zero industries:
I can't find some of the NewGRFs in that save to test it myself, but is that a 128x512 map? Unfortunately, industries don't currently generate when either side of the map is less than 256. In 1.2.0 I've added an error that tells you this when generating a map which is too small.

The reason for this is code which manually selects the number of industries of each type, scaled to a "normal" 256x256 map. This is necessary to introduce industries over time, since the game tries to maintain a certain number of industries based on the selected industry density and map size, and will fill the map with whatever is available, leaving no allowance for industries which haven't been invented yet.

That said, I don't understand why this limitation exists, since 0 should always be less than whatever decimal is calculated by the algorithm. Here's the relevant code. Does anyone know if NML switch code rejects decimal numbers?

Code: Select all

/*	Slot Reservations - all industries */

// Compare how many industries are currently on the map with the target number, scaled to the map size from a "normal" 256 x 256 map. If less than the target number, proceed to town distance checks, otherwise disallow construction.
switch (FEAT_INDUSTRIES, SELF, switch_oil_wells_density_high,
	industry_count(industry_oil_wells, -1) < 12 * (map_x_edge / 256) * (map_y_edge / 256)) 
	{1: switch_oil_wells_location_check_1; return CB_RESULT_LOCATION_DISALLOW;}

switch (FEAT_INDUSTRIES, SELF, switch_oil_wells_density_normal,
	industry_count(industry_oil_wells, -1) < 8 * (map_x_edge / 256) * (map_y_edge / 256)) 
	{1: switch_oil_wells_location_check_1; return CB_RESULT_LOCATION_DISALLOW;}

switch (FEAT_INDUSTRIES, SELF, switch_oil_wells_density_low,
	industry_count(industry_oil_wells, -1) < 4 * (map_x_edge / 256) * (map_y_edge / 256)) 
	{1: switch_oil_wells_location_check_1; return CB_RESULT_LOCATION_DISALLOW;}

switch (FEAT_INDUSTRIES, SELF, switch_oil_wells_density_verylow,
	industry_count(industry_oil_wells, -1) < 1 * (map_x_edge / 256) * (map_y_edge / 256)) 
	{1: switch_oil_wells_location_check_1; return CB_RESULT_LOCATION_DISALLOW;}

// Get the selected industry density from parameter and redirect to the appropriate switch
switch (FEAT_INDUSTRIES, SELF, switch_oil_wells_density_selector, param_industry_density) {
	0: switch_oil_wells_density_verylow;
	1: switch_oil_wells_density_low;
	2: switch_oil_wells_density_normal;
	3: switch_oil_wells_density_high;
}

/*
Industry Totals on 256 x 256 map:

	Industry		Very Low (10)			Low (25)		Normal (55)			High (80)
	Oil Wells		1				4			8				12
	Farm			1				5			12				12
	Lumber Camp		1				3			8				12
	Coal Mine		1				3			6				12
	Iron Mine		1				3			6				12
	Steel Mill		1				1			2				3
	Factory			1				3			6				7
	Paper Mill		1				1			2				3
	Oil Refinery		1				1			2				3
	Power Plant		1				1			3				4

*/

Re: Improved Town Industries

Posted: 21 Jul 2020 09:14
by Limyx826
2TallTyler wrote: 20 Jul 2020 16:21 I don't understand what you mean. That train set should be fully compatible and able to carry all the cargos used by this industry set. Or did you mean something else?
True the train set is fully compatible, just the introduction date just a bit too late for 1700 play. If you start at 1700, there are no trailer that able to carry any of the goods at the time.