Advertisement
Guest User

Untitled

a guest
Dec 8th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. //switch to hide the 4th part if a 3part EMU is chosen
  2. switch(FEAT_TRAINS, SELF, sw_cfl2200_graphics_middle, ((position_in_consist % 4) == 2) && (cargo_subtype == 0)) {
  3. 1: set_cfl2200_invisible;
  4. set_cfl2200_middle;
  5. }
  6.  
  7. /* Choose between front, middle and back parts */
  8. switch(FEAT_TRAINS, SELF, sw_cfl2200_graphics, position_in_consist % 4) {
  9. 3: set_cfl2200_rear_lighted;
  10. 0: set_cfl2200_front_lighted;
  11. sw_cfl2200_graphics_middle;
  12. }
  13.  
  14. //articulated
  15. switch(FEAT_TRAINS, SELF, sw_cfl2200_articulated_part, extra_callback_info1) {
  16. 1..3: return item_cfl2200;
  17. return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
  18. }
  19.  
  20.  
  21.  
  22. switch(FEAT_TRAINS, SELF, sw_cfl2200_start_stop, num_vehs_in_consist) {
  23. /* Vehicles may be coupled to a maximum of 4 units (12 cars) */
  24. 1 .. 12: return CB_RESULT_NO_TEXT;
  25. return string(STR_CFL2200_CANNOT_START);
  26. }
  27.  
  28. switch(FEAT_TRAINS, SELF, sw_cfl2200_can_attach_wagon, vehicle_type_id) {
  29. /* SELF refers to the wagon here, check that it's an ICM */
  30. item_cfl2200: return CB_RESULT_ATTACH_ALLOW;
  31. return string(STR_CFL2200_CANNOT_ATTACH_OTHER);
  32. }
  33. switch(FEAT_TRAINS, SELF, sw_cfl2200_cargo_subtype_text, cargo_subtype) {
  34. 0: return string(STR_CFL2200_SUBTYPE_3_PART);
  35. 1: return string(STR_CFL2200_SUBTYPE_4_PART);
  36. return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
  37. }
  38.  
  39. /* --- Shorten vehicle callback --- */
  40. switch(FEAT_TRAINS, SELF, sw_cfl2200_shorten_3_part_vehicle, position_in_consist % 4) {
  41. /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8
  42. * The rear (1/8) part is then made invisisble */
  43. 1: return 7;
  44. 2: return 1;
  45. return 8;
  46. }
  47.  
  48. switch(FEAT_TRAINS, SELF, sw_cfl2200_shorten_vehicle, cargo_subtype) {
  49. 0: sw_cfl2200_shorten_3_part_vehicle;
  50. return 8; // 4-part vehicle needs no shortening
  51. }
  52.  
  53. // 4parts are heavier than 3
  54. switch(FEAT_TRAINS, SELF, sw_cfl2200_weight, cargo_subtype) {
  55. 0: return 193; //ton, 3 part train
  56. return 252; //ton, 4 part train
  57. }
  58.  
  59. switch(FEAT_TRAINS, SELF, sw_cfl2200_te, cargo_subtype) {
  60. /* Base TE coefficient = 0.3
  61. * 3 parts: 4/12 of weight on driving wheels
  62. * 4 parts: 6/16 of weight on driving wheels */
  63. 0: return int(0.3 * 255 / 3);
  64. return int(0.3 * 255 * 3 / 8);
  65. }
  66.  
  67. switch(FEAT_TRAINS, SELF, sw_cfl2200_rc, cargo_subtype) {
  68. return (cargo_subtype == 1) ? 150 : 100;
  69. }
  70.  
  71. switch(FEAT_TRAINS, SELF, sw_cfl2200_capac, cargo_subtype) {
  72. return (cargo_subtype == 0) && ((position_in_consist % 4) == 2) ? 0 : 110;
  73. }
  74.  
  75. /* Power, weight and TE are all applied to the front vehicle only */
  76. switch(FEAT_TRAINS, SELF, sw_cfl2200_power, cargo_subtype) {
  77. 0: return 3160; // kW -> hp
  78. return 3160; // kW -> hp
  79. }
  80.  
  81. /* Define the actual train */
  82. item(FEAT_TRAINS, item_cfl2200) {
  83. /* Define properties first, make sure to set all of them */
  84. property {
  85. name: string(STR_CFL2200_NAME);
  86. climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
  87. introduction_date: date(2004, 1, 1);
  88. model_life: VEHICLE_NEVER_EXPIRES;
  89. vehicle_life: 30;
  90. reliability_decay: 20;
  91. refittable_cargo_classes: bitmask(CC_PASSENGERS);
  92. non_refittable_cargo_classes: bitmask();
  93. // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling
  94. // It's an intercity train, loading is relatively slow:
  95. loading_speed: 40;
  96. cost_factor: 50;
  97. running_cost_factor: 100; //changed by CB, in gfx
  98. sprite_id: SPRITE_ID_NEW_TRAIN;
  99. speed: 160 km/h; // actually 140, but there are rounding errors
  100. //misc_flags: bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);
  101. refit_cost: 0; //refit costs don't apply to subcargo display
  102. cargo_capacity: 110; //change by CB , change in gfx
  103. track_type: ELRL; // from rail type table
  104. ai_special_flag: AI_FLAG_PASSENGER;
  105. power: 3160 hp; //cb in gfx
  106. extra_power_per_wagon: 0 kW;
  107. running_cost_base: RUNNING_COST_ELECTRIC;
  108. dual_headed: 0;
  109. ai_engine_rank: 0; // not intended to be used by the ai
  110. engine_class: ENGINE_CLASS_ELECTRIC;
  111. weight: 193 ton; // Total, changed by callback in gfx
  112. extra_weight_per_wagon: 0 ton;
  113. // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:
  114. tractive_effort_coefficient: 0.3/3; // changed by callback in gfx
  115. air_drag_coefficient: 0.06;
  116. // Overridden by callback to disable for non-powered wagons:
  117. visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
  118. bitmask_vehicle_info: 0;
  119.  
  120.  
  121. }
  122.  
  123. /* Define graphics and callbacks
  124. * Setting all callbacks is not needed, only define what is used */
  125. graphics {
  126.  
  127. default: sw_cfl2200_graphics;
  128. purchase: set_cfl2200_purchase;
  129. articulated_part: sw_cfl2200_articulated_part;
  130. cargo_subtype_text: sw_cfl2200_cargo_subtype_text;
  131. start_stop: sw_cfl2200_start_stop;
  132. additional_text: return string(STR_CFL2200_ADDITIONAL_TEXT);
  133. can_attach_wagon: sw_cfl2200_can_attach_wagon;
  134. length: sw_cfl2200_shorten_vehicle;
  135. running_cost_factor: return (cargo_subtype == 1) ? 150 : 100;
  136. cargo_capacity: return (cargo_subtype == 0) && ((position_in_consist % 4) == 2) ? 0 : 110;
  137. purchase_cargo_capacity: 110;
  138.  
  139. /* Only the front vehicle has power */
  140. power: sw_cfl2200_power;
  141. /* Only the front vehicle has weight */
  142. weight: sw_cfl2200_weight;
  143. /* Only the front vehicle has TE */
  144. tractive_effort_coefficient: sw_cfl2200_te;
  145. /* Only 1/3 of the weight is on the driving weels. */
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement