DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Find and discuss all the latest NewGRF releases for TTDPatch and OpenTTD here.

Moderator: Graphics Moderators

Post Reply
12Piggie81
Engineer
Engineer
Posts: 1
Joined: 04 Apr 2021 06:25
Location: Leipzig, Germany

DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by 12Piggie81 »

Dear community,

I am exited to share my first NewGrf with you. Even though there are some awesome trainsets for german railway networks in TTD (DB Set XL, DACH Trains, etc.), I was always missing some special trains from the high-speed segment in Germany.
It seems like there is a new modern DB Set under development, but no release so far. The trains I was looking for are class 411 and class 415 EMUs. These trains are often used on lines which are upgraded for up to 230 km/h. Upgraded lines are usually not straight like new built high-speed lines, so classes 411 and 415 are able to tilt in the curve to keep as much speed as possible on curvy lines.

Since there seems to be any released NewGrf of these EMUs out there, I decided to create them on my own. So here is what I came up with:

Image

You can find the NewGrf file at the end of the post. Available languages are English and German.

Information for gameplay:
- You can use these EMUs in multi-traction operation. It is possible to connect 2 CL411, 1 CL411 + 1 CL415, or up to 3 CL415.
- All engine parameters, etc. are very close to the real model.
- Parameters like loading speed, purchase costs, running costs (base) are oriented to the DB Set XL.
- Running costs will drop a little bit per EMU in multi-traction operation, since there is only 1 train driver needed for the entire consist.
- Graphics will glitch as soon as you put one of the EMUs into a consist that is not leaded by a CL411/415. Didn't figure out how to solve this. Which means: CL411/415 never go with another train... :D

Information about the NewGrf:
As I mentioned before this is my first NewGrf, so I had to learn a lot about creating them.

Special thanks goes to the people writing the NML tutorial, but also to all the people asking questions and all the people answering these questions here. All of that helped a lot to understand how to code in NML and draw (or edit) sprites. Thank you all very much!!

It was my claim to make the EMUs as realistic as possible. Let me explain a few aspects:

Push-pull train
Since the trains are not totally symmetric I had to make them push-pull. The biggest challenge was to make that work not only for a single EMU, but for the consist of two or three and the special combination of a 5 car EMU operation together with a 7 car EMU. But I finally managed to organise the sprites in correct order for every possible consist of CL411 and CL415 EMUs.

Image
Multi-traction of CL415 and CL411 reversing.

Carriage line-up
The carriage line-up changes every time the train stops and "turns" for example in terminus stations. The carriages from the back will be at the front of the train. But if the EMUs operate in multi-traction it is possible, and gives you more graphic variablitlity, that one of the EMUs in the consist is turned as a whole. To enable this, the carriage line-up of each EMU can be changed from depot as an "initial-line-up". You can do this by changing the cargo subtype. Notice that the leading EMU decides for all other EMUs in the consist how they are lined-up.

Image
Refit GUI with 4 different options, since there are 4 possible combinations for the line-up of the whole consist.

The refit option for a single EMU lets you choose between 2 options and the triple multi-traction from CL415 EMUs offers you 8 possible line-ups for the entire consist. That is a total of 28 different "views" you are able to create with this NewGrf. But of course this is only for eyecandy reasons and has no impact on the game mechanics. So if you do not care about eyecandy, do not use that option.

Image
All 28 possible line-ups. (Graphics are from an earlier stage in development, windows are now more black than blue)


Pantographs
Each EMU has two pantographs. To be honest, I have no idea who decides on which factors, which one to use and when. This is again only for eyecandy, but here is how it works in my NewGrf:
A single EMU always uses the pantograph in direction of travel while leaving the depot. From this moment on it does not matter if the EMU has turned or not, it will always use the pantograph that was first up.
Two EMUs that operate in multi-traction will always use the outer pantographs.
Three EMUs behave like a combination of two EMUs in multi-traction which are the outer EMUs in the consist and a single EMU which is the EMU in the middle of the triple-traction.

Image
Different (multi-traction) EMUs reversing to show how the pantographs work.

Dining cars
Class 411 and class 415 look pretty much the same, except the fact that class 411 has 2 additional cars. If you take a closer look to the real EMUs, you will notice that the dining cars are not the same. Since I tried to make it as realistic as possible I also considered this detail. So all doors along the entire train should be at the right place right now.

Image
The dining cars of class 411 and class 415 are outlined.

Headlights
In the animated images above you could already see that the headlights switch between yellow and red. In case of multi-traction operations the inner headlights facing each other are turned off.

Image
Different multi-traction EMUs reversing to show how the headlights work.

Credits:
Most players who have already played with the DB Set XL will have noticed that the graphics have a high similarity. This has been done deliberately to ensure that my ICE T looks good together with trains from the DB Set XL. Of course, this is not a replacement but an extension. Most parts for my sprites are from the ICE TD (Diesel) from the DB Set XL, this is why all credits for the graphics go to Michael Blunck and his incredible DB Set XL.

Image
Comparison ICE TD from the DB Set XL and class 411/415 EMUs.

The credits for coding go to the people creating the NML Tutorial for the three part articulated train. Even though there is not much left of the original template, this one has helped extremly.

For people thinking about creating their own detailed-multi-traction-push-pull trains here is the NML code I ended up with:
[+] Spoiler

