Adjusting Vehicle Speeds

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Adjusting Vehicle Speeds

Post by Smit_h_y »

OK so with TTDPatch i was able to use Rudge's TTDAlter to adjust most things about the game. Is there something similar to this for OTTD?
ta
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Yes. Newgrf.
Or the source.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

er... :?:
User avatar
AlexH.
Engineer
Engineer
Posts: 24
Joined: 29 Jul 2006 00:35
Location: Northern Poland
Contact:

Post by AlexH. »

In easier words, DaleStan said that there are no programs that can edit vehicle stats in way similar to TTDAlter one. You can modify vehicles by creating NewGRF files that could alter or overwrite specs or modify directly the Source :)
I ride the sky, I rule the night
Till I am free, with sword and sorcery.
The gods look down, hear battle sound.
I carry on, until the fight is won
Miranda
Engineer
Engineer
Posts: 11
Joined: 16 Sep 2006 21:23

Post by Miranda »

I modified the source and Rebuilt it so trains are always max speed no matter if they come to a hill bridge depot or anything. I only did it to trains cus I dont care for busses etc, not sure if im allowed to post my game here though
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Post by Grolsch »

Miranda wrote:I modified the source and Rebuilt it so trains are always max speed no matter if they come to a hill bridge depot or anything. I only did it to trains cus I dont care for busses etc, not sure if im allowed to post my game here though
where can you change the code to do that? i found the place where i can alter the vehicle speed, but not where the curve/slope slow is located...
Beer equals power
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

are there any complete tutorials on going about editing the source?
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Post by Grolsch »

I know that here is explained how to compile the source. If you have the source, and some knowledge of programming, it should be doable. However, I have no knowledge of it, and am proud to have found a way to adjust trainspeeds ;)
Beer equals power
User avatar
Campmaster
Engineer
Engineer
Posts: 24
Joined: 24 Feb 2005 11:59

Post by Campmaster »

Grolsch wrote:
Miranda wrote:I modified the source and Rebuilt it so trains are always max speed no matter if they come to a hill bridge depot or anything. I only did it to trains cus I dont care for busses etc, not sure if im allowed to post my game here though
where can you change the code to do that? i found the place where i can alter the vehicle speed, but not where the curve/slope slow is located...
I don't have a compiler at hands now but in train_cmd.c you can find the function UpdateTrainSpeed:
Replace

Code: Select all

v->cur_speed = spd = clamp(v->cur_speed + ((int)spd >> 8), 0, tempmax);
with

Code: Select all

v->cur_speed = spd = tempmax;
and your trains should always travel at max speed :)

As I have no compiler at hands I can't test if it actually will work but I'm quite sure of it. Personally I'd prefer to change some lines above the quoted one from "accel * 2" to "accel * 200" which means your trains will reach full speed 100 times faster which is almost like instant full speed but you can still see them accelerate if you watch them ingame. (I think instant full speed looks more unrealistic then the 100 times faster acceleration).

PS: Trainspeeds are located in table\engines.h
Look for "const RailVehicleInfo const RailVehicleInfo orig_rail_vehicle_info". The struct is well documented - you should be able to find the max-speed-column.
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

ok so i decided to take the Newgrf route. Isnt too taxing i can see but i have a question;
If all i am changing about a train is its speed/power etc, then is it still necessary to have an action1 line? Also does that mean i dont have to define its sprite for each view?
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1796
Joined: 30 Mar 2005 09:43

Post by peter1138 »

If you're not changing the graphics, then you only need the Action 0s
He's like, some kind of OpenTTD developer.
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

thanks :D thats a relief.

Oh one more question;
At the bottom of this page, theres an example of an action 0 line for a train engine. The value given for the speed property is 'C0 00', this is supposed to represent 192, but i cant see how. The other bytes seem to follow some sort of conversion like str -> hex or whatever, but i cant see how that got that as a value. Kind of stuffs me up if i want to go about changing the speed and i dont even know what value i should be using :?
User avatar
MacLir
Engineer
Engineer
Posts: 48
Joined: 10 Aug 2006 18:07
Location: Marion, OH

Post by MacLir »

If you're using WinXP (not sure on older versions, its been too long :P ), the caculator 'accessory' can convert the numbers from decimal to hex. Just click on the 'View' menu and change it to 'Scientific' and the displayed window will expand.
Image
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

ok nevermind, i just forgot to convert the hex into little-endian ;)

Sweet, now i have created my first NewGRF, thanks guys :D

By the way, does anyone know the max speed i can set the trains at? Or any vehicles for that matter now that im on a roll...
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

The largest value that fits in the given width.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

OK so i got to increasing the trains max speed and hp. Checked it in game and all works well, apart from the trains will never reach that speed because of acceleration, and i found nothing in the wiki of action 0 properties for trains about acceleration.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Power, weight, coef. of TE, and coef. of air drag.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

gotcha, but its still taking its time accelerating. Think im gonna have to change weight etc for Wagons and Cargo's...
Smit_h_y
Engineer
Engineer
Posts: 12
Joined: 26 Sep 2006 16:40
Location: England

Post by Smit_h_y »

hmm, if the <Num-info> element is greater than 1, do i then go to list the vehicles in the <ID> element one after the other? i.e.

Code: Select all

4 * 10 00 00 01 04 59 5A 5B 5C 16 00
Or is it done like counting fron one to the next inside 2 given values. i.e

Code: Select all

4 * 8 00 00 01 11 59 63 16 00
Where <Num-info> is 11, and there are 11 vehicles from 59 to 63.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Smit_h_y wrote:hmm, if the <Num-info> element is greater than 1, do i then go to list the vehicles in the <ID> element one after the other?
No. Only the first vehicle's ID. The other vehicles (if any) are the ones with the next sequential ID(s).
Smit_h_y wrote:there are 11 vehicles from 59 to 63.
No, there aren't. There are 0B. There are 11 from 59 to 69.
Don't mix your bases.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 6 guests