﻿
namespace = house_arrest_ongoing

#0000 - 0999:	Ongoing events
#9000 - 9999:	Long term imprisonment events


##################
# 				 #
# ONGOING EVENTS #
#				 #
##################

#To be ambitious is terrible
house_arrest_ongoing.0001 = {
	type = character_event
	title = house_arrest_ongoing.0001.t
	desc = house_arrest_ongoing.0001.desc
	
	theme = prison
	left_portrait = {
		character = root
		animation = boredom
	}
	
	trigger = {
		has_trait = ambitious
		NOT = { has_character_flag = had_event_house_arrest_ongoing_0001 }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_house_arrest_ongoing_0001
			days = 1000
		}
		imprisoner = {
			save_scope_as = prison_holder
		}
	}

	option = { #You're an anxious mess
		name = house_arrest_ongoing.0001.a
		stress_impact = {
			ambitious = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = cynical
					has_trait = impatient
					has_trait = greedy
					has_trait = paranoid
				}
			}
		}
	}

	option = { #Try to keep it cool and plan for the future
		name = house_arrest_ongoing.0001.b
		trigger = {
			OR = {
				has_trait = calm
				has_trait = patient
			}
		}
		trait = calm
		trait = patient
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 50
				OR = {
					has_trait = calm
					has_trait = patient
					has_trait = diligent
				}
			}
		}
	}
}


#To be arrogant is terrible
house_arrest_ongoing.0002 = {
	type = character_event
	title = house_arrest_ongoing.0002.t
	desc = house_arrest_ongoing.0002.desc
	
	theme = prison
	left_portrait = {
		character = root
		animation = angry
	}
	right_portrait = {
		character = scope:prison_holder
		animation = dismissal
	}

	trigger = {
		has_trait = arrogant
		NOT = { has_character_flag = had_event_house_arrest_ongoing_0002 }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_house_arrest_ongoing_0002
			days = 1000
		}
		imprisoner = {
			save_scope_as = prison_holder
		}
	}

	option = { #I'm insulted!
		name = house_arrest_ongoing.0002.a
		stress_impact = {
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
		}
	}

	option = { #Keep my mind zen
		name = house_arrest_ongoing.0002.b
		trigger = {
			OR = {
				has_trait = calm
				has_trait = patient
			}
		}
		trait = calm
		trait = patient
		stress_impact = {
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

#Missing love ones
house_arrest_ongoing.0003 = {
	type = character_event
	title = house_arrest_ongoing.0003.t
	desc = {
		desc = house_arrest_ongoing.0003.desc_opening
		triggered_desc = {
			trigger = {
				exists = scope:friendly_prisoner
			}
			desc = house_arrest_ongoing.0003.desc_friendly_prisoner
		}
	}
	
	theme = prison
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:friendly_prisoner
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_house_arrest_ongoing_0003 }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_house_arrest_ongoing_0003
			days = 1000
		}
		imprisoner = {
			random_prisoner = {
				limit = {
					OR = {
						NOT = { this = root }
						root = { has_trait = lunatic }
					}
					is_ai = yes
					is_adult = yes
					is_in_prison_type = house_arrest
					is_close_family_or_spouse_of_root_trigger = no
					has_friendly_relationship_with_root_trigger = no
					OR = {
						opinion = {
							target = root
							value >= 10
						}
						AND = {
							opinion = {
								target = root
								value >= 0
							}
							number_of_personality_traits_in_common = {
								target = root
								value >= 2
							}
						}
					}
				}
				save_scope_as = friendly_prisoner
				if = {
					limit = {
						mgr_can_seduce = yes
						OR = {
							AND = {
								is_attracted_to_women = yes
								scope:friendly_prisoner = { is_female = yes }
							}
							AND = {
								is_attracted_to_men = yes
								scope:friendly_prisoner = { is_male = yes }
							}
						}
						OR = {
							opinion = {
								target = root
								value >= 30
							}
							AND = {
								opinion = {
									target = root
									value >= 15
								}
								number_of_personality_traits_in_common = {
									target = root
									value >= 2
								}
							}
						}
					}
					hidden_effect ={
						random_list = {
							80 = {
								modifier = {
									add = 50
									root = { has_trait = lustful }
								}
								root = {
									add_character_flag = {
										flag = lover
										days = 2
									}
								}
							}
							20 = {
								modifier = {
									add = 80
									root = { has_trait = chaste }
								}
							}
						}
					}
				}
				if = {
					limit = {
						root = {
							NOT = { has_character_flag = lover }
						}
						OR = {
							opinion = {
								target = root
								value >= 10
							}
							AND = {
								opinion = {
									target = root
									value >= 0
								}
								number_of_personality_traits_in_common = {
									target = root
									value >= 2
								}
							}
						}
					}
					root = {
						add_character_flag = {
							flag = friend
							days = 2
						}
					}
				}
			}
		}
	}

	option = { #All alone
		name = house_arrest_ongoing.0003.a
		trigger = {
			NOT = {
				OR ={
					has_character_flag = lover
					has_character_flag = friend
				}
			}
		}
		trait = shy
		if = {
			limit = {
				NOT = { has_trait = shy }
			}
			stress_impact = {
				base = minor_stress_gain
			}
		}
		else_if = {
			limit = {
				has_trait = shy
			}
			stress_impact = {
				base = medium_stress_gain
			}
		}
	}

	option = { #Gregarious helps you talk to people
		name = house_arrest_ongoing.0003.b
		trigger = {
			has_trait = gregarious
		}
		trait = gregarious
		stress_impact = {
			base = minor_stress_loss
		}
		
	}

	option = { #Gain fellow prison friend
		name = house_arrest_ongoing.0003.c
		trigger = {
			has_character_flag = friend
			NOT = { scope:friendly_prisoner = root }
		}
		if = {
			limit = {
				has_character_flag = friend
			}
			set_relation_friend = scope:friendly_prisoner
		}
	}

	option = { #Gain fellow prison lover
		name = house_arrest_ongoing.0003.d
		trigger = {
			has_character_flag = lover
			NOT = { scope:friendly_prisoner = root }
		}
		if = {
			limit = {
				has_character_flag = lover
			}
			set_relation_lover = scope:friendly_prisoner
		}
	}

	option = {
		name = house_arrest_ongoing.0003.e
		trait = lunatic_1
		trait = lunatic_genetic
		trigger = {
			exists = scope:friendly_prisoner
			scope:friendly_prisoner = root
		}
		stress_impact = {
			base = medium_stress_loss
		}
	}

	after = {
		remove_character_flag = lover
		remove_character_flag = friend
	}
}

