#Logic for peace AI
#Written by Niko92

#General rules
#1. Always take cored and claimed states
#2. Western and Emerging will liberate annexed countries of the same ideology
#3. Puppet rest
#(4. Special cases for islands to act as bases [Diego Garcia, Caribbean etc.])

#Only factors are available, "add" doesn't work 
#AI does option with the highest factor first

default_peace = {
	enable = {
		always = yes
	}

	annex_randomness = 0
	liberate_randomness = 0
	puppet_randomness = 0
	take_states_randomness = 0
	force_government_randomness = 0
	
	#Annex means annex a whole country - FROM is loser, ROOT is winner. This is poop, use take_states instead
	annex = {
		factor = 0
	}

	#ROOT = Taker, FROM = State
	take_states = {
		factor = 1
		
		modifier = {	#If not core/claim, don't take
			factor = 5000
			FROM = {
				OR = {
					is_claimed_by = ROOT
					is_core_of = ROOT
				}
			}
		}		
		modifier = {	#Make Rojava get as much territory as possible in Syrian civil war
			factor = 5000
			ROOT = {
				original_tag = ROJ
			}
			FROM = {
				OR = {
					is_core_of = SYR
					is_core_of = NUS
					is_core_of = FSA
				}
			}
		}
		modifier = {	#Rojava always want to take lands from ISIS
			factor = 5000
			ROOT = {
				original_tag = KUR
			}
			FROM = {
				is_owned_by = ISI
			}
		}
		modifier = {	#Have to have this because peace AI is garbage
			factor = 0
			NOT = {
				FROM = { is_claimed_by = ROOT }
				FROM = { is_core_of = ROOT }
			}
			NOT = {
				AND = {
					ROOT = {
						original_tag = ROJ
					}
					FROM = {
						OR = {
							is_core_of = SYR
							is_core_of = NUS
							is_core_of = FSA
						}
					}
				}
			}
			NOT = {
				AND = {
					ROOT = {
						original_tag = ROJ
					}
					FROM = {
						is_owned_by = ISI
					}
				}
			}
		}
	}
	
	# ROOT = Taker, FROM = Liberated
	liberate = {
		factor = 1
		modifier = {		#Western and Emerging will liberate annexed countries of same ideology
			factor = 4000
			OR = {
				AND = {
					ROOT = { has_government = democratic }
					FROM = { has_government = democratic }
				}
				AND = {
					ROOT = { has_government = communism }
					FROM = { has_government = communism }
				}
			}
		}
		modifier = {	#Have to have this because peace AI is garbage
			factor = 0
			NOT = {
				OR = {
					AND = {
						ROOT = { has_government = democratic }
						FROM = { has_government = democratic }
					}
					AND = {
						ROOT = { has_government = communism }
						FROM = { has_government = communism }
					}
				}
			}
		}
	}

	#Makes country puppet - FROM is target, ROOT puppeter
	puppet = {
		factor = 3000
		modifier = {	#Don't puppet nations in civil war... this is too buggy.
			factor = 0
			FROM = { has_civil_war = yes }
		}
		modifier = {	#Don't puppet if target is super strong
			factor = 0
			FROM = {
				ic_ratio = {
					tag = ROOT
					ratio > 2
				}
			}
		}
		modifier = {	#Don't puppet ISIS
			factor = 0
			FROM = {
				original_tag = ISI
			}
		}
	}

	#Changes ideology of target - FROM is target, ROOT winner
	force_government = {
		factor = 2000
		modifier = {	#Don't do this to ISIS
			factor = 0
			FROM = {
				original_tag = ISI
			}
		}
	}
}
