Page 1 of 1

Dual Locomotive trains NML

Posted: 15 Sep 2024 22:16
by temporal8
I am working on my TGV, in real life consist in two power cars (locomotives) and 8 articulated passenger carriages.

I've seen that adding a second engine to the game and then Ctrl+click to rotate the second one is impossible due to the way each engine is made.

So, I'm wondering what my options are:

- The first would be for the train to have a predefined configuration, that is, the player creates the train and it automatically appears with the 2 locomotives and the 8 cars. (or maybe just 4 so it's not so long)

- That the 2nd locomotive be a simple wagon but with locomotive graphics, in this way the player could customize the length of the train as they want and finally add the "locomotive" wagon.

- Maybe there is a 3rd option that I am not considering?

Thanks in advance.

Image

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 22:38
by peter1138
The third option is "design your graphics to TTD scale, with 8/8 as the maximum length" I suppose...

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 23:07
by PikkaBird
peter1138 wrote: 15 Sep 2024 22:38 The third option is "design your graphics to TTD scale, with 8/8 as the maximum length" I suppose...
This is, of course, the correct answer.

What I would suggest is using ID counting to select the front vs rear cars - ie if there are multiple locomotives in the train, the even-numbered ones get the reversed graphics. Should work just fine.

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 23:11
by temporal8
peter1138 wrote: 15 Sep 2024 22:38 The third option is "design your graphics to TTD scale, with 8/8 as the maximum length" I suppose...
That is very good! hahaha, have a good Sunday. :D

PikkaBird wrote: 15 Sep 2024 23:07 What I would suggest is using ID counting to select the front vs rear cars - ie if there are multiple locomotives in the train, the even-numbered ones get the reversed graphics. Should work just fine.
Thanks a lot, I'm not sure how to do it or I'm not sure I fully understand.

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 23:28
by PikkaBird
count_veh_id with scope PARENT will get the number of vehicles of a particular ID in the whole train.
count_veh_id with scope SELF will get the number of vehicles of a particular ID in the train from this vehicle on.

By comparing these two values, you can determine whether your vehicle is an even- or odd-numbered locomotive, and select the graphics accordingly.

An even simpler, but less flexible, way of doing it would be to simply use reverse graphics for any locomotive that isn't at the front of the train - but that wouldn't allow you to, for example, connect two train sets together.

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 23:34
by temporal8
PikkaBird wrote: 15 Sep 2024 23:28 count_veh_id with scope PARENT will get the number of vehicles of a particular ID in the train.
count_veh_id with scope SELF will get the number of vehicles of a particular ID in the train from this vehicle on.

By comparing these two values, you can determine whether your vehicle is an even- or odd-numbered locomotive, and select the graphics accordingly.

An even simpler, but less flexible, way of doing it would be to simply use reverse graphics for any locomotive that wasn't at the front of the train - but that wouldn't allow you to, for example, connect two train sets together.
"An even simpler, but less flexible, way of doing it would be to simply use reverse graphics for any locomotive that wasn't at the front of the train - but that wouldn't allow you to, for example, connect two train sets together."

I think this would work for me, since I have advanced with my nml knowledge but I am still limited in certain aspects.

What I forgot to say is that I had done tests using dual_headed: 1; I managed to have the second locomotive appear by default, but overlaped with locomotive 1 if there are no cars and overlaped with the last car if there are cars... what can define the position of the second locomotive in order to solve it? or its a dead end?
tgv-dual2.png
tgv-dual2.png (348.96 KiB) Viewed 7616 times

Re: Dual Locomotive trains NML

Posted: 15 Sep 2024 23:37
by PikkaBird
What's happening there is it's not building the articulated vehicle; vehicles can be dual-headed or articulated, but not both.
temporal8 wrote: 15 Sep 2024 23:34 I think this would work for me, since I have advanced with my nml knowledge but I am still limited in certain aspects.
I can talk you through it. Do you use the same vehicle ID for all the articulated parts, or are the invisible parts a different ID? Let's see the code.

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 01:23
by temporal8
You will notice that the ids are not correlative because I only take the parts corresponding to the TGV Sud Est Orange. (actually in the complete code I have all the locomotives first and then the cars)

I am going to post the code in several posts since the forum does not allow me in just one.

Locomotive:

Code: Select all

//================================================================================================================================================================
//======																																				  ========
//====== TGV Sud Est Orange Locomotive ========
//======																																				  ========
//================================================================================================================================================================ 
//Front Part Template 1 of 3

    template template_realtrains1_frontpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -102]
    [400,        320*x,          400,        320,           -251,         -126]
    [800,        320*x,          400,        320,           -280,         -151]
    [1200,       320*x,          400,        320,           -219,         -165]
    [1600,       320*x,          400,        320,           -196,         -174]
    [2000,       320*x,          400,        320,           -179,         -162]
    [2400,       320*x,          400,        320,           -120,         -151]
    [2800,       320*x,          400,        320,           -147,         -129]
}

spriteset(spriteset_realtrains1_frontpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains1_frontpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_locomotives.png") {
template_realtrains1_frontpart(0)
}

