﻿je_positivist_movement = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"

	group = je_group_internal_affairs
	
	is_shown_when_inactive = {
		has_technology_researched = psychiatry
		has_global_variable = positivism_invented
		has_dlc_feature = rp1_content
	}

	scripted_progress_bar = positivist_progress_bar

	possible = {
		has_technology_researched = philosophical_pragmatism
		radical_fraction = {
			value >= 0.1
		}
		OR = {
			country_has_state_religion = rel:catholic
			has_law = law_type:law_state_atheism
		}
		custom_tooltip = {
			text = is_democratic_tt
			country_has_voting_franchise = yes
		}
	}

	immediate = {
		show_as_tooltip = {
			if = {
				limit = {
					NOT = {
						any_political_movement = {
							is_political_movement_type = movement_positivist
						}
					}
				}
				create_political_movement = { type = movement_positivist }
			}
		}
		trigger_event = { id = positivism.2 popup = yes }
		set_variable = positivism_happened
	}

	scripted_button = je_positivist_movement_embrace_positivism_button
	scripted_button = je_positivist_movement_suppress_positivism_button


	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = positivism_pulse.1
			10 = positivism_pulse.2
			10 = positivism_pulse.3
			10 = positivism_pulse.4
			10 = positivism_pulse.5
			10 = bp1_misc.3
		}
	}

	complete = {
		custom_tooltip = {
			text = positivism_at_100_tt
			scope:journal_entry = {
				"scripted_bar_progress(positivist_progress_bar)" > 100
			}
		}
	}

	on_complete = {
		set_variable = { name = positivism_progress_var value = "scripted_bar_progress(positivist_progress_bar)" days = 120 }
		custom_tooltip = positivism_effects_most_tt
		trigger_event = { id = positivism.3 popup = yes }
	}

	timeout = 3650

	on_timeout = {
		set_variable = { name = positivism_progress_var value = "scripted_bar_progress(positivist_progress_bar)" days = 120 }
		if = {
			limit = {
				scope:journal_entry = {
					"scripted_bar_progress(positivist_progress_bar)" >= 50
				}
			}
			custom_tooltip = {
				text = positivism_positive_epoch_tt
				trigger_event = { id = positivism.3 popup = yes }
			}
			if = {
				limit = {
					scope:journal_entry = {
						"scripted_bar_progress(positivist_progress_bar)" >= 85
					}
				}
				custom_tooltip = positivism_effects_most_tt
			}
			else_if = {
				limit = {
					scope:journal_entry = {
						"scripted_bar_progress(positivist_progress_bar)" >= 65
					}
				}
				custom_tooltip = positivism_effects_avg_tt
			}
			else = {
				custom_tooltip = positivism_effects_least_tt
			}
		}
		else = {
			custom_tooltip = {
				text = positivism_peculiar_cult_tt
				trigger_event = { id = positivism.4 popup = yes }
			}
			if = {
				limit = {
					scope:journal_entry = {
						"scripted_bar_progress(positivist_progress_bar)" >= 35
					}
				}
				custom_tooltip = positivism_effects_least_tt
			}
			else_if = {
				limit = {
					scope:journal_entry = {
						"scripted_bar_progress(positivist_progress_bar)" >= 15
					}
				}
				custom_tooltip = positivism_effects_avg_tt
			}
			else = {
				custom_tooltip = positivism_effects_most_tt
			}
		}
	}

	weight = 100

	should_be_pinned_by_default = yes
}
