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

Suggestion: Allow Game Scripts to set the max loan of a company. #8049

Closed
James103 opened this issue Mar 29, 2020 · 6 comments
Closed

Suggestion: Allow Game Scripts to set the max loan of a company. #8049

James103 opened this issue Mar 29, 2020 · 6 comments
Labels
enhancement Issue would be a good enhancement; we accept Pull Requests!

Comments

@James103
Copy link
Contributor

Version of OpenTTD

As of 1.10.0-RC1

Expected result

Game Scripts should be able to set the loan amount of a company independent of any restrictions like the loan interval and bank balance. For example, a Game Script should be able to set the loan of a company to £1,234,567 without changing the bank balance (which is both greater than the max loan and not a multiple of the loan interval).

An entirely new function designed for this purpose could be implemented to allow for this behavior to occur while taking the loan amount and company as parameters, or alternatively GSCompany.SetLoanAmount could be expanded to take an additional optional parameter for the company ID. If the additional parameter is supplied and there's no company scope, then the proposed behavior is executed instead of the current behavior.

Actual result

Game Scripts are unable to set the loan of a company to any value that is not a multiple of the loan interval (£10,000) or that is greater than the max loan.

Steps to reproduce

  1. Run the following code in a Game Script without company mode scope:
GSCompany.SetLoanAmount(...) // Fails (no company scope)
  1. Run the following code in a Game Script with company mode scope:
GSCompany.SetLoanAmount(1234567) // Fails (bigger than max loan)
GSCompany.SetLoanAmount(123456) // Fails (not a multiple of 10000)
GSTile.DemolishTile(...) // Spend some money
GSCompany.SetLoanAmount(0) // Fails (not enough money to set the loan)
@LordAro LordAro added the enhancement Issue would be a good enhancement; we accept Pull Requests! label Apr 4, 2020
@LordAro
Copy link
Member

LordAro commented Apr 4, 2020

I don't see a particular reason why you'd want to set a non-multiple-of-10000 loan amount. To avoid complicating the SetLoadAmount code, perhaps a better solution would be to add a new SetMaxLoanAmount GS-only function, that takes a company ID as parameter

@James103
Copy link
Contributor Author

James103 commented Apr 4, 2020

Note that OpenTTD handles hacked loan amounts in a way that still (mostly) makes sense. Paying off a loan between 1 and 9999 still works correctly (even in the error handler), unless you control-click to pay off the loan. This will set the loan to a negative number, resulting in loan interest adding to your bank balance instead of subtracting.

@James103
Copy link
Contributor Author

James103 commented Apr 15, 2020

The part about setting loans that aren't multiples of 10000 can be dropped as it is not as important as being able to set a loan higher than the max loan via a Game Script. I would still like it if a Game Script can set the max loan of a company to any non-negative multiple of 10,000 (this includes zeroing the max loan). I have changed the title to reflect this.

@James103 James103 changed the title Suggestion: Allow Game Scripts to set company loan beyond max loan and independent of cash on hand Suggestion: Allow Game Scripts to set the max loan of a company. Apr 15, 2020
@nielsmh
Copy link
Contributor

nielsmh commented Apr 15, 2020

I suppose the idea here is to let a GS give a company a loan they can pay back, but not take out again?

@James103
Copy link
Contributor Author

That, and there's the possibility of allowing Game Scripts to reward big companies with good financial management with bigger loans and/or penalize companies with bad financial management by disallowing large loans. Custom scenarios could also be designed with Game Scripts that disallow loans at all (by setting everyone's loan and max loan to 0).

Note: This will mean that AIs and Game Scripts may need to find new ways of determining the inflation factor, for example by using the ratio of prices (original to current) of the zeroth engine.

@James103
Copy link
Contributor Author

James103 commented Jan 1, 2021

Closing this issue as feature is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue would be a good enhancement; we accept Pull Requests!
Projects
None yet
Development

No branches or pull requests

3 participants