namespace = est_liberty

#Liberty 2, gives faction happiness when no faction is suppressed.
#country_event = {
#	id = est_liberty.1
#	hide_window = yes
#	is_triggered_only = yes
#	
#	trigger = {	
#		has_active_tradition = tr_est_liberty_2			
#	}
#	
#	immediate = {
#		if = {
#			limit = {
#				count_pop_faction = {
#					limit = {
#						has_modifier = suppressed_faction
#					} 
#					count < 1 
#				}
#			}
#			every_pop_faction = {
#				limit = {
#					Not = {
#						has_modifier = mod_est_liberty_2
#					}
#				}
#				add_modifier = {
#					modifier = "mod_est_liberty_2"
#					days = -1
#				}
#			}
#		}
#		else = {
#			every_pop_faction = {
#				limit = {
#					has_modifier = mod_est_liberty_2							
#				}
#				remove_modifier = "mod_est_liberty_2"
#			}			
#		}
#	}
#}

#Try if this modifies works in country scope.
#Liberty 2 AI, checks if any new factions available to give happiness boost to.
#country_event = {
#	id = est_liberty.2
#	hide_window = yes
#	is_triggered_only = yes
#	
#	trigger = {
#		has_active_tradition = tr_est_liberty_2_AI
#	}
#	
#	immediate = {
#		every_pop_faction = {
#			limit = {
#				Not = {
#					has_modifier = mod_est_liberty_2_AI
#				}
#			}
#			add_modifier = {
#				modifier = "mod_est_liberty_2_AI"
#				days = -1
#			}
#		}
#	}
#}

#Liberty 3, bonus happiness for 10 years on newly colonized planet
planet_event = {
	id = est_liberty.3
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		owner = {
			has_active_tradition = tr_est_liberty_3
		}
		Not = {
			has_modifier = mod_est_liberty_3
		}
	}
	
	immediate = {
		add_modifier = { 
			modifier = mod_est_liberty_3
			years = 10
		}
	}
}

#Liberty 5, bonus while fighting the bad guys.
country_event = {
	id = est_liberty.4
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {	
		has_active_tradition = tr_est_liberty_5
	}
	
	immediate = {
		if = {
			limit = {
				any_war = {
					any_war_participant = {
						is_war_leader = yes
						is_at_war_with = prevprev
						Or = {
							has_policy_flag = purge_allowed
							has_policy_flag = purge_displacement_only
							has_policy_flag = slavery_allowed
							has_valid_civic = civic_fanatic_purifiers
						}							
					}
				}							
			}
			if = {
				limit = {
					Not = {
						has_modifier = mod_est_liberty_5
					}
				}
				add_modifier = {
					modifier = "mod_est_liberty_5"
					days = -1
				}
			}	
		}			
		else = {
			if = {
				limit = {
					has_modifier = mod_est_liberty_5
				}
				remove_modifier = "mod_est_liberty_5"
			}
		}
	}
}

planet_event = {
	id = est_liberty.5
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			OR = {
				has_active_tradition = tr_est_liberty_3_slavery
				has_active_tradition = tr_est_liberty_3
				has_active_tradition = tr_est_swarm_4
			}		
		}
	}
	
	immediate = {
		planet_event = { id = est_liberty.6 days = 1 }
	}

}

planet_event = {
	id = est_liberty.6
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		random_owned_species = {
			limit = { is_sapient = yes }
			root = {
				create_pop_group = {
					species = prev
					ethos = random
					size = 100
				}
			}
		}
	}
	
}
