add_namespace = monuments_events

country_event = {
	id = monuments_events.1000
	title = monuments_events.EVTNAME1000
	desc = monuments_events.EVTDESC1000
	picture = GFX_report_event_generic_sign_treaty1

	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			var:monument_state_temp = {
				remove_monument_effects = yes
			}
		}
	}

	option = {
		name = monuments_events1000.EVTOPT1

		ai_chance = { factor = 100 }
	}
}

country_event = {
	id = monuments_events.0
	title = monuments_events.EVTNAME0
	desc = monuments_events.EVTDESC0
	picture = GFX_report_event_generic_sign_treaty1

	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			clr_country_flag = monuments_are_getting_downgraded_after_war
			clr_country_flag = monuments_got_downgraded_after_war
		}
	}

	option = {
		name = monuments_events0.EVTOPT1

		ai_chance = { factor = 100 }
	}
}

country_event = {
	id = monuments_events.1
	title = monuments_events.EVTNAME1
	desc = monuments_events.EVTDESC1
	picture = GFX_report_event_spain_civil_war_volunteers_01

	fire_only_once = yes

	trigger = {
		has_dlc = "La Resistance"
		tag = SPC
		has_civil_war = yes
		controls_province = 9764
		OR = {
			owns_state = 165
			165 = {
				OWNER = {
					original_tag = SPR
					has_war_with = ROOT
				}
			}
		}
		165 = {
			set_temp_variable = { monument_id = 79 }
			has_monument = yes
			set_temp_variable = { level = 1 }
			has_at_least_monument_level = yes
		}
	}

	mean_time_to_happen = {
		days = 5
	}

	option = {
		name = monuments_events1.EVTOPT1

		trigger = {
			165 = {
				set_temp_variable = { monument_id = 79 }
				set_temp_variable = { level = 2 }
				has_at_least_monument_level = yes
			}
		}

		ai_chance = {
			factor = 0.9
		}

		add_political_power = 50
		add_war_support = 0.05
		165 = {
			set_temp_variable = { monument_id = 79 }
			set_temp_variable = { level = 0 }
			set_monument_level = yes
		}
		hidden_effect = {
			random_country = {
				limit = {
					OR = {
						AND = {
							NOT = { scope_for_monument_bonus_receiver_is_controller = yes }
							owns_state = 165
						}
						AND = {
							scope_for_monument_bonus_receiver_is_controller = yes
							controls_state = 165
						}
					}
					is_ai = no
					NOT = { is_in_array = { monument_alert_popup_downgrade_array = monument_id } }
				}
				add_to_array = { monument_alert_popup_downgrade_array = monument_id }
				update_monument_alert_popup_window = yes
				scoped_sound_effect = "Resistance_Notifcation_Low_Resource_For_Laws"
			}
			every_other_country = {
				news_event = { id = monuments_events.10 hours = 3 }
			}
		}
	}

	option = {
		name = monuments_events1.EVTOPT2

		ai_chance = {
			factor = 0.9
			modifier = {
				factor = 0
				165 = {
					set_temp_variable = { monument_id = 79 }
					set_temp_variable = { level = 2 }
					has_at_least_monument_level = yes
				}
			}
		}

		add_political_power = 25
		add_war_support = 0.025
		165 = {
			set_temp_variable = { monument_id = 79 }
			downgrade_monument = yes
		}
		hidden_effect = {
			every_other_country = {
				news_event = { id = monuments_events.11 hours = 3 }
			}
		}
	}

	option = {
		name = monuments_events1.EVTOPT3

		ai_chance = {
			factor = 0.1
		}

		add_political_power = -10
	}
}

country_event = {
	id = monuments_events.2
	title = monuments_events.EVTNAME2
	desc = monuments_events.EVTDESC2
	picture = GFX_report_event_physics_lab_02

	is_triggered_only = yes

	trigger = {
		has_used_monument_upgrade_slot = yes
		NOT = { has_variable = random_monument_mission }
	}

	immediate = {
		hidden_effect = {
			random_list = {
				10 = {
					modifier = {
						factor = 0
						NOT = { has_active_mission = monument_construction_mission_1 }
					}
					set_variable = { random_monument_mission = 1 }
					var:monument_construction_state_1 = {
						save_event_target_as = monument_construction_state
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { has_active_mission = monument_construction_mission_2 }
					}
					set_variable = { random_monument_mission = 2 }
					var:monument_construction_state_2 = {
						save_event_target_as = monument_construction_state
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { has_active_mission = monument_construction_mission_3 }
					}
					set_variable = { random_monument_mission = 3 }
					var:monument_construction_state_3 = {
						save_event_target_as = monument_construction_state
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { has_active_mission = monument_construction_mission_4 }
					}
					set_variable = { random_monument_mission = 4 }
					var:monument_construction_state_4 = {
						save_event_target_as = monument_construction_state
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { has_active_mission = monument_construction_mission_5 }
					}
					set_variable = { random_monument_mission = 5 }
					var:monument_construction_state_5 = {
						save_event_target_as = monument_construction_state
					}
				}
			}
		}
	}

	option = {
		name = monuments_events2.EVTOPT1

		if = {
			limit = {
				check_variable = { random_monument_mission = 1 }
				has_active_mission = monument_construction_mission_1
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_1
				days = -5
			}
		}
		else_if = {
			limit = {
				check_variable = { random_monument_mission = 2 }
				has_active_mission = monument_construction_mission_2
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_2
				days = -5
			}
		}
		else_if = {
			limit = {
				check_variable = { random_monument_mission = 3 }
				has_active_mission = monument_construction_mission_3
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_3
				days = -5
			}
		}
		else_if = {
			limit = {
				check_variable = { random_monument_mission = 4 }
				has_active_mission = monument_construction_mission_4
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_4
				days = -5
			}
		}
		else_if = {
			limit = {
				check_variable = { random_monument_mission = 5 }
				has_active_mission = monument_construction_mission_5
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_5
				days = -5
			}
		}
		hidden_effect = {
			clear_variable = random_monument_mission
		}
	}
}

country_event = {
	id = monuments_events.3
	title = monuments_events.EVTNAME3
	desc = monuments_events.EVTDESC3
	picture = GFX_report_event_generic_sign_treaty1

	is_triggered_only = yes

	trigger = {
		NOT = { has_idea = generic_monument_cost_reduction_idea }
		OR = {
			is_ai = no
			NOT = { has_global_flag = monuments_game_rule_no_pp_cost_ai }
		}
		any_controlled_state = {
			OR = {
				is_owned_by = ROOT
				scope_for_monument_bonus_receiver_is_controller = yes
			}
			state_has_any_monument = yes
			has_no_monument_construction = yes
			any_of = {
				array = state_monuments_array
				set_temp_variable = { monument_id = v }
				set_temp_variable = { level = 3 }
				has_less_monument_level = yes
				can_use_monument_bonuses = yes
			}
		}
	}

	option = {
		name = monuments_events3.EVTOPT1

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
		}

		add_political_power = -20
		add_timed_idea = {
			idea = generic_monument_cost_reduction_idea
			days = 100
		}
	}

	option = {
		name = monuments_events3.EVTOPT2

		ai_chance = {
			factor = 0.25
		}
	}
}

