Road Vehicles - change wagon length?

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Road Vehicles - change wagon length?

Post by andythenorth »

I would like to reduce the lengths of some road vehicles to improve the appearance of articulated vehicles.

Can I use the wagon length callback (11) to fix situations such as displayed by the screenshots below?
reduce_road_vehicle_width_2.png
reduce_road_vehicle_width_2.png (7.22 KiB) Viewed 1894 times
reduce_road_vehicle_width.png
reduce_road_vehicle_width.png (8.89 KiB) Viewed 1897 times
cheers,

Andy
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Road Vehicles - change wagon length?

Post by michael blunck »

andythenorth wrote:I would like to reduce the lengths of some road vehicles [...] Can I use the wagon length callback (11) [?]
Yes, should be possible.

regards
Michael
Image
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Road Vehicles - change wagon length?

Post by FooBar »

Here's what I use for trams. For road vehicles it's basically the same except for the vehicle flag in the action 0. Please see file attached below.
Attachments
shortervehicle.txt
(2.98 KiB) Downloaded 81 times
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Road Vehicles - change wagon length?

Post by DJ Nekkid »

Code: Select all


action1
action2 cID A0
-1 * 0  02 01 A1 81 0C 00 FF 01          // callback, 1 case
                             02 80 11 11 // 02 shorter in CB11
                             A0 00       // Default cID
action3
that made sense?
Member of the
ImageImage
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Road Vehicles - change wagon length?

Post by DJ Nekkid »

hehe, callbacks are a b**** to understand, until you suddenly get an "eureka" ... then you understand most of them :)
Member of the
ImageImage
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Road Vehicles - change wagon length?

Post by andythenorth »

EDIT: Nothing to see here, the behaviour described below doesn't persist through a save / reload of a game. I'm not looking for any answers - but I've left the post intact in case anyone searches for a similar issue in future. :wink:


--
Nothing says 'Christmas day' like a varaction 2 chain right?

I have some RV code (below) which is 'correct' but should not provide what I understand to be the varaction 2 / action 2 chain that I need, but does gives me the result I need.

My intention is to reduce vehicle length by the same amount for all cargos. This code appears to provide my intended wagon length irrespective of which cargo the vehicle is refitted to. As I read it though, cargo ID AA for the cargoes should not be used (for cargos where an ID is defined), so callback 11 shouldn't be getting handled (which would leave vehicle length unchanged). :shock:

Quirk, or expected behaviour? If this is reliable it means I don't have to construct the 31 different varaction 2s I thought I'd need to set vehicle length. :lol: If it's not reliable, obviously I'll sack it in favour of the correct method.

(I wondered if the default cargo ID always used at some point in the process of building the vehicle?)

cheers,

Andy

Code: Select all

 [...many regular action 2s with IDs 00 - 17]
 362 * 14	 02 01 AA  // handle callbacks
                 81 0C 00 FF // check variable 0C
                 01 // range
                  04 80 11 11 // vehicle length callback
                 02 00
  363 * 106	 03 01 01 00 // Action 3
    20 // Number of different cargo types to support 
    00 00 00 // 
    01 01 00
    02 02 00
    03 03 00
    04 04 00 
    05 05 00
    06 06 00
    07 07 00
    08 08 00
	  09 09 00
	  0A 0A 00
	  0B 0B 00
	  0C 0C 00
	  0D 0C 00
	  0E 0E 00
	  0F 03 00
	  10 03 00
	  11 11 00
	  12 05 00
	  13 13 00 
	  14 05 00
	  15 15 00
	  16 03 00
	  17 17 00
	  18 18 00
	  19 03 00
	  1A 1A 00
	  1B 06 00
	  1C 0A 00
	  1D 06 00
	  1E 07 00
	  1F 0A 00 
	  AA 00 // default   
Last edited by andythenorth on 25 Dec 2008 14:01, edited 1 time in total.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Road Vehicles - change wagon length?

Post by DJ Nekkid »

then you either need 17 lines of "shorter" code, or make the vehicle itself shorter in the action0, and then just make the "lead vehicle" longer? :)
if you use "shorter code" on each attached vehicle, you can reuse it's cID to make it easier.
Member of the
ImageImage
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Road Vehicles - change wagon length?

