Loading

Paste #pea9f0s3j

  1. // License: GPLv2
  2. // Author: Zuu + forsch123
  3.  
  4. grf {
  5.  grfid : "ZUU0";
  6.  name : string(STR_GRF_NAME);
  7.  desc : string(STR_GRF_DESCRIPTION);
  8.  version: 2;
  9.  min_compatible_version: 1;
  10. }
  11.  
  12. /* Behaviour:
  13.  *   Industry is constructed with 'storage 0' set to 512, which means 100%.
  14.  *   GS sets 'storage 0' via command.
  15.  *   Actual production modifier is: (1 + storage0/256) / 3
  16.  *     storage0 = 0   ->  33%
  17.  *     storage0 = 256 ->  66%
  18.  *     storage0 = 512 -> 100%
  19.  *     storage0 = 1024 -> 166%
  20.  *   Special value:
  21.  *     Adding 0x10000 to storage0 announces closure and closes the industry next month.
  22.  */
  23.  
  24. produce (primary_produce,
  25.   0, 0, 0,
  26.   production_rate_1 * (LOAD_PERM(0) & 0xFFFF) / 256,
  27.   production_rate_2 * (LOAD_PERM(0) & 0xFFFF) / 256,
  28. );
  29.  
  30. produce (secondary_produce,
  31.   0, 0, 0,
  32.   waiting_cargo_1 * (1 + (LOAD_PERM(0) & 0xFFFF)) / 256 / 3,
  33.   waiting_cargo_2 * (1 + (LOAD_PERM(0) & 0xFFFF)) / 256 / 3,
  34. );
  35.  
  36. switch (FEAT_INDUSTRIES, SELF, monthly_check, [
  37.   LOAD_PERM(0) >> 16
  38. ]) {
  39.   1: return CB_RESULT_IND_PROD_CLOSE;
  40.   0: return CB_RESULT_IND_PROD_NO_CHANGE;
  41. }
  42.  
  43. switch (FEAT_INDUSTRIES, SELF, switch_prod_change, [
  44.   STORE_PERM(extra_callback_info1, 0),
  45.   extra_callback_info1
  46. ]) {
  47.   return CB_RESULT_IND_PROD_NO_CHANGE;
  48. }
  49.  
  50. switch (FEAT_INDUSTRIES, SELF, init_industry, [
  51.   STORE_PERM(512, 0),
  52.   extra_callback_info1
  53. ]) {
  54.   return 16;
  55. }
  56.  
  57. // Create items for all default primary industries
  58. FOR_EACH_BEGIN (INDUSTRY in [INDUSTRYTYPE_COAL_MINE, INDUSTRYTYPE_FOREST, INDUSTRYTYPE_TROPICAL_FARM, INDUSTRYTYPE_COPPER_ORE_MINE, INDUSTRYTYPE_OIL_WELLS, INDUSTRYTYPE_GOLD_MINE, INDUSTRYTYPE_DIAMOND_MINE, INDUSTRYTYPE_IRON_ORE_MINE, INDUSTRYTYPE_FRUIT_PLANTATION, INDUSTRYTYPE_RUBBER_PLANTATION, INDUSTRYTYPE_WATER_WELL, INDUSTRYTYPE_CANDYFLOSS_FOREST, INDUSTRYTYPE_BATTERY_FARM, INDUSTRYTYPE_COLA_WELLS, INDUSTRYTYPE_PLASTIC_FOUNTAIN, INDUSTRYTYPE_BUBBLE_GENERATOR, INDUSTRYTYPE_TOFFE_QUARRY, INDUSTRYTYPE_SUGAR_MINE])
  59. item (FEAT_INDUSTRIES, item_industry_INDUSTRY) {
  60.   property {
  61.     substitute: INDUSTRY;
  62.     override: INDUSTRY;
  63.     prod_multiplier: [5, 0];
  64.   }
  65.   graphics {
  66.     build_prod_change: init_industry;
  67.     random_prod_change: switch_prod_change;
  68.     monthly_prod_change: monthly_check;
  69.     produce_256_ticks: primary_produce;
  70.   }
  71. }
  72. FOR_EACH_END
  73.  
  74. // Two cargo type producers
  75. item (FEAT_INDUSTRIES, item_industry_INDUSTRYTYPE_OIL_RIG) {
  76.   property {
  77.     substitute: INDUSTRYTYPE_OIL_RIG;
  78.     override: INDUSTRYTYPE_OIL_RIG;
  79.     prod_multiplier: [5, 1];
  80.   }
  81.   graphics {
  82.     build_prod_change: init_industry;
  83.     random_prod_change: switch_prod_change;
  84.     monthly_prod_change: monthly_check;
  85.     produce_256_ticks: primary_produce;
  86.   }
  87. }
  88. item (FEAT_INDUSTRIES, item_industry_INDUSTRYTYPE_TEMPERATE_ARCTIC_FARM) {
  89.   property {
  90.     substitute: INDUSTRYTYPE_TEMPERATE_ARCTIC_FARM;
  91.     override: INDUSTRYTYPE_TEMPERATE_ARCTIC_FARM;
  92.     prod_multiplier: [5, 5];
  93.   }
  94.   graphics {
  95.     build_prod_change: init_industry;
  96.     random_prod_change: switch_prod_change;
  97.     monthly_prod_change: monthly_check;
  98.     produce_256_ticks: primary_produce;
  99.   }
  100. }
  101.  
  102. // Default secondary industries
  103. FOR_EACH_BEGIN (INDUSTRY in [INDUSTRYTYPE_SAWMILL, INDUSTRYTYPE_OIL_REFINERY, INDUSTRYTYPE_TEMPERATE_FACTORY, INDUSTRYTYPE_TROPICAL_FACTORY, INDUSTRYTYPE_PRINTING_WORKS, INDUSTRYTYPE_STEEL_MILL, INDUSTRYTYPE_FOOD_PROCESSING_PLANT, INDUSTRYTYPE_PAPER_MILL, INDUSTRYTYPE_LUMBER_MILL, INDUSTRYTYPE_SWEETS_FACTORY, INDUSTRYTYPE_TOY_FACTORY, INDUSTRYTYPE_FIZZY_DRINKS_FACTORY])
  104. item (FEAT_INDUSTRIES, item_industry_INDUSTRY) {
  105.   property {
  106.     substitute: INDUSTRY;
  107.     override: INDUSTRY;
  108.   }
  109.   graphics {
  110.     random_prod_change: switch_prod_change;
  111.     monthly_prod_change: monthly_check;
  112.     produce_cargo_arrival: secondary_produce;
  113.   }
  114. }
  115. FOR_EACH_END
  116.  
  117. // Remaining default industries:
  118. FOR_EACH_BEGIN (cargo in [INDUSTRYTYPE_POWER_PLANT, INDUSTRYTYPE_TEMPERATE_BANK, INDUSTRYTYPE_TROPICAL_ARCTIC_BANK, INDUSTRYTYPE_WATER_TOWER, INDUSTRYTYPE_TOY_SHOP])

Comments