Code: Select all

/* Define grf */
grf {
    grfid: "CS\06\01";
    name: string(STR_GRF_NAME);
    desc: string(STR_GRF_DESC);
    version: 1;
    min_compatible_version: 1;
}


/* Define a rail type table, this allows referring to railtypes irrespective of the grfs loaded. */
railtypetable {
    RAIL, ELRL, MONO, MGLV,
}


/* Templates */
template tmpl_vehicle_basic(x, y) {
    // arguments x, y: coordinates of top-left corner of first sprite
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel
    [x +  9, y, 22, 20, -14, -12]
    [x + 32, y, 32, 16, -16, -12]
    [x + 65, y, 22, 20,  -6, -12]
}
template tmpl_vehicle_8_views(num, reversed) {
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)
}
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]
}


/* Spritesets
 * Abkürzungen:
 * -> PO/PU = Pantograph oben/unten
 * -> N/R   = Normal/Reversed
 * -> UL    = Unlighted
 * -> 5/7   = BR415/BR411
 */
spriteset (set_Front_PO_N,    "gfx/icet.png") { tmpl_vehicle_8_views(0, 0) }
spriteset (set_Front_PO_R,    "gfx/icet.png") { tmpl_vehicle_8_views(0, 1) }
spriteset (set_Front_PU_N,    "gfx/icet.png") { tmpl_vehicle_8_views(1, 0) }
spriteset (set_Front_PU_R,    "gfx/icet.png") { tmpl_vehicle_8_views(1, 1) }
spriteset (set_Rear_PO_N,     "gfx/icet.png") { tmpl_vehicle_8_views(2, 1) }
spriteset (set_Rear_PO_R,     "gfx/icet.png") { tmpl_vehicle_8_views(2, 0) }
spriteset (set_Rear_PU_N,     "gfx/icet.png") { tmpl_vehicle_8_views(3, 1) }
spriteset (set_Rear_PU_R,     "gfx/icet.png") { tmpl_vehicle_8_views(3, 0) }
spriteset (set_Front_PO_N_UL, "gfx/icet.png") { tmpl_vehicle_8_views(4, 0) }
spriteset (set_Front_PO_R_UL, "gfx/icet.png") { tmpl_vehicle_8_views(4, 1) }
spriteset (set_Front_PU_N_UL, "gfx/icet.png") { tmpl_vehicle_8_views(5, 0) }
spriteset (set_Front_PU_R_UL, "gfx/icet.png") { tmpl_vehicle_8_views(5, 1) }
spriteset (set_Rear_PO_N_UL,  "gfx/icet.png") { tmpl_vehicle_8_views(4, 1) }
spriteset (set_Rear_PO_R_UL,  "gfx/icet.png") { tmpl_vehicle_8_views(4, 0) }
spriteset (set_Rear_PU_N_UL,  "gfx/icet.png") { tmpl_vehicle_8_views(5, 1) }
spriteset (set_Rear_PU_R_UL,  "gfx/icet.png") { tmpl_vehicle_8_views(5, 0) }
spriteset (set_Restaurant_7_N,"gfx/icet.png") { tmpl_vehicle_8_views(6, 0) }
spriteset (set_Restaurant_7_R,"gfx/icet.png") { tmpl_vehicle_8_views(6, 1) }
spriteset (set_Restaurant_5_N,"gfx/icet.png") { tmpl_vehicle_8_views(7, 0) }
spriteset (set_Restaurant_5_R,"gfx/icet.png") { tmpl_vehicle_8_views(7, 1) }
spriteset (set_ErsteKlasse_N ,"gfx/icet.png") { tmpl_vehicle_8_views(8, 0) }
spriteset (set_ErsteKlasse_R ,"gfx/icet.png") { tmpl_vehicle_8_views(8, 1) }
spriteset (set_ZweiteKlasse_N,"gfx/icet.png") { tmpl_vehicle_8_views(9, 0) }
spriteset (set_ZweiteKlasse_R,"gfx/icet.png") { tmpl_vehicle_8_views(9, 1) }
spriteset (set_purchase_411,  "gfx/icet.png") { tmpl_vehicle_single(10,76, 14, -38, -7) }
spriteset (set_purchase_415,  "gfx/icet.png") { tmpl_vehicle_single(11,76, 14, -38, -7) }
spriteset (set_invisible,     "gfx/icet.png") { tmpl_vehicle_single(12, 1,  1,   0,   0) }



/* --- Graphic Callback Beginn --- */

/* Überprüfen ob der Steuerwagen innerhalb der Traktion gekuppelt und ist ggf. die UL Grafik verwenden */
switch(FEAT_TRAINS, SELF, sw_Rear_PO_N, ((position_in_consist == 0) | (position_in_consist + 1 == num_vehs_in_consist))){
    1: set_Rear_PO_N;
	set_Rear_PO_N_UL;
}
switch(FEAT_TRAINS, SELF, sw_Rear_PU_N, ((position_in_consist == 0) | (position_in_consist + 1 == num_vehs_in_consist))){
    1: set_Rear_PU_N;
	set_Rear_PU_N_UL;
}
switch(FEAT_TRAINS, SELF, sw_Front_PO_N, ((position_in_consist == 0) | (position_in_consist + 1 == num_vehs_in_consist))){
    1: set_Front_PO_N;
	set_Front_PO_N_UL;
}
switch(FEAT_TRAINS, SELF, sw_Front_PU_N, ((position_in_consist == 0) | (position_in_consist + 1 == num_vehs_in_consist))){
    1: set_Front_PU_N;
	set_Front_PU_N_UL;
}

