Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Configurable subsidy duration #9081

Merged
merged 1 commit into from Jun 10, 2021

Conversation

2TallTyler
Copy link
Member

@2TallTyler 2TallTyler commented Apr 22, 2021

Motivation / Problem

Subsidies are hard-coded to last only one year, with a maximum distance of 70 tiles (Manhattan distance). While this incentivizes local, short-distance routes which ordinarily don't pay much, even with the subsidy multiplier the short duration of the subsidy often isn't worth the player's time and effort.

Description

subsidy_255

This PR adds a Settings > Subsidy duration to allow players to select the subsidy length, in years.

Slightly longer subsidies would be more powerful and beneficial to players. Additionally, allowing much longer subsidies would allow new gameplay modes, such as making unsubsidized NewGRF cargos unprofitable and forcing players to compete for long-term subsidies created by the game or a GS.

The setting defaults to 1, the current hard-coded duration. The minimum value is 0, which disables subsidies, and the maximum is 5000; a nice round number which doesn't overflow the uint16 storing the subsidy duration in months. The longest games I've seen in screenshots are between 500 and 1000 years, so this should be plenty of space for an effectively indefinite subsidy. (Note: the maximum was originally 256 when I created the PR, but I realized this wasn't long enough.)

I know that adding settings needs strong justification, so I considered several alternatives, none of which felt right:

  • Inverse correlation with company score, using the same stages as the company HQ — introducing a Mario Kart item-like negative feedback loop to boost new and struggling companies while being less effective for larger companies. I actually started with this and it was cool, but would need major changes to news and the Subsidies GUI to display different information for each player.
  • Inverse correlation with the selected subsidy payment multiplier, e.g. a 1.5x multiplier for 5 years or a 4x multiplier for 1 year. But this breaks existing gameplay styles and customization.
  • The above, but chosen randomly for each subsidy and using a new "Random" option for the multiplier setting. It's a messy reuse of an existing setting. Bleh.

So I added a setting.

Note that while subsidies are randomly calculated each month without regard to how many subsidies currently exist, new subsidy offers will not accumulate forever since towns and industries with more than 42% of cargo transported are ineligible for new subsidies.

I also plan to look at increasing the maximum distance of the subsidy based on town and industry density to fix subsidies not being possible on low-density maps, but that is a separate project entirely.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@2TallTyler 2TallTyler force-pushed the custom_subsidy_length branch 2 times, most recently from cca3f45 to 898752b Compare April 22, 2021 18:47
@James103
Copy link
Contributor

In theory, combining this with GS should allow a Game Script to create any number of subsidies, each with arbitrary multipliers and durations. For example, a GS could do the following to create a 4x subsidy for 5 years and a 1.5x subsidy for 20 years while keeping subsidies disabled otherwise:

  1. Store a value of 5 for the subsidy duration (in years).
  2. Store a value that corresponds to "4x" for the subsidy multiplier.
  3. Create the first subsidy.
  4. Store a value of 20 for the subsidy duration. This should not affect the duration of the first subsidy created from step 3.
  5. Store a value that corresponds to "1.5x" for the subsidy multiplier.
  6. Create the second subsidy.
  7. Store a value of 0 for the subsidy duration. This prevents new subsidies from being naturally spawned.

The maximum subsidy duration should remain at 255 unless it needs to be lowered for technical reasons.

@2TallTyler 2TallTyler force-pushed the custom_subsidy_length branch 5 times, most recently from d019090 to 66a23ab Compare April 24, 2021 02:25
src/lang/english.txt Outdated Show resolved Hide resolved
src/lang/english.txt Outdated Show resolved Hide resolved
src/subsidy.cpp Outdated Show resolved Hide resolved
src/subsidy.cpp Outdated Show resolved Hide resolved
src/subsidy.cpp Outdated Show resolved Hide resolved
@2TallTyler 2TallTyler force-pushed the custom_subsidy_length branch 3 times, most recently from 32e0634 to 9cc86d0 Compare May 8, 2021 14:14
src/subsidy.cpp Show resolved Hide resolved
src/table/settings/settings.ini Outdated Show resolved Hide resolved
src/lang/english.txt Outdated Show resolved Hide resolved
src/subsidy_base.h Outdated Show resolved Hide resolved
src/lang/english.txt Show resolved Hide resolved
@michicc michicc merged commit d09210e into OpenTTD:master Jun 10, 2021
@2TallTyler 2TallTyler deleted the custom_subsidy_length branch June 10, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants