
###################
#GENERAL VARIABLES#
###################
init_variables = {
    every_state = {
        set_variable = {resis_cantrefi_autonomy = 0.00}
        set_variable = {resis_growth_cantrefi_autonomy = 0.00}
        set_variable = {resis_damage_cantrefi_autonomy = 0.00}
        #set_variable = {yee_haw_level = 0.00}#This was meant to control the on_action state switching to change supply levels
        #set_variable = {resis_supplyredux_cantrefi_autonomy = 0.00}
    }


	#VAR Raiding Defines
	set_variable = {global.var_seize_civ_value = 7}
	set_variable = {global.var_seize_mil_value = 4}
	set_variable = {global.var_seize_inf_value = 2}

	set_variable = {global.var_pillage_civ_value = 5}
	set_variable = {global.var_pillage_mil_value = 2}
	set_variable = {global.var_pillage_inf_value = 1}

	#Divided by on this one.
	set_variable = {global.var_seize_pop_value = 300}
	
    #CYM = {
    #    set_variable = {resis_cantrefi_autonomy = 0.20}
    #    set_variable = {resis_growth_cantrefi_autonomy = 0.00}
    #    set_variable = {resis_damage_cantrefi_autonomy = 0.00}
    #    set_variable = {resis_supplyredux_cantrefi_autonomy = 0.00}
    #}
}


##########
#AUTONOMY#
##########
set_base_autonomy_level = {
    set_variable = {resis_cantrefi_autonomy = 0.20}
    set_variable = {resis_growth_cantrefi_autonomy = 0.00}
    set_variable = {resis_damage_cantrefi_autonomy = 0.00}
}

set_elevated_autonomy_level = {
    set_variable = {resis_cantrefi_autonomy = 0.30}
    set_variable = {resis_growth_cantrefi_autonomy = 0.10}
    set_variable = {resis_damage_cantrefi_autonomy = 0.00}
}

set_militant_autonomy_level = {
    set_variable = {resis_cantrefi_autonomy = 0.25}
    set_variable = {resis_growth_cantrefi_autonomy = 0.15}
    set_variable = {resis_damage_cantrefi_autonomy = 0.10}
}

set_elevated_militant_autonomy_level = {
    set_variable = {resis_cantrefi_autonomy = 0.40}
    set_variable = {resis_growth_cantrefi_autonomy = 0.20}
    set_variable = {resis_damage_cantrefi_autonomy = 0.40}
}


##############################
#GENERAL PURPOSE USEFUL STUFF#
##############################
force_update_factory_count = {
	hidden_effect = {
		country_event = oevent.10
	}
	
}


#########
#STARTUP#
#########

var_add_pop = {
	#Outer islands, big/small
	148 = {
		add_manpower = 450000
	}
	149 = {
		add_manpower = 450000
	}
	150 = {
		add_manpower = 220000
	}
	151 = {
		add_manpower = 220000
	}

	#Two orignal major cities, already have a lot of pop
	154 = {
		add_manpower = 520000
	}
	157 = {
		add_manpower = 520000
	}

	#Two minor cities, buffed to be pretty major 
	155 = {
		add_manpower = 1520000
	}
	156 = {
		add_manpower = 1520000
	}

	#Countryside areas
	152 = {
		add_manpower = 100000
	}
	153 = {
		add_manpower = 150000
	}
}

var_add_industry = {
	every_core_state = {
		add_state_modifier = {
			modifier = {
				local_building_slots = 2
			}
		}
		add_state_modifier = {
			modifier = {
				local_factories = 0.10
			}
		}
		add_building_construction = {
			type = infrastructure 
			level = 1
			instant_build = yes
		}
		
	}
	#Home Island building additions
	153 = {
		set_state_category = town
		add_building_construction = {
			type = dockyard 
			level = 3
			instant_build = yes
		}
	}
	152 = {
		set_state_category = town
		add_building_construction = {
			type = industrial_complex 
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 1
			instant_build = yes
		}
	}
	155 = {
		set_state_category = metropolis
		add_building_construction = {
			type = industrial_complex 
			level = 5
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 1
			instant_build = yes
		}
	}
	156 = {
		set_state_category = metropolis
		add_building_construction = {
			type = industrial_complex 
			level = 5
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 1
			instant_build = yes
		}
	}

	154 = {
		add_state_modifier = {
			modifier = {
				local_building_slots = 2
			}
		}
		add_building_construction = {
			type = industrial_complex 
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = dockyard 
			level = 1
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 4
			instant_build = yes
		}
	}

	157 = {
		add_state_modifier = {
			modifier = {
				local_building_slots = 2
			}
		}
		add_building_construction = {
			type = industrial_complex 
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = dockyard 
			level = 1
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 4
			instant_build = yes
		}
	}


	#Secondary Islands
	150 = {
		set_state_category = city
		add_building_construction = {
			type = industrial_complex 
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = air_base  
			level = 1
			instant_build = yes
		}
	}
	151 = {
		set_state_category = city
		add_building_construction = {
			type = industrial_complex 
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = air_base  
			level = 1
			instant_build = yes
		}
	}
	148 = {
		set_state_category = large_city
		add_building_construction = {
			type = industrial_complex 
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = air_base  
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = infrastructure  
			level = 1
			instant_build = yes
		}
	}
	149 = {
		set_state_category = large_city
		add_building_construction = {
			type = industrial_complex 
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = arms_factory  
			level = 3
			instant_build = yes
		}
		add_building_construction = {
			type = air_base  
			level = 2
			instant_build = yes
		}
		add_building_construction = {
			type = infrastructure  
			level = 1
			instant_build = yes
		}
	}

}


var_add_resources = {
	add_equipment_to_stockpile = {
		type = infantry_equipment
		amount = 40000
		producer = VAR
	}

	add_equipment_to_stockpile = {
		type = artillery_equipment
		amount = 350
		producer = VAR
	}

	add_equipment_to_stockpile = {
		type = convoy_1
		amount = 75
	}

	#Steel to the islands
	add_resource = {
		type = steel
		amount = 18
		state = 150
	}
	add_resource = {
		type = steel
		amount = 22
		state = 149
	}
	add_resource = {
		type = steel
		amount = 18
		state = 151
	}
	add_resource = {
		type = steel
		amount = 22
		state = 148
	}

	#Steel, Aluminium, Chromium, and Rubber to home
	add_resource = {
		type = steel
		amount = 28
		state = 154
	}
	add_resource = {
		type = steel
		amount = 28
		state = 157
	}

	add_resource = {
		type = aluminium 
		amount = 48
		state = 154
	}
	add_resource = {
		type = tungsten 
		amount = 32
		state = 152
	}
	add_resource = {
		type = aluminium 
		amount = 48
		state = 157
	}

	add_resource = {
		type = chromium 
		amount = 9
		state = 155
	}
	add_resource = {
		type = chromium 
		amount = 9
		state = 156
	}
}


var_annex_islands = {
	transfer_state = 148
	transfer_state = 149
	transfer_state = 150
	transfer_state = 151
}

main_annex_major_island = {
	CYM = {
		transfer_state = 153
		transfer_state = 156
		transfer_state = 157
	}
	153 = {
		add_compliance = 50
	}
	156 = {
		add_compliance = 50
	}
	157 = {
		add_compliance = 50
	}
	EDS = {
		transfer_state = 152
		transfer_state = 154
		transfer_state = 155
	}
	152 = {
		add_compliance = 50
	}
	154 = {
		add_compliance = 50
	}
	155 = {
		add_compliance = 50
	}
}

VAR_ALLY_CYM = {
	VAR = {
		create_faction = VAR_CYM_FACTION
		add_to_faction = CYM
	}
}

VAR_ALLY_EDS = {
	VAR = {
		create_faction = VAR_EDS_FACTION
		add_to_faction = EDS
	}
}

CYM_ALLY_EDS = {
	CYM = {
		create_faction = CYM_EDS_FACTION
		add_to_faction = EDS
	}
}


#########
#END OF STARTUP#
#########


clamp_thrall_pp_boost = {
	clamp_temp_variable = {
		var = thrall_pp_boost
		min = 0
		max = 2
	}
}

clamp_thrall_build_boost = {
	clamp_temp_variable = {
		var = thrall_build_boost
		min = 0
		max = 0.5
	}
}

clamp_thrall_manpower_boost = {
	clamp_temp_variable = {
		var = thrall_manpower_boost
		min = 0
		max = 2500
	}
	round_temp_variable = thrall_manpower_boost
}	

drain_thralls = {
	log = "Draining Thralls    Previous: [?thralls_pp_gain] [?thrall_build_gain] [?thrall_manpower_gain]"
	multiply_variable = {thralls_pp_gain = 0.9}
	subtract_from_variable = {thralls_pp_gain = 0.1}
	clamp_variable = {
		var = thralls_pp_gain
		min = 0
		max = 2
	}

	multiply_variable = {thrall_build_gain = 0.9}
	subtract_from_variable = {thrall_build_gain = 0.025}
	clamp_variable = {
		var = thrall_build_gain
		min = 0
		max = 0.5
	}


	multiply_variable = {thrall_manpower_gain = 0.9}
	subtract_from_variable = {thrall_manpower_gain = 125}
	round_variable = thrall_manpower_gain
	clamp_variable = {
		var = thrall_manpower_gain
		min = 0
		max = 2500
	}
	
	force_update_dynamic_modifier = yes
	log = "After: [?thralls_pp_gain] [?thrall_build_gain] [?thrall_manpower_gain]"
}




d_test_effect = {

	
    log = "Command passed"
}