/* Switches die für Einzeltriebzüge und den mittleren Triebzug einer Dreifachtraktion den richtigen Stromabnehmer wählen, damit sozusagen immer der selbe oben ist */
switch(FEAT_TRAINS, PARENT, sw_Final_Direction_Rear_N_1, vehicle_is_reversed){
    0: sw_Rear_PO_N;
	default: sw_Rear_PU_N;
}
switch(FEAT_TRAINS, PARENT, sw_Final_Direction_Rear_N_2, vehicle_is_reversed){
    0: sw_Rear_PU_N;
	default: sw_Rear_PO_N;
}
switch(FEAT_TRAINS, PARENT, sw_Final_Direction_Front_N_1, vehicle_is_reversed){
    0: sw_Front_PO_N;
	default: sw_Front_PU_N;
}
switch(FEAT_TRAINS, PARENT, sw_Final_Direction_Front_N_2, vehicle_is_reversed){
    0: sw_Front_PU_N;
	default: sw_Front_PO_N;
}

/* Hier wird festgelegt welcher Stromabnehmer gewählt werden soll, die Idee ist dabei folgende:
 * Bei einzelnen Triebzügen wird bei der Ausfahrt aus dem Depot der Stromabnehmer in Fahrtrichtung gewählt, unabhängig von der gewählten Wagenreihung
 * Bei Doppeltraktionen werden immer die Stromabnehmer an des äußeren Ende des Gesamtzuges genutzt
 * Bei Dreifachtraktion werden für den vorderen und hinteren Triebzug ebenfalls die Stromabnehmer an den äußeren Enden genutzt, für den mittleren Triebzug der bei der Ausfahrt aus Depot in Fahrtrichtung liegende Stromabnehmer ausgewählt
 *
 * Sobald der Zug das Depot verlassen hat findet kein Wechsel der Stromabnehmer mehr statt
 */
switch(FEAT_TRAINS, SELF, sw_Rear_N_1, position_in_consist) {
    0:      sw_Final_Direction_Rear_N_1;
	4..6:   sw_Final_Direction_Rear_N_2;
	sw_Final_Direction_Rear_N_1;
}
switch(FEAT_TRAINS, SELF, sw_Rear_N_2, position_in_consist) {
    0:      sw_Rear_PO_N;
	4..7:   sw_Rear_PU_N;
	set_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_Rear_N_3, position_in_consist) {
    0:      sw_Rear_PO_N;
	13:     sw_Rear_PO_N;
	5:      sw_Final_Direction_Rear_N_1;
	4:      sw_Rear_PU_N;
	10:     sw_Rear_PU_N;
	9:      sw_Final_Direction_Rear_N_2;
	sw_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_Front_N_1, position_in_consist) {
    0:      sw_Final_Direction_Front_N_1;
	4..6:   sw_Final_Direction_Front_N_2;
	sw_Final_Direction_Front_N_1;
}
switch(FEAT_TRAINS, SELF, sw_Front_N_2, position_in_consist) {
    0:      sw_Front_PO_N;
	4..7:   sw_Front_PU_N;
	sw_Front_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_Front_N_3, position_in_consist) {
    0:      sw_Front_PO_N;
	13:     sw_Front_PO_N;
	5:      sw_Final_Direction_Front_N_1;
	4:      sw_Front_PU_N;
	10:     sw_Front_PU_N;
	9:      sw_Final_Direction_Front_N_2;
	sw_Front_PO_N;
}
switch(FEAT_TRAINS, PARENT, sw_Rear_N, num_vehs_in_consist) {
    5..7:    sw_Rear_N_1;              /* 1 Triebzug  */
    10..14:  sw_Rear_N_2;              /* 2 Triebzüge */
	15:      sw_Rear_N_3;              /* 3 Triebzüge */
	sw_Rear_PO_N;
}
switch(FEAT_TRAINS, PARENT, sw_Front_N, num_vehs_in_consist) {
    5..7:    sw_Front_N_1;              /* 1 Triebzug  */
    10..14:  sw_Front_N_2;              /* 2 Triebzüge */
	15:      sw_Front_N_3;              /* 3 Triebzüge */
	set_Front_PO_N;   /* Verfahren wie für einen Triebzug */
}

