namespace = WL_lv_zinara_fleet_lust

######
######
######

planet_event = {
	id = WL_lv_zinara_fleet_lust.1
	title = WL_lv_zinara_fleet_lust.1.name
	desc = WL_lv_zinara_fleet_lust.1.desc
	picture = GFX_evt_enigmatic_cache
	show_sound = event_mystic_reveal
	location = Root
	is_triggered_only = yes

	trigger = {
	}

	immediate = {
	}

	option = {
		name = WL_lv_zinara_fleet_lust.10.a
	}
}


# border
fleet_event = {
	id = WL_lv_zinara_fleet_lust.2
	title = WL_lv_zinara_fleet_lust.2.name
	desc = WL_lv_zinara_fleet_lust.2.desc
	picture = GFX_evt_enigmatic_cache
	show_sound = event_mystic_reveal
	location = Root
	is_triggered_only = yes

	trigger = {
		exists = event_target:zinara_fleet_02
		is_same_value = event_target:zinara_fleet_02
		fromfrom = {
			exists = space_owner
			space_owner = { is_country_type = default }
			NOT = { has_country_flag = first_arrival_of_zinara_1 }
		}
		from = {
			OR = {
				NOT = { exists = space_owner }
				AND = {
					exists = space_owner
					space_owner = { NOT = { is_same_value = root.fromfrom.space_owner } }
					# technically redundant
				}
			}
		}
	}

	immediate = {
		fromfrom.space_owner = { 
			set_country_flag = first_arrival_of_zinara_1
			country_event =  { id =  WL_lv_zinara_fleet_lust.3 } 
		}
	}

	option = {
		name = WL_lv_zinara_fleet_lust.2.a
	}
}

country_event = {
	id = WL_lv_zinara_fleet_lust.3
	title = WL_lv_zinara_fleet_lust.3.name
	desc = WL_lv_zinara_fleet_lust.3.desc
	picture = GFX_evt_enigmatic_cache
	show_sound = event_mystic_reveal
	location = Root
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_country_flag = first_arrival_of_zinara_1 }
	}

	option = {
		name = WL_lv_zinara_fleet_lust.3.a
		owner = {
			add_resource = { influence = 50 }
		}
	}
}


##### THE ENIGMATIC CACHE COPY FOR ZINARA ######
######
######
######

# when clear_auto_move_on_arrival is set to no the fleet will return to planet even if its orbit is interrupted until it is given another auto_move order.

# ON arrival to its new target the Enigmatic Cache "scans the planet"
country_event = {
	id = WL_lv_zinara_fleet_lust.10
	hide_window = yes
	is_triggered_only = yes

	trigger = {	
		any_owned_fleet = {
			has_fleet_flag = zinara_manifestation_fleet
		}
	}

	immediate = {
		if = {
			limit = {
				from.orbit = {
					is_colony = yes
				}
			}
			from.orbit = {
#				if = {
#					limit = {
#						NOT = {
#							has_modifier = WL_lv_zinara_fleet_in_orbit
#						}
#					}
#					add_modifier = {
#						modifier = WL_lv_zinara_fleet_in_orbit
#					}
#				}
				planet_event = { id = WL_lv_zinara_fleet_lust.12 days = 1080 }
				planet_event = { id = WL_lv_zinara_fleet_lust.120 days = 1080 }
				event_target:zinara_fleet_02 = {
						fleet_event = { id = WL_lv_zinara_fleet_lust.9002 days = 360 }
				}
				planet_event = { id = WL_lv_zinara_fleet_lust.11 days = 1 }
				planet_event = { id = WL_lv_zinara_fleet_lust.13 }
				planet_event = { id = WL_lv_zinara_fleet_lust.14 }
			}
		}
	}
}

