﻿je_scramble_for_africa = {

	icon = "gfx/interface/icons/event_icons/event_map.dds"

	group = je_group_foreign_affairs

	is_shown_when_inactive = {
		has_technology_researched = quinine
		any_scope_state = {
			is_incorporated = no
			state_in_africa = yes
		}
	}

	possible = {
		has_technology_researched = malaria_prevention
		any_scope_state = {
			is_incorporated = no
			state_in_africa = yes
			has_state_trait = state_trait_malaria
		}
		OR = {
			has_law = law_type:law_colonial_resettlement
			has_law = law_type:law_colonial_exploitation
		}
	}

	immediate = {
		trigger_event = {
			id = africa_colonial_events.1
			days = 0
			popup = yes
		}
		save_scope_as = scramble_for_africa_self
	}

	complete = {
		custom_tooltip = {
			text = scramble_for_africa_complete_tt
			any_scope_state = {
				is_incorporated = no
				state_in_africa = yes
				count >= 7
			}
		}
		custom_tooltip = {
			text = scramble_for_africa_complete_2_tt
			any_state_region = {
				filter = {
					OR = {
						region = sr:region_nile_basin
						region = sr:region_ethiopia
						region = sr:region_north_africa
						region = sr:region_senegal
						region = sr:region_niger
						region = sr:region_congo
						region = sr:region_southern_africa
						region = sr:region_zanj		
					}
				}
				NOT = {
					any_scope_state = {
						owner = {
							country_is_in_africa = yes
							OR = {
								is_country_type = decentralized
								is_country_type = unrecognized
							}
							is_subject = no
						}
					}
				}
				percent >= 0.95
			}
		}
	}

	on_complete = {
		trigger_event = {
			id = africa_colonial_events.2
			days = 0
			popup = yes
		}
	}

	fail = {
		custom_tooltip = {
			text = scramble_for_africa_fail_tt
			NOT = {
				any_scope_state = {
					is_incorporated = no
					state_in_africa = yes
				}
			}
		}
	}

	#on_fail = {
	#	trigger_event = {
	#		id = africa_colonial_events.3
	#		days = 0
	#		popup = yes
	#	}
	#}

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = scramble_for_africa_6_states
				trigger = {
					any_scope_state = {
						count >= 6
						is_incorporated = no
						state_in_africa = yes
					}
				}
			}
			triggered_desc = {
				desc = scramble_for_africa_4_states
				trigger = {
					any_scope_state = {
						count >= 4
						is_incorporated = no
						state_in_africa = yes
					}
				}
			}
			triggered_desc = {
				desc = scramble_for_africa_3_states
				trigger = {
					any_scope_state = {
						count >= 1
						is_incorporated = no
						state_in_africa = yes
					}
				}
			}
			triggered_desc = {
				desc = scramble_for_africa_0_states
			}
		}
	}

	# No timeout. Imperialism never ends.
	# timeout = 7300

	on_timeout = {

	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = africa_colonial_events.4
			10 = africa_colonial_events.5
			10 = africa_colonial_events.6
			5 = africa_colonial_events.7
			10 = patagonia.2
			10 = amazon.2

			10 = africa_colonial_events.40
			10 = africa_colonial_events.41
			10 = africa_colonial_events.51
			10 = africa_colonial_events.53
			10 = africa_colonial_events.54
		}
	}

	weight = 200
	should_be_pinned_by_default = yes
}
