Skip to content

Commit

Permalink
Added Class 345 7-car, renamed Class 345 to Class 345 9-car
Browse files Browse the repository at this point in the history
  • Loading branch information
audigex committed May 13, 2024
1 parent 33770a5 commit 78739f3
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 21 deletions.
Binary file modified docs/SpriteIDs.xlsx
Binary file not shown.
13 changes: 12 additions & 1 deletion src/trains/_spriteset/EMU_Sprites/345.pnml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ spriteset (spriteset_br_345_rear, "gfx/Aventra.png") { template_train32px_old(0,

spriteset (spriteset_br_345_purchase, "gfx/Aventra.png") {
template_purchase(200, 39)
}
}

// Start/stop switch, used to limit maximum length
switch(FEAT_TRAINS, SELF, switch_br_345_start_stop, num_vehs_in_consist) {
return CB_RESULT_NO_TEXT; // Allow any length
}

// Only allow the same train type to be added to itself
switch(FEAT_TRAINS, SELF, switch_br_345_can_attach_wagon, vehicle_type_id) {
item_br_345: return CB_RESULT_ATTACH_ALLOW;
return string(STR_CANNOT_ATTACH);
}
74 changes: 74 additions & 0 deletions src/trains/emu/345_7car.pnml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Choose sprites depending on car position
switch(FEAT_TRAINS, SELF, switch_br_345_7car_spriteset, position_in_articulated_veh % 9) {
0: spriteset_br_345_front;
5: spriteset_br_345_middle_panto;
6: spriteset_br_345_rear;
spriteset_br_345_middle;
}

// Define articulations
switch(FEAT_TRAINS, SELF, switch_br_345_7car_articulated, extra_callback_info1) {
// extra_callback_info1 returns the car number, so 1 is the second car, 2 the third, .. so on
// The callback runs this switch until it returns NO_MORE_ARTICULATED_PARTS, which ends the growth
1..6: return item_br_345;
return CB_RESULT_NO_MORE_ARTICULATED_PARTS; // Stop adding more cars
}

// Only give particle effects to front/rear cars
switch(FEAT_TRAINS, SELF, switch_br_345_7car_particles, position_in_articulated_veh % 9) {
5: visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
}

// Class 345
item(FEAT_TRAINS, item_br_345_7car), 599) {
property {
name: string(STR_BR_345_7CAR);
climates_available: ALL_CLIMATES; // available in all climates
introduction_date: date(2017, 06, 02);
model_life: 5; // replaced by 9 car after a few years
vehicle_life: 30; // years after vehicle is deemed "old" and should be replaced
reliability_decay: 0; // dont reduce reliabilty, (will grow from 75% upwards over the years)
refittable_cargo_classes: bitmask(CC_PASSENGERS);
non_refittable_cargo_classes: bitmask();
cost_factor: 105;
loading_speed: 25;
running_cost_factor: 80;
cargo_allow_refit: [];
cargo_disallow_refit: [];

speed: 90 mph;
power: 3100 hp;
cargo_capacity: (1160/7);
weight: 264.21 ton;

sprite_id: SPRITE_ID_NEW_TRAIN; // required
misc_flags: bitmask(TRAIN_FLAG_MU); // acts as multiple-unit
refit_cost: 0;
track_type: railtype("ELRL");
ai_special_flag: AI_FLAG_PASSENGER; // tell ai that this is a passenger train
running_cost_base: RUNNING_COST_ELECTRIC;
dual_headed: 0;
engine_class: ENGINE_CLASS_ELECTRIC;
extra_power_per_wagon: 0 kW;
tractive_effort_coefficient: 0.3;
air_drag_coefficient: 0.06;
length: 8; // full tile length vehicle
visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER); // visual fx
extra_weight_per_wagon: 0 ton;
bitmask_vehicle_info: 0;
}

