C:\Users\k-Knight\Git\firs (rfirs)                                                                                                                                                             
λ git show                                                                                                                                                                                     
commit 834354a03e6354819a31ef99d39a1123f1c61c03 (HEAD -> rfirs)                                                                                                                                
Author: k-Knight <----------.-----@gmail.com>                                                                                                                                                  
Date:   Wed Sep 23 00:36:57 2020 +0300                                                                                                                                                         
                                                                                                                                                                                               
    Start of RFIRS                                                                                                                                                                             
                                                                                                                                                                                               
diff --git a/src/industry.py b/src/industry.py                                                                                                                                                 
index 7ceaf832..db5785ec 100644                                                                                                                                                                
--- a/src/industry.py                                                                                                                                                                          
+++ b/src/industry.py                                                                                                                                                                          
@@ -1051,16 +1051,16 @@ class IndustryPrimary(Industry):                                                                                                                                       
         self.perm_storage = IndustryPermStorage(['var_num_supplies_delivered', # amount of supplies delivered this month                                                                      
                                                  'var_num_supplies_delivered_last',                                                                                                           
                                                  'var_num_supplies_delivered_bef_last',                                                                                                       
-                                                 'var_current_supplies_prod_factor',                                                                                                          
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
-                                                 'unused',                                                                                                                                    
+                                                 'var_current_supplies_prod_factor_1',                                                                                                        
+                                                 'var_current_supplies_prod_factor_2',                                                                                                        
+                                                 'var_last_month_transported_1',                                                                                                              
+                                                 'var_last_month_transported_2',                                                                                                              
+                                                 'var_transported_p_month_1',                                                                                                                 
+                                                 'var_transported_pp_month_1',                                                                                                                
+                                                 'var_transported_ppp_month_1',                                                                                                               
+                                                 'var_transported_p_month_2',                                                                                                                 
+                                                 'var_transported_pp_month_2',                                                                                                                
+                                                 'var_transported_ppp_month_2',                                                                                                               
                                                  'unused',                                                                                                                                    
                                                  'unused',                                                                                                                                    
                                                  'unused'])                                                                                                                                   
diff --git a/src/templates/check_primary_supplies_delivered.pynml b/src/templates/check_primary_supplies_delivered.pynml                                                                       
index ca3ea39e..c116c341 100644                                                                                                                                                                
--- a/src/templates/check_primary_supplies_delivered.pynml                                                                                                                                     
+++ b/src/templates/check_primary_supplies_delivered.pynml                                                                                                                                     
@@ -4,7 +4,152 @@                                                                                                                                                                              
 /* Production change evaluated monthly */                                                                                                                                                     
 /* =================================== */                                                                                                                                                     
 <tal:block define="perm_storage industry.perm_storage">                                                                                                                                       