country_event = {
	id = monuments_events.4
	title = monuments_events.EVTNAME4
	desc = monuments_events.EVTDESC4
	picture = GFX_report_event_generic_sign_treaty2

	is_triggered_only = yes

	trigger = {
		OR = {
			is_ai = no
			NOT = { has_global_flag = monuments_game_rule_no_pp_cost_ai }
		}
		any_controlled_state = {
			OR = {
				is_owned_by = ROOT
				scope_for_monument_bonus_receiver_is_controller = yes
			}
			state_has_any_monument = yes
			has_no_monument_construction = yes
			NOT = { has_dynamic_modifier = { modifier = generic_monument_cost_reduction_modifier } }
			any_of = {
				array = state_monuments_array
				set_temp_variable = { monument_id = v }
				set_temp_variable = { level = 3 }
				has_less_monument_level = yes
				can_use_monument_bonuses = yes
			}
		}
	}

	immediate = {
		hidden_effect = {
			random_controlled_state = {
				limit = {
					OR = {
						is_owned_by = ROOT
						scope_for_monument_bonus_receiver_is_controller = yes
					}
					state_has_any_monument = yes
					has_no_monument_construction = yes
					NOT = { has_dynamic_modifier = { modifier = generic_monument_cost_reduction_modifier } }
					any_of = {
						array = state_monuments_array
						set_temp_variable = { monument_id = v }
						set_temp_variable = { level = 3 }
						has_less_monument_level = yes
						can_use_monument_bonuses = yes
					}
				}
				save_event_target_as = monument_reduction_state
			}
		}
	}

	option = {
		name = monuments_events3.EVTOPT1

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
		}

		add_political_power = -20
		event_target:monument_reduction_state = {
			custom_effect_tooltip = MONUMENTS_REGIONAL_EFFORTS_TT
			hidden_effect = {
				add_dynamic_modifier = {
					modifier = generic_monument_cost_reduction_modifier
					days = 50
				}
			}
		}
	}

	option = {
		name = monuments_events3.EVTOPT2

		ai_chance = {
			factor = 0.25
		}
	}
}

