revolution_peace = {
	enable = {
		has_country_flag = liberated_by_sov #For some reasons if the revolution wins they won't stop WHITE PEACE with the enemy, hopefully this fixes it
	}

	annex_randomness = 0
	liberate_randomness = 0
	puppet_randomness = 0
	take_states_randomness = 0
	force_government_randomness = 0

	annex = {
		factor = 100

		modifier = {
			factor = 0
			OR = {
				NOT = {
					has_annex_war_goal = FROM
				}
				NOT = {
					is_owner_neighbor_of = FROM
				}
			}
			FROM = {
				any_owned_state = {
					NOT = {
						OR = {
							is_claimed_by = ROOT
							is_core_of = ROOT
							has_claimed_state_in_peace_conference = ROOT
						}
					}
				}
			}
		}
	}

	# ROOT = Taker, FROM = Liberated
	liberate = { #Liberate might be buggy and might require country-specific workarounds...
		factor = 0
	}

	# ROOT = Taker, FROM = Giver
	puppet = {
		factor = 5000
	}

	# ROOT = Taker, FROM = Giver
	puppet_all = {
		base = 0
	}

	# ROOT = STATE, FROM = Taker, FROM.FROM = Giver
	puppet_state = {
		base = 0
		modifier = { #puppet state only if already puppeted
			add = 200
			#only if already puppetted the country
			is_in_array = { subject_countries@FROM = FROM.FROM }
			#only if already puppetted a neighbor state
			any_neighbor_state = {
				is_in_array = { subject_states@FROM = this }
			}
		}
	}

	# ROOT = Taker, FROM = State
	take_states = {
		factor = 1000
		modifier = {
			add = 9000

			FROM = {
				OR = {
					is_claimed_by = ROOT
					is_core_of = ROOT
				}
			}
		}
		modifier = { # prefer not to take from humans in our own faction
			factor = 0.5
			NOT = {
				FROM = {
					OR = {
						is_claimed_by = ROOT
						is_core_of = ROOT
					}
				}
			}
			FROM = {
				controller = {
					is_ai = no
					has_capitulated = no
					is_puppet = no
					is_in_faction_with = ROOT
				}
			}
		}
		modifier = { #Don't steal claims and cores from faction members unless we also have a right to that clay unless they are puppets
			factor = 0
			NOT = {
				FROM = {
					OR = {
						is_claimed_by = ROOT
						is_core_of = ROOT
					}
				}
			}
			any_country = {
				is_in_faction_with = ROOT
				is_puppet = no
				FROM = {
					OR = {
						is_claimed_by = PREV
						is_core_of = PREV
					}
				}
			}
		}

		modifier = {
			factor = 1.25

			capital_scope = {
				distance_to = {
					target = FROM
					value < 100
				}
			}
		}

		modifier = {
			factor = 1.25

			capital_scope = {
				distance_to = {
					target = FROM
					value < 200
				}
			}
		}

		modifier = {
			factor = 1.25

			capital_scope = {
				distance_to = {
					target = FROM
					value < 300
				}
			}
		}

		modifier = {
			factor = 1.25

			capital_scope = {
				distance_to = {
					target = FROM
					value < 400
				}
			}
		}

		modifier = {
			factor = 1.5
			FROM = {
				OR = {
					num_owned_neighbour_states = {
						count > 1
						owner = ROOT
					}
					num_claimed_peace_conference_neighbour_states = {
						count > 1
						owner = ROOT
					}
				}
			}
		}

		modifier = {
			factor = 1.5
			FROM = {
				OR = {
					num_owned_neighbour_states = {
						count > 2
						owner = ROOT
					}
					num_claimed_peace_conference_neighbour_states = {
						count > 2
						owner = ROOT
					}
				}
			}
		}

		modifier = {
			factor = 1.5
			FROM = {
				OR = {
					num_owned_neighbour_states = {
						count > 3
						owner = ROOT
					}
					num_claimed_peace_conference_neighbour_states = {
						count > 3
						owner = ROOT
					}
				}
			}
		}

		modifier = {
			factor = 1.5
			FROM = {
				OR = {
					num_owned_neighbour_states = {
						count > 4
						owner = ROOT
					}
					num_claimed_peace_conference_neighbour_states = {
						count > 4
						owner = ROOT
					}
				}
			}
		}

		modifier = {
			factor = 1.5
			FROM = {
				OR = {
					num_owned_neighbour_states = {
						count > 5
						owner = ROOT
					}
					num_claimed_peace_conference_neighbour_states = {
						count > 5
						owner = ROOT
					}
				}
			}
		}

		modifier = {
			factor = 0
			NOT = {
				FROM = {
					OR = {
						is_claimed_by = ROOT
						is_core_of = ROOT
					}
				}
			}
			NOT = {
				FROM = {
					any_neighbor_state = {
						OR = {
							owner = { tag = ROOT }
							has_claimed_state_in_peace_conference = ROOT
						}
					}
				}
			}
			OR = {
				NOT = {
					FROM = {
						OR = {
							is_island_state = yes
							is_coastal = yes
						}
					}
				}
				NOT = { any_owned_state = { is_coastal = yes } }
			}

		}

		modifier = { #Only take claims - and colonial states (ie unclaimed) as well if major.
			factor = 0
			NOT = {
				FROM = {
					OR = {
						is_claimed_by = ROOT
						is_core_of = ROOT
					}
				}
			}
			OR = {
				AND = {
					#Is NOT a major
					NOT = { num_of_factories > 100 }
					NOT = { tag = GER }
					NOT = { tag = ENG }
					NOT = { tag = ITA }
					NOT = { tag = FRA }
					NOT = { tag = USA }
					NOT = { tag = JAP }
					NOT = { tag = SOV }
				}
				FROM = {
					owner = {
						FROM = { is_core_of = PREV }
					}
				}
			}
		}

		modifier = { #Only take claimed/core land if a puppet.
			factor = 0
			is_puppet = yes
			FROM = {
				NOT = {
					OR = {
						is_claimed_by = ROOT
						is_core_of = ROOT
					}
				}
			}
		}

	}

	# ROOT = Taker, FROM = Giver
	force_government = {
		factor = 0
	}
}