spritegroup sgroup_realtrains1_frontpart_0 {
	loaded:     [spriteset_realtrains1_frontpart_0];
    loading:    [spriteset_realtrains1_frontpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains1_frontpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (-1)] - var[0x62, 24, 0x000000FF, -0 - (-1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (-1)] - var[0x62, 24, 0x000000FF, 1 - (-1)]) & 0xFF)) {
    0 : sgroup_realtrains1_frontpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains1_frontpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (-1)] - var[0x62, 0, 0x0000000F, -0 - (-1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (-1)] - var[0x62, 0, 0x0000000F, 1 - (-1)]) & 0xF)) {
 
    0x00000000: item_realtrains1_frontpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains1_frontpart_0, cargo_type_in_veh){
PASS: item_realtrains1_frontpart_0_direction_switch;
item_realtrains1_frontpart_0_direction_switch;
}

// ------------------------------ Back Part ----------------------------------
    template template_realtrains1_backpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -198]
    [400,        320*x,          400,        320,           -155,         -174]
    [800,        320*x,          400,        320,           -88,         -151]
    [1200,       320*x,          400,        320,           -124,         -117]
    [1600,       320*x,          400,        320,           -196,         -78]
    [2000,       320*x,          400,        320,           -275,         -114]
    [2400,       320*x,          400,        320,           -312,         -151]
    [2800,       320*x,          400,        320,           -243,         -177]
}

spriteset(spriteset_realtrains1_backpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains1_backpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_locomotives.png") {
template_realtrains1_backpart(0)
}

spritegroup sgroup_realtrains1_backpart_0 {
	loaded:     [spriteset_realtrains1_backpart_0];
    loading:    [spriteset_realtrains1_backpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains1_backpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (1)] - var[0x62, 24, 0x000000FF, -0 - (1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (1)] - var[0x62, 24, 0x000000FF, 1 - (1)]) & 0xFF)) {
    0 : sgroup_realtrains1_backpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains1_backpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (1)] - var[0x62, 0, 0x0000000F, -0 - (1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (1)] - var[0x62, 0, 0x0000000F, 1 - (1)]) & 0xF)) {
 
    0x00000000: item_realtrains1_backpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains1_backpart_0, cargo_type_in_veh){
PASS: item_realtrains1_backpart_0_direction_switch;
item_realtrains1_backpart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains1_backpart) {
    property {
        name:                         string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               //Climas
        introduction_date:            date(1700, 1, 1);         //Fecha Creacion
        model_life:                   VEHICLE_NEVER_EXPIRES;    //Vida del vehiculo
        vehicle_life:                 200;                      //Vida util antes del reemplazo
        reliability_decay:            0;                        //Confiabilidad según la edad, 0: la confiabilidad no disminuye con la edad
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);   //Ver tabla de cargas
        non_refittable_cargo_classes: bitmask();                              
        cost_factor:                  0;                        //Precio de compra
        running_cost_base:            RUNNING_COST_NONE;        //Costo de funcionamiento base
        running_cost_factor:          0;                        //Aumenta costo de funcionamiento segun antiguedad
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       5;
        track_type:                   RAIL;                     //Segun rail type table
        power:                        0;                        //vagon=0
        dual_headed:                  0;                        //1= doble cabina
        weight:                       385 ton;                  //Peso del vagon vacio
	cargo_capacity:               1;
        ai_special_flag:              AI_FLAG_PASSENGER;        
        ai_engine_rank:               3;                        //Que tan bueno es
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  1;            //coeficiente de fricción de adhesión - no cambiar
        air_drag_coefficient:         0;            //resistencia del aire - cálculo 8/velocidad máxima
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains1_backpart_0; // default graphic
	cargo_capacity:               return 0;
    }
   
}

// ------------------------------ Middle Part ----------------------------------

    template template_realtrains1_middlepart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -142]
    [400,        320*x,          400,        320,           -211,         -146]
    [800,        320*x,          400,        320,           -200,         -151]
    [1200,       320*x,          400,        320,           -179,         -145]
    [1600,       320*x,          400,        320,           -196,         -134]
    [2000,       320*x,          400,        320,           -219,         -142]
    [2400,       320*x,          400,        320,           -200,         -151]
    [2800,       320*x,          400,        320,           -187,         -149]
}

    template template_realtrains1_middlepart_cut(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -142]
    [400,        320*x,          400,        320,           -211,         -146]
    [800,        320*x,          400,        320,           -200,         -151]
    [1200,       320*x,          400,        320,           -179,         -145]
    [1600,       320*x,          400,        320,           -196,         -134]
    [2000,       320*x,          400,        320,           -219,         -142]
    [2400,       320*x,          400,        320,           -200,         -151]
    [2800,       320*x,          400,        320,           -187,         -149]
}

spriteset(spriteset_realtrains1_middlepart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains1_middlepart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_locomotives.png") {
template_realtrains1_middlepart(0)
}

//Cut

spriteset(spriteset_realtrains1_middlepart_0_cut, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains1_middlepart_0_cut, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_locomotives.png") {
template_realtrains1_middlepart_cut(0)
}

spritegroup sgroup_realtrains1_middlepart_0 {
	loaded:     [spriteset_realtrains1_middlepart_0];
    loading:    [spriteset_realtrains1_middlepart_0];
}
spritegroup sgroup_realtrains1_middlepart_0_cut {
	loaded:     [spriteset_realtrains1_middlepart_0_cut];
    loading:    [spriteset_realtrains1_middlepart_0_cut];
}

