This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[Bug]: GS has no autonomous way to remove industries #10390
Labels
component: AI/Game script (squirrel)
This issue is related to Squirrel (Scripting language)
enhancement
Issue would be a good enhancement; we accept Pull Requests!
Version of OpenTTD
13-ish
Expected result
GS has one or more methods to remove an industry from the map, which are entirely within the control of the GS.
Actual result
There are multiple routes to remove industries, none are inherently reliable.
Use GSTile.DemolishTile()
See #10383 - this method can't remove industries currently, which is a bug. This issue might be resolve by resolving #10383.
DemolishTile() does work if the player has enabled magic bulldozer via the cheat menu. GS has no way to enable / disable cheats.
Side-channel signalling to grf industries
The GS can use GSIndustry.SetControlFlags() to signal intents to an industry. These can be interpreted by grf industries, and used to trigger the industry closure mechanism (via monthly industry callback 35).
Control flags are currently:
enum | IndustryControlFlags { INDCTL_NO_PRODUCTION_DECREASE, INDCTL_NO_PRODUCTION_INCREASE, INDCTL_NO_CL }
There is no appropriate flag for 'closure requested' or 'closure required'. However a GS and grf can collaborate to abuse one of the other flags.
We could add further flags.
Forced closure of an industry
This would be via monthly industry callback 35 (or the random equivalent). We delegated to grf the right to refuse closure, and I'm not proposing changing that.
Forced removal of all of a type from the map
This would primarily be of use when modifying the map at game start, but there might be other uses.
Assuming #10383 was resolved, industries could be removed by DemolishTile(). Mass removal could be done by creating a GSIndustryList() instance, and filtering for industry type, then valuating with the tile index for each industry instance. Then running a foreach loop and calling DemolishTile on each instance. This would consume a command for every instance, and commands are limited / expensive.
A method to mass-remove all of a type might be useful.
Steps to reproduce
I can provide a test GS, but it's not much use really except as evidence for the findings above.
If we have proposed solutions, I can write a GS to test them.
The text was updated successfully, but these errors were encountered: