Straight flat tracks: 1 sprite per articulated part
Sloped tracks: 1 sprites per every two articulated parts (because of how slopes work)
Curves: 1 sprite per vehicle
This works pretty well, except for the transition between flat tracks and sloped tracks. My idea was to use the same concept as with the extra turning angles, and use the other_veh_z_offset variable to decide when a vehicle is entering a entering a slope tile. And it ...kind of... works. But I can't figure out what's going on.
My idea was to use other_veh_z_offset to check the value of the first part and the last part (as shown in the picture):
Code: Select all
other_veh_z_offset(first_part) - other_veh_z_offset(last_part)
Code: Select all
Part 1: +0 - (-3) = 3
Part 2: +1 - (-2) = 3
Part 3: +2 - (-1 = 3
Part 4: +3 - 0 = 3
Part 5: +3 - 0 = 3
Part 6: +3 - 0 = 3
Code: Select all
-3: return train_spriteset_slope_down_3;
-2: return train_spriteset_slope_down_2;
-1: return train_spriteset_slope_down_1;
0: return train_spriteset_normal;
1: return train_spriteset_slope_up_1;
2: return train_spriteset_slope_up_2;
3: return train_spriteset_slope_up_3;
So for some reason, it picks the wrong spritesets for last parts. It picks sprites for down slopes instead, which means that the returned value must be negative, which I simply cannot understand, since the last part should return 3-0=3. How can this value ever be negative?
However, if I instead add the results by using the formula (plus instead of minus):
Code: Select all
other_veh_z_offset(first_part) + other_veh_z_offset(last_part)
Code: Select all
Part 1: +0 + (-3) = -3
Part 2: +1 + (-2) = -1
Part 3: +2 + (-1) = 1
Part 4: +3 + 0 = 3
Part 5: +3 + 0 = 3
Part 6: +3 + 0 = 3
So, my questions are:
1. A tile is 16 X/Y units, but how many Z units?
2. Can the formula other_veh_z_offset(first_part) - other_veh_z_offset(last_part) be used to achieve what I want?
3. Is there any way I can debug this and check what values the switches actually return?
4. Is there a NewGRF that has solved this problem in a similiar fashion?