@CONST_max_inv_targets_regional_base = 5 @CONST_max_inv_targets_large_base = 8 @CONST_max_inv_targets_global_base = 12 @CONST_max_inv_targets_super_base = 15 @CONST_max_inv_targets_regional_friends = 5 @CONST_max_inv_targets_large_friends = 7 @CONST_max_inv_targets_global_friends = 9 @CONST_max_inv_targets_super_friends = 10 @CONST_max_inv_targets_regional_allies = 3 @CONST_max_inv_targets_large_allies = 4 @CONST_max_inv_targets_global_allies = 5 @CONST_max_inv_targets_super_allies = 6 yearly_investment_targets_routine = { clear_array = investment_targets if = { limit = { has_idea = regional_power } set_temp_variable = { targets_count = @CONST_max_inv_targets_regional_base } set_temp_variable = { friends_targets_count = @CONST_max_inv_targets_regional_friends } set_temp_variable = { allies_targets_count = @CONST_max_inv_targets_regional_allies } } else_if = { limit = { has_idea = large_power } set_temp_variable = { targets_count = @CONST_max_inv_targets_large_base } set_temp_variable = { friends_targets_count = @CONST_max_inv_targets_large_friends } set_temp_variable = { allies_targets_count = @CONST_max_inv_targets_large_allies } } else_if = { limit = { has_idea = great_power } set_temp_variable = { targets_count = @CONST_max_inv_targets_global_base } set_temp_variable = { friends_targets_count = @CONST_max_inv_targets_global_friends } set_temp_variable = { allies_targets_count = @CONST_max_inv_targets_global_allies } } else = { set_temp_variable = { targets_count = @CONST_max_inv_targets_super_base } set_temp_variable = { friends_targets_count = @CONST_max_inv_targets_super_friends } set_temp_variable = { allies_targets_count = @CONST_max_inv_targets_super_allies } } # we get random countries which are not hostile and store them as investment targets get_random_investment_targets = yes # we add countries which are friendly to us get_random_friend_investment_targets = yes # we add allies/repeat for friends if not in faction get_random_allies_investment_targets = yes # add permanent targets from special array add_permanent_investment_targets = yes } get_random_investment_targets = { set_temp_variable = { country_counter = 0 } while_loop_effect = { limit = { check_variable = { country_counter < targets_count } } random_scope_in_array = { array = global.countries limit = { PREV = { has_opinion = { target = THIS value > -25 } } } add_to_array = { PREV.investment_targets = THIS } } add_to_temp_variable = { country_counter = 1 } } } get_random_friend_investment_targets = { set_temp_variable = { country_counter = 0 } while_loop_effect = { limit = { check_variable = { country_counter < friends_targets_count } } random_scope_in_array = { array = global.countries limit = { PREV = { has_opinion = { target = THIS value > 75 } } } if = { limit = { NOT = { is_in_array = { PREV.investment_targets = THIS } } } add_to_array = { PREV.investment_targets = THIS } } } add_to_temp_variable = { country_counter = 1 } } } get_random_allies_investment_targets = { if = { limit = { is_in_faction = yes } set_temp_variable = { country_counter = 0 } while_loop_effect = { limit = { check_variable = { country_counter < allies_targets_count } } random_scope_in_array = { array = THIS.allies if = { limit = { NOT = { is_in_array = { PREV.investment_targets = THIS } } } add_to_array = { PREV.investment_targets = THIS } } } add_to_temp_variable = { country_counter = 1 } } } else = { set_temp_variable = { country_counter = 0 } while_loop_effect = { limit = { check_variable = { country_counter < allies_targets_count } } random_scope_in_array = { array = global.countries limit = { PREV = { has_opinion = { target = THIS value > 75 } } } if = { limit = { NOT = { is_in_array = { PREV.investment_targets = THIS } } } add_to_array = { PREV.investment_targets = THIS } } } add_to_temp_variable = { country_counter = 1 } } } } add_permanent_investment_targets = { for_each_scope_loop = { array = PREV.permanent_investment_targets if = { limit = { NOT = { is_in_array = { PREV.investment_targets = THIS } } } add_to_array = { PREV.investment_targets = THIS } } } } # purpose: remove permanent_investment_target or add permanent_investment_target # target_nation - The nation whose investment targets array we modify # adding_nation - The nation being added (defaults to ROOT if not set) # remove_nation - Executes the removal version of this script change_permanent_investment_target = { if = { limit = { check_variable = { adding_nation = 0 } check_variable = { remove_nation = 0 } } set_temp_variable = { adding_nation = ROOT } } custom_effect_tooltip = change_permanent_investment_target_tt if = { limit = { NOT = { check_variable = { target_nation = 0 } } } var:target_nation = { if = { limit = { NOT = { check_variable = { adding_nation = 0 } } NOT = { is_in_array = { permanent_investment_targets = var:adding_nation } } } add_to_array = { permanent_investment_targets = var:adding_nation } } else_if = { limit = { NOT = { check_variable = { remove_nation = 0 } } } remove_from_array = { permanent_investment_targets = var:remove_nation } } } } }