Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Dec 12, 2018 1:24 pm

All times are UTC




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Nov 09, 2014 1:15 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
With this GS you will not get paid based on distance cargo is transported or based on the time it took to transport cargo. Instead you will get paid based on amount of cargo you delivered to industries and towns.

The payment is currently not dependent on NewGRFs. Instead it is just a constant equal for all cargo types. You can change this in the GS settings window.

Features:
  • Pay companies monthly based on cargo delivery past month
  • Reverses OpenTTD default income by the end of quarter (can be a bit later as it happens in the next monthly update)
  • All money transfers by this script are shown on the other row in the finances window
  • AIs can identify this GS and get the payment factor using SCP.

Later ToyLib support may be added when it is available on bananas.

Expect that AIs in general will have problem with this GS, as they need to specifically write code to be aware of if this run in your game and then act differently based on that.

Edit: It requires OpenTTD 1.4+ to work.


Attachments:
CashDrainGS-v1.tar [30 KiB]
Downloaded 163 times

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Top
   
PostPosted: Mon Nov 10, 2014 2:29 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
Nice! I'd been hoping for something exactly like this!

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Wed Nov 12, 2014 8:38 am 
Offline
President
President
User avatar

Joined: Tue Feb 01, 2011 11:22 am
Posts: 910
Location: Beer
That sounds like massive advantage for fast trains :P

_________________
ImageImageImage


Top
   
PostPosted: Wed Nov 12, 2014 11:21 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Yes, if faster trains give you more roundtrips and your supply is good, then faster trains will be good.

But note that the payment for delivering some piece of cargo will be the same independent of delivery time with this game script. The API that I use to monitor delivery doesn't give this information.

I could employ some Neighbour logic where towns that have no nearby neighbours pay more for example. With some semi-working heuristics to guess what cargos are not accepted by town houses, those could be monitored at industry level instead of town-level and further detail payment based on distance to closest supply etc.

It could also possible give you some silly speed bonus by inspecting your vehicle fleet, but then it would be based on engine stats rather than measured delivery time.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun Nov 23, 2014 7:58 am 
Offline
Engineer
Engineer

Joined: Fri Nov 21, 2014 1:34 pm
Posts: 4
This is very interesting.

I tried to modify it so that the reversal could be adjusted with an option (so instead of always taking away 100% of default income, you could specify between 0-100%), as this would allow for this kind of payment scheme:
Code:
Base Fee + Lower Rate * Distance


Unfortunately I got an error, probably because I have no idea what I'm doing (my best guess is that I need a float or some kind of rounding to get the proportion of income bit right).

Any chance you could include this option in your base GS?


For reference, what I changed:
Line 133 of companydata.nut
Code:
this._next_bank_transfer.rawset("vehicle_income", old_amount - tot_veh_income);

To
Code:
this._next_bank_transfer.rawset("vehicle_income", old_amount - tot_veh_income * GSController.GetSetting("veh_income_reverse_rate") * 0.01);


And I added this to info.nut
Code:
      AddSetting({name = "veh_income_reverse_rate", 
            description = "Percentage of vehicle income to reverse",
            easy_value = 0,
            medium_value = 50,
            hard_value = 100,
            custom_value = 50,
            flags = CONFIG_INGAME,
            min_value = 0,
            max_value = 100,
      });


Top
   
PostPosted: Sun Nov 23, 2014 9:16 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9062
Location: Sol d
"got an error" is not exactly a verbose error description. The AI/GS errors can be looked at in the AI/GS window and are written to the console as well (ok, windows doesn't have a console).

You explained well what you did very well (which indeed should make it easy to reproduce), but you missed out on the part to explain of what you see. Thus it's not possible to answer you without spending oneself quite some time in an attempt to reproduce in an attempt and in the hope that one gets the very same one.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Sun Nov 23, 2014 9:24 am 
Offline
Engineer
Engineer

Joined: Fri Nov 21, 2014 1:34 pm
Posts: 4
planetmaker wrote:
"got an error" is not exactly a verbose error description. The AI/GS errors can be looked at in the AI/GS window and are written to the console as well (ok, windows doesn't have a console).

You explained well what you did very well (which indeed should make it easy to reproduce), but you missed out on the part to explain of what you see. Thus it's not possible to answer you without spending oneself quite some time in an attempt to reproduce in an attempt and in the hope that one gets the very same one.


This is the error

It didn't seem that useful to me, but I suppose there could be something in there that adds useful information that I don't recognise as useful.

Ultimately my query was more "can this feature be added" and less "can you debug something for me" with my attempt being a "this seems like it should be straight-forward, except I must be missing something because this doesn't work".


Top
   
PostPosted: Sun Nov 23, 2014 9:42 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Well, pretty easy, support type are there :
http://wiki.openttd.org/AI:Save/Load#Save
and
Code:
this._next_bank_transfer.rawset("vehicle_income", old_amount - tot_veh_income * GSController.GetSetting("veh_income_reverse_rate") * 0.01);

this will gaves you a float result and float is not in the list of support data type to save.
drop float calc or calc in float but .tointeger() the result.


Top
   
PostPosted: Sun Nov 23, 2014 6:19 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
sinkingmist wrote:
Code:
this._next_bank_transfer.rawset("vehicle_income", old_amount - tot_veh_income * GSController.GetSetting("veh_income_reverse_rate") * 0.01);


Nice to hear there is some interest in this GS.

I would not use floating point at all. This code below will give you an integer division which in most programming languages including Squirrel gives you an integer result. The multiply will happen before the division here, and then the larger number will be divided by 100 and the reminder will be thrown away as this is an integer division. Though if tot_veh_income is very large, it may overflow when doing /100 at the end compared to dividing tot_veh_income first.
Code:
this._next_bank_transfer.rawset("vehicle_income", old_amount - tot_veh_income * GSController.GetSetting("veh_income_reverse_rate") / 100);

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Tue Nov 25, 2014 7:19 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Here are the proposed changes implemented and recorded in a patch.

I cannot decide if I should reverse the setting. The proposed way is closer to how it is implemented. But from user point of view it would more clear to describe it as percentage of OpenTTD default vehicle income to keep. (or retain which may be better at implying that money transfer is asynchronous)

Also I haven't reviewed the docs in lang.txt or Readme.txt if they need to be updated. If anyone feels like doing that and include in the patch, that is welcome. (I haven't yet uploaded the first version to a public repo, but you can do a "hg init" or "git init" in a copy of it and commit all files so it is then possible to track changes and produce a patch file)


Attachments:
reverse-rate.patch [1.6 KiB]
Downloaded 47 times

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.