scripted_diplomatic_actions = {
		peace = {
		allowed = {		#The country making the diplomatic request
			
		}
		visible = {		#The target country
			
			THIS = {has_war_with = ROOT}
			
		}
		visible = { #if action is visible on gui
			always = yes
		}
		selectable = {
			
			ROOT = {
				OR = {
					is_faction_leader = yes
					is_in_faction = no
				}
			}
			THIS = {
				OR = {
					is_faction_leader = yes
					is_in_faction = no
				}
			}
			THIS = {
				NOT = {
					has_civil_war = yes
				}
			}
			ROOT = {
				NOT = {
					has_civil_war = yes
				}
			}
		}

		requires_acceptance = yes # if true the action will require acceptance of target country
		cost = 0 # pp cost, can be zero
		command_power = 0 # cp cost, can be zero

		
		show_acceptance_on_action_button = yes # set to no if acceptance shouldn't be displayed on the action button

		icon = 1 # icon frame to use in notification

      #for effects/triggers/variables, root is the sender and this is receiver

		# runs when the action is sent
		on_sent_effect = {
			
		}

		# runs when the action is properly sent and accepted
		complete_effect = {
		 #	ROOT = {
			#	IF = {
			#		limit = {is_faction_leader = yes}
			#		every_country = {
			#			limit = {is_in_faction_with = ROOT
			#				NOT = {tag = ROOT}
			#			}
			#			leave_faction = yes
			#		}
			#		else = {
			#			leave_faction = yes
			#		}
			#	}
			#}
			#THIS = {
			#	IF = {
			#		limit = {is_faction_leader = yes}
			#		every_country = {
			#			limit = {is_in_faction_with = PREV
			#				NOT = {tag = PREV}
			#			}
			#			leave_faction = yes
			#		}
			#		else = {
			#			leave_faction = yes
			#		}
			#	}
			#	
			#}

			
			
			
			#every_country = {
			#	limit = {
			#		has_war_with = FROM
			#	}
			#	country_event = {
			#		id = peace_mid_war.1
			#		days = 1 
			#	}
			#}
			
	
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 0}} }
				FROM = {white_peace = ROOT}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 1}} }
				every_country = {
					limit = {
						is_in_faction_with = PREV
					}
					every_owned_state = {
						limit = {any_neighbor_state={is_owned_by = ROOT}}
						
						set_demilitarized_zone = yes
					}	
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 2}} }
				THIS = {
					ROOT = {
						add_to_variable = {dx = PREV.dx}

					}
					THIS = {
						set_variable = {dx = 0}

					}
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 3}} }
				every_country = {
					limit = {
						is_in_faction_with = PREV
					}
					every_owned_state = {
						limit = {any_neighbor_state={is_owned_by = ROOT}}
						
						ROOT = {
							transfer_state = PREV
						}
					}	
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 4}} }
				every_country = {
					limit = {
						is_in_faction_with = PREV
					}
					every_owned_state = {
						limit = {OR = {is_core_of = ROOT   is_claimed_by = ROOT}}
						
						ROOT = {
							transfer_state = PREV
						}
					}	
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 5}} }
				every_country = {
					limit = {
						OR = {
						is_in_faction_with = PREV
						tag = PREV
						}
					}
					every_country = {
						limit = {
							OR = {
								is_in_faction_with = ROOT
								is_subject_of = ROOT
								tag = ROOT
							}
						}
						every_controlled_state = {
							limit = {
								is_owned_by = PREV.PREV
							}
							PREV = {
								transfer_state = PREV
							}
						}	
					}
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 6}} }
				THIS = {
					#annex_country = {target = PREV}
					white_peace = ROOT
					every_state = {
						limit = {
							is_owned_by = PREV
						}
					}
				}
				ROOT = {puppet = PREV}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 7}} }
				every_country = {
					limit = {
						is_in_faction_with = ROOT
					}
					every_owned_state = {
						limit = {any_neighbor_state={is_owned_by = PREV.PREV.PREV}}
						
						set_demilitarized_zone = yes
					}	
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 8}} }
				THIS = {
					PREV = {
						add_to_variable = {dx = ROOT.dx}

					}
					ROOT = {
						set_variable = {dx = 0}

					}
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 9}} }

				
				THIS = {
					
					every_country = {
						limit = {
							is_in_faction_with = ROOT
						}
						every_owned_state = {
						limit = {
							any_neighbor_state={
								is_owned_by = PREV.PREV.PREV
						
							}
						}
							set_state_flag = transfer_state_peace
						
					}
					
					}
					every_state = {limit = {has_state_flag = transfer_state_peace}
						PREV = {transfer_state = PREV}
						clr_state_flag = transfer_state_peace
					}
				}
				
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 10}} }
				THIS = {
					every_country = {
						limit = {
							is_in_faction_with = ROOT
						}
					every_owned_state = {
						limit = {OR = {is_core_of = PREV.PREV   is_claimed_by = PREV.PREV}}
						set_state_flag = transfer_state_peace
						
						
						
					}	
				}
				every_state = {limit = {has_state_flag = transfer_state_peace}
						PREV = {transfer_state = PREV}
						clr_state_flag = transfer_state_peace
					}
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 11}} }
				THIS = {
					every_country = {
						limit = {
							is_in_faction_with = ROOT
						}
					every_owned_state = {
						limit = {is_controlled_by = PREV.PREV}
						set_state_flag = transfer_state_peace
						
						
						
					}	
				}
				every_state = {limit = {has_state_flag = transfer_state_peace}
						PREV = {transfer_state = PREV}
						clr_state_flag = transfer_state_peace
					}
				}
			}
			IF = {
				limit = {ROOT = {check_variable = {peacetype = 12}} }
				ROOT = {
					leave_faction = yes
				}
				THIS = {white_peace = ROOT}
				THIS = {puppet = ROOT}
			}
			every_country = {
				limit = {
					OR = {
					is_in_faction_with = FROM
					is_subject_of = FROM
					tag = FROM
					}
				}
				every_country = {
					limit = {
						OR = {
						is_in_faction_with = ROOT
						is_subject_of = ROOT
						tag = ROOT
						}
					}
					white_peace = {
						tag = PREV
							
					}
				}
			}
		}

		# runs when the action is properly sent and rejected
		reject_effect = {
		}

		# SEND POPUP CUSTOMIZATION
		# use diplomatic_action as context in scripted gui
		
		can_be_sent = { # send button will be disabled if no
			always = yes
		}
		send_description = send_peace # if there is no scripted gui, this desc will be used in send yes/no pop up


	# RECEIVE POPUP CUSTOMIZATION
		# use diplomatic_action as context in scripted gui
		# receive_scripted_gui = receive_scripted_gui_name #if specified the receiver of the action will get this scripted gui instead of yes-no popup when they receive the propose
		reset_receive_effect = {
			# clear action
			if = {
				limit = { 
					is_ai = yes
				}
				# change stuff for ai
			}
		}
		can_be_accepted = { # accept button will be disabled if no
			always = yes
		}
		receive_description = peace_rec # if there is no scripted gui, this desc will be used in send yes/no pop up

		
		# PLAYER FEEDBACK ON ACCEPT/REJECT
		accept_title = loc_key_accept #can be overridden to customize accepted/rejected pop ups for the sender
		accept_description = loc_key_accept_desc
		reject_title = loc_key_reject
		reject_description = loc_key_reject_desc
	
		
		# AI
		# a list of ai_will_do entries that will be used to decide if AI should accept or reject a request
		ai_acceptance = {
			condition = {
				base = 00
				modifier = {
					
					add = 1
					THIS = {surrender_progress > 0.1}
					ROOT = {check_variable = {peacetype = 1}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					THIS = {surrender_progress > 0.7}
					ROOT = {check_variable = {peacetype = 2}}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 3}}
					OR = {
						NOT = {any_owned_state = {any_neighbor_state = {is_owned_by = ROOT}}}
						THIS = {surrender_progress > 0.4}
						
					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}

				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 4}}
					OR = {
						NOT = {any_owned_state = {OR = {is_core_of = ROOT is_claimed_by = ROOT}}}
						THIS = {surrender_progress > 0.4}
					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 5}}
					OR = {
						
						THIS = {surrender_progress > 0.25}
					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 6}}
					OR = {
						
						THIS = {surrender_progress > 0.8}
					}
					NOT = {has_government = fascism}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 7}}
					OR = {
						
						ROOT = {surrender_progress < 0.15}
					}
					NOT = {has_government = fascism}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 8}}
					AND = {
						
						ROOT = {surrender_progress < 0.50}
						ROOT = {check_variable = {dx > 20}}
						NOT = {has_government = fascism}
						THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1 }}}
					}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 9}}
					AND = {
						NOT = {has_government = fascism}
						ROOT = {surrender_progress < 0.50}
						ROOT = {any_owned_state = {any_neighbor_state = {is_owned_by = PREV.PREV.PREV}}}
					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1.5 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 10}}
					AND = {
						NOT = {has_government = fascism}
						ROOT = {surrender_progress < 0.50}
						ROOT = {any_owned_state = {is_core_of = PREV.PREV.PREV}}
					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1.5 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 11}}
					AND = {
						NOT = {has_government = fascism}
						ROOT = {surrender_progress < 0.50}
						ROOT = {surrender_progress > 0.10}

					}
					THIS = {NOT = {strength_ratio = { tag = ROOT ratio > 1.5 }}}
				}
			}
			condition = {
				base = 00
				modifier = {
					
					add = 1
					
					ROOT = {check_variable = {peacetype = 12}}
				}
			}
			
		}

		# ai_will_do to decide if AI should send this action or not
		ai_desire = {
			base = -1
			modifier = {
				
			}
			
		} 
	}



}