switch(FEAT_TRAINS, SELF, item_realtrains1_middlepart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (0)] - var[0x62, 24, 0x000000FF, -0 - (0)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (0)] - var[0x62, 24, 0x000000FF, 1 - (0)]) & 0xFF)) {
    0 : sgroup_realtrains1_middlepart_0_cut;
    sgroup_realtrains1_middlepart_0;
}
switch(FEAT_TRAINS, SELF, item_realtrains1_middlepart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (0)] - var[0x62, 0, 0x0000000F, -0 - (0)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (0)] - var[0x62, 0, 0x0000000F, 1 - (0)]) & 0xF)) { 
    0x00000000: item_realtrains1_middlepart_0_height_switch;
    sgroup_realtrains1_middlepart_0;
}

switch (FEAT_TRAINS, SELF, switch_realtrains1_middlepart_0, cargo_type_in_veh){
PASS: item_realtrains1_middlepart_0_direction_switch;
item_realtrains1_middlepart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains1_middlepart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);       
        non_refittable_cargo_classes: bitmask();                              
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                        
        refit_cost:                   0;                        
        loading_speed:                100;                     
        speed:                        300 km/h;
        length:                       7;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
	cargo_capacity:               1;		
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  1;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, -6, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains1_middlepart_0; // default graphic
		cargo_capacity:               return 0;
    }
}
	
// TGV Sud Est Orange Locomotive (final item)

 //-----Purchase-----
spriteset(spriteset_realtrains1_purchase, "gfx/PLACEHOLDER.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtrains1_purchase, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_locomotives.png") {[2400,0,400,320,-200,-164]}
 
switch (FEAT_TRAINS, SELF, switch_articulated_realtrains1, extra_callback_info1) {
    1: return item_realtrains1_middlepart;
    2: return item_realtrains1_backpart;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}

item(FEAT_TRAINS, item_realtrains1) {
    property {
        name:                         string(STR_NAME_realtrains1);
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           ALL_CLIMATES; 			
        introduction_date:            date(1978, 1, 1); 		
        model_life:                   VEHICLE_NEVER_EXPIRES; 	
        vehicle_life:                 30; 				    
        reliability_decay:            0; 			            
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();			    	        	
	    cost_factor:                  49;						
        running_cost_base:            RUNNING_COST_ELECTRIC;		
        running_cost_factor:          47; 						
        refit_cost:                   10; 				     
        loading_speed:                18; 				    
        speed:                        300 km/h; 
	length:			      5;
        track_type:                   RAIL;				    
        power:                        6450 kW; 				    
	cargo_capacity:               98;		
        dual_headed:                  0;				    
        weight:                       385 ton; 				    
        ai_special_flag:              AI_FLAG_PASSENGER;		    
        ai_engine_rank:               2; 				    
        engine_class:                 ENGINE_CLASS_ELECTRIC;
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  1; 			            
        air_drag_coefficient:         0;			            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
    
    graphics {
        default:                      switch_realtrains1_frontpart_0;
		articulated_part:             switch_articulated_realtrains1;
        purchase:                     spriteset_realtrains1_purchase;
		additional_text:              return string(STR_DESC_realtrains1);
		sound_effect:                 locomotive_sound_switch;
    }
}

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 01:24
by temporal8
Wagon 1:

Code: Select all

//================================================================================================================================================================
//======																																				  ========
//====== TGV Sud Est Orange Wagon 1 ========
//======																																				  ========
//================================================================================================================================================================ 
//Front Part Template 1 of 3

    template template_realtrains6_frontpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -102]
    [400,        320*x,          400,        320,           -251,         -126]
    [800,        320*x,          400,        320,           -280,         -151]
    [1200,       320*x,          400,        320,           -219,         -165]
    [1600,       320*x,          400,        320,           -196,         -174]
    [2000,       320*x,          400,        320,           -179,         -162]
    [2400,       320*x,          400,        320,           -120,         -151]
    [2800,       320*x,          400,        320,           -147,         -129]
}

spriteset(spriteset_realtrains6_frontpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains6_frontpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains6_frontpart(0)
}

spriteset(spriteset_realtrains6_frontpart_1, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}

spritegroup sgroup_realtrains6_frontpart_0 {
	loaded:     [spriteset_realtrains6_frontpart_0];
    loading:    [spriteset_realtrains6_frontpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains6_frontpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (-1)] - var[0x62, 24, 0x000000FF, -0 - (-1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (-1)] - var[0x62, 24, 0x000000FF, 1 - (-1)]) & 0xFF)) {
    0 : sgroup_realtrains6_frontpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains6_frontpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (-1)] - var[0x62, 0, 0x0000000F, -0 - (-1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (-1)] - var[0x62, 0, 0x0000000F, 1 - (-1)]) & 0xF)) {
 
    0x00000000: item_realtrains6_frontpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains6_frontpart_0, cargo_type_in_veh){
PASS: item_realtrains6_frontpart_0_direction_switch;
item_realtrains6_frontpart_0_direction_switch;
}

// ------------------------------ Back Part ----------------------------------
    template template_realtrains6_backpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -198]
    [400,        320*x,          400,        320,           -155,         -174]
    [800,        320*x,          400,        320,           -88,         -151]
    [1200,       320*x,          400,        320,           -124,         -117]
    [1600,       320*x,          400,        320,           -196,         -78]
    [2000,       320*x,          400,        320,           -275,         -114]
    [2400,       320*x,          400,        320,           -312,         -151]
    [2800,       320*x,          400,        320,           -243,         -177]
}

spriteset(spriteset_realtrains6_backpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains6_backpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains6_backpart(0)
}

spritegroup sgroup_realtrains6_backpart_0 {
	loaded:     [spriteset_realtrains6_backpart_0];
    loading:    [spriteset_realtrains6_backpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains6_backpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (1)] - var[0x62, 24, 0x000000FF, -0 - (1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (1)] - var[0x62, 24, 0x000000FF, 1 - (1)]) & 0xFF)) {
    0 : sgroup_realtrains6_backpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains6_backpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (1)] - var[0x62, 0, 0x0000000F, -0 - (1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (1)] - var[0x62, 0, 0x0000000F, 1 - (1)]) & 0xF)) {
 
    0x00000000: item_realtrains6_backpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains6_backpart_0, cargo_type_in_veh){
PASS: item_realtrains6_backpart_0_direction_switch;
item_realtrains6_backpart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains6_backpart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);        
        non_refittable_cargo_classes: bitmask();                              
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                        
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       5;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
		cargo_capacity:               1;
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains6_backpart_0; // default graphic
	cargo_capacity:               return 0;
    }
   
 
}

// ------------------------------ Middle Part ----------------------------------

    template template_realtrains6_middlepart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -142]
    [400,        320*x,          400,        320,           -211,         -146]
    [800,        320*x,          400,        320,           -200,         -151]
    [1200,       320*x,          400,        320,           -179,         -145]
    [1600,       320*x,          400,        320,           -196,         -134]
    [2000,       320*x,          400,        320,           -219,         -142]
    [2400,       320*x,          400,        320,           -200,         -151]
    [2800,       320*x,          400,        320,           -187,         -149]
}
//střed cut zavřené dveře+liché řádky základní sprity neořezané
    template template_realtrains6_middlepart_cut(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*x,          400,        320,           -196,         -142]
    [400,        320*x,          400,        320,           -211,         -146]
    [800,        320*x,          400,        320,           -200,         -151]
    [1200,       320*x,          400,        320,           -179,         -145]
    [1600,       320*x,          400,        320,           -196,         -134]
    [2000,       320*x,          400,        320,           -219,         -142]
    [2400,       320*x,          400,        320,           -200,         -151]
    [2800,       320*x,          400,        320,           -187,         -149]
}

spriteset(spriteset_realtrains6_middlepart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains6_middlepart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains6_middlepart(0)
}

//Cut

spriteset(spriteset_realtrains6_middlepart_0_cut, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains6_middlepart_0_cut, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains6_middlepart_cut(0)
}

spritegroup sgroup_realtrains6_middlepart_0 {
	loaded:     [spriteset_realtrains6_middlepart_0];
    loading:    [spriteset_realtrains6_middlepart_0];
}
spritegroup sgroup_realtrains6_middlepart_0_cut {
	loaded:     [spriteset_realtrains6_middlepart_0_cut];
    loading:    [spriteset_realtrains6_middlepart_0_cut];
}

switch(FEAT_TRAINS, SELF, item_realtrains6_middlepart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (0)] - var[0x62, 24, 0x000000FF, -0 - (0)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (0)] - var[0x62, 24, 0x000000FF, 1 - (0)]) & 0xFF)) {
    0 : sgroup_realtrains6_middlepart_0_cut;
    sgroup_realtrains6_middlepart_0;
}
switch(FEAT_TRAINS, SELF, item_realtrains6_middlepart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (0)] - var[0x62, 0, 0x0000000F, -0 - (0)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (0)] - var[0x62, 0, 0x0000000F, 1 - (0)]) & 0xF)) { 
    0x00000000: item_realtrains6_middlepart_0_height_switch;
    sgroup_realtrains6_middlepart_0;
}

switch (FEAT_TRAINS, SELF, switch_realtrains6_middlepart_0, cargo_type_in_veh){
PASS: item_realtrains6_middlepart_0_direction_switch;
item_realtrains6_middlepart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains6_middlepart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);     
        non_refittable_cargo_classes: bitmask();                          
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                       
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       7;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
	cargo_capacity:               1;		
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains6_middlepart_0; // default graphic
	cargo_capacity:               return 0;
    }
}

	
// 857 TGV Sud Est Orange Wagon 1(final item)
 //-----Purchase-----
spriteset(spriteset_realtrains6_purchase, "gfx/PLACEHOLDER.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtrains6_purchase, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {[2400,0,400,320,-200,-164]}
 
switch (FEAT_TRAINS, SELF, switch_articulated_realtrains6, extra_callback_info1) {
    1: return item_realtrains6_middlepart;
    2: return item_realtrains6_backpart;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}

item(FEAT_TRAINS, item_realtrains6) {
    property {
        name:                         string(STR_NAME_realtrains6);
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           ALL_CLIMATES; 			
        introduction_date:            date(1969, 1, 1); 		
        model_life:                   VEHICLE_NEVER_EXPIRES; 	
        vehicle_life:                 30; 						
        reliability_decay:            0; 						
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();			            	
	cost_factor:                  49;						
        running_cost_base:            RUNNING_COST_DIESEL;		
        running_cost_factor:          47; 						
        refit_cost:                   10; 						
        loading_speed:                18; 						
        speed:                        300 km/h; 
	length:			      5;
        track_type:                   RAIL;						
        power:                        0; 					
	cargo_capacity:               98;		
        dual_headed:                  0;						
        weight:                       0 ton; 					
        ai_special_flag:              AI_FLAG_PASSENGER;			
        ai_engine_rank:               2; 						
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3; 			            
        air_drag_coefficient:         0.08;			            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
    
    graphics {
        default:                      switch_realtrains6_frontpart_0;
	articulated_part:             switch_articulated_realtrains6;
        purchase:                     spriteset_realtrains6_purchase;
	additional_text:              return string(STR_DESC_realtrains6);
	sound_effect:                 loko_cd851_sound_switch;
    }
}

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 01:25
by temporal8
Wagon 2:

Code: Select all

//================================================================================================================================================================
//======																																				  ========
//====== TGV Sud Est Orange Wagon 2 ========
//======																																				  ========
//================================================================================================================================================================ 
//Front Part Template 1 of 3

    template template_realtrains7_frontpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*1,          400,        320,           -196,         -102]
    [400,        320*1,          400,        320,           -251,         -126]
    [800,        320*1,          400,        320,           -280,         -151]
    [1200,       320*1,          400,        320,           -219,         -165]
    [1600,       320*1,          400,        320,           -196,         -174]
    [2000,       320*1,          400,        320,           -179,         -162]
    [2400,       320*1,          400,        320,           -120,         -151]
    [2800,       320*1,          400,        320,           -147,         -129]
}