country_event = {
	id = monuments_events.5
	title = monuments_events.EVTNAME5
	desc = monuments_events.EVTDESC5
	picture = GFX_report_event_generic_strike

	is_triggered_only = yes

	trigger = {
		has_active_mission = monument_construction_mission_1
	}

	immediate = {
		hidden_effect = {
			var:monument_construction_state_1 = {
				save_event_target_as = monument_construction_state
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT1

		ai_chance = {
			factor = 0.25
		}

		if = {
			limit = {
				has_active_mission = monument_construction_mission_1
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_1
				days = 10
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT2

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}

		add_political_power = -10
	}
}

country_event = {
	id = monuments_events.6
	title = monuments_events.EVTNAME5
	desc = monuments_events.EVTDESC5
	picture = GFX_report_event_generic_strike

	is_triggered_only = yes

	trigger = {
		has_active_mission = monument_construction_mission_2
	}

	immediate = {
		hidden_effect = {
			var:monument_construction_state_2 = {
				save_event_target_as = monument_construction_state
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT1

		ai_chance = {
			factor = 0.25
		}

		if = {
			limit = {
				has_active_mission = monument_construction_mission_2
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_2
				days = 10
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT2

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}

		add_political_power = -10
	}
}

country_event = {
	id = monuments_events.7
	title = monuments_events.EVTNAME5
	desc = monuments_events.EVTDESC5
	picture = GFX_report_event_generic_strike

	is_triggered_only = yes

	trigger = {
		has_active_mission = monument_construction_mission_3
	}

	immediate = {
		hidden_effect = {
			var:monument_construction_state_3 = {
				save_event_target_as = monument_construction_state
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT1

		ai_chance = {
			factor = 0.25
		}

		if = {
			limit = {
				has_active_mission = monument_construction_mission_3
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_3
				days = 10
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT2

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}

		add_political_power = -10
	}
}

country_event = {
	id = monuments_events.8
	title = monuments_events.EVTNAME5
	desc = monuments_events.EVTDESC5
	picture = GFX_report_event_generic_strike

	is_triggered_only = yes

	trigger = {
		has_active_mission = monument_construction_mission_4
	}

	immediate = {
		hidden_effect = {
			var:monument_construction_state_4 = {
				save_event_target_as = monument_construction_state
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT1

		ai_chance = {
			factor = 0.25
		}

		if = {
			limit = {
				has_active_mission = monument_construction_mission_4
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_4
				days = 10
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT2

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}

		add_political_power = -10
	}
}

country_event = {
	id = monuments_events.9
	title = monuments_events.EVTNAME5
	desc = monuments_events.EVTDESC5
	picture = GFX_report_event_generic_strike

	is_triggered_only = yes

	trigger = {
		has_active_mission = monument_construction_mission_5
	}

	immediate = {
		hidden_effect = {
			var:monument_construction_state_5 = {
				save_event_target_as = monument_construction_state
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT1

		ai_chance = {
			factor = 0.25
		}

		if = {
			limit = {
				has_active_mission = monument_construction_mission_5
			}
			add_days_mission_timeout = {
				mission = monument_construction_mission_5
				days = 10
			}
		}
	}

	option = {
		name = monuments_events5.EVTOPT2

		ai_chance = {
			factor = 0.75
			modifier = {
				factor = 0
				NOT = { AI_has_required_amount_of_PP_for_monuments = yes }
			}
			modifier = {
				factor = 0
				has_political_power < 50
			}
		}

		add_political_power = -10
	}
}

news_event = {
	id = monuments_events.10
	title = monuments_events.EVTNAME10
	desc = monuments_events.EVTDESC10
	picture = GFX_news_event_spr_spanish_civil_war3

	is_triggered_only = yes

	option = {
		name = monuments_events10.EVTOPT1

		trigger = {
			NOT = { monument_ideology_trigger_communism = yes }
		}
	}

	option = {
		name = monuments_events10.EVTOPT2

		trigger = {
			monument_ideology_trigger_communism = yes
		}
	}
}

news_event = {
	id = monuments_events.11
	title = monuments_events.EVTNAME11
	desc = monuments_events.EVTDESC11
	picture = GFX_news_event_spr_spanish_civil_war3

	is_triggered_only = yes

	option = {
		name = monuments_events11.EVTOPT1

		trigger = {
			NOT = { monument_ideology_trigger_communism = yes }
		}
	}

	option = {
		name = monuments_events11.EVTOPT2

		trigger = {
			monument_ideology_trigger_communism = yes
		}
	}
}

country_event = {
	id = monuments_events.12
	title = monuments_events.EVTNAME12
	desc = monuments_events.EVTDESC12
	picture = GFX_report_event_gre_athens

	is_triggered_only = yes

	trigger = {
		NOT = { has_country_flag = got_free_monument_upgrade_via_event }
		has_war = no
		has_stability > 0.8
		date > 1938.1.1
		any_owned_state = {
			is_fully_controlled_by = ROOT
			state_has_any_monument = yes
			has_no_monument_construction = yes
			any_of = {
				array = state_monuments_array
				set_temp_variable = { monument_id = v }
				set_temp_variable = { level = 1 }
				has_at_least_monument_level = yes
				set_temp_variable = { level = 3 }
				has_less_monument_level = yes
				can_use_monument_bonuses = yes
			}
		}
	}

	immediate = {
		hidden_effect = {
			set_country_flag = got_free_monument_upgrade_via_event
			random_owned_state = {
				limit = {
					is_fully_controlled_by = ROOT
					state_has_any_monument = yes
					has_no_monument_construction = yes
					any_of = {
						array = state_monuments_array
						set_temp_variable = { monument_id = v }
						set_temp_variable = { level = 1 }
						has_at_least_monument_level = yes
						set_temp_variable = { level = 3 }
						has_less_monument_level = yes
						can_use_monument_bonuses = yes
					}
				}
				save_event_target_as = state_target
				set_temp_variable = { max_random_value = state_monuments_array^num }
				subtract_from_temp_variable = { max_random_value = 1 }
				set_temp_variable_to_random = {
					var = monument_id_temp
					min = 0
					max = max_random_value
					integer = yes
				}
				clamp_temp_variable = {
					var = monument_id_temp
					min = 0
					max = max_random_value
				}
				set_variable = { random_monument_id = state_monuments_array^monument_id_temp }
			}
		}
	}

	option = {
		name = monuments_events12.EVTOPT1

		event_target:state_target = {
			set_temp_variable = { monument_id = random_monument_id }
			if = {
				limit = {
					check_variable = { monument_id > 0 }
				}
				upgrade_monument = yes
			}
			clear_variable = random_monument_id
		}
	}
}