#Written by Doolittle & Marvin #IF YOU ARE NOT BIRD AND YOU TOUCH THIS #I WILL KILL YOU. DO. NOT. FUCK. WITH. THE. MATH. resource_storage_system = { if = { limit = { has_game_rule = { rule = rule_enable_resource_storage_system option = yes } } if = { limit = { check_variable = { modifier@resource_storage_max_capacity > 0 } } if = { limit = { NOT = { has_dynamic_modifier = { modifier = resource_storage_modifier } } } resource_storage_system_setup = yes } set_temp_variable = { max_storage = modifier@resource_storage_max_capacity } resource_storage_steel_calc_effect = yes resource_storage_rubber_calc_effect = yes resource_storage_light_calc_effect = yes resource_storage_tech_calc_effect = yes resource_storage_precious_calc_effect = yes clamp_variable = { var = steel_in_storage min = 0 max = max_storage } clamp_variable = { var = rubber_in_storage min = 0 max = max_storage } clamp_variable = { var = light_in_storage min = 0 max = max_storage } clamp_variable = { var = tech_in_storage min = 0 max = max_storage } clamp_variable = { var = precious_in_storage min = 0 max = max_storage } } if = { limit = { is_ai = no has_country_flag = open_storage_screen } update_dirty_resource_storage_var = yes } } else_if = { limit = { has_dynamic_modifier = { modifier = resource_storage_modifier } } remove_dynamic_modifier = { modifier = resource_storage_modifier } } } resource_storage_system_setup = { if = { limit = { has_game_rule = { rule = rule_enable_resource_storage_system option = yes } } if = { limit = { NOT = { has_variable = rubber_in_storage } } set_variable = { rubber_in_storage = 0 } } if = { limit = { NOT = { has_variable = light_in_storage } } set_variable = { light_in_storage = 0 } } if = { limit = { NOT = { has_variable = precious_in_storage } } set_variable = { precious_in_storage = 0 } } if = { limit = { NOT = { has_variable = tech_in_storage } } set_variable = { tech_in_storage = 0 } } if = { limit = { NOT = { has_variable = steel_in_storage } } set_variable = { steel_in_storage = 0 } } if = { limit = { NOT = { has_dynamic_modifier = { modifier = resource_storage_modifier } } } add_dynamic_modifier = { modifier = resource_storage_modifier } } } } resource_storage_steel_calc_effect = { #This should include all the steel that the nation has left, *including* the buff set_temp_variable = { old_resource_draw_value = steel_from_storage } set_temp_variable = { resource_base_value = { value = resource@steel subtract = old_resource_draw_value } } # Only draw resources if we have a deficit, want to draw, and have the resources to draw if = { limit = { check_expr = { value = resource_base_value less_than = 1 } check_expr = { value = steel_in_storage greater_than = 0 } OR = { is_ai = yes has_country_flag = steel_storage_draw } } subtract_from_variable = { var = steel_in_storage value = { value = resource_base_value multiply = -1 clamp = { min = -1000 max = max_storage } } } if = { limit = { check_expr = { value = steel_in_storage less_than = 0 } } #We overdrew and don't have enough in storage anymore, so reduce the amount taken and empty the store add_to_temp_variable = { resource_base_value = steel_in_storage } set_variable = { steel_in_storage = 0 } } set_variable = { steel_from_storage = { value = resource_base_value multiply = -1 } } set_variable = { steel_storage_display = resource_base_value } set_temp_variable = { resource_base_value = 0 } } else_if = { #check if we ran out. if we ran out, stop pulling limit = { check_expr = { value = steel_in_storage equals = 0 } } set_variable = { steel_from_storage = 0 } set_variable = { steel_storage_display = 0 } } if = { limit = { check_expr = { value = resource_base_value greater_than = 0 } check_expr = { value = steel_in_storage less_than = max_storage } } add_to_variable = { var = steel_in_storage value = { value = resource_base_value clamp = { min = -1000 max = max_storage } } } set_variable = { steel_from_storage = 0 } set_variable = { steel_storage_display = resource_base_value } } } resource_storage_light_calc_effect = { #This should include all the steel that the nation has left, *including* the buff set_temp_variable = { old_resource_draw_value = light_from_storage } set_temp_variable = { resource_base_value = { value = resource@aluminium subtract = light_from_storage } } if = { #Only draw resources if we have a deficit, want to draw, and have the resources to draw limit = { check_expr = { value = resource_base_value less_than = 1 } check_expr = { value = light_in_storage greater_than = 0 } OR = { is_ai = yes has_country_flag = light_storage_draw } } subtract_from_variable = { var = light_in_storage value = { value = resource_base_value multiply = -1 clamp = { min = -1000 max = max_storage } } } if = { limit = { check_expr = { value = light_in_storage less_than = 0 } } #We overdrew and don't have enough in storage anymore, so reduce the amount taken and empty the store add_to_temp_variable = { resource_base_value = light_in_storage } set_variable = { light_in_storage = 0 } } set_variable = { light_from_storage = { value = resource_base_value multiply = -1 } } set_variable = { light_storage_display = resource_base_value } set_temp_variable = { resource_base_value = 0 } } else_if = { #check if we ran out. if we ran out, stop pulling limit = { check_expr = { value = light_in_storage equals = 0 } } set_variable = { light_from_storage = 0 } set_variable = { light_storage_display = 0 } } if = { limit = { check_expr = { value = resource_base_value greater_than = 0 } check_expr = { value = light_in_storage less_than = max_storage } } add_to_variable = { var = light_in_storage value = { value = resource_base_value clamp = { min = -1000 max = max_storage } } } set_variable = { light_from_storage = 0 } set_variable = { light_storage_display = resource_base_value } } } resource_storage_rubber_calc_effect = { #This should include all the steel that the nation has left, *including* the buff set_temp_variable = { old_resource_draw_value = rubber_from_storage } set_temp_variable = { resource_base_value = { value = resource@rubber subtract = rubber_from_storage } } if = { #Only draw resources if we have a deficit, want to draw, and have the resources to draw limit = { check_expr = { value = resource_base_value less_than = 1 } check_expr = { value = rubber_in_storage greater_than = 0 } OR = { is_ai = yes has_country_flag = rubber_storage_draw } } subtract_from_variable = { var = rubber_in_storage value = { value = resource_base_value multiply = -1 clamp = { min = -1000 max = max_storage } } } if = { limit = { check_expr = { value = rubber_in_storage less_than = 0 } } #We overdrew and don't have enough in storage anymore, so reduce the amount taken and empty the store add_to_temp_variable = { resource_base_value = rubber_in_storage } set_variable = { rubber_in_storage = 0 } } set_variable = { rubber_from_storage = { value = resource_base_value multiply = -1 } } set_variable = { rubber_storage_display = resource_base_value } set_temp_variable = { resource_base_value = 0 } } else_if = { #check if we ran out. if we ran out, stop pulling limit = { check_expr = { value = rubber_in_storage equals = 0 } } set_variable = { rubber_from_storage = 0 } set_variable = { rubber_storage_display = 0 } } if = { limit = { check_expr = { value = resource_base_value greater_than = 0 } check_expr = { value = rubber_in_storage less_than = max_storage } } add_to_variable = { var = rubber_in_storage value = { value = resource_base_value clamp = { min = -1000 max = max_storage } } } set_variable = { rubber_from_storage = 0 } set_variable = { rubber_storage_display = resource_base_value } } } resource_storage_tech_calc_effect = { set_temp_variable = { old_resource_draw_value = tech_from_storage } set_temp_variable = { resource_base_value = { value = resource@tungsten subtract = tech_from_storage } } if = { #Only draw resources if we have a deficit, want to draw, and have the resources to draw limit = { check_expr = { value = resource_base_value less_than = 1 } check_expr = { value = tech_in_storage greater_than = 0 } OR = { is_ai = yes has_country_flag = tech_storage_draw } } subtract_from_variable = { var = tech_in_storage value = { value = resource_base_value multiply = -1 clamp = { min = -1000 max = max_storage } } } if = { limit = { check_expr = { value = tech_in_storage less_than = 0 } } #We overdrew and don't have enough in storage anymore, so reduce the amount taken and empty the store add_to_temp_variable = { resource_base_value = tech_in_storage } set_variable = { tech_in_storage = 0 } } set_variable = { tech_from_storage = { value = resource_base_value multiply = -1 } } set_variable = { tech_storage_display = resource_base_value } set_temp_variable = { resource_base_value = 0 } } else_if = { #check if we ran out. if we ran out, stop pulling limit = { check_expr = { value = tech_in_storage equals = 0 } } set_variable = { tech_from_storage = 0 } set_variable = { tech_storage_display = 0 } } if = { limit = { check_expr = { value = resource_base_value greater_than = 0 } check_expr = { value = tech_in_storage less_than = max_storage } } add_to_variable = { var = tech_in_storage value = { value = resource_base_value clamp = { min = -1000 max = max_storage } } } set_variable = { tech_from_storage = 0 } set_variable = { tech_storage_display = resource_base_value } } } resource_storage_precious_calc_effect = { set_temp_variable = { old_resource_draw_value = precious_from_storage } set_temp_variable = { resource_base_value = { value = resource@chromium subtract = precious_from_storage } } if = { #Only draw resources if we have a deficit, want to draw, and have the resources to draw limit = { check_expr = { value = resource_base_value less_than = 1 } check_expr = { value = precious_in_storage greater_than = 0 } OR = { is_ai = yes has_country_flag = precious_storage_draw } } subtract_from_variable = { var = precious_in_storage value = { value = resource_base_value multiply = -1 clamp = { min = -1000 max = max_storage } } } if = { limit = { check_expr = { value = precious_in_storage less_than = 0 } } #We overdrew and don't have enough in storage anymore, so reduce the amount taken and empty the store add_to_temp_variable = { resource_base_value = precious_in_storage } set_variable = { precious_in_storage = 0 } } set_variable = { precious_from_storage = { value = resource_base_value multiply = -1 } } set_variable = { precious_storage_display = resource_base_value } set_temp_variable = { resource_base_value = 0 } } else_if = { #check if we ran out. if we ran out, stop pulling limit = { check_expr = { value = precious_in_storage equals = 0 } } set_variable = { precious_from_storage = 0 } set_variable = { precious_storage_display = 0 } } if = { limit = { check_expr = { value = resource_base_value greater_than = 0 } check_expr = { value = precious_in_storage less_than = max_storage } } add_to_variable = { var = precious_in_storage value = { value = resource_base_value clamp = { min = -1000 max = max_storage } } } set_variable = { precious_from_storage = 0 } set_variable = { precious_storage_display = resource_base_value } } } update_dirty_resource_storage_var = { if = { limit = { check_expr = { value = global.storage_scripted_gui_var less_than = 1000000 } } add_to_variable = { global.storage_scripted_gui_var = 1 } } else = { set_variable = { global.storage_scripted_gui_var = 0 } } }