/* Basiszuordnung für Einzeltriebzüge und identische Mehrfachtraktionen der Grafiken je Wagen entsprechend der beiden Baureihen */
switch(FEAT_TRAINS, SELF, sw_graphics_N_411, position_in_consist % 7) {
    0:      sw_Front_N;
	1..3:   set_ZweiteKlasse_N;
	4:      set_Restaurant_7_N;
	5:      set_ErsteKlasse_N;
    6:      sw_Rear_N;
    set_invisible;
}
switch(FEAT_TRAINS, SELF, sw_graphics_R_411, position_in_consist % 7) {
    6:      sw_Rear_N;
	3..5:   set_ZweiteKlasse_R;
	2:      set_Restaurant_7_R;
	1:      set_ErsteKlasse_R;
    0:      sw_Front_N;
    set_invisible;
}
switch(FEAT_TRAINS, SELF, sw_graphics_N_415, position_in_consist % 5) {
    0:      sw_Front_N;
	1..2:   set_ZweiteKlasse_N;
	3:      set_Restaurant_5_N;
    4:      sw_Rear_N;
    set_invisible;
}
switch(FEAT_TRAINS, SELF, sw_graphics_R_415, position_in_consist % 5) {
    4:      sw_Rear_N;
	2..3:   set_ZweiteKlasse_R;
	1:      set_Restaurant_5_R;
    0:      sw_Front_N;
    set_invisible;
}
switch(FEAT_TRAINS, SELF, sw_graphics_N, vehicle_type_id) {
    item_BR411: sw_graphics_N_411;
	item_BR415: sw_graphics_N_415;
    set_invisible;
}
switch(FEAT_TRAINS, SELF, sw_graphics_R, vehicle_type_id) {
    item_BR411: sw_graphics_R_411;
	item_BR415: sw_graphics_R_415;
    set_invisible;
}

/* Vorfinaler Check für die Steuerwagen und Finaler Check für die Mittelwagen ob der Zug zur Zeit Reversed ist */
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W1, vehicle_is_reversed){
    0: sw_graphics_N;
	default: sw_graphics_R;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W2, vehicle_is_reversed){
    0: sw_graphics_R;
	default: sw_graphics_N;
}

/* Anwendung der verschiedenen möglichen Wagenreihungen bei Einzeltriebzügen oder Mehrfachtraktionen identischer Baureihen
 * Bei Doppeltraktion werden -vorne- und -hinten- betrachtet
 * Bei Dreifachtraktion der BR415 wird der switch -mitte- zusätzlich genutzt
 */
switch(FEAT_TRAINS, PARENT, sw_direction_base_vorne, cargo_subtype) {
    0: sw_direction_vehicle_W1;
    1: sw_direction_vehicle_W2;
	2: sw_direction_vehicle_W1;
	3: sw_direction_vehicle_W2;
	4: sw_direction_vehicle_W1;
	5: sw_direction_vehicle_W2;
	6: sw_direction_vehicle_W1;
	7: sw_direction_vehicle_W2;
    sw_direction_vehicle_W1;
}
switch(FEAT_TRAINS, PARENT, sw_direction_base_mitte, cargo_subtype) {
    0: sw_direction_vehicle_W1;
    1: sw_direction_vehicle_W2;
	2: sw_direction_vehicle_W2;
	3: sw_direction_vehicle_W1;
    4: sw_direction_vehicle_W2;
    5: sw_direction_vehicle_W1;
	6: sw_direction_vehicle_W1;
	7: sw_direction_vehicle_W2;
    sw_direction_vehicle_W1;
}
switch(FEAT_TRAINS, PARENT, sw_direction_base_hinten, cargo_subtype) {
    0: sw_direction_vehicle_W1;
    1: sw_direction_vehicle_W2;
	2: sw_direction_vehicle_W2;
	3: sw_direction_vehicle_W1;
    4: sw_direction_vehicle_W1;
    5: sw_direction_vehicle_W2;
	6: sw_direction_vehicle_W2;
	7: sw_direction_vehicle_W1;
    sw_direction_vehicle_W1;
}