spriteset(spriteset_realtrains7_frontpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains7_frontpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains7_frontpart(0)
}

spritegroup sgroup_realtrains7_frontpart_0 {
	loaded:     [spriteset_realtrains7_frontpart_0];
    loading:    [spriteset_realtrains7_frontpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains7_frontpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (-1)] - var[0x62, 24, 0x000000FF, -0 - (-1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (-1)] - var[0x62, 24, 0x000000FF, 1 - (-1)]) & 0xFF)) {
    0 : sgroup_realtrains7_frontpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains7_frontpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (-1)] - var[0x62, 0, 0x0000000F, -0 - (-1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (-1)] - var[0x62, 0, 0x0000000F, 1 - (-1)]) & 0xF)) {
 
    0x00000000: item_realtrains7_frontpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains7_frontpart_0, cargo_type_in_veh){
PASS: item_realtrains7_frontpart_0_direction_switch;
item_realtrains7_frontpart_0_direction_switch;
}

// ------------------------------ Back Part ----------------------------------
    template template_realtrains7_backpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*1,          400,        320,           -196,         -198]
    [400,        320*1,          400,        320,           -155,         -174]
    [800,        320*1,          400,        320,           -88,         -151]
    [1200,       320*1,          400,        320,           -124,         -117]
    [1600,       320*1,          400,        320,           -196,         -78]
    [2000,       320*1,          400,        320,           -275,         -114]
    [2400,       320*1,          400,        320,           -312,         -151]
    [2800,       320*1,          400,        320,           -243,         -177]
}

spriteset(spriteset_realtrains7_backpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains7_backpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains7_backpart(0)
}

spritegroup sgroup_realtrains7_backpart_0 {
	loaded:     [spriteset_realtrains7_backpart_0];
    loading:    [spriteset_realtrains7_backpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains7_backpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (1)] - var[0x62, 24, 0x000000FF, -0 - (1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (1)] - var[0x62, 24, 0x000000FF, 1 - (1)]) & 0xFF)) {
    0 : sgroup_realtrains7_backpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains7_backpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (1)] - var[0x62, 0, 0x0000000F, -0 - (1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (1)] - var[0x62, 0, 0x0000000F, 1 - (1)]) & 0xF)) {
 
    0x00000000: item_realtrains7_backpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains7_backpart_0, cargo_type_in_veh){
PASS: item_realtrains7_backpart_0_direction_switch;
item_realtrains7_backpart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains7_backpart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);        
        non_refittable_cargo_classes: bitmask();                               
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                        
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       5;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
		cargo_capacity:               1;
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains7_backpart_0; // default graphic
		cargo_capacity:               return 0;
    }
   
 
}

// ------------------------------ Middle Part ----------------------------------

    template template_realtrains7_middlepart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*1,          400,        320,           -196,         -142]
    [400,        320*1,          400,        320,           -211,         -146]
    [800,        320*1,          400,        320,           -200,         -151]
    [1200,       320*1,          400,        320,           -179,         -145]
    [1600,       320*1,          400,        320,           -196,         -134]
    [2000,       320*1,          400,        320,           -219,         -142]
    [2400,       320*1,          400,        320,           -200,         -151]
    [2800,       320*1,          400,        320,           -187,         -149]
}

    template template_realtrains7_middlepart_cut(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*1,          400,        320,           -196,         -142]
    [400,        320*1,          400,        320,           -211,         -146]
    [800,        320*1,          400,        320,           -200,         -151]
    [1200,       320*1,          400,        320,           -179,         -145]
    [1600,       320*1,          400,        320,           -196,         -134]
    [2000,       320*1,          400,        320,           -219,         -142]
    [2400,       320*1,          400,        320,           -200,         -151]
    [2800,       320*1,          400,        320,           -187,         -149]
}

spriteset(spriteset_realtrains7_middlepart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains7_middlepart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains7_middlepart(0)
}

//Cut

spriteset(spriteset_realtrains7_middlepart_0_cut, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains7_middlepart_0_cut, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains7_middlepart_cut(0)
}

spritegroup sgroup_realtrains7_middlepart_0 {
	loaded:     [spriteset_realtrains7_middlepart_0];
    loading:    [spriteset_realtrains7_middlepart_0];
}
spritegroup sgroup_realtrains7_middlepart_0_cut {
	loaded:     [spriteset_realtrains7_middlepart_0_cut];
    loading:    [spriteset_realtrains7_middlepart_0_cut];
}

