Articulated parts Length (Tram)

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Articulated parts Length (Tram)

Post by temporal8 »

I was making a tram in 32bpp and I have finished it but it has an error, the central wagon is shorter and according to the NML Tram tutorial (https://www.tt-wiki.net/wiki/NMLTutorial/Tram_graphics) the "length" callback must be used, and I did so, But the error persists. (i Used 8 for both locomotives, 7 for larger wagons and 2 for the central one, but I see no difference in the final result)
VLT CARIOCA.png
VLT CARIOCA.png (380.4 KiB) Viewed 1297 times

locomotive code only:

Code: Select all

/* ------------------------------------------------- LOCOMOTORA TRAM 1 VLT CARIOCA ------------------------------------------------- */

/* Sprite template for a realtram full*/
template tmpl_realtram_full(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_realtram_full(x) {
	[0,     0,   48,   93,   -24,  -46, NOANIM]
	[51,    0,   116,  93,   -67,  -36, NOANIM] 
	[171,   0,   127,  93,   -67,  -43, NOANIM]
	[303,   0,   116,  93,   -47,  -38, NOANIM]
	[423,   0,   48,   93,   -23,  -43, NOANIM]
	[474,   0,   116,  93,   -69,  -35, NOANIM]
	[594,   0,   131,  93,   -65,  -57, NOANIM]
	[728,   0,   116,  93,   -46,  -39, NOANIM]
}

template tmpl_32_realtram_full_MASK(x) {
	[0,     0,   48,   93,   -24,  -46, NOANIM, mask]
	[51,    0,   116,  93,   -67,  -36, NOANIM, mask] 
	[171,   0,   127,  93,   -67,  -43, NOANIM, mask]
	[303,   0,   116,  93,   -47,  -38, NOANIM, mask]
	[423,   0,   48,   93,   -23,  -43, NOANIM, mask]
	[474,   0,   116,  93,   -69,  -35, NOANIM, mask]
	[594,   0,   131,  93,   -65,  -57, NOANIM, mask]
	[728,   0,   116,  93,   -46,  -39, NOANIM, mask]
}

/* Sprite template for a realtram empty*/
template tmpl_realtram_empty(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_realtram_empty(x) {
	[0,     96,   48,   93,   -24,  -46, NOANIM]
	[51,    96,   116,  93,   -67,  -36, NOANIM] 
	[171,   96,   127,  93,   -67,  -43, NOANIM]
	[303,   96,   116,  93,   -47,  -38, NOANIM]
	[423,   96,   48,   93,   -23,  -43, NOANIM]
	[474,   96,   116,  93,   -69,  -35, NOANIM]
	[594,   96,   131,  93,   -65,  -57, NOANIM]
	[728,   96,   116,  93,   -46,  -39, NOANIM]
}

template tmpl_32_realtram_empty_MASK(x) {
	[0,     96,   48,   93,   -24,  -46, NOANIM, mask]
	[51,    96,   116,  93,   -67,  -36, NOANIM, mask] 
	[171,   96,   127,  93,   -67,  -43, NOANIM, mask]
	[303,   96,   116,  93,   -47,  -38, NOANIM, mask]
	[423,   96,   48,   93,   -23,  -43, NOANIM, mask]
	[474,   96,   116,  93,   -69,  -35, NOANIM, mask]
	[594,   96,   131,  93,   -65,  -57, NOANIM, mask]
	[728,   96,   116,  93,   -46,  -39, NOANIM, mask]
}

/* Define various cargo-specific graphics */

/* Goods */
spriteset(realtram_empty, "gfx/realtrams.png") { tmpl_realtram_empty(0) }
alternative_sprites(realtram_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrams_32.png","gfx/real_trams_mask.png")  
{ tmpl_32_realtram_empty(0) }

spriteset(realtram_full, "gfx/realtrams.png") { tmpl_realtram_full(0) }
alternative_sprites(realtram_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrams_32.png","gfx/real_trams_mask.png")  
{ tmpl_32_realtram_full(0) }

spritegroup realtram {
    loaded: [realtram_empty,realtram_full];
    loading: [realtram_empty,realtram_full];
}


/* ARTICULATED PART START */

switch (FEAT_ROADVEHS, SELF, switch_realtram_1_trailer, position_in_consist ) {
    1: realtram2;  
    2: realtram3; 
    3: realtram4; 
    4: realtram3;  
    5: realtram; 
}

//set number of articulated parts
switch (FEAT_ROADVEHS, SELF, switch_articulated_realtram_1_trailer, extra_callback_info1) {
    1: return flatbed_realtram3_1; 
    2: return flatbed_realtram4_1; 
    3: return flatbed_realtram3_1; 
    4: return flatbed_realtram2_1; 

 //   return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}

//set length of each part
switch (FEAT_ROADVEHS, SELF, switch_length_realtram_1, position_in_consist) {
    1: return 8;
    2: return 7;
    3: return 2;
    4: return 7;
    5: return 8;
}

//set capacity of each part
switch (FEAT_ROADVEHS, SELF, switch_capacity_realtram_1, position_in_consist ) {
    1: return 26;
    return 38; //default
}


/* ARTICULATED PART END */

/* Purchase Menu Image */
spriteset(spriteset_realtram_purchase, "gfx/realtrams.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtram_purchase, ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/realtrams_32.png","gfx/real_trams_mask.png") {[0,794,494,93,-247,-55]} 

/* Properties */

/* Define the road vehicle */
item(FEAT_ROADVEHS, flatbed_realtram_1) {
    property {
        /* Properties common to all vehicle types */
        name: string(STR_NAME_realtram_1);
        climates_available: ALL_CLIMATES;
        road_type: ELRL;
        introduction_date: date(1980,01,01);
        model_life: VEHICLE_NEVER_EXPIRES;
        /* retire_early not set, use default retirement behaviour */
        vehicle_life: 15;
        reliability_decay: 20;
        non_refittable_cargo_classes: bitmask(CC_PASSENGERS);
        default_cargo_type: PASS;
        cargo_allow_refit: [];
        cargo_disallow_refit: []; // we allow other cargoes, if class matches
        loading_speed: 8;
        cost_factor: 20;
        running_cost_factor: 170;
        /* cargo_age_period is left at default */

        /* RV-specific properties */
        sprite_id: SPRITE_ID_NEW_ROADVEH;
        speed: 90 km/h;
        misc_flags: bitmask(ROADVEH_FLAG_TRAM);
        refit_cost: 0; // Refitting is free
        /* callback_flags are not set, no need to manually enable callbacks */
        running_cost_base: RUNNING_COST_ROADVEH;
        power: 103 hp;
        weight: 5.5 ton;
        /* TE and air drag coefficient is left at default */
        cargo_capacity: 25;
        sound_effect: SOUND_BUS_START_PULL_AWAY;
        /* Visual effect is left at default (no effect) */
    }

    /* Define graphics for various cargo types, as well as the capacity callback */
    graphics {
        default: realtram; // Default to Passengers.
        purchase: spriteset_realtram_purchase;
        articulated_part: switch_articulated_realtram_1_trailer;
        length: switch_length_realtram_1;
        cargo_capacity: switch_capacity_realtram_1;
    }
}
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Articulated parts Length (Tram)

Post by PikkaBird »

Since you use different vehicle IDs for the trailing parts, obviously any callbacks that affect the trailing parts need to be in those vehicles' code.

If each different part has a different ID, you could simply set the lengths in the properties, rather than using callbacks at all. The advice in the wiki to use the callback is because the typical way to do articulated vehicles is to use the same ID for all parts.
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Articulated parts Length (Tram)

Post by temporal8 »

Thanks Pal, i did exactly that, it worked.

The different vehicles ids is because each part has full and empty states, I don't know if everything can be done within the same vehicle ID, it was the easiest way for me that I found to do it.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: Articulated parts Length (Tram)

Post by Eddi »

there are many ways to do that. same ID for all, different ID for each. different ID for certain visually different parts.
  1. all same ID: the graphics and length callbacks need to check position in consist
  2. different ID for each: no callbacks needed, but possibly lots of duplication
  3. different ID for visually different parts: e.g. first and last part can use the same ID (set the flipped bit in the articulation callback). also second and fourth part can use same ID (flipped or not)
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Articulated parts Length (Tram)

Post by temporal8 »

And how would it be to make a train?

I can make the locomotive in the same way, but how would it be in the case of the wagons?

I mean, make a free-standing wagon (not an articulated part) that can be attached to a locomotive? (SOLVED: a Wagon it´s just like a locomotive but with power: 0)

locomotive.png
locomotive.png (494.71 KiB) Viewed 1142 times
Last edited by temporal8 on 25 Jul 2022 00:54, edited 2 times in total.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Articulated parts Length (Tram)

Post by temporal8 »

New problem, the space between diferent wagons, i already set the length: 8 but the problem still there.

In the picture you can see a locomotive with 4 wagons, below how it should really look, above how it looks in the game with all the wagons stacked on top of each other.
wagon-error1.png
wagon-error1.png (697.74 KiB) Viewed 1124 times

Code: Select all

grf {
    grfid: "TEM\11";
    name: string(STR_GRF_NAME);
    desc: string(STR_GRF_DESC);
    url : string(STR_GRF_WEBSITE);
    version: 0;
    min_compatible_version: 0;
}
/* Check for engine pool */
if (!dynamic_engines) {
    error(ERROR, USED_WITH, string(STR_ERROR_ENGINE_POOL));
}

basecost {
    PR_RUNNING_TRAIN_DIESEL: 2;
}

/* Define a cargo translation table */
cargotable {
/* Used in refit mask */
    PASS, // Passengers 
    MAIL, // Mail
    GOOD, // Goods
    VALU, // Valuables
    STEL, // Steel
    GRAI, // Grain
    OIL_, // Oil
    LVST, // Livestock
    WOOD, // Wood
    COAL, // Coal
    IORE, // Iron Iore
    WDPR, // Timber  
    TOUR, // Tourist 
    PRIS, // Prisioners
    STUD, // Students
    SOCC, // Soccer Players
}
railtypetable {
RAIL, ELRL, MONO, MGLV,	

}

/* ------------------------------------------------- VAGON 1 MATERFER ------------------------------------------------- */

/* Sprite template for a vagon1 full*/
template tmpl_vagon1_full(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_vagon1_full(x) {
	[0,     143,   48,   138,  -20,  -69, NOANIM] 
	[51,    143,   164,  138,  -101, -69, NOANIM] 
	[218,   143,   187,  138,  -93,  -75, NOANIM]
	[409,   143,   164,  138,  -58,  -69, NOANIM]
	[578,   143,   48,   138,  -20,  -69, NOANIM]
	[629,   143,   164,  138,  -82,  -77, NOANIM]
	[799,   143,   164,  138,  -82,  -72, NOANIM]
	[990,   143,   164,  138,  -60,  -69, NOANIM]
}

template tmpl_32_vagon1_full_MASK(x) {
	[0,     143,   48,   138,  -20,  -69, NOANIM, mask] 
	[51,    143,   164,  138,  -101, -69, NOANIM, mask] 
	[218,   143,   187,  138,  -93,  -75, NOANIM, mask]
	[409,   143,   164,  138,  -58,  -69, NOANIM, mask]
	[578,   143,   48,   138,  -20,  -69, NOANIM, mask]
	[629,   143,   164,  138,  -82,  -77, NOANIM, mask]
	[799,   143,   164,  138,  -82,  -72, NOANIM, mask]
	[990,   143,   164,  138,  -60,  -69, NOANIM, mask]
}

/* Sprite template for a realtram empty*/
template tmpl_vagon1_empty(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_vagon1_empty(x) {
	[0,     143,   48,   138,  -20,  -69, NOANIM] 
	[51,    143,   164,  138,  -101, -69, NOANIM] 
	[218,   143,   187,  138,  -93,  -75, NOANIM]
	[409,   143,   164,  138,  -58,  -69, NOANIM]
	[578,   143,   48,   138,  -20,  -69, NOANIM]
	[629,   143,   164,  138,  -82,  -77, NOANIM]
	[799,   143,   164,  138,  -82,  -72, NOANIM]
	[990,   143,   164,  138,  -60,  -69, NOANIM]
}

template tmpl_32_vagon1_empty_MASK(x) {
	[0,     143,   48,   138,  -20,  -69, NOANIM, mask] 
	[51,    143,   164,  138,  -101, -69, NOANIM, mask] 
	[218,   143,   187,  138,  -93,  -75, NOANIM, mask]
	[409,   143,   164,  138,  -58,  -69, NOANIM, mask]
	[578,   143,   48,   138,  -20,  -69, NOANIM, mask]
	[629,   143,   164,  138,  -82,  -77, NOANIM, mask]
	[799,   143,   164,  138,  -82,  -72, NOANIM, mask]
	[990,   143,   164,  138,  -60,  -69, NOANIM, mask]
}

/* Define various cargo-specific graphics */

/* Goods */
spriteset(vagon1_empty, "gfx/realtrains.png") { tmpl_vagon1_empty(0) }
alternative_sprites(vagon1_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png")  
{ tmpl_32_vagon1_empty(0) }

spriteset(vagon1_full, "gfx/realtrains.png") { tmpl_vagon1_full(0) }
alternative_sprites(vagon1_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png")  
{ tmpl_32_vagon1_full(0) }

spritegroup vagon1 {
    loaded: [vagon1_empty,vagon1_full];
    loading: [vagon1_empty,vagon1_full];
}

/* Purchase Menu Image */
spriteset(spriteset_vagon1_purchase, "gfx/realtrains.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_vagon1_purchase, ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png") {[799,143,164,138,-82,-72]} 

/* Properties */

/* Define the road vehicle */
item(FEAT_TRAINS, flatbed_vagon1_1) {
    property {
        /* Properties common to all vehicle types */
        name: string(STR_NAME_vagon1_1);
        climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); // not available in toyland
        introduction_date: date(1980,01,01);
        model_life: VEHICLE_NEVER_EXPIRES;
        vehicle_life: 30;
        reliability_decay: 20;
        non_refittable_cargo_classes: bitmask(CC_PASSENGERS);
        default_cargo_type: PASS;
        cargo_allow_refit: [];
        cargo_disallow_refit: []; // we allow other cargoes, if class matches
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling

        // It's an intercity train, loading is relatively slow:
        loading_speed: 6;
        length:8;
        cost_factor: 45;
        running_cost_factor: 100;
        sprite_id: SPRITE_ID_NEW_TRAIN;
        speed: 141 km/h;
        misc_flags: bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);
        refit_cost: 0; // Refitting is free
        // callback flags are not set manually

        track_type: RAIL; // from rail type table
        ai_special_flag: AI_FLAG_PASSENGER;
        power: 0 kW;
        running_cost_base: RUNNING_COST_DIESEL;
        dual_headed: 0;
        cargo_capacity: 25;
        weight: 144 ton;
        ai_engine_rank:               0; // not intended to be used by the ai
        engine_class:                 ENGINE_CLASS_DIESEL;
        extra_power_per_wagon:        0 kW;

       // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:
        tractive_effort_coefficient:  0.3 / 3; // changed by callback
        air_drag_coefficient:         0.06;
        // Overridden by callback to disable for non-powered wagons:
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_DIESEL, 2, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }

    /* Define graphics for various cargo types, as well as the capacity callback */
    graphics {
        default: vagon1; // Default to Passengers.
        purchase: spriteset_vagon1_purchase;
    }
}

/* ------------------------------------------------- LOCOMOTORA GR12W ------------------------------------------------- */

/* Sprite template for a train1 full*/
template tmpl_train1_full(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_train1_full(x) {
	[0,     0,   48,   138,  -20,  -69, NOANIM] 
	[51,    0,   164,  138,  -101, -69, NOANIM] 
	[218,   0,   187,  138,  -93,  -75, NOANIM]
	[409,   0,   164,  138,  -58,  -69, NOANIM]
	[578,   0,   48,   138,  -20,  -69, NOANIM]
	[629,   0,   164,  138,  -82,  -77, NOANIM]
	[799,   0,   164,  138,  -82,  -72, NOANIM]
	[990,   0,   164,  138,  -60,  -69, NOANIM]
}

template tmpl_32_train1_full_MASK(x) {
	[0,     0,   48,   138,  -20,  -69, NOANIM, mask] 
	[51,    0,   164,  138,  -101, -69, NOANIM, mask] 
	[218,   0,   187,  138,  -93,  -75, NOANIM, mask]
	[409,   0,   164,  138,  -58,  -69, NOANIM, mask]
	[578,   0,   48,   138,  -20,  -69, NOANIM, mask]
	[629,   0,   164,  138,  -82,  -77, NOANIM, mask]
	[799,   0,   164,  138,  -82,  -72, NOANIM, mask]
	[990,   0,   164,  138,  -60,  -69, NOANIM, mask]
}

/* Sprite template for a realtram empty*/
template tmpl_train1_empty(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_train1_empty(x) {
	[0,     0,   48,   138,  -20,  -69, NOANIM] 
	[51,    0,   164,  138,  -101, -69, NOANIM] 
	[218,   0,   187,  138,  -93,  -75, NOANIM]
	[409,   0,   164,  138,  -58,  -69, NOANIM]
	[578,   0,   48,   138,  -20,  -69, NOANIM]
	[629,   0,   164,  138,  -82,  -77, NOANIM]
	[799,   0,   164,  138,  -82,  -72, NOANIM]
	[990,   0,   164,  138,  -60,  -69, NOANIM]
}

template tmpl_32_train1_empty_MASK(x) {
	[0,     0,   48,   138,  -20,  -69, NOANIM, mask] 
	[51,    0,   164,  138,  -101, -69, NOANIM, mask] 
	[218,   0,   187,  138,  -93,  -75, NOANIM, mask]
	[409,   0,   164,  138,  -58,  -69, NOANIM, mask]
	[578,   0,   48,   138,  -20,  -69, NOANIM, mask]
	[629,   0,   164,  138,  -82,  -77, NOANIM, mask]
	[799,   0,   164,  138,  -82,  -72, NOANIM, mask]
	[990,   0,   164,  138,  -60,  -69, NOANIM, mask]
}

/* Define various cargo-specific graphics */

/* Goods */
spriteset(train1_empty, "gfx/realtrains.png") { tmpl_train1_empty(0) }
alternative_sprites(train1_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png")  
{ tmpl_32_train1_empty(0) }

spriteset(train1_full, "gfx/realtrains.png") { tmpl_train1_full(0) }
alternative_sprites(train1_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png")  
{ tmpl_32_train1_full(0) }

spritegroup train1 {
    loaded: [train1_empty,train1_full];
    loading: [train1_empty,train1_full];
}

/* Purchase Menu Image */
spriteset(spriteset_train1_purchase, "gfx/realtrains.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_train1_purchase, ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/realtrains_32.png","gfx/real_trains_mask.png") {[799,0,164,138,-82,-72]} 

/* Properties */

/* Define the road vehicle */
item(FEAT_TRAINS, flatbed_train1_1) {
    property {
        /* Properties common to all vehicle types */
        name: string(STR_NAME_train1_1);
        climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); // not available in toyland
        introduction_date: date(1980,01,01);
        model_life: VEHICLE_NEVER_EXPIRES;
        vehicle_life: 30;
        reliability_decay: 20;
        non_refittable_cargo_classes: bitmask(CC_PASSENGERS);
        default_cargo_type: PASS;
        cargo_allow_refit: [];
        cargo_disallow_refit: []; // we allow other cargoes, if class matches
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling

        // It's an intercity train, loading is relatively slow:
        loading_speed: 6;
        length:8;
        cost_factor: 45;
        running_cost_factor: 100;
        sprite_id: SPRITE_ID_NEW_TRAIN;
        speed: 141 km/h;
        misc_flags: bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);
        refit_cost: 0; // Refitting is free
        // callback flags are not set manually

        track_type: RAIL; // from rail type table
        ai_special_flag: AI_FLAG_PASSENGER;
        power: 1260 kW;
        running_cost_base: RUNNING_COST_DIESEL;
        dual_headed: 0;
        cargo_capacity: 25;
        weight: 144 ton;
        ai_engine_rank:               0; // not intended to be used by the ai
        engine_class:                 ENGINE_CLASS_DIESEL;
        extra_power_per_wagon:        0 kW;

       // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:
        tractive_effort_coefficient:  0.3 / 3; // changed by callback
        air_drag_coefficient:         0.06;
        // Overridden by callback to disable for non-powered wagons:
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_DIESEL, 2, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }

    /* Define graphics for various cargo types, as well as the capacity callback */
    graphics {
        default: train1; // Default to Passengers.
        purchase: spriteset_train1_purchase;
    }
}    
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Articulated parts Length (Tram)

Post by PikkaBird »

If you're trying to make vehicles longer than the standard 8/8, you need to use invisible articulated parts to space them out.
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Articulated parts Length (Tram)

Post by temporal8 »

PikkaBird wrote: 25 Jul 2022 01:28 If you're trying to make vehicles longer than the standard 8/8, you need to use invisible articulated parts to space them out.
Thank you! I hadn't thought about it, I'm going to do it.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: Articulated parts Length (Tram)

Post by Eddi »

mind you that you'll probably get graphical glitches with vehicles this long. like overlapping bridges or tunnels
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests