Timberwolf's UK.... trains?

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

Electricfox
Engineer
Engineer
Posts: 21
Joined: 19 Jun 2006 18:13

Re: Timberwolf's UK.... trains?

Post by Electricfox »

Oooh, very Art Deco, I like it!

PEPSprinterPacer
Engineer
Engineer
Posts: 71
Joined: 20 Jul 2020 13:43
Location: Nether you mind

Re: Timberwolf's UK.... trains?

Post by PEPSprinterPacer »

Ooooh!

(142nd post, *screeching in background*
Only ever been on a 185 and 144 023!

User avatar
Darthrafael
Engineer
Engineer
Posts: 103
Joined: 03 Aug 2011 14:10
Location: Yes

Re: Timberwolf's UK.... trains?

Post by Darthrafael »

So uh, it seems that the FFA container wagon looks a bit... interesting when not fully loaded. I don't think containers work like this?
The same thing happens to the FSA and the KTA wagons.
Container.PNG
Container.PNG (15.62 KiB) Viewed 366 times
Hi~

Timberwolf
Traffic Manager
Traffic Manager
Posts: 161
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: Timberwolf's UK.... trains?

Post by Timberwolf »

Ooh, interesting. Looks like the object composition isn't working properly and putting part of the third container on the output object.

Edit: rather more interesting, in fact. It looks like the front, middle and rear sections aren't in agreement over which cargo sprite to show, so you're seeing the "full" sprite on the front and middle, but the "half-full" sprite on the rear (and getting the container cut off at the transition point). This will require some delving into the switch logic to figure out what's happening - I have a theory it may be due to the capacities of each section not updating evenly.

So... this is down to how long vehicles are implemented. The FFA container wagons aren't one vehicle, they're in fact 3 articulated sections - front, middle and rear. In turns and on hills only the middle has a sprite, but on straight rails each section has its own sprite. The reason for this is to avoid glitches on tunnel entrances or crossing slope foundations. Normally this works fine, but when you have a partial load OpenTTD selects the load sprite based on how much cargo is in each part of the vehicle. If the cargo isn't a multiple of 3 it's possible for the front and sometimes middle to have a different load graphic to the rear.

I think this may be possible to work around with a bit of switch trickery, if I can get the total cargo in vehicle and use it to emulate the built-in spriteset functionality.

Timberwolf
Traffic Manager
Traffic Manager
Posts: 161
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: Timberwolf's UK.... trains?

Post by Timberwolf »

And now fixed. v1.1.2 is up on BaNaNaS, also allows auto-refit for the first time.

As to that fix... ever get the feeling OpenTTD is telling you that you shouldn't be doing what you're doing? I get that a lot with the over-length vehicles :). In order to make all sections of the vehicle load consistently, I have to use a switch based on the cargo to emulate spritegroups. But on top of that, the variables for cargo_countand cargo_capacity refer to the current section of the articulated vehicle, not the whole thing. If I use those I just recreate the same problem I had before with uneven loads.

Luckily, there's variable 61 on hand which can be used to get values from other vehicles in a chain. So I use that to make the front and rear sections of the articulated vehicle base their sprites on the cargo capacity of the middle vehicle:

Code: Select all

// Cargo switch for front flat&straight
switch(FEAT_TRAINS, SELF, switch_cargo_{{.}}_sections_front, [
        STORE_TEMP(1, 0x10F), // use variable of next vehicle
        (var[0x61, 0, 0x0000FFF, 0xBC] * 4) / cargo_capacity
    ])
{
    1..2: return spriteset_{{.}}_half_sections_front;
    3..4: return spriteset_{{.}}_full_sections_front;
    return spritegroup_{{.}}_none_sections_front;
}

// Cargo switch for rear flat&straight
switch(FEAT_TRAINS, SELF, switch_cargo_{{.}}_sections_rear,  [
        STORE_TEMP(-1, 0x10F), // use variable of previous vehicle
        (var[0x61, 0, 0x0000FFF, 0xBC] * 4) / cargo_capacity
    ])
{
    1..2: return spriteset_{{.}}_half_sections_rear;
    3..4: return spriteset_{{.}}_full_sections_rear;
    return spritegroup_{{.}}_none_sections_rear;
}
(This is not pure NML, it's what I use in my templating system... {{.}} gets replaced with a name when the file is generated. This is also why I use a spritegroup for _none, to keep the templating simple)

Variable 0xBC is the cargo count of the current vehicle, and because cargo capacities are the same for all sections of the articulated unit I can just use the local variable for that. So far this calculation matches the spritegroups used for the middle section, and in all my tests has given consistent results so vehicles don't suddenly increase or decrease the amount of visible cargo going into a corner or hill (where a single sprite is used). And so another glitch in the abomination that is a 12/8 or 14/8 length vehicle is fixed... although keep your eye out for any other situations where the cargo load of the middle section is inconsistent with the front/rear.

User avatar
TrainLover
Engineer
Engineer
Posts: 108
Joined: 01 Jul 2015 15:03

Re: Timberwolf's UK.... trains?

Post by TrainLover »

They look a lot more like Locomotion models than OpenTTD/TTD sprites
Developer of North American Passenger Liveries: viewtopic.php?f=26&t=87228

Timberwolf
Traffic Manager
Traffic Manager
Posts: 161
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: Timberwolf's UK.... trains?

Post by Timberwolf »

Gradual station progress - I've mocked up the 2-tile Art Deco building as two single tile buildings for now, but I'm happy enough with the artwork to start coding multi-tile stations.

Image

(A couple of liberties may have been taken with the prototype to make it fit in two tiles...)

The Locomotion resemblance is semi-deliberate. I dislike an enormous list of things about Locomotion: the brown buildings on a brown landscape, the million clicks to build a tiny length of track, somehow making TTD's original mechanics for reliability and vehicle replacement even more tedious, the lack of epic scale... but the detail in the trains and the naturalistic way they take corners and hills really appeals to me. I wanted a combination of that model railway appeal of creating some trains and watching them go about their business, but with the playability and the scope for complex networks of OpenTTD.

Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: GarryG, superdrive1 and 16 guests