/* Anwendung der verschiedenen möglichen Wagenreihungen bei Doppeltraktionen von BR411 und BR415 gemeinsam
 * Das ist eine Art spezialfall, da die Triebzüge unterschiedlich lang sind
 * Hier gibt es 4 Varianten mit BR411 vorne und 4 Varianten mit BR415 vorne, dazu zusätzlich die Reversed Variante, das wären eigentlich 16 Reihungen
 * Da es aber jeweils zu Doppelungen einer Reversed und einer Normalen Variante kommt reduziert sich das Ganze auf 8 Varianten
 * Die Zusammenfassung und Überleitung der Varianten erfolgt weiter unten
 */
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_1_N, position_in_consist % 12) {
    0:      sw_Front_PO_N;
	1..3:   set_ZweiteKlasse_N;
	4:      set_Restaurant_7_N;
	5:      set_ErsteKlasse_N;
    6:      sw_Rear_PU_N;
    7:      sw_Front_PU_N;
	8..9:   set_ZweiteKlasse_N;
	10:     set_Restaurant_5_N;
    11:     sw_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_1_R, position_in_consist % 12) {
    11:     sw_Rear_PO_N;
	8..10:  set_ZweiteKlasse_R;
	7:      set_Restaurant_7_R;
	6:      set_ErsteKlasse_R;
    5:      sw_Front_PU_N;
    4:      sw_Rear_PU_N;
	2..3:   set_ZweiteKlasse_R;
	1:      set_Restaurant_5_R;
    0:      sw_Front_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_2_N, position_in_consist % 12) {
	11:      sw_Rear_PO_N;
	9..10:   set_ZweiteKlasse_R;
	8:       set_Restaurant_5_R;
    7:       sw_Front_PU_N;
    6:       sw_Rear_PU_N;
	3..5:    set_ZweiteKlasse_R;
	2:       set_Restaurant_7_R;
	1:       set_ErsteKlasse_R;
    0:       sw_Front_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_2_R, position_in_consist % 12) {
	0:      sw_Front_PO_N;
	1..2:   set_ZweiteKlasse_N;
	3:      set_Restaurant_5_N;
    4:      sw_Rear_PU_N;
    5:      sw_Front_PU_N;
	6..8:   set_ZweiteKlasse_N;
	9:      set_Restaurant_7_N;
	10:     set_ErsteKlasse_N;
    11:     sw_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_3_N, position_in_consist % 12) {
    0:      sw_Front_PO_N;
	1..3:   set_ZweiteKlasse_N;
	4:      set_Restaurant_7_N;
	5:      set_ErsteKlasse_N;
    6:      sw_Rear_PU_N;
	7:      sw_Front_PU_N;
	8:      set_Restaurant_5_R;
	9..10:  set_ZweiteKlasse_R;
    11:     sw_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_3_R, position_in_consist % 12) {
    11:     sw_Rear_PO_N;
	8..10:  set_ZweiteKlasse_R;
	7:      set_Restaurant_7_R;
	6:      set_ErsteKlasse_R;
    5:      sw_Front_PU_N;
	4:      sw_Rear_PU_N;
	3:      set_Restaurant_5_N;
	1..2:   set_ZweiteKlasse_N;
    0:      sw_Front_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_4_N, position_in_consist % 12) {
    0:      sw_Front_PO_N;
	1:      set_ErsteKlasse_R;
	2:      set_Restaurant_7_R;
	3..5:   set_ZweiteKlasse_R;
    6:      sw_Rear_PU_N;
	7:      sw_Front_PU_N;
	8..9:   set_ZweiteKlasse_N;
	10:     set_Restaurant_5_N;
    11:     sw_Rear_PO_N;
}
switch(FEAT_TRAINS, SELF, sw_graphics_spezial_4_R, position_in_consist % 12) {
    11:     sw_Rear_PO_N;
	10:     set_ErsteKlasse_N;
	9:      set_Restaurant_7_N;
	6..8:   set_ZweiteKlasse_N;
    5:      sw_Front_PU_N;
	4:      sw_Rear_PU_N;
	2..3:   set_ZweiteKlasse_R;
	1:      set_Restaurant_5_R;
    0:      sw_Front_PO_N;
}

/* Immer noch nur für den Spezialfall: Hier findet die Überleitung aus der möglichen Varianten in die Grafiken statt */
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W1_spezial_BR411_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_1_N;
	default: sw_graphics_spezial_1_R;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W2_spezial_BR415_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_1_R;
	default: sw_graphics_spezial_1_N;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W2_spezial_BR411_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_2_N;
	default: sw_graphics_spezial_2_R;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W1_spezial_BR415_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_2_R;
	default: sw_graphics_spezial_2_N;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W3_spezial_BR411_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_3_N;
	default: sw_graphics_spezial_3_R;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W4_spezial_BR415_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_3_R;
	default: sw_graphics_spezial_3_N;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W4_spezial_BR411_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_4_N;
	default: sw_graphics_spezial_4_R;
}
switch(FEAT_TRAINS, PARENT, sw_direction_vehicle_W3_spezial_BR415_preswitch, vehicle_is_reversed){
    0: sw_graphics_spezial_4_R;
	default: sw_graphics_spezial_4_N;
}

/* Immer noch nur für den Spezialfall: Hier findet die Zusammenfassung der möglichen Varianten aus dem Cargosubtypes statt */
switch(FEAT_TRAINS, PARENT, sw_direction_base_spezial_BR415, cargo_subtype) {
    0: sw_direction_vehicle_W1_spezial_BR415_preswitch; /* Zusammenfassen der 8 möglichen Varianten der BR 415 vorne auf 4 mögliche Reihungen */
    1: sw_direction_vehicle_W2_spezial_BR415_preswitch;
	2: sw_direction_vehicle_W3_spezial_BR415_preswitch;
	3: sw_direction_vehicle_W4_spezial_BR415_preswitch;
    4: sw_direction_vehicle_W3_spezial_BR415_preswitch;
    5: sw_direction_vehicle_W4_spezial_BR415_preswitch;
	6: sw_direction_vehicle_W1_spezial_BR415_preswitch;
	7: sw_direction_vehicle_W2_spezial_BR415_preswitch;
    sw_direction_vehicle_W1_spezial_BR415_preswitch; /* Fehler: Dann hiermit weiter */
}
switch(FEAT_TRAINS, PARENT, sw_direction_base_spezial_BR411, cargo_subtype) {
    0: sw_direction_vehicle_W1_spezial_BR411_preswitch; /* 4 Varianten der BR 411 vorne ergeben 4 mögliche Reihungen */
    1: sw_direction_vehicle_W2_spezial_BR411_preswitch;
	2: sw_direction_vehicle_W3_spezial_BR411_preswitch;
	3: sw_direction_vehicle_W4_spezial_BR411_preswitch;
    sw_direction_vehicle_W1_spezial_BR411_preswitch; /* Fehler: Dann hiermit weiter */
}

/* Bei Mehrfachtraktionen reicht es nicht aus lediglich die Grafiken von N auf R zu tauschen
 * Würde man lediglich dies tun, so würden die Triebzüge in sich zwar nicht springen, jedoch würde der vorderste mit dem hintersten vertauscht werden
 * Deshalb vertauscht dieser Switch sozusagen den vordersten mit dem hintersten Triebzug, insofern der Zug Reversed unterwegs ist
 */