graphics {
default: switch_br_345_7car_spriteset;
purchase: spriteset_br_345_purchase;
cargo_capacity: return(1160/7 * param_pax);
articulated_part: switch_br_345_7car_articulated;
start_stop: switch_br_345_start_stop;
can_attach_wagon: switch_br_345_can_attach_wagon;
visual_effect_and_powered: switch_br_345_7car_particles;
additional_text: string(STR_DSC_BR_345);
cost_factor: return(GetAdjustedCost(105));
running_cost_factor: return(GetAdjustedCost(80));
}
}
29 changes: 9 additions & 20 deletions src/trains/emu/345.pnml → src/trains/emu/345_9car.pnml
Original file line number Diff line number Diff line change
@@ -1,43 +1,32 @@
// Choose sprites depending on car position
switch(FEAT_TRAINS, SELF, switch_br_345_spriteset, position_in_articulated_veh % 9) {
switch(FEAT_TRAINS, SELF, switch_br_345_9car_spriteset, position_in_articulated_veh % 9) {
0: spriteset_br_345_front;
7: spriteset_br_345_middle_panto;
8: spriteset_br_345_rear;
spriteset_br_345_middle;
}

// Define articulations
switch(FEAT_TRAINS, SELF, switch_br_345_articulated, extra_callback_info1) {
switch(FEAT_TRAINS, SELF, switch_br_345_9car_articulated, extra_callback_info1) {
// extra_callback_info1 returns the car number, so 1 is the second car, 2 the third, .. so on
// The callback runs this switch until it returns NO_MORE_ARTICULATED_PARTS, which ends the growth
1..8: return item_br_345;
return CB_RESULT_NO_MORE_ARTICULATED_PARTS; // Stop adding more cars
}

// Only give particle effects to front/rear cars
switch(FEAT_TRAINS, SELF, switch_br_345_particles, position_in_articulated_veh % 9) {
switch(FEAT_TRAINS, SELF, switch_br_345_9car_particles, position_in_articulated_veh % 9) {
7: visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
}

// Start/stop switch, used to limit maximum length
switch(FEAT_TRAINS, SELF, switch_br_345_start_stop, num_vehs_in_consist) {
return CB_RESULT_NO_TEXT; // Allow any length
}

// Only allow the same train type to be added to itself
switch(FEAT_TRAINS, SELF, switch_br_345_can_attach_wagon, vehicle_type_id) {
item_br_345: return CB_RESULT_ATTACH_ALLOW;
return string(STR_CANNOT_ATTACH);
}


// Class 345
item(FEAT_TRAINS, item_br_345, 426) {
item(FEAT_TRAINS, item_br_345_9car, 426) {
property {
name: string(STR_BR_345);
name: string(STR_BR_345_9CAR);
climates_available: ALL_CLIMATES; // available in all climates
introduction_date: date(2017, 06, 02);
introduction_date: date(2021, 06, 02);
model_life: VEHICLE_NEVER_EXPIRES; // keep available forever
vehicle_life: 30; // years after vehicle is deemed "old" and should be replaced
reliability_decay: 0; // dont reduce reliabilty, (will grow from 75% upwards over the years)
Expand Down Expand Up @@ -72,13 +61,13 @@ item(FEAT_TRAINS, item_br_345, 426) {
}

graphics {
default: switch_br_345_spriteset;
default: switch_br_345_9car_spriteset;
purchase: spriteset_br_345_purchase;
cargo_capacity: return(1500/9 * param_pax);
articulated_part: switch_br_345_articulated;
articulated_part: switch_br_345_9car_articulated;
start_stop: switch_br_345_start_stop;
can_attach_wagon: switch_br_345_can_attach_wagon;
visual_effect_and_powered: switch_br_345_particles;
visual_effect_and_powered: switch_br_345_9car_particles;
additional_text: string(STR_DSC_BR_345);
cost_factor: return(GetAdjustedCost(110));
running_cost_factor: return(GetAdjustedCost(85));
Expand Down

0 comments on commit 78739f3

Please sign in to comment.