External Publication
Visit Post

OpenTTD AIs and Game Scripts • Re: [NoGo] Neighbours are important

Transport Tycoon Forums - Index page [Unofficial] March 5, 2026
Source

Hello, about town effects - with TEmodifier, cargos can be assigned to Town Effects and it works pretty well with NAI. I have a suggestion about the GoalTown::SetGoal() function:

Code:

function GoalTown::SetGoal() { // ... this.SetCargoGoal(GSCargo.TE_PASSENGERS, MaxAsInt(((population / 10) - 5) * factor, 1)); this.SetCargoGoal(GSCargo.TE_MAIL, MaxAsInt(((population / 50) - 5) * factor, 0)); if (GSCargo.IsValidTownEffect(GSCargo.TE_GOODS)) { this.SetCargoGoal(GSCargo.TE_GOODS, MaxAsInt(((population / 20) - 5) * factor, 0)); } if (GSCargo.IsValidTownEffect(GSCargo.TE_FOOD)) { this.SetCargoGoal(GSCargo.TE_FOOD, MaxAsInt(((population / 50) - 5) * factor, 0)); } if (GSCargo.IsValidTownEffect(GSCargo.TE_WATER)) { this.SetCargoGoal(GSCargo.TE_WATER, MaxAsInt(((population / 100) - 5) * factor, 0)); }}

I noticed in GoalTown::SetGoal() that the original function uses a switch on landscape types with different multipliers and preconditions for each TE (e.g., desert towns and water requirements). For easier integration with TEmodifier, I tried a simplified version using IsValidTownEffect() to check whether a TE is active before setting its cargo goal.

This simplifies the original function by using IsValidTownEffect() to check whether a TE is active. It keeps the general logic of setting cargo goals, but ignores the original climate-specific multipliers. This allows TEmodifier to dynamically enable or disable any TE in-game without altering the switch structure.

I’m not sure if TE_WATER needs additional preconditions, and whether the unified numbers work well across all economies, but this approach makes it easier to adjust TE assignments on the fly.

Note: this is just an example of how TEmodifier could integrate with GoalTown::SetGoal(). It does not intend to change the original climate-specific multipliers or balancing.

Statistics: Posted by MustBe — 05 Mar 2026 19:22


Discussion in the ATmosphere

Loading comments...