#Friend at court helps you
house_arrest_ongoing.0004 = {
	type = character_event
	title = house_arrest_ongoing.0004.t
	desc = {
		random_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = desc1
				}
				desc = house_arrest_ongoing.0004.desc1
			}
			triggered_desc = {
				trigger = {
					has_character_flag = desc2
				}
				desc = house_arrest_ongoing.0004.desc2
			}
			triggered_desc = {
				trigger = {
					has_character_flag = desc3
				}
				desc = house_arrest_ongoing.0004.desc3
			}
			desc = house_arrest_ongoing.0004.desc4
		}
		desc = house_arrest_ongoing.0004.desc
	}
	
	theme = prison
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:friend_at_court
		animation = happiness
	}

	trigger = {
		NOT = { has_character_flag = had_event_house_arrest_ongoing_0004 }
		imprisoner = {
			any_courtier_or_guest = {
				is_available_healthy_ai_adult = yes
				has_relation_friend = root
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_house_arrest_ongoing_0004
			days = 1000
		}
		imprisoner = {
			random_courtier_or_guest = {
				limit = {
					is_available_healthy_ai_adult = yes
					has_relation_friend = root
				}
				save_scope_as = friend_at_court
			}
		}
		hidden_effect = {
			random_list = {
				25 = {
					modifier = {
						add = 50
						OR = {
							has_learning_lifestyle_trait_trigger = yes
							has_trait = diligent
						}
					}
					add_character_flag = {
						flag = desc1
						days = 2
					}
				}
				25 = {
					modifier = {
						add = 50
						has_trait = gluttonous
					}
					modifier = {
						add = -20
						has_trait = temperate
					}
					add_character_flag = {
						flag = desc2
						days = 2
					}
				}
				25 = {
					modifier = {
						add = 50
						has_trait = greedy
					}
					modifier = {
						add = -20
						OR = {
							has_trait = temperate
							has_trait = generous
						}
					}
					add_character_flag = {
						flag = desc3
						days = 2
					}
				}
			}
		}
	}

	option = {
		name = house_arrest_ongoing.0004.a
		add_opinion = {
			modifier = helped_me_in_time_of_need
			target = scope:friend_at_court
		}
		stress_impact = {
			base = medium_stress_loss
		}
	}
}


#Rival at court is a nuisance
house_arrest_ongoing.0005 = {
	type = character_event
	title = house_arrest_ongoing.0005.t
	desc = house_arrest_ongoing.0005.desc
	
	theme = prison
	left_portrait = {
		character = root
		animation = angry
	}
	right_portrait = {
		character = scope:rival_at_court
		animation = schadenfreude
	}

	trigger = {
		NOT = { has_character_flag = had_event_house_arrest_ongoing_0005 }
		imprisoner = {
			OR = {
				AND = {
					is_available_healthy_ai_adult = yes
					has_relation_rival = root
				}
				any_courtier_or_guest = {
					is_available_healthy_ai_adult = yes
					has_relation_rival = root
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_house_arrest_ongoing_0005
			days = 1000
		}

		imprisoner = {	
			if = {
				limit = {
					is_available_healthy_ai_adult = yes
					has_relation_rival = root
				}
				save_scope_as = rival_at_court
			}
			else = {
				random_courtier_or_guest = {
					limit = {
						is_available_healthy_ai_adult = yes
						has_relation_rival = root
					}
					save_scope_as = rival_at_court
				}
			}
		}
	}

	option = {
		name = house_arrest_ongoing.0005.a
		add_opinion = {
			modifier = mocked_me_in_time_of_need
			target = scope:rival_at_court
		}
		stress_impact = {
			base = medium_stress_gain
		}
	}
}