namespace = nsc_events_flagship

############################
### FLAGSHIP EVENT CHAIN ###
############################

#1. Player obtains Flagship tech, which opens the Flagship in the ship designer. The Flagship Shipyard mega becomes available to build.
#the notification event to tell players that they can now design a flagship and build a shipyard for it
country_event = {
	id = nsc_events_flagship.1
	title = "nsc_events_flagship.1.name"
	desc = "nsc_events_flagship.1.desc"
	picture = GFX_evt_megashipyard
	show_sound = event_bad_omen
	is_triggered_only = yes

	trigger = {
		last_increased_tech = tech_Flagship_1
	}

	option = {
		name = nsc_events_flagship.1.a #ok
	}
}


#4. When the third Flagship stage is done, an event popup tells you that other empires know about this and may start their own Flagship programs.
#the notification event to tell players that other empires know about their flagship project by now
country_event = {
	id = nsc_events_flagship.3
	title = "nsc_events_flagship.3.name"
	desc = "nsc_events_flagship.3.desc"
	picture = GFX_evt_board_meeting
	show_sound = event_red_alert
	is_triggered_only = yes

	option = {
		name = nsc_events_flagship.3.a
	}
}


#5. When the final stage is complete, the Flagship is spawned from the player design and an event popup talks about the completion of the project, its awesome power, and the reaction of other empires.
#the notification event to tell players that their flagship construction has finished
ship_event = {
	id = nsc_events_flagship.4
	title = "nsc_events_flagship.4.name"
	desc = "nsc_events_flagship.4.desc"
	picture = GFX_evt_space_hangar
	show_sound = relic_activation_khans_throne
	location = this
	is_triggered_only = yes

	trigger = {
		is_ship_size = Flagship #ok I'm an idiot sandwich, sorry mates :(
	}

	immediate = {
		#6. A year (or whatever time frame) after the Flagship is spawned, you get an event telling you that other empires have rushed their flagships into production, and they're operational.
		#This is also the event that spawns Flagships for a random set of AI empires.
		owner = { country_event = { id = nsc_events_flagship.6 days = 360 random = 180 } }
	}

	option = {
		name = nsc_events_flagship.4.a
		owner = { add_resource = { influence = 100 } }
	}
}


#the event that spawns Flagships for a random set of AI empires.
country_event = {
	id = nsc_events_flagship.6
	title = "nsc_events_flagship.6.name"
	desc = "nsc_events_flagship.6.desc"
	picture = GFX_evt_unknown_ships
	show_sound = event_bad_omen
	is_triggered_only = yes

	immediate = {
		every_rival_country = {
			limit = {
				is_ai = yes
				is_country_type = default
				NOT = { any_controlled_ship = { is_ship_size = Flagship } }
			}
			nsc_flagship_creation_for_ai_effect = yes
		}
		every_neighbor_country = {
			limit = {
				is_ai = yes
				is_country_type = default
				NOT = { any_controlled_ship = { is_ship_size = Flagship } }
			}
			nsc_flagship_creation_for_ai_effect = yes
		}
		while = {
			random_country = {
				limit = {
					is_ai = yes
					is_country_type = default
					OR = {
						opinion_level = { who = root level = poor }
						opinion_level = { who = root level = terrible }
					}
					NOT = { any_controlled_ship = { is_ship_size = Flagship } }
				}
				nsc_flagship_creation_for_ai_effect = yes
			}
			count = 3
		}
	}

	option = {
		name = nsc_events_flagship.6.a
	}
}


#7. Flagship is destroyed, an event popup then tells the player that a special project will be created to allow them to build another Flagship, and will be available for them to start at any time. 
#At the end of that special project, the Flagship once again spawns. This event should repeat each time the Flagship is destroyed.
#the event for destroyed flagship
country_event = {
	id = nsc_events_flagship.7
	title = "nsc_events_flagship.7.name"
	desc = "nsc_events_flagship.7.desc"
	picture = GFX_evt_exploding_ship
	show_sound = event_ship_explosion
	is_triggered_only = yes

	trigger = {
		fromfrom = { is_ship_size = Flagship }
	}

	option = {
		name = nsc_events_flagship.7.a
	}
}

#the event for disbanded flagship
country_event = {
	id = nsc_events_flagship.8
	title = "nsc_events_flagship.8.name"
	desc = "nsc_events_flagship.8.desc"
	picture = GFX_evt_space_debris
	show_sound = event_ship_explosion
	is_triggered_only = yes

	trigger = {
		from = { any_controlled_ship = { is_ship_size = Flagship } }
	}

	option = {
		name = nsc_events_flagship.8.a
	}
}

country_event = {
	id = nsc_events_flagship.9
	title = "nsc_events_flagship.9.name"
	desc = "nsc_events_flagship.9.desc"
	picture = GFX_evt_flagship
	show_sound = event_celebration
	is_triggered_only = yes

	option = {
		name = nsc_events_flagship.9.a
	}
}

#notification event for the first time two flagships fight against each other
country_event = {
	id = nsc_events_flagship.10
	title = "nsc_events_flagship.10.name"
	desc = "nsc_events_flagship.10.desc"
	picture = GFX_evt_small_space_battle
	show_sound = event_space_battle
	is_triggered_only = yes
	fire_only_once = yes #I can add more trigger if this is not working properly
	location = fromfrom

	trigger = {
		fromfrom = { any_controlled_ship = { is_ship_size = Flagship } }
		fromfromfrom = { any_controlled_ship = { is_ship_size = Flagship } }
	}

	option = {
		name = nsc_events_flagship.10.a
		add_resource = { influence = 100 unity = 100 }
	}
}