# Notification the first time the cache scans one of your planets
planet_event = {
	id = WL_lv_zinara_fleet_lust.11
	title = WL_lv_zinara_fleet_lust.11.name
	desc = WL_lv_zinara_fleet_lust.11.desc
	picture = GFX_evt_WL_lv_zinara_fleet_lust_11
	show_sound = event_mystic_reveal
	location = Root

	is_triggered_only = yes
	trigger = {
		exists = owner
			NOT = { has_planet_flag = first_arrival_of_zinara_1 }
			event_target:zinara_country_target = {
				NOT = { is_hostile = owner }
			}
		NOR = { 
			has_modifier = WL_lv_zinara_fleet_in_orbit_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_machine_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
		}
	}

	immediate = {
		if = {
			limit = {
				root.owner = {
					NOR = { 
						has_authority = auth_machine_intelligence
						is_hive_empire = yes
					}
					OR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			every_owned_pop = {
				limit = {
					OR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_phobe_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					NOR = { 
						is_hive_empire = yes
						has_authority = auth_machine_intelligence
					}
					NOR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			every_owned_pop = {
				limit = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					has_authority = auth_machine_intelligence
					NOR = {
						is_hive_empire = yes
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
						has_civic = civic_machine_servitor	
					}
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_machine_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					has_civic = civic_machine_servitor	
					has_authority = auth_machine_intelligence
					NOR = {
						is_hive_empire = yes
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			every_owned_pop = {
				limit = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					is_hive_empire = yes
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				days = 360
			}
		}
		set_planet_flag = first_arrival_of_zinara_1
		set_planet_flag = zinara_visit_not_available
		solar_system = { set_star_flag = zinara_recently_visited_system }
	}

	option = {
		name = WL_lv_zinara_fleet_lust.11.a
		owner = {
			add_resource = { influence = 50 }
		}
	}
}


#Zinara is hostile when arrives start abduct pops and generate unhappines
planet_event = {
	id = WL_lv_zinara_fleet_lust.13
	title = WL_lv_zinara_fleet_lust.13.name
	desc = WL_lv_zinara_fleet_lust.13.desc
	picture = GFX_evt_WL_lv_zinara_fleet_lust_13
	show_sound = event_mystic_reveal
	location = Root

	is_triggered_only = yes
	trigger = {
		exists = owner
			event_target:zinara_country_target = {
				is_hostile = owner
			}
		NOR = {
			has_modifier =  WL_lv_zinara_fleet_in_orbit_hostile_planet
			has_modifier =  WL_lv_zinara_fleet_in_orbit_hostile_hive_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_hostile_machine_planet
		}
	}

	immediate = {
		if = {
			limit = {
				root.owner = {
					has_authority = auth_machine_intelligence
					NOT = { is_hive_empire = yes }
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_hostile_machine_planet
				days = 360
			}
		}
		if = {
			limit = {
				root.owner = {
					is_hive_empire = yes
					NOT = { has_authority = auth_machine_intelligence }
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_hostile_hive_planet
				days = 360
			}
		}
		if = {
			limit = {
				root.owner = {
					NOR = { 
						is_hive_empire = yes
						has_authority = auth_machine_intelligence
					}
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_hostile_planet
				days = 360
			}
		}
		set_planet_flag = zinara_visit_not_available
		solar_system = { set_star_flag = zinara_recently_visited_system }
	}

	option = {
		name = WL_lv_zinara_fleet_lust.13.a
		owner = {
			add_resource = { influence = -50 }
		}
	}
}


#Zinara is back
planet_event = {
	id = WL_lv_zinara_fleet_lust.14
	title = WL_lv_zinara_fleet_lust.14.name
	desc = WL_lv_zinara_fleet_lust.14.desc
	picture = GFX_evt_WL_lv_zinara_fleet_lust_14
	show_sound = event_mystic_reveal
	location = Root
	is_triggered_only = yes

	trigger = {
		exists = owner
		has_planet_flag = first_arrival_of_zinara_1
		event_target:zinara_country_target = {
			NOT = { is_hostile = owner }
		}
		NOR = { 
			has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
			has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
			has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
			has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
		}
	}

	immediate = {
		if = {
			limit = {
				root.owner = {
					NOR = { 
					has_authority = auth_machine_intelligence
					is_hive_empire = yes
					}
					OR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
			}
			every_owned_pop = {
				limit = {
					OR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_phobe_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					NOR = { 
					is_hive_empire = yes
					has_authority = auth_machine_intelligence
					}
					NOR = {
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
			}
			every_owned_pop = {
				limit = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_planet
				days = 360
			}
		}
		
		
		if = {
			limit = {
				root.owner = {
					has_authority = auth_machine_intelligence
					NOR = {
						is_hive_empire = yes
						has_civic = civic_machine_servitor	
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				NOR = { 
				has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
				has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
				has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
				has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
				has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_machine_planet
				days = 360
			}
		}
		
		
		if = {
			limit = {
				root.owner = {
					has_civic = civic_machine_servitor	
					has_authority = auth_machine_intelligence
					NOR = {
						is_hive_empire = yes
						has_ethic = ethic_fanatic_xenophobe
						has_ethic = ethic_xenophobe
					}
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			every_owned_pop = {
				limit = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
						has_trait = trait_hive_mind
					}
				}
				add_modifier = {
					modifier = WL_lv_zinara_fleet_in_orbit_pop
					days = 360
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
				days = 360
			}
		}
		
		if = {
			limit = {
				root.owner = {
					is_hive_empire = yes
				}
				NOR = { 
					has_modifier =  WL_lv_zinara_fleet_in_orbit_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_servitor_planet
					has_modifier =  WL_lv_zinara_fleet_in_orbit_machine_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_phobe_planet
					has_modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				}
			}
			add_modifier = {
				modifier = WL_lv_zinara_fleet_in_orbit_hive_planet
				days = 360
			}
		}
		set_planet_flag = second_arrival_of_zinara_1
		set_planet_flag =  zinara_visit_not_available
		solar_system = { set_star_flag = zinara_recently_visited_system }
	}

	option = {
		name = WL_lv_zinara_fleet_lust.14.a
		owner = {
			add_resource = { influence = 50 }
		}
	}
}

######
######
planet_event = {
	id = WL_lv_zinara_fleet_lust.12
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		remove_planet_flag =  zinara_visit_not_available
	}

}

planet_event = { #5 years?
	id = WL_lv_zinara_fleet_lust.120
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		solar_system = { remove_star_flag = zinara_recently_visited_system }
	}

}

######################################################
#Zinara explore and visit other planets
#TO DO
#change event_target:zinara_fleet_01 to the new explorer fleet
#First visit to a planet provides 50% growt speed for 1 year
#First visit to a non gestalt planet provides 10% hapiness for 1 year
#First visit to a hive planet provides 50% food for 1 year
#First visit to a xenophobe planet provides 50% army defensive bonus for 1 year
#First visit to a xenophobe planet provides 25% unity production for 1 year
#First visit to a xenophobe planet provides 20% random ethic shift for 1 year
#First visit to a machine pop planet provides 25% energy production for 1 year
#First visit to a machine pop planet provides 25% pop build speed for 1 year
#Zinara will stay 1 year in orbit ignoring all
#Zinara will try to make a deal eventualy
#Zinara will eventually abandon random consumed species in planets.
######FIX LATER
#Zinara can visit primitives. Planned special event for Sol system.
#Zinara can visit primitives.
######Add Later Crisis Instance
#Zinara stop visiting planets to fight crisis

event = { 
	id = WL_lv_zinara_fleet_lust.9001
	hide_window = yes
	is_triggered_only = yes
	
	trigger  = {
		any_country = { is_country_type = zinara_extradimensional }
		NOT = { any_country = { has_country_flag = zinara_celebration } }
	}
	
	immediate = {
		event_target:zinara_fleet_02 = {
			fleet_event = { id = WL_lv_zinara_fleet_lust.9002 }
		}
	}
}
	
fleet_event = { 
	id = WL_lv_zinara_fleet_lust.9002
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				event_target:zinara_fleet_02	= { 
					NOT = { has_fleet_flag = zinara_activated_fleet }
				}
			}
			event_target:zinara_fleet_02	= { 
				set_fleet_flag = zinara_activated_fleet
			}
		}

		random_planet = {
			limit = {
				exists = owner
				solar_system = { NOT = { has_star_flag = zinara_recently_visited_system } }
				owner = {
					OR  = {
						is_country_type = default
						is_country_type = awakened_fallen_empire
						is_country_type = fallen_empire
					}
					NOR = {
						has_ethic = ethic_fanatic_xenophobe
						has_civic = civic_hive_devouring_swarm
						has_civic = civic_machine_assimilator
						has_civic = civic_machine_terminator
						has_civic = civic_fanatic_purifiers
						has_civic = civic_inwards_perfection
					}
					NOR = {  
						is_hostile_to = event_target:zinara_country_target 
						has_country_flag = zinara_rival
					}
					NOT	= { is_at_war = yes }
				}
				NOT	= { has_planet_flag = zinara_visit_not_available }
    	}
			save_event_target_as = new_location
		}

		auto_move_to_planet = {
			target = event_target:new_location
			clear_auto_move_on_arrival = no
		}
	}
}

event = {
	id = WL_lv_zinara_fleet_lust.9003
	hide_window = yes
	is_triggered_only = yes
	
	trigger  = {
		exists = event_target:zinara_country_target 
		exists = event_target:zinara_fleet_02
		any_country = {
			is_country_type = zinara_extradimensional
		}
		event_target:zinara_fleet_02	= {
			NOT = { has_fleet_flag = zinara_activated_fleet }
		}
	}
	
	immediate = {
		event_target:zinara_fleet_02 = {
			fleet_event = { id = WL_lv_zinara_fleet_lust.9002 }
		}
	}
}
