﻿## Demand conquer state

REPLACE_OR_CREATE:demand_conquest = {
	groups= {
		general
	}
	
	texture = "gfx/interface/icons/diplomatic_action_icons/take_state.dds"
	
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	state_selection = second_required
	second_state_list = second_country
	can_use_obligations = no

	potential = {
		has_war_with = scope:target_country
		is_ai = yes
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
	}

	second_state_trigger = {
		owner = scope:target_country
		is_under_colonization = no
		NOT = { is_target_of_wargoal = scope:target_country }
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		if = {
			limit = { exists = scope:second_state }	
			random_diplomatic_play = { 
				limit = {
					is_war = yes
					any_scope_play_involved = { THIS = scope:target_country } 
					any_scope_play_involved = { THIS = root }
				}
				add_war_goal = { holder = ROOT type = conquer_state target_state = scope:second_state primary_demand = no target_country = scope:target_country }
			}

			create_incident = {
				country = ROOT
				value = {
					#recommend doing something else
					value = "scope:second_state.ai_state_value(scope:target_country)"
					divide = 36
					max = 50
					min = 3						
				}
			}		
		}
	}
		
	ai = {
		evaluation_chance = {
			value = 0.25	
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}		
		
		will_select_as_second_state = {	
		}	
		
		will_propose_with_states = {
			exists = scope:second_state
			
			
			any_neighbouring_state = {
					owner = ROOT
				}	
		}	
		
		will_propose = {
			has_game_rule = ai_wargoals_allowed
			NOT = { ROOT = { infamy >= 64.9 } }
			
		}
	
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_return_claim = {
	groups= {
		general
	}
	
	texture = "gfx/interface/icons/war_goals/return_state.dds"
	
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	state_selection = second_required
	second_state_list = second_country
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
			any_state = { has_claim_by = ROOT }
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
	}

	second_state_trigger = {
		owner = scope:target_country
		has_claim = ROOT
		NOT = { is_target_of_wargoal = scope:target_country }
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		if = {
			limit = { exists = scope:second_state }	
			random_diplomatic_play = { 
			limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
			add_war_goal = { holder = ROOT type = return_state target_state = scope:second_state primary_demand = no target_country = scope:target_country }
			}

			create_incident = {
				country = ROOT
				value = {
					value = "scope:second_state.ai_state_value(scope:target_country)"
					divide = 42
					max = 50
					min = 3						
				}
			}		
		}
	}
		
	ai = {
		evaluation_chance = {
			value = 0.25	
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}		
		
		will_select_as_second_state = {
			is_incorporated = no		
		}	
		
		will_propose_with_states = {
			exists = scope:second_state		
		}	
		
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
	
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_treaty_port = {
	groups= {
		general
	}
	
	texture = "gfx/interface/icons/war_goals/take_treaty_port.dds"
	
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	state_selection = second_required
	second_state_list = second_country
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		country_rank > rank_value:minor_power
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
	}
	
	second_state_trigger = {
		owner = scope:target_country
		is_coastal = yes
		is_under_colonization = no
		NOT = { is_target_of_wargoal = scope:target_country }
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		if = {
			limit = { exists = scope:second_state }	
			random_diplomatic_play = { 
			limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
			add_war_goal = { holder = ROOT type = take_treaty_port target_state = scope:second_state primary_demand = no target_country = scope:target_country }
			}

			create_incident = {
				country = ROOT
				value = {
					value = "scope:second_state.ai_state_value(scope:target_country)"
					divide = 32
					max = 50
					min = 5						
				}
			}		
		}
	}
	
	ai = {
		evaluation_chance = {
			value = 0.25		
			if = {
				limit = { ROOT = { infamy > 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}		
	
		will_select_as_second_state = {
			is_incorporated = no		
		}	
		
		will_propose_with_states = {
			exists = scope:second_state
			
			# The AI only uses take state on disconnected colonial bits of subjects which are adjacent to their own lands
			NOT = {
				any_neighbouring_state = {
					owner = ROOT.owner
					is_incorporated = yes
				}
			}
			ROOT = {
				any_neighbouring_state = {
					owner = ROOT
				}
			}
		}
		
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
	
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_ban_slavery = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/ban_slavery.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = ban_slavery
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = ban_slavery primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 11
					divide = 1
					max = 12
					min = 5						
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.1
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		
		if = {
				limit = { country_rank >= rank_value:major_power }
				add = {
					value = country_rank
					multiply = 0.01
				}				
			}
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_iraqi_freedom = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/regime_change.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = regime_change
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = regime_change primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 16
					divide = 1
					max = 14
					min = 6					
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.03
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		
		if = {
				limit = { country_rank >= rank_value:major_power }
				add = {
					value = country_rank
					multiply = 0.01
				}				
			}
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_containment = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/contain_threat.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		scope:target_country.infamy >= infamy_threshold:pariah
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = contain_threat
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = contain_threat primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 0
					max = 0
					min = 0						
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.03
		if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_standard_oil = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/foreign_investment_rights.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = foreign_investment_rights
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = foreign_investment_rights primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 16
					max = 12
					min = 4						
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.03
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_humiliation = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/humiliation.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = humiliation
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
	ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
	random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = humiliation primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 24
					divide = 1
					max = 18
					min = 4	
				}
			}		
	}
	
	ai = {
		evaluation_chance = {
			value = 0.03
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_dominion = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/make_dominion.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no

	potential = { is_ai = yes
		rank_value:great_power
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
			NOT = { rank_value:great_power }
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = make_dominion
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = make_dominion primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 40
					divide = 1
					max = 46
					min = 32						
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.03
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}

REPLACE_OR_CREATE:demand_protectorate2 = {
	groups= {
		general
	}
	texture = "gfx/interface/icons/war_goals/make_protectorate.dds"
	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	can_use_obligations = no
	custom_tooltip = {
		text = "WARGOAL_ON_COOLDOWN"
		ROOT = {
			NOT = { has_variable = war_goal_add_cooldown }
		}
	 }
	potential = { is_ai = yes
		rank_value:great_power
		has_war_with = scope:target_country
		scope:target_country = {
			is_secessionist = no is_revolutionary = no
			NOT = { rank_value:great_power }
		}
	}
	
	possible = {
		is_subject = no
		OR = {
			any_diplomatic_play = {
				ROOT = {
					is_ai = yes
					has_game_rule = ai_wargoals_allowed
					should_set_wargoal = {
						value = yes
						target = prev
					}
				}
			}
			ROOT = { is_ai = no }
		}
		AND = {
			custom_tooltip = {
				text = "WAR_NOT_WELL_ENOUGH"
				scope:target_country = {
				  enemy_occupation > 0.15
				}
			 }
			custom_tooltip = {
				text = "WARGOAL_ON_COOLDOWN"
				ROOT = {
					NOT = { has_variable = war_goal_add_cooldown }
					}
				}
		}
		ROOT = {
			NOT = {
				war_participant_has_war_goal_of_type_against = {
					type = make_protectorate
					target = scope:target_country
				}
			}
		}
	}
	
	accept_effect = {
		ROOT = {
			set_variable = {
				name = war_goal_add_cooldown
				months = 6
			}
		}
		random_diplomatic_play = { 
		limit = { is_war = yes any_scope_play_involved = { THIS = scope:target_country } }
		add_war_goal = { holder = ROOT type = make_protectorate primary_demand = no target_country = scope:target_country }
		}
			create_incident = {
				country = ROOT
				value = {
					value = 42
					divide = 1
					max = 45
					min = 36						
				}
			}		
		}
	
	ai = {
		evaluation_chance = {
			value = 0.03
				if = {
				limit = {  has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { ROOT = { infamy >= 49.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}			
		will_propose = { 
		OR = {
			NOT = { ROOT = { infamy >= 64.9 } }
			NOT = { has_game_rule = ai_wargoals_blocked }
			NOT = { has_modifier = ai_wargoal_are_blocked }
		  }
		}
		propose_score = {
			value = 10
			if = {
				limit = { ROOT = { infamy >= 64.9 } }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
			if = {
				limit = { has_game_rule = ai_wargoals_blocked }
				add = {
					value = country_rank
					multiply = 0
				}				
			}
		}
	}
}