switch(FEAT_TRAINS, SELF, item_realtrains7_middlepart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (0)] - var[0x62, 24, 0x000000FF, -0 - (0)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (0)] - var[0x62, 24, 0x000000FF, 1 - (0)]) & 0xFF)) {
    0 : sgroup_realtrains7_middlepart_0_cut;
    sgroup_realtrains7_middlepart_0;
}
switch(FEAT_TRAINS, SELF, item_realtrains7_middlepart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (0)] - var[0x62, 0, 0x0000000F, -0 - (0)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (0)] - var[0x62, 0, 0x0000000F, 1 - (0)]) & 0xF)) { 
    0x00000000: item_realtrains7_middlepart_0_height_switch;
    sgroup_realtrains7_middlepart_0;
}

switch (FEAT_TRAINS, SELF, switch_realtrains7_middlepart_0, cargo_type_in_veh){
PASS: item_realtrains7_middlepart_0_direction_switch;
item_realtrains7_middlepart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains7_middlepart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);        
        non_refittable_cargo_classes: bitmask();                              
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                        
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       7;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
		cargo_capacity:               1;		
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains7_middlepart_0; // default graphic
		cargo_capacity:               return 0;
    }
}


	
// 858 TGV Sud Est Wagon 2 (final item)
 //-----Purchase-----
spriteset(spriteset_realtrains7_purchase, "gfx/PLACEHOLDER.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtrains7_purchase, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {[2400,320,400,320,-200,-164]}
 
switch (FEAT_TRAINS, SELF, switch_articulated_realtrains7, extra_callback_info1) {
    1: return item_realtrains7_middlepart;
    2: return item_realtrains7_backpart;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}
 
item(FEAT_TRAINS, item_realtrains7) {
    property {
        name:                         string(STR_NAME_realtrains7);
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           ALL_CLIMATES; 			
        introduction_date:            date(1969, 1, 1); 		
        model_life:                   VEHICLE_NEVER_EXPIRES; 	
        vehicle_life:                 30; 						
        reliability_decay:            0; 						
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();			    	        	
	    cost_factor:                  49;						
        running_cost_base:            RUNNING_COST_ELECTRIC;		
        running_cost_factor:          47; 						
        refit_cost:                   10; 						
        loading_speed:                18; 						
        speed:                        300 km/h; 
	length:			      5;
        track_type:                   RAIL;						
        power:                        0; 					
	cargo_capacity:               98;		
        dual_headed:                  0;						
        weight:                       0 ton; 					
        ai_special_flag:              AI_FLAG_PASSENGER;			
        ai_engine_rank:               2; 						
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3; 			            
        air_drag_coefficient:         0.08;			            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
    
    graphics {
        default:                      switch_realtrains7_frontpart_0;
		articulated_part:             switch_articulated_realtrains7;
        purchase:                     spriteset_realtrains7_purchase;
		additional_text:              return string(STR_DESC_realtrains7);
		sound_effect:                 loko_cd851_sound_switch;
    }
}

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 01:25
by temporal8
Wagon 3:

Code: Select all

//================================================================================================================================================================
//======																																				  ========
//====== TGV Sud Est Orange Wagon 3 ========
//======																																				  ========
//================================================================================================================================================================ 
//Front Part Template 1 of 3

    template template_realtrains8_frontpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*2,          400,        320,           -196,         -102]
    [400,        320*2,          400,        320,           -251,         -126]
    [800,        320*2,          400,        320,           -280,         -151]
    [1200,       320*2,          400,        320,           -219,         -165]
    [1600,       320*2,          400,        320,           -196,         -174]
    [2000,       320*2,          400,        320,           -179,         -162]
    [2400,       320*2,          400,        320,           -120,         -151]
    [2800,       320*2,          400,        320,           -147,         -129]
}

spriteset(spriteset_realtrains8_frontpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains8_frontpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains8_frontpart(0)
}

spritegroup sgroup_realtrains8_frontpart_0 {
	loaded:     [spriteset_realtrains8_frontpart_0];
    loading:    [spriteset_realtrains8_frontpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains8_frontpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (-1)] - var[0x62, 24, 0x000000FF, -0 - (-1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (-1)] - var[0x62, 24, 0x000000FF, 1 - (-1)]) & 0xFF)) {
    0 : sgroup_realtrains8_frontpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains8_frontpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (-1)] - var[0x62, 0, 0x0000000F, -0 - (-1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (-1)] - var[0x62, 0, 0x0000000F, 1 - (-1)]) & 0xF)) {
 
    0x00000000: item_realtrains8_frontpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains8_frontpart_0, cargo_type_in_veh){
PASS: item_realtrains8_frontpart_0_direction_switch;
item_realtrains8_frontpart_0_direction_switch;
}


// ------------------------------ Back Part ----------------------------------
    template template_realtrains8_backpart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*2,          400,        320,           -196,         -198]
    [400,        320*2,          400,        320,           -155,         -174]
    [800,        320*2,          400,        320,           -88,         -151]
    [1200,       320*2,          400,        320,           -124,         -117]
    [1600,       320*2,          400,        320,           -196,         -78]
    [2000,       320*2,          400,        320,           -275,         -114]
    [2400,       320*2,          400,        320,           -312,         -151]
    [2800,       320*2,          400,        320,           -243,         -177]
}

