﻿namespace = character_events

character_events.100 = {
	type = country_event
	hidden = yes
	immediate = {
		random_interest_group = {
			limit = {
				NOT = { has_variable = memento_mori }
				NOT = {
					any_scope_character = {
						is_ruler = yes
					}
				}
			}
			save_scope_as = memento_mori_ig
			leader = {
				save_scope_as = memento_mori_leader
			}
			set_variable = {
				name = memento_mori
				years = 5
			}
		}
		post_notification = ig_leader_memento_mori
		scope:memento_mori_leader = {
			kill_character = yes
		}
	}
}

character_events.1 = {
	type = character_event
	hidden = yes
	immediate = {
		remove_trait = wounded
	}
}


character_events.2 = { #Rich industrialist wants to build a university
	type = country_event
	placement = scope:university_state

	title = character_events.2.t
	desc = character_events.2.d
	flavor = character_events.2.f

	duration = 3

	gui_window = event_window_1char_tabloid

	left_icon = scope:university_benefactor

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/1Character_Banner"

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

	trigger = {
		has_technology_researched = academia
		ig:ig_industrialists = {
			is_marginal = no
		}
		any_scope_state = {
			is_incorporated = yes
			has_building = building_urban_center
			NOT = {
				has_building = building_university
			}
		}
	}

	immediate = {
		ig:ig_industrialists = {
			leader = { 
				save_scope_as = university_benefactor
			}
		}
		random_scope_state = {
			limit = {
				is_incorporated = yes
				has_building = building_urban_center
				NOT = {
					has_building = building_university
				}
			}
			save_scope_as = university_state
		}
	}

	option = {
		default_option = yes
		name = character_events.2.a
		scope:university_state = {
			create_building={
 				building="building_university"
 				level=1
 				reserves=1
 			}
		}
		scope:university_benefactor.interest_group = {
			add_modifier = {
				name = modifier_university_built
				months = normal_modifier_time
			}
		}
	}

	option = {
		name = character_events.2.b
		scope:university_benefactor.interest_group = {
			add_modifier = {
				name = modifier_blocked_building_university
				months = normal_modifier_time
			}
		}
	}
}

character_events.3 = { #The duel
	type = country_event
	placement = root

	title = character_events.3.t
	desc = character_events.3.d
	flavor = character_events.3.f

	duration = 3

	gui_window = event_window_2char

	left_icon = scope:duel_participant_1
	right_icon = scope:duel_participant_2

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/2Characters"

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

	trigger = {
		NOT = { has_variable = duels_banned }
		any_scope_character = {
			is_ruler = no
			NOT = {
				has_trait = cautious
			}
			age >= 18
			count >= 2
		}
	}

	immediate = {
		random_scope_character = {
			limit = {
				is_ruler = no
				NOT = {
					has_trait = cautious
				}
				age >= 18
			}
			save_scope_as = duel_participant_1
		}

		random_scope_character = {
			limit = {
				is_ruler = no
				NOT = { this = scope:duel_participant_1 }
				NOT = {
					has_trait = cautious
				}
				age >= 18
			}
			save_scope_as = duel_participant_2
		}
	}

	option = { #Duel
		default_option = yes

		name = character_events.3.a

		random_list = {
			50 = {
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 50
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 60
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 70
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = bandit
							}
						}
						add = 10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = wounded
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = beetle_ear
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = kidney_stones
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = shellshocked
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_role = general
							}
						}
						add = -5
					}
				}
				scope:duel_participant_1 = {
					kill_character = yes
				}
			}
			50 = {
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 50
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 60
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								age >= 70
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = bandit
							}
						}
						add = 10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = wounded
							}
						}
						add = -10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = beetle_ear
							}
						}
						add = -5
					}
				}

				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = kidney_stones
							}
						}
						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_trait = shellshocked
							}
						}

						add = -5
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_role = general
							}
						}
						add = 10
					}
				}
				modifier = {
					if = {
						limit = {
							scope:duel_participant_1 = {
								has_role = admiral
							}
						}
						add = 10
					}
				}
				scope:duel_participant_2 = {
					kill_character = yes
				}
			}
		}
	}

	option = { #Block this duel
		name = character_events.3.b
		scope:duel_participant_1 = {
			add_modifier = {
				name = tarnished_honor_modifier #popularity
				months = normal_modifier_time
			}
		}
		scope:duel_participant_2 = {
			add_modifier = {
				name = tarnished_honor_modifier #popularity
				months = normal_modifier_time
			}
		}
	}

	option = { #Ban duels
		name = character_events.3.c
		custom_tooltip = banned_duels_tt
		set_variable = duels_banned
		if = {
			limit = {
				ig:ig_landowners = {
					OR = {
						is_powerful = yes
						is_in_government = yes
					}
				}
			}
			ig:ig_landowners = {
				add_modifier = {
					name = angry_duels_banned
					months = normal_modifier_time
				}
			}
		}
		else = {
			ig:ig_armed_forces = {
				add_modifier = {
					name = angry_duels_banned
					months = normal_modifier_time
				}
			}
		}
		ig:ig_intelligentsia = {
			add_modifier = {
				name = happy_duels_banned
				months = normal_modifier_time
			}
		}
	}
}


