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 2TallTyler:custom_subsidy_length branch 2 times, most recently from cca3f45 to 898752b Apr 22, 2021
@James103
Copy link
Contributor

@James103 James103 commented Apr 22, 2021

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 2TallTyler:custom_subsidy_length branch 5 times, most recently from d019090 to 66a23ab Apr 23, 2021
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 2TallTyler:custom_subsidy_length branch 3 times, most recently from 32e0634 to 9cc86d0 May 1, 2021
@michicc michicc force-pushed the 2TallTyler:custom_subsidy_length branch from 9cc86d0 to 2eaa28d Jun 10, 2021
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 force-pushed the 2TallTyler:custom_subsidy_length branch from 2eaa28d to 8ce33f1 Jun 10, 2021
@michicc michicc force-pushed the 2TallTyler:custom_subsidy_length branch from 8ce33f1 to c28d46b Jun 10, 2021
@michicc michicc merged commit d09210e into OpenTTD:master Jun 10, 2021
13 checks passed
13 checks passed
@github-actions
Emscripten
Details
@github-actions
Commit checker
Details
@github-actions
Check preview needs update Check preview needs update
Details
@github-actions
Linux (clang, clang++, libsdl2-dev)
Details
@github-actions
Linux (gcc, g++, libsdl2-dev)
Details
@github-actions
Linux (gcc, g++, libsdl1.2-dev)
Details
@github-actions
Linux (gcc, g++, -DOPTION_DEDICATED=ON)
Details
@github-actions
Mac OS (x64, x86_64)
Details
@github-actions
Windows (windows-latest, x86)
Details
@github-actions
Windows (windows-latest, x64)
Details
@github-actions
Windows (windows-2016, x86)
Details
@github-actions
Windows (windows-2016, x64)
Details
@github-actions
Check Annotations
Details
@2TallTyler 2TallTyler deleted the 2TallTyler:custom_subsidy_length branch Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants