organized_raiding = {
	var_dec_seize_valuables = {
		icon = GFX_decision_hol_attract_foreign_investors

		allowed = {
			tag = VAR
		}

		available = {
			FROM = {
				is_fully_controlled_by = VAR
			}
		}
		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = no

		target_array = controlled_states
		target_trigger = {
			can_var_seize_valuables = yes
		}


		cost = 0


		#remove_effect = {
		#	add_stability = 0.10
		#}

		complete_effect = {
			log = "[?FROM.GetName], [FROM.GetName],    [?THIS.GetName], [THIS.GetName],    [?ROOT.GetName], [ROOT.GetName],      [?PREV.GetName], [PREV.GetName]"
			FROM = {
				#Mark the state as already having stuff confiscated
				set_state_flag = var_seized

				#Initialize
				set_temp_variable = {var_seized_value = 0}


				#Add civ's value using global define.
				set_temp_variable =  {var_seized_civ_value = industrial_complex_level}
				multiply_temp_variable = {var_seized_civ_value = global.var_seize_civ_value}

				add_to_temp_variable = {var_seized_value = var_seized_civ_value} #Add the calculated value


				#Add mil's value using global define.
				set_temp_variable =  {var_seized_mil_value = arms_factory_level}
				multiply_temp_variable = {var_seized_mil_value = global.var_seize_mil_value}

				add_to_temp_variable = {var_seized_value = var_seized_mil_value} #Add the calculated value


				#Add infra's value using global define.
				set_temp_variable =  {var_seized_inf_value = infrastructure_level}
				multiply_temp_variable = {var_seized_inf_value = global.var_seize_inf_value}

				add_to_temp_variable = {var_seized_value = var_seized_inf_value} #Add the calculated value


				#Add pop's value using global define.
				set_temp_variable =  {var_seized_pop_value = state_population_k}
				divide_temp_variable = {var_seized_pop_value = global.var_seize_pop_value}

				add_to_temp_variable = {var_seized_value = var_seized_pop_value} #Add the calculated value

				add_compliance = -15
				add_resistance_target = {
					id = THIS
					amount = 15
					#occupied = EDS
					occupier = ROOT
					days = 180
					tooltip = var_dec_seize_valuables_res_t
				}

				#if = {
				#	limit = {check_variable = {industrial_complex_level > 1}}
				#	remove_building = {
				#		type = industrial_complex
				#		level = 1
				#	}
				#}
			}
			
			add_political_power = var_seized_value
		}

		ai_will_do = {
			base = 10
		}
	}

#################################################
#################################################
#################################################

	var_dec_displace_influential = {
		icon = GFX_decision_hol_war_on_pacifism

		allowed = {
			tag = VAR
		}

		available = {
			FROM = {
				is_fully_controlled_by = VAR	
			}
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = no

		target_array = controlled_states
		target_trigger = {
			can_var_displace_influential = yes
		}


		cost = 0

		complete_effect = {
			FROM = {
				set_state_flag = var_displaced_influential
				add_resistance_target = {
					id = THIS
					amount = -10
					#occupied = EDS
					occupier = ROOT
					#days = 180
					tooltip = var_dec_displace_influential_t
				}
				add_resistance = 10		
			}			
		}

		ai_will_do = {
			base = 10
		}
	}

#################################################
#################################################
#################################################

	var_dec_settle = {
		icon = GFX_decision_POL_looming_peasants_strike

		allowed = {
			tag = VAR
		}

		available = {
			FROM = {
				is_fully_controlled_by = VAR					
			}
			FROM = {
				custom_trigger_tooltip = {
					tooltip = var_dec_settle_t		
					has_state_flag = var_displaced_influential
				}
			}
			
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = no

		target_array = controlled_states
		target_trigger = {
			can_var_settle = yes
		}


		cost = 25

		complete_effect = {
			FROM = {
				set_state_flag = var_settled
				add_manpower = 10000
				add_compliance = 10
				add_state_modifier = {
					modifier = {
						local_non_core_manpower = 0.15
					}
				}	
			}			
		}

		ai_will_do = {
			base = 1
		}
	}

#################################################
#################################################
#################################################

	var_dec_pillage = {
		icon = GFX_decision_generic_disband_irregulars

		allowed = {
			tag = VAR
		}

		available = {
			FROM = {
				is_fully_controlled_by = VAR					
			}			
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = no

		target_array = controlled_states
		target_trigger = {
			can_var_pillage = yes
		}


		cost = 25

		complete_effect = {
			FROM = {
				set_state_flag = var_pillaged
				if = {
					limit = {check_variable = {arms_factory_level > 6}}
					set_variable = {var_pillaging_mills_to_give = 5}
					remove_building = {
						type = arms_factory
						level = 3
					}
				}
				else_if = {
					limit = {check_variable = {arms_factory_level > 4}}
					set_variable = {var_pillaging_mills_to_give = 3}
					remove_building = {
						type = arms_factory
						level = 2
					}
				}
				else_if  = {
					limit = {check_variable = {arms_factory_level > 2}}
					set_variable = {var_pillaging_mills_to_give = 2}
					remove_building = {
						type = arms_factory
						level = 1
					}
				}
				else_if  = {
					limit = {check_variable = {arms_factory_level > 0}}
					set_variable = {var_pillaging_mills_to_give = 1}
					remove_building = {
						type = arms_factory
						level = 1
					}
				}
				else = {
					set_variable = {var_pillaging_mills_to_give = 0}
				}

				if = {
					limit = {check_variable = {industrial_complex_level > 6}}
					set_variable = {var_pillaging_civs_to_give = 5}
					remove_building = {
						type = industrial_complex
						level = 3
					}
				}
				else_if = {
					limit = {check_variable = {industrial_complex_level > 4}}
					set_variable = {var_pillaging_civs_to_give = 3}
					remove_building = {
						type = industrial_complex
						level = 2
					}
				}
				else_if  = {
					limit = {check_variable = {industrial_complex_level > 2}}
					set_variable = {var_pillaging_civs_to_give = 2}
					remove_building = {
						type = industrial_complex
						level = 1
					}
				}
				else_if  = {
					limit = {check_variable = {industrial_complex_level > 0}}
					set_variable = {var_pillaging_civs_to_give = 1}
					remove_building = {
						type = industrial_complex
						level = 1
					}
				}
				else = {
					set_variable = {var_pillaging_civs_to_give = 0}
				}
				damage_building = {
					type = infrastructure
    				damage = 1
				}
				damage_building = {
					type = industrial_complex
    				damage = 1
				}
				damage_building = {
					type = arms_factory
    				damage = 1
				}
				add_resistance = 20
			}	
			custom_effect_tooltip = var_dec_pillage_t
			log = "[?FROM.var_pillaging_civs_to_give]"
			log = "[?FROM.var_pillaging_mills_to_give]"
			hidden_effect = {
				add_offsite_building = {type = arms_factory level = FROM.var_pillaging_mills_to_give}	
				add_offsite_building = {type = industrial_complex level = FROM.var_pillaging_civs_to_give}	
				activate_targeted_decision = { target = FROM decision = var_dec_pillaging }
			}
			
			
			FROM = {
				multiply_variable = {var_pillaging_mills_to_give = -1}
				multiply_variable = {var_pillaging_civs_to_give = -1}
			}
		}

		ai_will_do = {
			base = 1
		}
	}

#################################################
#################################################
#################################################

	var_dec_pillaging = {
		icon = GFX_decision_generic_reorganize_irregulars

		allowed = {
			always = no
		}

		available = {
			hidden_trigger = {
				always = no
			}			
		}

		cancel_trigger = {
			FROM = {
				NOT = {is_fully_controlled_by = VAR}
			}
		}

		is_good = yes
		days_mission_timeout = 120
		selectable_mission = no

		on_map_mode = map_and_decisions_view 
		state_target = yes
		fire_only_once = yes

		timeout_effect = {
			add_offsite_building = {type = arms_factory level = FROM.var_pillaging_mills_to_give}
			add_offsite_building = {type = industrial_complex level = FROM.var_pillaging_civs_to_give}
			add_political_power = 75
			FROM = {
				clear_variable = var_pillaging_mills_to_give
				clear_variable = var_pillaging_civs_to_give
				add_resistance_target = {
					id = THIS
					amount = -15
					#occupied = EDS
					occupier = ROOT
					#days = 180
					tooltip = var_dec_pillagingl_t
				}
			}
		}
		cancel_effect = {
			hidden_effect = {
				add_offsite_building = {type = arms_factory level = FROM.var_pillaging_mills_to_give}
				add_offsite_building = {type = industrial_complex level = FROM.var_pillaging_civs_to_give}
				FROM = {
					clear_variable = var_pillaging_mills_to_give
					clear_variable = var_pillaging_civs_to_give
					add_resistance_target = {
						id = THIS
						amount = -15
						#occupied = EDS
						occupier = ROOT
						#days = 180
						tooltip = var_dec_pillaging_t
					}
				}
				
			}
			
        }
		ai_will_do = {
			base = 1
		}
	}

#################################################
#################################################
#################################################

	var_dec_raze = {
		icon = GFX_decision_generic_scorched_earth

		allowed = {
			tag = VAR
		}

		available = {
			FROM = {
				is_fully_controlled_by = VAR	
			}
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = no

		target_array = controlled_states
		target_trigger = {
			can_var_raze = yes
		}


		cost = 10

		complete_effect = {
			FROM = {
				set_state_flag = var_razed
				add_resistance_target = {
					id = THIS
					amount = -25
					#occupied = EDS
					occupier = ROOT
					#days = 180
					tooltip = var_dec_raze_t
				}
				add_resistance = -10		
				damage_building = {
					type = arms_factory
    				damage = 5
				}
				damage_building = {
					type = industrial_complex
    				damage = 5
				}
			}
		}

		ai_will_do = {
			base = 0
		}
	}

#################################################
#################################################
#################################################

	var_dec_core = {
		icon = GFX_decision_generic_military

		allowed = {
			tag = VAR
		}
		available = {
			FROM = {
				is_fully_controlled_by = VAR					
			}			
			FROM = {
				custom_trigger_tooltip = {
					tooltip = var_dec_core_ta		
					has_state_flag = var_displaced_influential
				}
			}
			FROM = {
				custom_trigger_tooltip = {
					tooltip = var_dec_core_tb	
					has_state_flag = var_settled
				}
			}
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = yes

		targets = {
			2 3 4 5 8 13 14 15 16 18 26 41 88 89 90 91 92 93 94 95 122 126 128 130 143 144
		}
		target_trigger = {
			can_var_core = yes
		}


		cost = 50

		complete_effect = {
			FROM = {
				add_core_of = VAR
			}
		}

		ai_will_do = {
			base = 0
		}
	}

#################################################
#################################################
#################################################

	var_dec_take_thralls = {
		icon = GFX_decision_generic_arrest

		allowed = {
			tag = VAR
		}
		available = {
			FROM = {
				is_fully_controlled_by = VAR					
			}
		}

		on_map_mode = map_and_decisions_view 
		state_target = yes

		fire_only_once = yes

		target_array = controlled_states
		target_trigger = {
			can_var_take_thralls = yes
		}


		cost = 0

		complete_effect = {
			#0.1 * (x-2.1)^{3} + 1, where x = state_population in the millions
			set_temp_variable = {thrall_x = FROM.state_population_k }
			divide_temp_variable = {thrall_x  = 10000}
			clamp_temp_variable = {
				var = thrall_x
				min = 0
				max = 2
			}

			subtract_from_temp_variable  = {thrall_x = 2.1} 

			set_temp_variable = {thrall_powering = thrall_x}
			multiply_temp_variable = {thrall_x = thrall_powering}
			multiply_temp_variable = {thrall_x = thrall_powering}

			multiply_temp_variable = {thrall_x = 0.1}

			add_to_temp_variable = {thrall_x = 1}

			log = "Taking thralls, [?thrall_x|%]"

			#The starts here are 'magic numbers', 37.5% of the maximal value at the time of writing
			set_temp_variable = {thrall_pp_boost = 0.75}
			multiply_temp_variable = {thrall_pp_boost = thrall_x}
			clamp_thrall_pp_boost = yes
			
			set_temp_variable = {thrall_build_boost = 0.188}
			multiply_temp_variable = {thrall_build_boost = thrall_x}
			clamp_thrall_build_boost = yes

			set_temp_variable = {thrall_manpower_boost = 937.5}
			multiply_temp_variable = {thrall_manpower_boost = thrall_x}
			clamp_thrall_manpower_boost = yes

			add_to_variable = {thralls_pp_gain = thrall_pp_boost 							  tooltip = var_dec_take_thralls_ta}
			add_to_variable = {thrall_build_gain = thrall_build_boost 						 tooltip = var_dec_take_thralls_tb}
			add_to_variable = {thrall_manpower_gain = thrall_manpower_boost 	   tooltip = var_dec_take_thralls_tc}

			#hidden_effect = {
			#	add_to_variable = {thralls_pp_gain = thrall_pp_boost}
			#	add_to_variable = {thralls_pp_gain = thrall_pp_boost}
			#}
			

		}

		ai_will_do = {
			base = 0
		}
	}

}