character_events.4 = { #Devout leader sleeping with a nun
	type = country_event
	placement = root

	title = character_events.4.t
	desc = character_events.4.d
	flavor = character_events.4.f

	duration = 3

	gui_window = event_window_1char_tabloid

	left_icon = scope:devout_scandal

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/1Character_Banner"

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

	cooldown = { months = long_modifier_time }

	trigger = {
		any_scope_character = {
			has_role = politician
			age > 18
			interest_group = {
				is_marginal = no
				is_interest_group_type = ig_devout
			}
		}
	}

	immediate = {
		random_scope_character = {
			limit = {
				has_role = politician
				age > 18
				interest_group = {
					is_marginal = no
					is_interest_group_type = ig_devout

				}

			}
			save_scope_as = devout_scandal
		}
	}

	option = { #Steps down
		default_option = yes
		trigger = {
			ig:ig_devout = {
				is_in_government = yes
			}
		}
		name = character_events.4.a
		custom_tooltip = character_events.4.a.tt
		hidden_effect = {
			scope:devout_scandal = {
				kill_character = yes
			}
		}
	}

	option = {
		name = character_events.4.c
		trigger = {
			ig:ig_devout = {
				is_in_government = no
			}
		}
		scope:devout_scandal = {
			add_modifier = {
				name = modifier_devout_in_scandal
				months = normal_modifier_time
				multiplier = 2
			}
		}
	}

	option = { #Ignore it
		name = character_events.4.b
		scope:devout_scandal = {
			add_modifier = {
				name = modifier_devout_in_scandal
				months = normal_modifier_time
			}
		}
	}
}

character_events.5 = { #A statue made of the king
	type = country_event
	placement = scope:statue_state

	title = character_events.5.t
	desc = character_events.5.d
	flavor = character_events.5.f

	duration = 3

	gui_window = event_window_1char_tabloid

	left_icon = scope:statue_ruler

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/1Character_Banner"

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

	trigger = {
		OR = {
			has_law = law_type:law_monarchy
			has_law = law_type:law_legitimist_monarchy
			has_law = law_type:law_orleanist_monarchy
			has_law = law_type:law_bonapartist_monarchy
		}
		any_scope_state = {
			is_incorporated = yes
			has_building = building_urban_center
			NOT = { has_variable = ruler_statue_var }
		}
		NOT = { has_variable = ruler_statue_cooldown }
	}

	immediate = {
		ruler = {
			save_scope_as = statue_ruler
		}
		random_scope_state = {
			limit = {
				is_incorporated = yes
				has_building = building_urban_center
				NOT = { has_variable = ruler_statue_var }
			}
			save_scope_as = statue_state
		}
		set_variable = {
			name = ruler_statue_cooldown
			months = very_long_modifier_time #20 years
		}
	}

	option = { #Do it
		name = character_events.5.a
		add_modifier = {
			name = modifier_statue_of_ruler #prestige
			months = normal_modifier_time
		}
		scope:statue_state = {
			set_variable = {
				name = ruler_statue_var
				months = normal_modifier_time
			}
			add_radicals = {
  				value = small_radicals
  			}
  			set_variable = {
  				name = fireworks_variable 
  				value = yes
  				days = 5
  			}
		}
	}

	option = { #No
		default_option = yes
		name = character_events.5.b
		if = {
			limit = {
				has_law = law_type:law_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_disapprove_of_no_statue
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_legitimist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_legitimist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_disapprove_of_no_statue
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_orleanist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_orleanist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_disapprove_of_no_statue
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_bonapartist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_bonapartist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_disapprove_of_no_statue
					months = normal_modifier_time
				}
			}
		}
	}
}


character_events.6 = { #Statue torn down
	type = country_event
	placement = scope:statue_state

	title = character_events.6.t
	desc = character_events.6.d
	flavor = character_events.6.f

	duration = 3

	event_image = {
		video = "gfx/event_pictures/europenorthamerica_political_extremism.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/europenorthamerica/political_extremism"

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

	trigger = {
		NOT = {
			has_law = law_type:law_monarchy
			has_law = law_type:law_legitimist_monarchy
			has_law = law_type:law_orleanist_monarchy
			has_law = law_type:law_bonapartist_monarchy
		}
		any_scope_state = {
			has_variable = ruler_statue_var
		}
	}

	immediate = {
		random_scope_state = {
			limit = {
				has_variable = ruler_statue_var
			}
			save_scope_as = statue_state
		}
	}

	option = { #Do it
		name = character_events.6.a
		scope:statue_state = {
			remove_variable = ruler_statue_var
		}
		if = {
			limit = {
				has_law = law_type:law_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_monarchy
						value < neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_legitimist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_legitimist_monarchy
						value < neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_orleanist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_orleanist_monarchy
						value < neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_bonapartist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_bonapartist_monarchy
						value < neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_statue_removal
					months = normal_modifier_time
				}
			}
		}
	}

	option = { #No
		default_option = yes
		name = character_events.6.b
		if = {
			limit = {
				has_law = law_type:law_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_no_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_legitimist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_legitimist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_no_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_orleanist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_orleanist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_no_statue_removal
					months = normal_modifier_time
				}
			}
		}
		if = {
			limit = {
				has_law = law_type:law_bonapartist_monarchy
			}
			random_interest_group = {
				limit = {
					law_stance = {
						law = law_type:law_bonapartist_monarchy
						value > neutral
					}
				}
				add_modifier = {
					name = modifier_ig_approve_no_statue_removal
					months = normal_modifier_time
				}
			}
		}
	}
	
	option = { #we should just relocate it
		name = character_events.6.c
		trigger = {
			scope:statue_state = { NOT = { this = root.capital } }
			any_scope_state = {
				NOT = { has_variable = ruler_statue_var }
			}
		}
		scope:statue_state = {
			remove_variable = ruler_statue_var
			add_loyalists = {
				value = small_radicals
			}
		}
		capital = {
			set_variable = {
				name = ruler_statue_var
				months = normal_modifier_time
			}
			add_radicals = {
				value = small_radicals
			}
		}
	}
}