switch(FEAT_TRAINS, PARENT, sw_direction_base_vorne_preswitch, vehicle_is_reversed) {
    1: sw_direction_base_hinten;
    sw_direction_base_vorne;
}
switch(FEAT_TRAINS, PARENT, sw_direction_base_hinten_preswitch, vehicle_is_reversed) {
    1: sw_direction_base_vorne;
    sw_direction_base_hinten;
}

/* Auf Basis der Position und unter Brücksichtigung der BR wird festgelegt, welche Position der Triebzug in der Mehrfachtraktion hat
 * Für den Spezialfall der Doppeltraktion aus BR411 und BR415 wird hier festgelegt welche BR die Doppeltraktion anführt
 * Die Triebzugposition -mitte- ist nur in der Mehrtraktion aus Triebzügen der BR415 möglich
 */
switch(FEAT_TRAINS, SELF, sw_position_triebzug_411, position_in_consist) {
    0..6: sw_direction_base_vorne_preswitch;   /* Vorderer Zug */
    7..13: sw_direction_base_hinten_preswitch; /* Hinterer Zug */
	sw_direction_base_vorne_preswitch;         /* Verfahren wie für vorderen Zug */
}
switch(FEAT_TRAINS, SELF, sw_position_triebzug_415, position_in_consist) {
    0..4: sw_direction_base_vorne_preswitch;   /* Vorderer Zug */
    5..9: sw_direction_base_hinten_preswitch; /* Hinterer Zug */
	sw_direction_base_vorne_preswitch;         /* Verfahren wie für vorderen Zug */
}
switch(FEAT_TRAINS, PARENT, sw_position_triebzug_spezial, vehicle_type_id) {
    item_BR411: sw_direction_base_spezial_BR411; /* BR 411 vorne, BR 415 hinten */
	item_BR415: sw_direction_base_spezial_BR415; /* BR 415 vorne, BR 414 hinten */
	sw_direction_base_vorne;                   /* Fehler: Nicht weiter definierbar */
}
switch(FEAT_TRAINS, SELF, sw_position_triebzug_dreifach, position_in_consist) {
    0..4:   sw_direction_base_vorne_preswitch;  /* Vorderer Zug */
	5..9:   sw_direction_base_mitte;            /* Mittlerer Zug */
    10..14: sw_direction_base_hinten_preswitch; /* Hinterer Zug */
	sw_direction_base_vorne_preswitch;          /* Verfahren wie für vorderen Zug */
}

/* Auf Basis der Anzahl der Wagen wird die Anzahl der Triebzüge ermittelt
 * Ist nur ein Triebzug vorhanden, so fährt dieser für die weiteren Berechnungen sozusagen vorne
 * Die Triebzugposition -mitte- ist nur in der Mehrtraktion aus Triebzügen der BR415 möglich
 */
switch(FEAT_TRAINS, PARENT, sw_anzahl_triebzuege, num_vehs_in_consist) {
    5:   sw_direction_base_vorne;       /* 1 Triebzug */
	7:   sw_direction_base_vorne;       /* 1 Triebzug */
    10:  sw_position_triebzug_415;      /* 2 Triebzüge einheitlich (415) */
	14:  sw_position_triebzug_411;      /* 2 Triebzüge einheitlich (411) */
	12:  sw_position_triebzug_spezial;  /* 2 Triebzüge nicht einheitlich */
	15:  sw_position_triebzug_dreifach; /* 3 Triebzüge (415) */
	default: sw_direction_base_vorne;   /* Verfahren wie für einen Triebzug */
}

/* --- Graphic Callback Ende --- */



/* --- Weitere Callbacks --- */

/* --- Cargo Subtype callback  --- */
/* Je nach dem wie viele Triebzüge gemeinsam verkehren, gibt es unterschiedliche Subcargotypes die ausgewählt werden können
 * Es gibt immer Wagenreihung 1 und Wagenreihung 2 je Triebzug zur auswahl, das entspricht in etwa der -Flip in Depot- option, allerdings nur grafikbasiert
 * Für Einzelne Triebzüge ergeben sich so zwei Möglichkeiten
 * -> 0: 1
 *    1: 2
 * Für Doppeltraktionen ergeben sich so vier Möglichkeiten
 * -> 0: 1 + 1
 *    1: 2 + 2
 *    2: 1 + 2
 *    3: 2 + 1
 * Für Dreifachtraktionen ergeben sich so acht Möglichkeiten
 * -> 0: 1 + 1 + 1
 *    1: 2 + 2 + 2
 *    2: 1 + 2 + 2
 *    3: 2 + 1 + 1
 *    4: 1 + 2 + 1
 *    5: 2 + 1 + 2
 *    6: 1 + 1 + 2
 *    7: 2 + 2 + 1
 */
