﻿tributary = {
	requires_approval = yes
	should_notify_third_parties = yes
	can_use_obligations = yes

	possible = {
		is_at_war = no
		scope:target_country = { is_at_war = no }
		has_diplomatic_relevance = scope:target_country
		is_revolutionary = no
		scope:target_country = {
			is_revolutionary = no
		}
		custom_tooltip = {
			text = DIPLO_ACTION_MARKET_CONNECTION_REQUIRED
			OR = {	
				AND = {
					market = { has_port = yes }
					scope:target_country.market = { has_port = yes }
				}
				scope:actor.market = {
					any_scope_country = {
						is_adjacent = root
					}
				}
			}
		}		
	}

	pact = {	
		cost = 25
		is_customs_union = yes
		has_junior_participant = yes
		recipient_pays_maintenance = no

		income_transfer = 0.2
		recipient_gets_income_transfer = no
		income_transfer_based_on_recipient = yes
		
		relations_progress_per_day = 1
		relations_improvement_max = 50

		target_requires_approval_to_break = yes	
		
		subject_type = subject_type_tributary
		
		actor_can_break = {
			is_diplomatic_play_committed_participant = no
		}

		target_can_break = {
			is_diplomatic_play_committed_participant = no
		}
		
		break_effect = {
			create_truce = { country = scope:target_country months = 12 }
		}
	}
	
	accept_effect = {
		create_incident = {
			country = scope:target_country
			value = 5
		}
	}
	
	ai = {
		check_acceptance_for_will_break = yes
		check_acceptance_for_will_propose = yes
		
		will_propose = { 
			#country_rank = rank_value:unrecognized_major_power
			#scope:target_country = { is_country_type = unrecognized }
			OR = {
				AND = {
					infamy < infamy_threshold:infamous
					has_attitude = {
						who = scope:target_country
						attitude = protective
					}					
				}
				AND = {
					infamy < infamy_threshold:notorious
					has_attitude = {
						who = scope:target_country
						attitude = domineering
					}				
				}			
			}		
		}
	
		will_break = {
			is_subject_of = scope:target_country
			has_attitude = {
				who = scope:target_country
				attitude = rebellious
			}			
		}
		
		propose_score = {
			value = 10
		}
		
		propose_break_score = {
			value = 10
		}		
		
		accept_score = {
			value = 0
	
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_BASE"
				value = -100
			}

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_ATTITUDE"
				if = {
					limit = {
						OR = {						
							has_attitude = {
								who = scope:actor
								attitude = protective
							}
							has_attitude = {
								who = scope:actor
								attitude = domineering
							}							
						}
					}
					value = 1000
				}
			}			
		}

		junior_accept_score = {
			value = 0
	
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_BASE"
				value = -100
			}	
	
			if = {
				limit = { has_truce_with = scope:actor }
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_TRUCE"
					value = -1000
				}	
			}
	
			if = {
				limit = {
					NOT = { has_strategic_adjacency = scope:actor }
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_NOT_NEIGHBORS"
					value = -10
				}	
			}			

			if = {
				limit = { 
					has_strategy = ai_strategy_armed_isolationism 
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_ISOLATIONIST"
					add = -25
				}
			}			
			
			
			if = {
				limit = {
					"scope:actor.ai_army_comparison(root)" > 0
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_ARMY_STRENGTH"
					value = "scope:actor.ai_army_comparison(root)"
					max = 25
				}				
			}
			else = {
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_ARMY_STRENGTH"
					value = -1000
				}			
			}	

			if = {
				limit = {
					"scope:actor.ai_ideological_opinion(root)" > 0
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_IDEOLOGICAL_OPINION"
					value = "scope:actor.ai_ideological_opinion(root)"
					multiply = 0.5
					max = 10
				}					
			}
			else_if = {
				limit = {
					"scope:actor.ai_ideological_opinion(root)" < 0
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_IDEOLOGICAL_OPINION_NEGATIVE"
					value = "scope:actor.ai_ideological_opinion(root)"
					min = -30
				}					
			}			

			if = {
				limit = {
					NOT = {
						has_diplomatic_pact = {
							who = scope:actor
							type = customs_union
						}					
					}
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_NO_CUSTOMS_UNION"
					value = -10
				}	
			}					
			
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_ATTITUDE"
				if = {
					limit = {
						OR = {
							has_attitude = {
								who = scope:actor
								attitude = genial
							}
							has_attitude = {
								who = scope:actor
								attitude = conciliatory
							}							
							has_attitude = {
								who = scope:actor
								attitude = loyal
							}	
							has_attitude = {
								who = scope:actor
								attitude = cooperative
							}							
						}
					}
					value = 10
				}			
				if = {
					limit = {
						has_attitude = {
							who = scope:actor
							attitude = cautious
						}
					}
					value = -25
				}					
				if = {
					limit = {
						OR = {
							has_attitude = {
								who = scope:actor
								attitude = antagonistic
							}
							has_attitude = {
								who = scope:actor
								attitude = domineering
							}	
							has_attitude = {
								who = scope:actor
								attitude = belligerent
							}	
							has_attitude = {
								who = scope:actor
								attitude = rebellious
							}
							has_attitude = {
								who = scope:actor
								attitude = protective
							}							
						}
					}
					value = -1000
				}							
			}			

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_RELATIONS"	
				if = {
					limit = {
						"relations(scope:actor)" < relations_threshold:cordial
					}
					value = -25
				}					
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:cordial
						"relations(scope:actor)" < relations_threshold:amicable
					}
					value = 5
				}					
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:amicable
						"relations(scope:actor)" < relations_threshold:friendly
					}
					value = 10
				}	
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:friendly
					}
					value = 25
				}				
			}
			
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_INFAMY"
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:infamous
						"scope:actor.infamy" < infamy_threshold:notorious
					}
					value = -25
				}	
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:notorious
						"scope:actor.infamy" < infamy_threshold:pariah
					}
					value = -50
				}
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:pariah
					}
					value = -100
				}					
			}					

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_RANK"
	
				if = {
					limit = { scope:actor = { country_rank > root.country_rank } }
					value = 10
				}
				
				if = {
					limit = { scope:actor = { country_rank < root.country_rank } }
					value = -10
				}				
			}	

			if = {
				limit = {
					any_country = {
						NOT = { this = scope:actor }
						OR = {
							country_rank >= scope:actor.country_rank
							army_size >= scope:actor.army_size
						}
						
						OR = {
							has_diplomatic_pact = {
								who = root
								type = alliance
							}
							has_diplomatic_pact = {
								who = root
								type = customs_union
							}
							has_diplomatic_pact = {
								who = root
								type = defensive_pact
							}									
						}							
					}
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_POWERFUL_PROTECTORS_THEM"
					value = -25
				}	
			}			
		}	
		
		accept_break_score = {
			value = 0

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_BASE"
				value = -100
			}				
	
			if = {
				limit = { has_truce_with = scope:actor }
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_TRUCE"
					value = -1000
				}	
			}			
			
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_ARMY_STRENGTH"
				value = "scope:actor.ai_army_comparison(root)"
				add = 0.5
				multiply = 5
				min = -50
				max = 50
			}		

			if = {
				limit = {
					"scope:actor.ai_ideological_opinion(root)" > 0
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_IDEOLOGICAL_OPINION"
					value = "scope:actor.ai_ideological_opinion(root)"
					multiply = -0.25
					min = -10
				}					
			}
			else_if = {
				limit = {
					"scope:actor.ai_ideological_opinion(root)" < 0
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_IDEOLOGICAL_OPINION_NEGATIVE"
					value = "scope:actor.ai_ideological_opinion(root)"
					multiply = 0.25
					max = 10
				}					
			}						
			
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_ATTITUDE"	
				if = {
					limit = {
						has_attitude = {
							who = scope:actor
							attitude = domineering
						}								
					}
					value = -50
				}							
			}			

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_RELATIONS"	
				if = {
					limit = {
						"relations(scope:actor)" < relations_threshold:cordial
					}
					value = -25
				}					
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:cordial
						"relations(scope:actor)" < relations_threshold:amicable
					}
					value = 10
				}					
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:amicable
						"relations(scope:actor)" < relations_threshold:friendly
					}
					value = 25
				}	
				if = {
					limit = {
						"relations(scope:actor)" >= relations_threshold:friendly
					}
					value = 50
				}				
			}
			
			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_INFAMY"
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:infamous
						"scope:actor.infamy" < infamy_threshold:notorious
					}
					value = -25
				}	
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:notorious
						"scope:actor.infamy" < infamy_threshold:pariah
					}
					value = -50
				}
				if = {
					limit = {
						"scope:actor.infamy" >= infamy_threshold:pariah
					}
					value = -100
				}					
			}					

			add = {
				desc = "DIPLOMATIC_ACCEPTANCE_RANK"
	
				if = {
					limit = { scope:actor = { country_rank > root.country_rank } }
					value = 10
				}
				
				if = {
					limit = { scope:actor = { country_rank < root.country_rank } }
					value = -10
				}				
			}	

			if = {
				limit = {
					any_country = {
						NOT = { this = root }
						OR = {
							country_rank >= root.country_rank
							army_size >= root.army_size
						}
						
						OR = {
							has_diplomatic_pact = {
								who = scope:actor
								type = alliance
							}
							has_diplomatic_pact = {
								who = scope:actor
								type = customs_union
							}
							has_diplomatic_pact = {
								who = scope:actor
								type = defensive_pact
							}									
						}							
					}
				}
				add = {
					desc = "DIPLOMATIC_ACCEPTANCE_POWERFUL_PROTECTORS_US"
					value = 25
				}	
			}		
		}	

		use_obligation_chance = {
			value = 50
		}

		owe_obligation_chance = {
			value = 25
		}		
	}
}

become_tributary = {
	requires_approval = yes
	should_notify_third_parties = yes

	potential = {
		#is_country_type = unrecognized	
		#scope:target_country = { is_country_type = unrecognized }
		is_subject = no		
	}

	possible = {
		is_at_war = no
		scope:target_country = { is_at_war = no }
		has_diplomatic_relevance = scope:target_country
		is_revolutionary = no
		scope:target_country = {
			is_revolutionary = no
		}
	}
	
	reverse_pact = tributary
	
	ai = {
		check_acceptance_for_will_propose = yes

		propose_score = {
			value = 10
		}

		propose_break_score = {
			value = 10
		}

		use_obligation_chance = {
			value = 0
		}

		owe_obligation_chance = {
			value = 0
		}
	}
}