spriteset(spriteset_realtrains8_backpart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains8_backpart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains8_backpart(0)
}

spritegroup sgroup_realtrains8_backpart_0 {
	loaded:     [spriteset_realtrains8_backpart_0];
    loading:    [spriteset_realtrains8_backpart_0];
}

switch(FEAT_TRAINS, SELF, item_realtrains8_backpart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (1)] - var[0x62, 24, 0x000000FF, -0 - (1)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (1)] - var[0x62, 24, 0x000000FF, 1 - (1)]) & 0xFF)) {
    0 : sgroup_realtrains8_backpart_0;
    spriteset_invisible;
}
switch(FEAT_TRAINS, SELF, item_realtrains8_backpart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (1)] - var[0x62, 0, 0x0000000F, -0 - (1)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (1)] - var[0x62, 0, 0x0000000F, 1 - (1)]) & 0xF)) {
 
    0x00000000: item_realtrains8_backpart_0_height_switch;
    spriteset_invisible;
}

switch (FEAT_TRAINS, SELF, switch_realtrains8_backpart_0, cargo_type_in_veh){
PASS: item_realtrains8_backpart_0_direction_switch;
item_realtrains8_backpart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains8_backpart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);        
        non_refittable_cargo_classes: bitmask();                              
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                        
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       5;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
		cargo_capacity:               1;
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains8_backpart_0; // default graphic
		cargo_capacity:               return 0;
    }
   
 
}

// ------------------------------ Middle Part ----------------------------------

    template template_realtrains8_middlepart(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*2,          400,        320,           -196,         -142]
    [400,        320*2,          400,        320,           -211,         -146]
    [800,        320*2,          400,        320,           -200,         -151]
    [1200,       320*2,          400,        320,           -179,         -145]
    [1600,       320*2,          400,        320,           -196,         -134]
    [2000,       320*2,          400,        320,           -219,         -142]
    [2400,       320*2,          400,        320,           -200,         -151]
    [2800,       320*2,          400,        320,           -187,         -149]
}

    template template_realtrains8_middlepart_cut(x) {
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]
    [0,          320*2,          400,        320,           -196,         -142]
    [400,        320*2,          400,        320,           -211,         -146]
    [800,        320*2,          400,        320,           -200,         -151]
    [1200,       320*2,          400,        320,           -179,         -145]
    [1600,       320*2,          400,        320,           -196,         -134]
    [2000,       320*2,          400,        320,           -219,         -142]
    [2400,       320*2,          400,        320,           -200,         -151]
    [2800,       320*2,          400,        320,           -187,         -149]
}



spriteset(spriteset_realtrains8_middlepart_0, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains8_middlepart_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains8_middlepart(0)
}

//Cut

