Page 1 of 2

Adjusting Vehicle Speeds

Posted: 26 Sep 2006 16:53
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

Posted: 26 Sep 2006 18:13
by DaleStan
Yes. Newgrf.
Or the source.

Posted: 26 Sep 2006 18:26
by Smit_h_y
er... :?:

Posted: 26 Sep 2006 18:55
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 :)

Posted: 27 Sep 2006 04:01
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

Posted: 27 Sep 2006 15:57
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...

Posted: 27 Sep 2006 15:58
by Smit_h_y
are there any complete tutorials on going about editing the source?

Posted: 28 Sep 2006 06:28
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 ;)

Posted: 28 Sep 2006 11:39
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.

Posted: 28 Sep 2006 12:38
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?

Posted: 28 Sep 2006 13:58
by peter1138
If you're not changing the graphics, then you only need the Action 0s

Posted: 28 Sep 2006 15:02
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 :?

Posted: 28 Sep 2006 16:01
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.

Posted: 28 Sep 2006 17:35
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...

Posted: 28 Sep 2006 17:39
by DaleStan
The largest value that fits in the given width.

Posted: 28 Sep 2006 19:30
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.

Posted: 28 Sep 2006 19:34
by DaleStan
Power, weight, coef. of TE, and coef. of air drag.

Posted: 28 Sep 2006 20:02
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...

Posted: 28 Sep 2006 20:36
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.

Posted: 28 Sep 2006 21:59
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.