+    switch(FEAT_INDUSTRIES, SELF, ${industry.id}_init_perm_storage, [                                                                                                                         
+        STORE_PERM(0, ${perm_storage.var_transported_ppp_month_1}),                                                                                                                           
+        STORE_PERM(0, ${perm_storage.var_transported_pp_month_1}),                                                                                                                            
+        STORE_PERM(0, ${perm_storage.var_transported_p_month_1}),                                                                                                                             
+                                                                                                                                                                                              
+        STORE_PERM(0, ${perm_storage.var_transported_ppp_month_2}),                                                                                                                           
+        STORE_PERM(0, ${perm_storage.var_transported_pp_month_2}),                                                                                                                            
+        STORE_PERM(0, ${perm_storage.var_transported_p_month_2}),                                                                                                                             
+                                                                                                                                                                                              
+        STORE_PERM(0, ${perm_storage.var_num_supplies_delivered_bef_last}),                                                                                                                   
+        STORE_PERM(0, ${perm_storage.var_num_supplies_delivered_last}),                                                                                                                       
+        STORE_PERM(0, ${perm_storage.var_num_supplies_delivered}),                                                                                                                            
+                                                                                                                                                                                              
+        STORE_PERM(100, ${perm_storage.var_current_supplies_prod_factor_1}),                                                                                                                  
+        STORE_PERM(100, ${perm_storage.var_current_supplies_prod_factor_2})                                                                                                                   
+    ]) {                                                                                                                                                                                      
+        return randomise_primary_production_on_build;                                                                                                                                         
+    }                                                                                                                                                                                         
+                                                                                                                                                                                              
     switch(FEAT_INDUSTRIES, SELF, ${industry.id}_monthly_update, [                                                                                                                            
+        STORE_PERM(LOAD_PERM(${perm_storage.var_transported_pp_month_1}), ${perm_storage.var_transported_ppp_month_1}),                                                                       
+        STORE_PERM(LOAD_PERM(${perm_storage.var_transported_p_month_1}), ${perm_storage.var_transported_pp_month_1}),                                                                         
+        STORE_PERM(transported_last_month_pct_1, ${perm_storage.var_transported_p_month_1}),                                                                                                  
+                                                                                                                                                                                              
+        STORE_PERM(LOAD_PERM(${perm_storage.var_transported_pp_month_2}), ${perm_storage.var_transported_ppp_month_2}),                                                                       
+        STORE_PERM(LOAD_PERM(${perm_storage.var_transported_p_month_2}), ${perm_storage.var_transported_pp_month_2}),                                                                         
+        STORE_PERM(transported_last_month_pct_2, ${perm_storage.var_transported_p_month_2}),                                                                                                  
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_PERM(${perm_storage.var_num_supplies_delivered}) +                                                                                                                           
+            LOAD_PERM(${perm_storage.var_num_supplies_delivered_last}) +                                                                                                                      
+            LOAD_PERM(${perm_storage.var_num_supplies_delivered_bef_last}),                                                                                                                   
+            8                                                                                                                                                                                 
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (LOAD_TEMP(8) >= (${industry.supply_requirements[2]} * primary_level2_requirement)) ? 150 :                                                                                       
+            (LOAD_TEMP(8) >= (${industry.supply_requirements[2]} * primary_level1_requirement)) ? 100 : 25,                                                                                   
+            9                                                                                                                                                                                 
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (random_bits % 2),                                                                                                                                                                
+            8                                                                                                                                                                                 
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_PERM(${perm_storage.var_transported_p_month_1}) +                                                                                                                            
+            LOAD_PERM(${perm_storage.var_transported_pp_month_1}) +                                                                                                                           
+            LOAD_PERM(${perm_storage.var_transported_ppp_month_1}),                                                                                                                           
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_PERM(${perm_storage.var_transported_p_month_2}) +                                                                                                                            
+            LOAD_PERM(${perm_storage.var_transported_pp_month_2}) +                                                                                                                           
+            LOAD_PERM(${perm_storage.var_transported_ppp_month_2}),                                                                                                                           
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(10) / 3 >= LOAD_PERM(${perm_storage.var_transported_p_month_1}) ?                                                                                                       
+            LOAD_TEMP(10) :                                                                                                                                                                   
+            LOAD_PERM(${perm_storage.var_transported_p_month_1}),                                                                                                                             
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(11) / 3 >= LOAD_PERM(${perm_storage.var_transported_p_month_2}) ?                                                                                                       
+            LOAD_TEMP(11) :                                                                                                                                                                   
+            LOAD_PERM(${perm_storage.var_transported_p_month_2}),                                                                                                                             
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(10) >= 80 ? (LOAD_TEMP(8) == 1 ? 10 :  2) :                                                                                                                             
+            LOAD_TEMP(10) >= 70 ? (LOAD_TEMP(8) == 1 ?  8 :  2) :                                                                                                                             
+            LOAD_TEMP(10) >= 60 ? (LOAD_TEMP(8) == 1 ? 10 :  5) :                                                                                                                             
+            LOAD_TEMP(10) >= 50 ? (LOAD_TEMP(8) == 1 ?  5 :  5) :                                                                                                                             
+            LOAD_TEMP(10) >= 40 ? (LOAD_TEMP(8) == 1 ?  6 :  9) :                                                                                                                             
+                                  (LOAD_TEMP(8) == 1 ?  5 : 10),                                                                                                                              
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(11) >= 80 ? (LOAD_TEMP(8) == 1 ? 10 :  2) :                                                                                                                             
+            LOAD_TEMP(11) >= 70 ? (LOAD_TEMP(8) == 1 ?  8 :  2) :                                                                                                                             
+            LOAD_TEMP(11) >= 60 ? (LOAD_TEMP(8) == 1 ? 10 :  5) :                                                                                                                             
+            LOAD_TEMP(11) >= 50 ? (LOAD_TEMP(8) == 1 ?  5 :  5) :                                                                                                                             
+            LOAD_TEMP(11) >= 40 ? (LOAD_TEMP(8) == 1 ?  6 :  9) :                                                                                                                             
+                                  (LOAD_TEMP(8) == 1 ?  5 : 10),                                                                                                                              
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(8) == 1 ? (LOAD_TEMP(10) * LOAD_TEMP(9)) / 100 : LOAD_TEMP(10),                                                                                                         
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(8) == 1 ? (LOAD_TEMP(11) * LOAD_TEMP(9)) / 100 : LOAD_TEMP(11),                                                                                                         
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (random_bits % 100) >= 49 ? LOAD_TEMP(10) : LOAD_TEMP(10) / 2,                                                                                                                    
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (random_bits % 100) >= 49 ? LOAD_TEMP(11) : LOAD_TEMP(11) / 2,                                                                                                                    
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_1}) * LOAD_TEMP(10)) / 100,                                                                                            
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            (LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_2}) * LOAD_TEMP(11)) / 100,                                                                                            
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(8) == 1 ? LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_1}) + LOAD_TEMP(10) :                                                                               
+                                LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_1}) - LOAD_TEMP(10),                                                                                
+            10                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_TEMP(                                                                                                                                                                           
+            LOAD_TEMP(8) == 1 ? LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_2}) + LOAD_TEMP(11) :                                                                               
+                                LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_2}) - LOAD_TEMP(11),                                                                                
+            11                                                                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_PERM(                                                                                                                                                                           
+            LOAD_TEMP(10) <= 85 ? 85 : (LOAD_TEMP(10) >= 10000 ? 10000 : LOAD_TEMP(10)),                                                                                                      
+            ${perm_storage.var_current_supplies_prod_factor_1}                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
+        STORE_PERM(                                                                                                                                                                           
+            LOAD_TEMP(11) <= 85 ? 85 : (LOAD_TEMP(11) >= 10000 ? 10000 : LOAD_TEMP(11)),                                                                                                      
+            ${perm_storage.var_current_supplies_prod_factor_2}                                                                                                                                
+        ),                                                                                                                                                                                    
+                                                                                                                                                                                              
         STORE_PERM(LOAD_PERM(${perm_storage.var_num_supplies_delivered_last}), ${perm_storage.var_num_supplies_delivered_bef_last}),                                                          
         STORE_PERM(LOAD_PERM(${perm_storage.var_num_supplies_delivered}), ${perm_storage.var_num_supplies_delivered_last}),                                                                   
         STORE_PERM(0, ${perm_storage.var_num_supplies_delivered})                                                                                                                             
diff --git a/src/templates/extra_text_primary.pynml b/src/templates/extra_text_primary.pynml                                                                                                   
index 28ff222e..56bd5ec1 100644                                                                                                                                                                
--- a/src/templates/extra_text_primary.pynml                                                                                                                                                   
+++ b/src/templates/extra_text_primary.pynml                                                                                                                                                   
@@ -3,7 +3,7 @@                                                                                                                                                                                
 switch(FEAT_INDUSTRIES, SELF, ${industry.id}_extra_text, [                                                                                                                                    
        STORE_TEMP((primary_level1_requirement * ${industry.supply_requirements[2]}) |                                                                                                         
        (primary_level2_requirement * ${industry.supply_requirements[2]}) << 16, 0x100),                                                                                                       
-       LOAD_PERM(${industry.perm_storage.var_current_supplies_prod_factor})                                                                                                                   
+       LOAD_PERM(${industry.perm_storage.var_current_supplies_prod_factor_1})                                                                                                                 
 ]) {                                                                                                                                                                                          
        primary_level2_bonus: return string(STR_${industry.supply_requirements[1]}_PRODUCTION_4X);                                                                                             
        primary_level1_bonus: return string(STR_${industry.supply_requirements[1]}_PRODUCTION_2X);                                                                                             
diff --git a/src/templates/industry_primary.pynml b/src/templates/industry_primary.pynml                                                                                                       
index 4045b705..60392655 100644                                                                                                                                                                
--- a/src/templates/industry_primary.pynml                                                                                                                                                     
+++ b/src/templates/industry_primary.pynml                                                                                                                                                     
@@ -43,7 +43,6 @@                                                                                                                                                                              
             item(FEAT_INDUSTRIES, ${industry.id}, ${industry.numeric_id}) {                                                                                                                   
                 graphics {                                                                                                                                                                    
                     construction_probability: ${industry.id}_check_availability;                                                                                                              
-                    build_prod_change:        randomise_primary_production_on_build;                                                                                                          
                     produce_cargo_arrival:    ${industry.id}_produce;                                                                                                                         
                     produce_256_ticks:        ${industry.id}_produce_256_ticks;                                                                                                               
                     monthly_prod_change:      ${industry.id}_monthly_update;                                                                                                                  
@@ -53,6 +52,7 @@                                                                                                                                                                              
                     extra_text_industry:      ${industry.id}_extra_text;                                                                                                                      
                     cargo_subtype_display:    ${industry.id}_cargo_subtype_display;                                                                                                           
                     colour:                   switch_colour;                                                                                                                                  
+                    build_prod_change:        ${industry.id}_init_perm_storage;                                                                                                               
                 }                                                                                                                                                                             
             }                                                                                                                                                                                 
         }                                                                                                                                                                                     
diff --git a/src/templates/produce_primary.pynml b/src/templates/produce_primary.pynml                                                                                                         
index edf15698..671497b1 100644                                                                                                                                                                
--- a/src/templates/produce_primary.pynml                                                                                                                                                      
+++ b/src/templates/produce_primary.pynml                                                                                                                                                      
@@ -7,18 +7,16 @@                                                                                                                                                                              
         ${industry.id}_production;                                                                                                                                                            
     }                                                                                                                                                                                         
                                                                                                                                                                                               