spriteset(spriteset_realtrains8_middlepart_0_cut, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_realtrains8_middlepart_0_cut, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {
template_realtrains8_middlepart_cut(0)
}

spritegroup sgroup_realtrains8_middlepart_0 {
	loaded:     [spriteset_realtrains8_middlepart_0];
    loading:    [spriteset_realtrains8_middlepart_0];
}
spritegroup sgroup_realtrains8_middlepart_0_cut {
	loaded:     [spriteset_realtrains8_middlepart_0_cut];
    loading:    [spriteset_realtrains8_middlepart_0_cut];
}

switch(FEAT_TRAINS, SELF, item_realtrains8_middlepart_0_height_switch, ((var[0x62, 24, 0x000000FF, -1 - (0)] - var[0x62, 24, 0x000000FF, -0 - (0)]) & 0xFF) << 8 | ((var[0x62, 24, 0x000000FF, -0 - (0)] - var[0x62, 24, 0x000000FF, 1 - (0)]) & 0xFF)) {
    0 : sgroup_realtrains8_middlepart_0_cut;
    sgroup_realtrains8_middlepart_0;
}
switch(FEAT_TRAINS, SELF, item_realtrains8_middlepart_0_direction_switch, ((var[0x62, 0, 0x0000000F, -1 - (0)] - var[0x62, 0, 0x0000000F, -0 - (0)]) & 0xF) << 8 | ((var[0x62, 0, 0x0000000F, -0 - (0)] - var[0x62, 0, 0x0000000F, 1 - (0)]) & 0xF)) { 
    0x00000000: item_realtrains8_middlepart_0_height_switch;
    sgroup_realtrains8_middlepart_0;
}

switch (FEAT_TRAINS, SELF, switch_realtrains8_middlepart_0, cargo_type_in_veh){
PASS: item_realtrains8_middlepart_0_direction_switch;
item_realtrains8_middlepart_0_direction_switch;
}

item (FEAT_TRAINS, item_realtrains8_middlepart) {
    property {
        name:                        string(STR_NAME_INVISIBLE); 
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           NO_CLIMATE;               
        introduction_date:            date(1700, 1, 1);         
        model_life:                   VEHICLE_NEVER_EXPIRES;    
        vehicle_life:                 200;                      
        reliability_decay:            0;                        
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);        
        non_refittable_cargo_classes: bitmask();                               
        cost_factor:                  0;                        
        running_cost_base:            RUNNING_COST_NONE;        
        running_cost_factor:          0;                       
        refit_cost:                   0;                        
        loading_speed:                100;                      
        speed:                        300 km/h;
        length:                       7;
        track_type:                   RAIL;                     
        power:                        0 kW;                     
        dual_headed:                  0;                        
        weight:                       0 ton;                    
		cargo_capacity:               1;		
        ai_special_flag:              AI_FLAG_PASSENGER;            
        ai_engine_rank:               3;                        
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;          
        air_drag_coefficient:         0;            
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
   
   graphics {
        default:                      switch_realtrains8_middlepart_0; // default graphic
		cargo_capacity:               return 0;
    }
}

	
// 859 TGV Sud Est Orange Wagon 3 (final item)
 //-----Purchase-----
spriteset(spriteset_realtrains8_purchase, "gfx/PLACEHOLDER.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtrains8_purchase, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tgv_wagons.png") {[2400,640,400,320,-200,-164]}
 
 
switch (FEAT_TRAINS, SELF, switch_articulated_realtrains8, extra_callback_info1) {
    1: return item_realtrains8_middlepart;
    2: return item_realtrains8_backpart;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}

item(FEAT_TRAINS, item_realtrains8) {
    property {
        name:                         string(STR_NAME_realtrains8);
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        climates_available:           ALL_CLIMATES; 			
        introduction_date:            date(1969, 1, 1); 		
        model_life:                   VEHICLE_NEVER_EXPIRES; 	
        vehicle_life:                 30; 						
        reliability_decay:            0; 						
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();			    	        	
	cost_factor:                  49;						
        running_cost_base:            RUNNING_COST_ELECTRIC;		
        running_cost_factor:          47; 						
        refit_cost:                   10; 						
        loading_speed:                18; 						
        speed:                        300 km/h; 
	length:						  5;
        track_type:                   RAIL;						
        power:                        0; 					
	cargo_capacity:               98;		
        dual_headed:                  0;						
        weight:                       0 ton; 					
        ai_special_flag:              AI_FLAG_PASSENGER;			
        ai_engine_rank:               2; 						
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3; 			            
        air_drag_coefficient:         0.08;			           
        visual_effect_and_powered:    VISUAL_EFFECT_DISABLE;
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
    
    graphics {
        default:                      switch_realtrains8_frontpart_0;
		articulated_part:             switch_articulated_realtrains8;
        purchase:                     spriteset_realtrains8_purchase;
		additional_text:              return string(STR_DESC_realtrains8);
		sound_effect:                 loko_cd851_sound_switch;
    }
}

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 02:32
by PikkaBird
Ok, so I can see you're doing a lot more than just invisible spacer parts, and I'm not going to try and unpick it. But since you're using a different ID for every articulated piece, the code to figure out if it's an even- or odd- numbered locomotive would be relatively simple. Just subtract the count of the part from this vehicle on (count_veh_id with scope SELF) from the total count (count_veh_id with scope PARENT), % 2, and bob's your uncle.

The easier alternative, as I said, would be to have reversed graphics for all but the lead locomotive. Just check position_in_consist and if it's not 0 (or 1, 2, etc for the articulated parts), draw graphics that make the vehicle appear reversed.

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 08:15
by michael blunck
Like pikka said.

And the most easy way would be to restrict such a train to a certain/fixed number of elements and use a modulo function to address them. E.g., this is how I do it for the ICE3 in DBXL:

Code: Select all

...

// ICE3 graphics
   
// number of coaches == 8 (24) or 16 (48)
def(1) veh_posabs(MOD24,
	ref(4) if(0 .. 2)   // 1 - trailer front
	ref(8) if(3 .. 5)   // 2 - panto down reverse
	ref(7) if(6 .. 8)   // 3 - panto down 
	ref(9) if(9 .. 14)  // 4 - middle - no panto
	ref(8) if(15 .. 17) // 5 - panto down reverse 
	ref(6) if(18 .. 20) // 6 - panto up, sparking
	ref(5) else           // 7 - trailer back
)

// depot display
spriteblock(
  set(
   sprite(db#ice3.pcx 10 194 01 16 352 -14 -12)
  )
)

def(0) spriteset(move(0),load(0))

def(2) veh_posabs(MOD24,
	ref(0) if(0)   // visible
	ref(VOID) else // transparent
)

def(3) displaymode(
	ref(1) if(DP_VIEWPORT)
	ref(2) else
)

def(4) art_veh_range(_ICE3, 24)
	               
// make callback for engine attach: only 2 * ICE-3 (=23/46 coaches), not more
def(5) veh_num(
	engine(
		attach(ATT_OK) if(< 23)       // max 7 coaches(3 parts)
		attach(ATT_MOTCARBADNUM) else // "wrong number of railcars" 
	)
)

// attach: only ICE-3
def(6) veh_id(
	ref(5) if(_ICE3)	    // OK
	attach(ATT_CARBADTYPE) else // "wrong type of car"
)

// only coach 6 (15 .. 17) and 13 (36 .. 38) is/are sparking!
def(7) veh_posabs(FRONT,
	effect(electric(4)) if(18, 39) // spark
	effect(NONE) else	        // don't spark
)


// CBs
def(16) callback(
	ref(7) if(CB_POWR)	    // power & ELECTRIC
	ref(4) if(CB_ARTI)	    // articulated
	grftext(TSX_IC) if(CB_TSFX) // "Intercity"
	ref(6) if(CB_ATAC)	    // engine attach
	ref(9) if(CB_RCOL)	    // lights
	ref(3) else		            // graphics
)

...
regards
Michael

Re: Dual Locomotive trains NML

Posted: 16 Sep 2024 20:04
by temporal8
Thank you very much for your time and all the help pals, I will see what I can do. :bow:

Cheers