switch(FEAT_TRAINS, SELF, sw_cargo_subtype_text_1, cargo_subtype) {
    0: return string(STR_SUBTYPE_1_0);
	1: return string(STR_SUBTYPE_1_1);
    return CB_RESULT_NO_TEXT;
}
switch(FEAT_TRAINS, SELF, sw_cargo_subtype_text_2, cargo_subtype) {
    0: return string(STR_SUBTYPE_2_0);
	1: return string(STR_SUBTYPE_2_1);
	2: return string(STR_SUBTYPE_2_2);
	3: return string(STR_SUBTYPE_2_3);
    return CB_RESULT_NO_TEXT;
}
switch(FEAT_TRAINS, SELF, sw_cargo_subtype_text_3, cargo_subtype) {
    0: return string(STR_SUBTYPE_3_0);
	1: return string(STR_SUBTYPE_3_1);
	2: return string(STR_SUBTYPE_3_2);
	3: return string(STR_SUBTYPE_3_3);
    4: return string(STR_SUBTYPE_3_4);
	5: return string(STR_SUBTYPE_3_5);
	6: return string(STR_SUBTYPE_3_6);
    7: return string(STR_SUBTYPE_3_7);
    return CB_RESULT_NO_TEXT;
}
switch(FEAT_TRAINS, PARENT, sw_cargo_subtype_text, num_vehs_in_consist) {
    5:   sw_cargo_subtype_text_1;        /* 1 Triebzug  */
	7:   sw_cargo_subtype_text_1;        /* 1 Triebzug  */
    10:  sw_cargo_subtype_text_2;        /* 2 Triebzüge */
	14:  sw_cargo_subtype_text_2;        /* 2 Triebzüge */
	12:  sw_cargo_subtype_text_2;        /* 2 Triebzüge */
	15:  sw_cargo_subtype_text_3;        /* 3 Triebzüge */
	sw_cargo_subtype_text_1;             /* Verfahren wie für einen Triebzug */
}

/* --- Running Cost Factor Callback --- */
/* Die Idee ist hier folgende: Wenn Triebzüge in Mehrfachtraktion fahren dann sinken die Betriebskosten, da alle Kosten pro Gesamtzug nur einmal auftreten
 * Angenommen wird, dann der Faktor 80 für die BR415 und der Faktor 100 für die BR411 die Grenzkosten je Triebzug darstellen
 * Dazu kommen dann Kosten die pro einem gesamten Zug auftreten, repräsentiert durch den Faktor 20
 * Die Betriebskosten werden anschließend pro Triebzug so herabgesetzt, dass sich die Gesamtbetriebskosten wie oben beschrieben ergeben.
 */
switch(FEAT_TRAINS, SELF, sw_running_cost_factor_BR, vehicle_type_id) {
    item_BR411: 110; // 100 + 10 = 110
	item_BR415: 90; // 80 +  10 = 90
	100;
}
switch(FEAT_TRAINS, PARENT, sw_running_cost_factor, num_vehs_in_consist) {
    5:   100;                       /* 1 x 415 -> 80  + 20          = 100      */
	7:   120;                       /* 1 x 411 -> 100 + 20          = 120      */
    10:  90;                        /* 2 x 415 -> 80 + 80 + 20      = 180 / 2  */
	14:  110;                       /* 2 x 411 -> 100 + 100 + 20    = 220 / 2  */
	12:  sw_running_cost_factor_BR; /* 1 x 411 + 1 x 415 -> siehe oben         */
	15:  87;                        /* 3 x 415 -> 80 + 80 + 80 + 20 = 260 / 3  */
	100;
}

/* --- Articulated part callback  --- */
switch(FEAT_TRAINS, SELF, sw_articulated_part_411, extra_callback_info1) {
    1 .. 6: return item_BR411;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
}
switch(FEAT_TRAINS, SELF, sw_articulated_part_415, extra_callback_info1) {
    1 .. 4: return item_BR415;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
}

/* --- Start/stop callback  --- */
switch(FEAT_TRAINS, SELF, sw_start_stop, num_vehs_in_consist) {
    1 .. 15: return CB_RESULT_NO_TEXT;
    return string(STR_CANNOT_START);
}

/* --- Wagon attach callback  --- */
switch(FEAT_TRAINS, SELF, sw_can_attach_wagon, vehicle_type_id) {
    /* SELF refers to the wagon here, check that it's an ICM */
    item_BR411: return CB_RESULT_ATTACH_ALLOW;
	item_BR415: return CB_RESULT_ATTACH_ALLOW;
    return string(STR_CANNOT_ATTACH_OTHER);
}