Post by andythenorth »

DJ Nekkid wrote:then you either need 17 lines of "shorter" code, or make the vehicle itself shorter in the action0, and then just make the "lead vehicle" longer? :)
Ach, nice idea, but RVs don't support prop 21 in an action 0. I tried it anyway, but unsurprisingly, and with it's usual beautiful accuracy nfo-renum was unhappy with it - rightly so because OpenTTD crashed when I tested the grf :wink:

Possibly there is a property that can be set for RV length, but if so I missed it in the documentation. :oops:

In this case, I need to provide a livery refit cycle for each cargo anyway, so I'll be writing varaction 2s to deal with the callback for that. It's only one line extra per varaction 2 to set the vehicle length.

cheers,

Andy
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Road Vehicles - change wagon length?

Post by DJ Nekkid »

When i checked the documentation did it seem like there is no "built in" support for shorter vehicles as you stated, so i'd just use the code i suggested first.

Code: Select all

a number of Action 1's
-1 * 0  02 01 <1st cid> 01 \w<from action1> \w<from action1>
-1 * 0  02 01 <1st cid> 81 0C 00 FF 01  04 80  11 11  <1st id>

-1 * 0  02 01 <2nd cid> 01 \w<from action1> \w<from action1>
-1 * 0  02 01 <2nd cid> 81 0C 00 FF 01  04 80  11 11  <2nd id>

-1 * 0  02 01 <3rd cid> 01 \w<from action1> \w<from action1>
-1 * 0  02 01 <3rd cid> 81 0C 00 FF 01  04 80  11 11  <3rd id>

etc

that phat action3
Member of the
ImageImage
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Road Vehicles - change wagon length?

Post by andythenorth »

DJ Nekkid wrote:When i checked the documentation did it seem like there is no "built in" support for shorter vehicles as you stated, so i'd just use the code i suggested first.
Well thanks DJ, but I found another way. :lol: This code sets wagon length, and allows multiple refits on the same cargo (wheeled trailers or sleds on skis). I use var 47 to decide which 'final' action 2 cargo ID to use.
I hope that using var 47 will also make it easier to:
- check classes in future for compatibility with industry sets
- use different graphics according to capacity (these trailers will increase capacity over time)

cheers,

Andy
magic of variable 47.png
magic of variable 47.png (10.61 KiB) Viewed 1344 times

Code: Select all

[...action 0...]
[...some text strings...]
[...real sprites...]
[...regular action 2s...]
 643 * 18	 02 01 CE  // choose sled sprites according to cargo
                 81 47 00 FF // var 47 in format ccccwwtt where I want tt 
                 02 // range
                  21 00 01 01 // 
                  26 00 06 06 // 
                  // lots more cargos to add here...
                 25 00 // default 
  644 * 18	 02 01 CD  // choose wheeled trailer sprites according to cargo
                 81 47 00 FF // var 47 in format ccccwwtt where I want tt 
                 02 // range
                  01 00 01 01 // 
                  06 00 06 06 // 
                  // lots more cargos to add here
                 05 00 // default 
  645 * 18	 02 01 CC  // set refit text strings
                 81 F2 00 FF //
                 02 // range
                  00 80 00 00 
                  01 80 01 01 
                 FF 80 // end callback chain
  646 * 18	 02 01 CB  // choose sprites according to refit
                 81 F2 00 FF //
                 02 // range
                  CD 00 00 00 // wheeled trailers 
                  CE 00 01 01 // sleds
                 05 00 // default 
  647 * 18	 02 01 C0  // handle callbacks
                 81 0C 00 FF //
                 02 // range
                  04 80 11 11 // vehicle length CB
                  CC 00 19 19 // text suffix CB 
                 CB 00 // graphics
  648 * 49	 03 01 01 08 // Action 3
    00 // Number of different cargo types to support (!! reminder: use hex) 
	  C0 00 // default
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Road Vehicles - change wagon length?

Post by DJ Nekkid »

same s***, different wrapping ;)
Member of the
ImageImage
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 13 guests