namespace = esc_action_tracking

############################################################
###                Action Tracking Events                ###
############################################################

### space dragon killing
country_event = {
	id = esc_action_tracking.1000
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		FROMFROMFROM = {
			OR = {
				is_ship_size = space_dragon_red
				is_ship_size = space_dragon_blue
				is_ship_size = space_dragon_origin
			}
		}
		ESC_TRIGGER_is_playable_empire = yes
	}

	immediate = {
		set_country_flag = ESC_COUNTRY_FLAG_killed_ether_drake

		if = {
			limit = {
				OR = {
					FROMFROMFROM = { is_ship_size = space_dragon_origin }
					has_origin = origin_here_be_dragons
				}
			}
			set_country_flag = ESC_COUNTRY_FLAG_can_clone_sky_dragon
		}
	}
}

### stellarite devourer killing
country_event = {
	id = esc_action_tracking.1100
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		FROMFROMFROM = { has_ship_flag = stellarite_ship }
		ESC_TRIGGER_is_playable_empire = yes
	}

	immediate = {
		set_country_flag = ESC_COUNTRY_FLAG_killed_stellarite_devourer
	}
}

### automated dreadnought killing
country_event = {
	id = esc_action_tracking.1200
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		FROMFROMFROM = { is_ship_size = npc_warship_01 }
		ESC_TRIGGER_is_playable_empire = yes
		NOR = {
			has_country_flag = ESC_COUNTRY_FLAG_dreadnought_computer_declined
			has_technology = esc_tech_dreadnought_computer
			has_tech_option = esc_tech_dreadnought_computer
		}
	}

	immediate = {
		set_country_flag = ESC_COUNTRY_FLAG_dreadnough_computer
		remove_country_flag = ESC_COUNTRY_FLAG_dreadnough_computer_queued
		add_research_option = esc_tech_dreadnought_computer

		if = {
			limit = { has_special_project = ESC_DREADNOUGHT_OBSERVATION }
			abort_special_project = { type = ESC_DREADNOUGHT_OBSERVATION }
		}
	}
}

### elder one killed
country_event = {
	id = esc_action_tracking.1300
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		FROMFROMFROM = {
			is_ship_size = dimensional_horror
			owner = { has_country_flag = eldritch_horror_country }
		}
	}

	immediate = {
		set_country_flag = ESC_COUNTRY_FLAG_killed_dimensional_horror
	}
}

### gray goo fleet killing
country_event = {
	id = esc_action_tracking.2000
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		FROM = { is_country_type = gray_goo }
		THIS = {
			NOR = {
				has_country_flag = ESC_COUNTRY_FLAG_nanite_computer_queued
				has_country_flag = ESC_COUNTRY_FLAG_nanite_computer
				has_country_flag = ESC_COUNTRY_FLAG_nanite_computer_rejected
			}
		}
	}

	immediate = {
		if = {
			limit = { is_ai = yes }
			add_research_option = esc_tech_nanite_thought_matrix
			set_country_flag = ESC_COUNTRY_FLAG_nanite_computer
		}
		else = {
			set_country_flag = ESC_COUNTRY_FLAG_nanite_computer_queued
			country_event = { id = esc_special_projects.3003 days = 10 }
		}
	}
}

############################################################
###              Technology Related Events               ###
############################################################

# reverse engineering propogation to lower-tier techs
country_event = {
	id = esc_action_tracking.5000
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		ESC_TRIGGER_is_playable_empire = yes
	}

	immediate = {
		ESC_EFFECT_reverse_engineer_techs = yes
	}
}

# biological repeatable : damage
country_event = {
	id = esc_action_tracking.6001
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_bio_damage
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_bio_damage_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_bio_damage_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_bio_damage_repeatables
				value = 1
			}
		}
	}
}

# biological repeatable : fire rate
country_event = {
	id = esc_action_tracking.6002
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_bio_fire_rate
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_bio_fire_rate_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_bio_fire_rate_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_bio_fire_rate_repeatables
				value = 1
			}
		}
	}
}

# nanite repeatable : damage
country_event = {
	id = esc_action_tracking.6003
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_nanite_damage
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_nanite_damage_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_nanite_damage_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_nanite_damage_repeatables
				value = 1
			}
		}
	}
}

# nanite repeatable : fire rate
country_event = {
	id = esc_action_tracking.6004
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_nanite_fire_rate
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_nanite_fire_rate_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_nanite_fire_rate_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_nanite_fire_rate_repeatables
				value = 1
			}
		}
	}
}

# psionic repeatable : damage
country_event = {
	id = esc_action_tracking.6005
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_psionic_damage
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_psionic_damage_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_psionic_damage_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_psionic_damage_repeatables
				value = 1
			}
		}
	}
}

# psionic repeatable : fire rate
country_event = {
	id = esc_action_tracking.6006
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		last_increased_tech = esc_tech_repeatable_psionic_fire_rate
	}

	immediate = {
		if = {
			limit = {
				NOT = { is_variable_set = ESC_COUNTRY_VARIABLE_psionic_fire_rate_repeatables }
			}
			set_variable = {
				which = ESC_COUNTRY_VARIABLE_psionic_fire_rate_repeatables
				value = 1
			}
		}
		else = {
			change_variable = {
				which = ESC_COUNTRY_VARIABLE_psionic_fire_rate_repeatables
				value = 1
			}
		}
	}
}