-    produce(${industry.id}_production_256, 0, 0, 0, LOAD_TEMP(9) * production_rate_1 / 100, LOAD_TEMP(9) * production_rate_2 / 100, 0);                                                       
+    produce(${industry.id}_production_256, 0, 0, 0, (LOAD_TEMP(8) * production_rate_1) / 100, (LOAD_TEMP(9) * production_rate_2) / 100, 0);                                                   
                                                                                                                                                                                               
-    switch(FEAT_INDUSTRIES, SELF, ${industry.id}_produce_256_ticks,                                                                                                                           
-            [STORE_TEMP(                                                                                                                                                                      
-                LOAD_PERM(${perm_storage.var_num_supplies_delivered}) +                                                                                                                       
-                LOAD_PERM(${perm_storage.var_num_supplies_delivered_last}) +                                                                                                                  
-                LOAD_PERM(${perm_storage.var_num_supplies_delivered_bef_last}),                                                                                                               
-            8),                                                                                                                                                                               
-            STORE_TEMP((LOAD_TEMP(8) >= (${industry.supply_requirements[2]} * primary_level2_requirement)) ? primary_level2_bonus :                                                           
-                       (LOAD_TEMP(8) >= (${industry.supply_requirements[2]} * primary_level1_requirement)) ? primary_level1_bonus : 0, 9),                                                    
-            STORE_PERM(LOAD_TEMP(9), ${perm_storage.var_current_supplies_prod_factor})                                                                                                        
-            ]) {                                                                                                                                                                              
+    switch(                                                                                                                                                                                   
+        FEAT_INDUSTRIES,                                                                                                                                                                      
+        SELF,                                                                                                                                                                                 
+        ${industry.id}_produce_256_ticks,                                                                                                                                                     
+        [                                                                                                                                                                                     
+            STORE_TEMP(LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_1}), 8),                                                                                                     
+            STORE_TEMP(LOAD_PERM(${perm_storage.var_current_supplies_prod_factor_2}), 9)                                                                                                      
+        ]) {                                                                                                                                                                                  
         ${industry.id}_production_256;                                                                                                                                                        
     }                                                                                                                                                                                         
 </tal:block>                                                                                                                                                                                  
                                                                                                                                                                                               
C:\Users\k-Knight\Git\firs (rfirs)                                                                                                                                                             
λ