/* Define BR 411 */
item(FEAT_TRAINS, item_BR411) {
     /* Define properties first, make sure to set all of them */
     property {
        name:                         string(STR_NAME_411);
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
        introduction_date:            date(2000, 1, 1);
        model_life:                   VEHICLE_NEVER_EXPIRES;
        vehicle_life:                 30;
        reliability_decay:            20;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();
        loading_speed:                12;
        cost_factor:                  180;
        running_cost_factor:          120; // Changed by callback
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        speed:                        230 km/h;
        misc_flags:                   bitmask(TRAIN_FLAG_TILT, TRAIN_FLAG_MU);
        refit_cost:                   0;
        track_type:                   ELRL; // from rail type table
        ai_special_flag:              AI_FLAG_PASSENGER;
        power:                        4000 kW;
        running_cost_base:            RUNNING_COST_ELECTRIC;
        dual_headed:                  0;
        cargo_capacity:               54;
        weight:                       368 ton;
        ai_engine_rank:               0; // not intended to be used by the ai
        engine_class:                 ENGINE_CLASS_ELECTRIC;
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;   // Laut Dokumentation guter Wert
        air_drag_coefficient:         0.035; // 8/230
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
     /* Define graphics and callbacks
     * Setting all callbacks is not needed, only define what is used */
     graphics {
        default:                      sw_anzahl_triebzuege;
        purchase:                     set_purchase_411;
        start_stop:                   sw_start_stop;
        articulated_part:             sw_articulated_part_411;
        can_attach_wagon:             sw_can_attach_wagon;
		cargo_subtype_text:           sw_cargo_subtype_text;
		additional_text:              return string(STR_ADDITIONAL_TEXT_411);
		running_cost_factor:          sw_running_cost_factor;
    }
}

/* Define BR 415 */
item(FEAT_TRAINS, item_BR415) {
     /* Define properties first, make sure to set all of them */
     property {
        name:                         string(STR_NAME_415);
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
        introduction_date:            date(2000, 1, 1);
        model_life:                   VEHICLE_NEVER_EXPIRES;
        vehicle_life:                 30;
        reliability_decay:            20;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();
        loading_speed:                12;
        cost_factor:                  160;
        running_cost_factor:          100; // Changed by callback
        sprite_id:                    SPRITE_ID_NEW_TRAIN;
        speed:                        230 km/h;
        misc_flags:                   bitmask(TRAIN_FLAG_TILT, TRAIN_FLAG_MU);
        refit_cost:                   0;
        track_type:                   ELRL; // from rail type table
        ai_special_flag:              AI_FLAG_PASSENGER;
        power:                        3000 kW;
        running_cost_base:            RUNNING_COST_ELECTRIC;
        dual_headed:                  0;
        cargo_capacity:               50;
        weight:                       273 ton;
        ai_engine_rank:               0; // not intended to be used by the ai
        engine_class:                 ENGINE_CLASS_ELECTRIC;
        extra_power_per_wagon:        0 kW;
        tractive_effort_coefficient:  0.3;   // Laut Dokumentation guter Wert
        air_drag_coefficient:         0.035; // 8/230
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
    }
     /* Define graphics and callbacks
     * Setting all callbacks is not needed, only define what is used */
     graphics {
        default:                      sw_anzahl_triebzuege;
        purchase:                     set_purchase_415;
        start_stop:                   sw_start_stop;
        articulated_part:             sw_articulated_part_415;
        can_attach_wagon:             sw_can_attach_wagon;
		cargo_subtype_text:           sw_cargo_subtype_text;
		additional_text:              return string(STR_ADDITIONAL_TEXT_415);
		running_cost_factor:          sw_running_cost_factor;
    }
}

Here are some impressions of class 411 and class 415 from a savegame:
[+] Spoiler
Image

Image

Image

Picture 4

I hope you enjoy the DB ICE T (CL411/CL415). If you find bugs or have some suggestions for an even more realistic version 2 of these EMUs, please leave a comment here in the thread.

Best regards from Leipzig
Christopher
Attachments
DB ICE T v1.0.grf
NewGrf: DB ICET (CL411/CL415) v1.0
(36.98 KiB) Downloaded 34 times
User avatar
2TallTyler
Transport Coordinator
Transport Coordinator
Posts: 293
Joined: 11 Aug 2019 18:15
Location: Massachusetts, USA
Contact:

Re: DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by 2TallTyler »

Very nice. :) I do push-pull sprite swapping in my Danish Trains set and know that it’s a lot of work, but the results are worth it.
gravelpit
Engineer
Engineer
Posts: 69
Joined: 26 Feb 2015 14:49
Location: Poland

Re: DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by gravelpit »

many thanks for your effort. This is exactly what I needed, actually I only use it with ICE 1 and 3 from DB SET XL, the rest was useless to me
michael blunck
Tycoon
Tycoon
Posts: 5908
Joined: 27 Apr 2005 07:09
Contact:

Re: DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by michael blunck »

Christopher, good choice for a start!

411/415 are also part of DBXL 0.9, although not using the mentioned push-pull feature. For v0.9 I've removed that feature completely from my set, since it turns out quite problematic when to be used together with other sophisticated features.

IMO, push-pull needs to be a basic feature of the game, not an additional hand-crafted feature of a newgrf.

regards
Michael
Image
gravelpit
Engineer
Engineer
Posts: 69
Joined: 26 Feb 2015 14:49
Location: Poland

Re: DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by gravelpit »

michael blunck wrote: 09 Apr 2021 08:37 Christopher, good choice for a start!

411/415 are also part of DBXL 0.9, although not using the mentioned push-pull feature. For v0.9 I've removed that feature completely from my set, since it turns out quite problematic when to be used together with other sophisticated features.

IMO, push-pull needs to be a basic feature of the game, not an additional hand-crafted feature of a newgrf.

regards
Michael
you haven't thought about refreshing your DB SET XLset for 32bpp I believe it would be a hit
michael blunck
Tycoon
Tycoon
Posts: 5908
Joined: 27 Apr 2005 07:09
Contact:

Re: DB ICE T (CL411/CL415) v1.0 [Push-Pull-EMUs]

Post by michael blunck »

Why do you think so? You're not talking about "extra zoom", don't you?

regards
Michael
Image
Post Reply

Return to “Graphics Releases”

Who is online

Users browsing this forum: No registered users and 4 guests