namespace = est_hacking

# Hacking 2, reduce border range of neighbours.
country_event = {
	id = est_hacking.1
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_active_tradition = tr_est_hacking_2
	}

	immediate = {
		every_neighbor_country = {
			limit = {
				Not = {
					has_ethic = ethic_gestalt_consciousness	
					has_defensive_pact = prev
					is_in_federation_with = prev
					is_overlord_to = prev
					prev = {
						is_overlord_to = prev
					}
				}
			}
			set_timed_country_flag = {
				flag = est_hacking_2_flag
				days = 1
			}
			if = {
				limit = {
					Not = {
						has_modifier = mod_est_shroudborn_2
						has_modifier = mod_est_hacking_2
					}
				}
				add_modifier = {
					modifier = "mod_est_hacking_2"
					days = -1
				}
			}
		}
	}
}

# Hacking 2, removes penalty from those that should not have it anymore.
country_event = {
	id = est_hacking.2
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		Not = {
			has_country_flag = est_hacking_2_flag
		}
		has_modifier = mod_est_hacking_2
	}

	immediate = {
		remove_modifier = "mod_est_hacking_2"
	}
}

# Hacking 4, penalty to rivals.
country_event = {
	id = est_hacking.3
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_active_tradition = tr_est_hacking_4
	}

	immediate = {
		every_country = {
			limit = {
				prev = {
					is_rival = prev
				}
			}
			if = {
				limit = {
					Not = { has_modifier = mod_est_hacking_4 }
				}
				add_modifier = {
					modifier = "mod_est_hacking_4"
					days = -1
				}					
			}
			set_timed_country_flag = {
				flag = est_hacking_4_modifier_just_added
				days = 1
			}
		}
	}
}

# Hacking 4 terminators, penalty to everyone else.
country_event = {
	id = est_hacking.4
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_active_tradition = tr_est_hacking_4_terminator
		has_global_flag = est_hacking_4_terminator_picked_flag
	}

	immediate = {
		every_country = {
			limit = {
				Not = { has_active_tradition = tr_est_hacking_4_terminator }
			}
			if = {
				limit = {
					Not = { has_modifier = mod_est_hacking_4 }
				}
				add_modifier = {
					modifier = "mod_est_hacking_4"
					days = -1
				}					
			}	
			set_timed_country_flag = {
				flag = est_hacking_4_terminator_modifier_just_added
				days = 1
			}
		}
	}
}

# Hacking 4 and Hacking 4 terminators, removes penalty from those that should not have it.
country_event = {
	id = est_hacking.5
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		NOR = {
			has_country_flag = est_hacking_4_modifier_just_added
			has_country_flag = est_hacking_4_terminator_modifier_just_added			
		}
		has_modifier = mod_est_hacking_4
	}

	immediate = {	
		remove_modifier = "mod_est_hacking_4"	
	}
}