# variables:
# parameters, data containing the specifics, eg which planet we're talking about
# warscore_cost, scripted value, root is target country, amount of warscore required to push this demand
# potential, trigger, root and from are main attackers and defenders, war is fromfrom, decides if this demand is listed
# possible, trigger, root and from are main attackers and defenders, war is fromfrom, fromfromfrom is the target country, decides if this demand can go through
# proposable, trigger, root and from are main attackers and defenders, war is fromfrom, fromfromfrom is the target country, decides if this demand is ok to propose
# demandable, trigger, root and from are main attackers and defenders, war is fromfrom, fromfromfrom is the target country, decides if you can send a peace offer demanding ( not surrendering ) the demand.
# effect, effect, root and main are main attacker and defender, war is fromfrom, fromfromfrom is the target country, effect which executes when the demand is accepted
# execution_order, integer, defines in which order demands are executed, lower is higher priority, having the same execution order will make the first defined one higher prio
# monthly_warscore, a descriptor on monthly wargoal score
#	amount, scripted value, root and from are main attackers and defenders, war is fromfrom, fromfromfrom is the target country
#   valid, trigger, root and from are main attackers and defenders, war is fromfrom, fromfromfrom is the target country

vassalize_country = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 40

		scaled_modifier = {
			scope = parameter:country
			add = 10
			calc = planets_in_country
		}		

		scaled_modifier = {
			scope = parameter:country
			add = 0.5
			calc = pop_count
		}

		scaled_modifier = {
			scope = parameter:country
			div = 0.05
			calc = planets_in_country
		}		
		
		modifier = {
			factor = 0.5
			parameter:country = {
				exists = overlord
			}
		}
	}

	potential = {
		custom_tooltip_fail = {
			text = "war_demand_vassalize_country_not_opponent"
			parameter:country = {
				OR = {
					AND = {
						exists = fromfrom
						from = {
							from = {
								is_war_participant = {
									who = prevprev
									side = prev
								}
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						would_join_war = {
							attacker = root
							defender = from
							side = from
						}
					}
					
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_vassalize_country_no_overlords"
			parameter:country = {
				OR = {
					AND = {
						exists = fromfrom
						from = {
							from = {
								count_war_participants = {
									side = root
									limit = {
										parameter:country = {
											OR = {
												can_be_subject = {
													overlord = prev
													subject_type = vassal
												}
												AND = {
													is_proposing_war_demands = no
													can_be_subject = {
														overlord = prev
														subject_type = protectorate
													}
												}
											}
										}
									}
									count > 0
								}
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						count_potential_war_participants = {
							attacker = root
							defender = from
							side = from

							limit = {
								parameter:country = {
									can_be_subject = {
										overlord = root
										subject_type = vassal
									}
								}
							}

							count > 0
						}
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_vassalize_country_missing_tech_all"
			any_country = {
				has_technology = tech_xeno_supremacy
				OR = {
					AND = {
						exists = fromfrom
						fromfrom = {
							is_war_participant = {
								who = prev
								side = root
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						would_join_war = {
							attacker = root
							defender = from
							side = root
						}
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_vassalize_country_wrong_type"
			parameter:country = {
				is_country_type = default 
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_no_vassals"
			NOT = { exists = overlord }
		}
	}
	
	possible = {			
		hidden:parameter:country = {
			custom_tooltip_fail = {
				text = "war_demand_vassalize_country_liberated"
				war_demand_counter = {
					type = liberated_or_vassalized
					value < 1
				}
			}
			custom_tooltip_fail = {
				text = "war_demand_vassalize_country_no_planets"
				war_demand_counter = {
					type = num_owned_planets
					value > 0
				}
			}
			custom_tooltip_fail = {
				text = "war_demand_vassalize_country_no_vassals_of_vassals"
				NOT = { exists = overlord }
			}
			custom_tooltip_fail = {
				text = "war_demand_vassalize_country_missing_tech"
				has_technology = tech_xeno_supremacy
			}
		}
	}
	
	proposable = {
		parameter:country = {
			can_be_subject = {
				overlord = fromfromfrom
				subject_type = vassal
			}
		}
	}
	
	effect = {
		add_threat = {
			who = fromfromfrom
			amount = 2 # scales to pops
		}		
		parameter:country = {		
			set_subject_of = {
				who = fromfromfrom
				subject_type = vassal
			}
		}
	}
	
	counters = {
		liberated_or_vassalized = {
			context = parameter:country
			value = { base = 1 }
		}
	}
	
	ai_weight = {
		base = 1000
		
		modifier = {
			factor = 0
			NOT = { this = { is_domineering_to = parameter:country } }
		}
	}
}

protectorate_country = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 60
		
		modifier = {
			factor = 0.5
			parameter:country = {
				exists = overlord
			}
		}
	}

	potential = {
		custom_tooltip_fail = {
			text = "war_demand_protectorate_country_not_opponent"
			parameter:country = {
				OR = {
					AND = {
						exists = fromfrom
						from = {
							from = {
								is_war_participant = {
									who = prevprev
									side = prev
								}
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						would_join_war = {
							attacker = root
							defender = from
							side = from
						}
					}
					
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_protectorate_country_no_overlords"
			parameter:country = {
				OR = {
					AND = {
						exists = fromfrom
						from = {
							from = {
								count_war_participants = {
									side = root
									limit = {
										parameter:country = {
											OR = {
												can_be_subject = {
													overlord = prev
													subject_type = protectorate
												}
												AND = {
													is_proposing_war_demands = no
													can_be_subject = {
														overlord = prev
														subject_type = vassal
													}
												}
											}
										}
									}
									count > 0
								}
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						count_potential_war_participants = {
							attacker = root
							defender = from
							side = from

							limit = {
								parameter:country = {
									can_be_subject = {
										overlord = root
										subject_type = protectorate
									}
								}
							}

							count > 0
						}
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_protectorate_country_missing_tech_all"
			any_country = {
				has_technology = tech_xeno_supremacy
				OR = {
					AND = {
						exists = fromfrom
						fromfrom = {
							is_war_participant = {
								who = prev
								side = root
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						would_join_war = {
							attacker = root
							defender = from
							side = root
						}
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_protectorate_country_wrong_type"
			parameter:country = {
				is_country_type = default 
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_no_vassals"
			NOT = { exists = overlord }
		}
	}
	
	possible = {
		hidden:parameter:country = {
			custom_tooltip_fail = {
				text = "war_demand_protectorate_country_liberated"
				war_demand_counter = {
					type = liberated_or_vassalized
					value < 1
				}
			}
			custom_tooltip_fail = {
				text = "war_demand_protectorate_country_no_planets"
				war_demand_counter = {
					type = num_owned_planets
					value > 0
				}
			}
		}
		hidden:fromfromfrom = {
			custom_tooltip_fail = {
				text = "war_demand_protectorate_country_no_vassals_of_vassals"
				NOT = { exists = overlord }
			}
			custom_tooltip_fail = {
				text = "war_demand_protectorate_country_missing_tech"
				has_technology = tech_xeno_supremacy
			}
		}
	}
	
	proposable = {	
		parameter:country = {
			can_be_subject = {
				overlord = fromfromfrom
				subject_type = protectorate
			}
		}
	}
	
	effect = {
		parameter:country = {
			set_subject_of = {
				who = fromfromfrom
				subject_type = protectorate
			}
		}
	}
	
	counters = {
		liberated_or_vassalized = {
			context = parameter:country
			value = { base = 1 }
		}
	}
	
	ai_weight = {
		base = 1000
		
		modifier = {
			factor = 0
			is_country_type = fallen_empire
		}		
		
		modifier = {
			factor = 0
			NOT = { this = { is_domineering_to = parameter:country } }
		}
	}
}

cede_planet = {
	execution_order = 0
	
	parameters = {
		planet = {
			type = planet
			filter = owned
		}
	}
	
	warscore_cost = {
		base = 20

		scaled_modifier = {
			scope = parameter:planet
			add = 0.8
			calc = pop_count
		}
		
		scaled_modifier = {
			scope = parameter:planet.owner
			div = 0.05
			calc = planets_in_country
		}
	
		modifier = {
			factor = 1.5
			hidden:parameter:planet = {
				is_capital = yes
			}
		}

		modifier = {
			factor = 0.33
			is_country_type = fallen_empire
		}	

		modifier = {
			factor = 0.5
			parameter:planet.owner = {
				is_country_type = fallen_empire
			}
		}			
				
		
		modifier = {
			factor = 0.9
			custom_tooltip = {
				text = "war_demand_cede_planet_our_species"
				OR = {
					has_ethic = "ethic_xenophobe"
					has_ethic = "ethic_fanatic_xenophobe"
				}
				parameter:planet = {
					any_pop = {
						is_same_species = root
					}
				}
			}
		}
		
		modifier = {
			factor = 0.9
			custom_tooltip = {
				text = "war_demand_cede_planet_bordering"
				OR = {
					has_ethic = "ethic_fanatic_militarist"
					has_ethic = "ethic_militarist"
				}
				parameter:planet = {
					solar_system = {
						any_bordering_country = {
							is_same_value = root
						}					
					}
				}
			}
		}

		# Ruler Trait - Warlike
		modifier = {
			factor = 0.95
			custom_tooltip = {
				text = "war_demand_trait_warlike"
				exists = ruler
				ruler = { has_trait = trait_ruler_warlike }
			}
		}

		# Ruler Trait - Expansionist
		modifier = {
			factor = 0.9
			custom_tooltip = {
				text = "war_demand_trait_expansionist"
				exists = ruler
				ruler = { has_trait = trait_ruler_expansionist }
			}
		}

		# Tech - Galactic Ambitions
		modifier = {
			factor = 0.95
			custom_tooltip = {
				text = "war_demand_tech_galactic_ambitions"
				has_technology = tech_galactic_ambitions
			}
		}

		# Tech - Manifest Destiny
		modifier = {
			factor = 0.8
			custom_tooltip = {
				text = "war_demand_tech_manifest_destiny"
				has_technology = tech_manifest_destiny
			}
		}
	}
	
	potential = {
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_belongs_to_opponent"
			parameter:planet = {
				owner = {
					OR = {
						AND = {
							exists = fromfrom
							from = {
								from = {
									is_war_participant = {
										who = prevprev
										side = prev
									}
								}
							}
						}
						AND = {
							NOT = { exists = fromfrom }
							would_join_war = {
								attacker = root
								defender = from
								side = from
							}
						}
						
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_no_vassals"
			subject_can_diplomacy = this
		}
	}
	
	possible = {
		always = yes
	}
	
	proposable = {
		hidden:parameter:planet = {
			custom_tooltip_fail = {
				text = "war_demand_cede_or_liberate"
				war_demand_counter = {
					type = ceded_or_liberated
					value < 1
				}
			}
		}	
	}
	
	demandable = {
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_not_under_our_control"
			parameter:planet = {
				controller = {
					OR = {
						is_country = parameter:planet.owner
						fromfrom = {
							is_war_participant = {
								who = prev
								side = from
							}
						}
					}
				}
			}
		}
	}
	
	effect = {
		parameter:planet = {		
			add_threat = {
				who = fromfromfrom
				amount = 3 # scales to pops
			}		
			
			# Create nationalists
			fromfromfrom = {
				if = {
					limit = {
						count_pop_factions = {
							limit = {
								is_pop_faction_type = nationalist
								check_pop_faction_parameter = {
									which = country
									value = parameter:planet.owner
								}
							}
							count > 0
						}
					}
					random_pop_faction = {
						limit = {
							is_pop_faction_type = nationalist
							check_pop_faction_parameter = {
								which = country
								value = parameter:planet.owner
							}
						}
						parameter:planet = {
							every_owned_pop = {
								set_pop_faction = prevprev
							}
						}
					}
					else = {
						create_pop_faction = {
							type = nationalist
							pop = parameter:planet.unhappiest_pop
							parameter:country = parameter:planet.owner
						}
						parameter:planet = {
							every_owned_pop = {
								set_pop_faction = last_created_pop_faction
							}
						}
					}
				}
			}
		
			set_owner = fromfromfrom
		}
	}

	counters = {
		num_owned_planets = {
			context = parameter:planet.owner
			value = {
				base = -1
			}
		}
		ceded_or_liberated = {
			context = parameter:planet
			value = {
				base = 1
			}			
		}
	}
	
	ai_weight = {
		base = 100
		
		modifier = {
			factor = 0.1
			NOT = { 
				has_ai_personality_behaviour = conqueror 
			}
		}

		scaled_modifier = {
			scope = parameter:planet
			div = 2
			calc = planet_distance_empire
		}
		
		scaled_modifier = {
			scope = parameter:planet
			add = 2
			calc = planets_in_country
		}

		modifier = {
			factor = 0
			is_country_type = fallen_empire
		}

		modifier = {
			factor = 0
			NOT = { 
				parameter:planet = {
					owner = {
						is_neighbor_of = root
					}
				}
			}
		}
	}
	
	AI_invasion_target = yes
}


liberate_planet = {
	execution_order = 0
	
	parameters = {
		planet = {
			type = planet
			filter = owned
		}
	}
	
	warscore_cost = {
		base = 15
		
		modifier = {
			factor = 2.0
			hidden:parameter:planet = {
				is_capital = yes
			}
		}	

		modifier = {
			factor = 0.33
			is_country_type = fallen_empire
		}	

		modifier = {
			factor = 0.5
			parameter:planet.owner = {
				is_country_type = fallen_empire
			}
		}		

		scaled_modifier = {
			scope = parameter:planet
			add = 0.8
			calc = pop_count
		}
		
		scaled_modifier = {
			scope = parameter:planet.owner
			div = 0.05
			calc = planets_in_country
		}

		# Ruler Trait - Warlike
		modifier = {
			factor = 0.95
			custom_tooltip = {
				text = "war_demand_trait_warlike"
				exists = ruler
				ruler = { has_trait = trait_ruler_warlike }
			}
		}

		# Ruler Trait - Expansionist
		modifier = {
			factor = 0.9
			custom_tooltip = {
				text = "war_demand_trait_expansionist"
				exists = ruler
				ruler = { has_trait = trait_ruler_expansionist }
			}
		}

		# Tech - Galactic Ambitions
		modifier = {
			factor = 0.95
			custom_tooltip = {
				text = "war_demand_tech_galactic_ambitions"
				has_technology = tech_galactic_ambitions
			}
		}

		# Tech - Manifest Destiny
		modifier = {
			factor = 0.8
			custom_tooltip = {
				text = "war_demand_tech_manifest_destiny"
				has_technology = tech_manifest_destiny
			}
		}
	}
	
	potential = {	
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_belongs_to_opponent"
			parameter:planet = {
				owner = {
					OR = {
						AND = {
							exists = fromfrom
							from = {
								from = {
									is_war_participant = {
										who = prevprev
										side = prev
									}
								}
							}
						}
						AND = {
							NOT = { exists = fromfrom }
							would_join_war = {
								attacker = root
								defender = from
								side = from
							}
						}
						
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_no_vassals"
			subject_can_diplomacy = this
		}
	}
	
	possible = {
		always = yes
	}
	
	proposable = {
		hidden:parameter:planet = {
			custom_tooltip_fail = {
				text = "war_demand_cede_or_liberate"
				war_demand_counter = {
					type = ceded_or_liberated
					value < 1
				}
			}
		}	
	}
	
	demandable = {
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_not_under_our_control"
			parameter:planet = {
				controller = {
					OR = {
						is_country = parameter:planet.owner
						fromfrom = {
							is_war_participant = {
								who = prev
								side = from
							}
						}
					}
				}
			}
		}
	}
	
	effect = {
		if = {
			limit = {
				NOT = {
					AND = {
						exists = last_created_country
						last_created_country = {
							has_country_flag = timed_liberated_country
						}
					}
				}
			}
			parameter:planet = {		
				create_country = {
					name = random
					government = random
					released_by_country = root
					released_from_country = parameter:planet.owner
					species = parameter:planet
					ethos = fromfromfrom
					flag = random
					type = default
					day_zero_contact = no
				}
			}	
			last_created_country = {
				set_timed_country_flag = { flag = timed_liberated_country days = 1 }
				establish_communications_no_message = root
				establish_communications_no_message = parameter:planet.owner
				establish_contact = { who = root location = parameter:planet }
				establish_contact = { who = parameter:planet.owner location = parameter:planet }
				add_modifier = {
					modifier = "puppet_government"
					days = 3600
				}
			}
		}
		parameter:planet = {
			set_owner = last_created_country
			set_controller = last_created_country
		}		
	}

	counters = {
		num_owned_planets = {
			context = parameter:planet.owner
			value = {
				base = -1
			}
		}
		ceded_or_liberated = {
			context = parameter:planet
			value = {
				base = 1
			}			
		}		
	}
	
	ai_weight = {
		base = 100
		
		modifier = {
			factor = 0.1
			has_ai_personality_behaviour = conqueror			
		}
		
		modifier = {
			factor = 0.5
			NOT = { 
				has_ai_personality_behaviour = liberator
			}
		}

		scaled_modifier = {
			scope = parameter:planet
			div = 2
			calc = planet_distance_empire
		}
		
		scaled_modifier = {
			scope = parameter:planet
			add = 2
			calc = planets_in_country
		}

		modifier = {
			factor = 0
			is_country_type = fallen_empire
			OR = {
				NOT = { 
					this = { has_ai_personality_behaviour = liberator } 
				}		
				parameter:planet = {
					is_capital = yes
				}
			}
		}
	}
	
	AI_invasion_target = yes
}

liberate_country = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 60
		
		modifier = {
			factor = 0.75
			has_ethic = ethic_pacifist
		}
		
		modifier = {
			factor = 0.5
			has_ethic = ethic_fanatic_pacifist
		}
	}
	
	potential = {
		custom_tooltip_fail = {
			text = "war_demand_liberate_country_not_vassal"
			parameter:country = {
				exists = overlord
				overlord = {
					OR = {
						AND = {
							exists = fromfrom
							from = {
								from = {
									is_war_participant = {
										who = prevprev
										side = prev
									}
								}
							}
						}
						AND = {
							NOT = { exists = fromfrom }
							would_join_war = {
								attacker = root
								defender = from
								side = from
							}
						}
					}
				}
			}
		}
		custom_tooltip_fail = {
			text = "war_demand_cede_planet_no_vassals"
			OR = {
				NOT = { exists = overlord }
				overlord = {
					is_same_value = from
				}
			}
		}
	}
	
	possible = {
		hidden:parameter:country = {
			custom_tooltip_fail = {
				text = "war_demand_liberate_country_already_vassalized"
				war_demand_counter = {
					type = liberated_or_vassalized
					value < 1
				}
			}
			custom_tooltip_fail = {
				text = "war_demand_liberate_country_no_planets"
				war_demand_counter = {
					type = num_owned_planets
					value > 0
				}
			}
		}
	}
	
	proposable = {
		always = yes
	}
	
	effect = {
		parameter:country = {
			set_subject_of = {
				who = none
			}
		}
	}
	
	monthly_warscore = {
		amount = {
			base = 1
		}
		valid = {
			parameter:country = {
				any_owned_planet = {
					count = all
					controller = {
						fromfrom = {
							is_war_participant = {
								who = prev
								side = root
							}
						}
					}
				}
			}
		}
	}
	
	counters = {
		liberated_or_vassalized = {
			context = parameter:country
			value = { base = 1 }
		}
	}

	ai_weight = {
		base = 50
		
		modifier = {
			factor = 0.1
			NOT = { 
				this = { has_ai_personality_behaviour = liberator } 
			}
		}
		
		modifier = {
			factor = 2
			parameter:country = { has_ai_personality_behaviour = liberator }
		}

		modifier = {
			factor = 0
			is_country_type = fallen_empire
		}

		modifier = {
			factor = 0
			parameter:country = {
				NOT = {
					is_neighbor_of = root
				}
			}
		}		
	}
}

# special fallen empire wargoals
abandon_planet = {
	execution_order = 0
	
	parameters = {
		planet = {
			type = planet
			filter = owned
		}
	}
	
	warscore_cost = {
		base = 5	

		scaled_modifier = {
			scope = parameter:planet
			add = 0.8
			calc = pop_count
		}
		
		scaled_modifier = {
			scope = parameter:planet.owner
			div = 0.05
			calc = planets_in_country
		}		
	}
	
	potential = {
		is_country_type = fallen_empire
		parameter:planet = {
			owner = {
				OR = {
					AND = {
						exists = fromfrom
						from = {
							from = {
								is_war_participant = {
									who = prevprev
									side = prev
								}
							}
						}
					}
					AND = {
						NOT = { exists = fromfrom }
						would_join_war = {
							attacker = root
							defender = from
							side = from
						}
					}
					
				}
			}
		}
		subject_can_diplomacy = this
		parameter:planet = {
			OR = {
				is_capital = no
				AND = {
					root = { has_ai_personality = fallen_empire_spiritualist }
					has_modifier = "holy_planet"
				}
				OR = {
					root = { has_ai_personality = fallen_empire_spiritualist }
					is_planet_class = pc_nuked
				}	
			}
		}		
	}
	
	possible = {
		always = yes
	}
	
	proposable = {
		war_demand_counter = {
			type = ceded_or_liberated
			value < 1
		}
	}
	
	demandable = {
		parameter:planet = {
			controller = {
				fromfrom = {
					is_war_participant = {
						who = prev
						side = from
					}
				}
			}
		}
	}
	
	effect = {
		parameter:planet = {		
			destroy_colony = yes
		}			
	}

	counters = {
		num_owned_planets = {
			context = parameter:planet.owner
			value = {
				base = -1
			}
		}
		ceded_or_liberated = {
			context = parameter:planet
			value = {
				base = 1
			}			
		}		
	}
	
	ai_weight = {
		base = 100
		
		modifier = {
			factor = 0.0
			parameter:planet = {
				NOT = { is_neighbor_of = root }
				OR = {
					NOT = { root = { has_ai_personality = fallen_empire_spiritualist } }
					NOT = { has_modifier = "holy_planet" }
				}
				OR = {
					NOT = { root = { has_ai_personality = fallen_empire_spiritualist } }
					NOT = { is_planet_class = pc_nuked }
				}		
			}
		}
			
		modifier = {
			factor = 10.0
			has_ai_personality = fallen_empire_xenophobe
		}		
		
		modifier = {
			factor = 10.0
			OR = {
				parameter:planet = { has_modifier = "holy_planet" }
				parameter:planet = { is_planet_class = pc_nuked }
			}
			has_ai_personality = fallen_empire_spiritualist
		}
		
		scaled_modifier = {
			scope = parameter:planet
			div = 2
			calc = planet_distance_empire
		}
		
		scaled_modifier = {
			scope = parameter:planet
			add = 2
			calc = planets_in_country
		}
		
		modifier = {
			factor = 0
			OR = {
				has_ai_personality_behaviour = liberator
				has_ai_personality_behaviour = conqueror
			}
		}
	}
	
	AI_invasion_target = yes
}

abolish_ai = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 20
	}
	
	potential = {
		is_country_type = fallen_empire	
		parameter:country = {
			is_country = from
		}		
	}
	
	possible = {			
		parameter:country = {
			NOT = { has_policy_flag = ai_outlawed }
			has_technology = tech_robotic_workers
		}
	}
	
	proposable = {
		always = yes
	}
	
	effect = {	
		parameter:country = {		
			hidden_effect = {
				set_policy = {
					policy = artificial_intelligence_policy
					option = ai_outlawed
					cooldown = yes
				}
			}		
		}
	}
	
	ai_weight = {
		base = 1000
		
		modifier = {
			factor = 0
			NOT = { has_ai_personality = fallen_empire_materialist }
		}
	}
}

abolish_slavery = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 20
	}

	potential = {
		is_country_type = fallen_empire	
		parameter:country = {
			is_country = from
		}		
	}
	
	possible = {			
		parameter:country = {
			NOT = { has_policy_flag = slavery_not_allowed }
		}
	}
	
	proposable = {
		always = yes
	}
	
	effect = {	
		parameter:country = {		
			hidden_effect = {
				set_policy = {
					policy = slavery
					option = slavery_not_allowed
					cooldown = yes
				}
			}		
		}
	}
	
	ai_weight = {
		base = 1000
		
		modifier = {
			factor = 0
			NOT = { has_ai_personality = fallen_empire_xenophile }
		}
	}
}

abolish_purge = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 20
	}

	potential = {
		is_country_type = fallen_empire	
		parameter:country = {
			is_country = from
		}		
	}
	
	possible = {			
		parameter:country = {
			NOT = { has_policy_flag = purge_not_allowed }
		}
	}
	
	proposable = {
		always = yes
	}
	
	effect = {	
		parameter:country = {		
			hidden_effect = {
				set_policy = {
					policy = purge
					option = purge_not_allowed
					cooldown = yes
				}
			}		
		}
	}
	
	ai_weight = {
		base = 1000
		
		modifier = {
			factor = 0
			NOT = { has_ai_personality = fallen_empire_xenophile }
		}
	}
}

humiliate = {
	execution_order = 1
	
	parameters = {
		country = {
			type = country
		}
	}
	
	warscore_cost = {
		base = 10
	}

	potential = {
		is_country_type = fallen_empire	
		parameter:country = {
			is_country = from
		}		
	}
	
	possible = {			
		always = yes
	}
	
	proposable = {
		always = yes
	}
	
	effect = {	
		parameter:country = {		
			add_modifier = { modifier = humiliated days = 7200 }			
		}
		hidden_effect = {
			remove_opinion_modifier = { modifier = opinion_accepted_fallen_empire_demand who = parameter:country }
			remove_opinion_modifier = { modifier = opinion_refused_fallen_empire_demand who = parameter:country }
			add_opinion_modifier = { modifier = opinion_put_in_their_place who = parameter:country }
		}		
	}
	
	ai_weight = {
		base = 1000
	}
}

#cede_frontier_outpost = {
#	execution_order = 1
#	
#	parameters = {
#		system = {
#			type = galactic_object
#		}
#	}
#	
#	warscore_cost = {
#		base = 10
#
#		# Ruler Trait - Warlike
#		modifier = {
#			factor = 0.95
#			custom_tooltip = {
#				text = "war_demand_trait_warlike"
#				exists = ruler
#				ruler = { has_trait = trait_ruler_warlike }
#			}
#		}
#
#		# Ruler Trait - Expansionist
#		modifier = {
#			factor = 0.9
#			custom_tooltip = {
#				text = "war_demand_trait_expansionist"
#				exists = ruler
#				ruler = { has_trait = trait_ruler_expansionist }
#			}
#		}
#
#		# Tech - Galactic Ambitions
#		modifier = {
#			factor = 0.95
#			custom_tooltip = {
#				text = "war_demand_tech_galactic_ambitions"
#				has_technology = tech_galactic_ambitions
#			}
#		}
#
#		# Tech - Manifest Destiny
#		modifier = {
#			factor = 0.9
#			custom_tooltip = {
#				text = "war_demand_tech_manifest_destiny"
#				has_technology = tech_manifest_destiny
#			}
#		}
#	}
#	
#	potential = {
#		custom_tooltip_fail = {
#			text = "war_demand_cede_frontier_outpost_no_stations"
#			parameter:system = {
#				any_ship_in_system = {
#					is_ship_class = shipclass_outpost_station
#					owner = {
#						OR = {
#							AND = {
#								exists = fromfrom
#								from = {
#									from = {
#										is_war_participant = {
#											who = prevprev
#											side = prev
#										}
#									}
#								}
#							}
#							AND = {
#								NOT = { exists = fromfrom }
#								would_join_war = {
#									attacker = root
#									defender = from
#									side = from
#								}
#							}
#							
#						}
#					}
#				}
#			}
#		}
#		custom_tooltip_fail = {
#			text = "war_demand_cede_planet_no_vassals"
#			subject_can_diplomacy = this
#		}
#	}
#	
#	possible = {
#		custom_tooltip_fail = {
#			text = "war_demand_cede_frontier_outpost_no_stations_left"
#			any_country = {
#				OR = {
#					AND = {
#						exists = fromfrom
#						from = {
#							from = {
#								is_war_participant = {
#									who = prevprev
#									side = prev
#								}
#							}
#						}
#					}
#					AND = {
#						NOT = { exists = fromfrom }
#						would_join_war = {
#							attacker = root
#							defender = from
#							side = from
#						}
#					}
#				}
#				
#				war_demand_counter = {
#					type = num_owned_planets
#					value > 0
#				}
#				parameter:system = {
#					any_ship_in_system = {
#						is_ship_class = shipclass_outpost_station
#						owner = {
#							is_same_value = prevprevprev
#						}
#					}
#				}
#			}
#		}
#	}
#	
#	proposable = {
#		always = yes
#	}
#	
#	effect = {	
#		parameter:system = {
#			every_fleet_in_system = {
#				limit = {
#					is_ship_class = shipclass_outpost_station
#					owner = {
#						from = {
#							from = {
#								is_war_participant = {
#									who = prevprev
#									side = prev
#								}
#							}
#						}
#					}
#				}
#				set_owner = fromfromfrom
#			}
#		}
#	}
#	
#	ai_weight = {
#		base = 0
#	}
#}