﻿#Events for Murder Scheme

namespace = murder_ongoing

############################################
#  ONGOING OPPORTUNITY EVENTS 3000 - 3999
############################################

#3001 - 3199 are events mainly triggered by agents
#3201 - 3299 are events mainly triggered by target
#3301 - 3399 are events mainly triggered by owner
#3401 - 3499 are events exclusive to children


#######################
# Drunkard Agent
# by Linnéa Thimrén and Petter Vilberg
#######################
murder_ongoing.3010 = {
	type = character_event
	title = murder_ongoing.3010.t
	desc = {
		desc = murder_ongoing.3010.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:agent_hero_of_the_moment
				}
				desc = murder_ongoing.3010.desc_hero
			}
			desc = murder_ongoing.3010.desc
		}
	}
	theme = murder_scheme
	left_portrait = {
		character = root
		animation = eyeroll
	}
	right_portrait = {
		character = scope:agent_in_question
		animation = wedding_drunk
	}
	lower_right_portrait = {
		character = scope:agent_hero_of_the_moment
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:scheme = {
			any_scheme_agent_character = { has_trait = drunkard }				
		}
		NOT = { exists = scope:scheme.var:had_drunkard_agent_event }
	}

	immediate = {
		scope:scheme = {
			random_scheme_agent_character = {
				limit = {
					has_trait = drunkard
					has_trait = wrathful
				}
				alternative_limit = {
					has_trait = drunkard
				}
				save_scope_as = agent_in_question
			}

			if = {
				limit = {
					scope:agent_in_question = {
						has_trait = wrathful
					}
					any_scheme_agent_character = { #A courtier of target that likes them well enough
						this != scope:agent_in_question
						is_courtier_of = scope:target
						reverse_opinion = {
							target = scope:target
							value >= 10
						}
					}
				}
				random_scheme_agent_character = {
					limit = {
						this != scope:agent_in_question
						is_courtier_of = scope:target
						reverse_opinion = {
							target = scope:target
							value >= 10
						}
					}
					save_scope_as = agent_hero_of_the_moment
					add_character_flag = {
						flag = use_stealth_clothes
						days = 1
					}
				}
			}

			set_variable = {
				name = had_drunkard_agent_event
				value = yes
				days = 730
			}
		}
	}

	# Encourage agents drunken escapades, gain plot power, risk exposing agent
	option = {
		name = murder_ongoing.3010.a
		scope:agent_in_question = {
			duel = {
				skill = intrigue
				value = 10
				20 = {		
					desc = murder_ongoing.3010.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
						min = -14
					}
					root = {
						send_interface_toast = {
							title = intrigue_scheme_ongoing.1008.a.success
							left_icon = scope:agent_in_question
							scope:scheme = {
								add_scheme_progress = scheme_progress_gain
							}
						}
					}
				}
				10 = {		
					desc = murder_ongoing.3010.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.5
						min = -14
					}
					root = {
						send_interface_toast = {
							title = intrigue_scheme_ongoing.1008.a.failure
							left_icon = scope:agent_in_question
							scope:scheme = {
								if = {
									limit = {
										is_scheme_exposed = no
									}
									expose_scheme = yes
								}
								expose_scheme_agent = scope:agent_in_question
							}
						}
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.75
			}
		}
	}

	# Stay away from the bottle, lay low and lose liking from agent
	option = {
		name = murder_ongoing.3010.b
		scope:agent_in_question = {
			add_opinion = {
				modifier = cruelty_opinion
				target = root
				opinion = -15
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.25
			}
		}
	}

	# Throw the agent under the bus to get big progress
	option = {
		name = murder_ongoing.3010.c
		trigger = {
			exists = scope:agent_hero_of_the_moment
		}
		scope:agent_in_question = {
			add_secret = {
				type = secret_murder_attempt
				target = scope:target
			}
			random_secret = {
				type = secret_murder_attempt
				limit = {
					secret_target = scope:target
				}
				expose_secret = scope:target
			}
		}
		scope:scheme.scheme_target_character = {			
			add_opinion = {
				modifier = hero_of_the_moment_opinion
				target = scope:agent_hero_of_the_moment
			}
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = scheme_hero_agent_modifier
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:agent_in_question
				multiplier = -1
			}
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}
}

###########################################
# Lose your knife
# by Linnéa Thimrén
###########################################

murder_ongoing.3301 = {
	type = character_event
	title = murder_ongoing.3301.t
	desc = murder_ongoing.3301.desc
	theme = murder_scheme
	left_portrait = {
		character = root
		animation = manic
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		is_available = yes
		age >= 14
		scope:scheme = {
			NOT = { has_variable = had_courtier_slander_event }
			scheme_type = murder #Only available for murder
		}
		has_trait_rank = {
			trait = intellect_bad
			rank > 0
		}
	}

	weight_multiplier = {
		base = 0.75
		modifier = {
			add = 0.5
			has_trait_rank = {
				trait = intellect_bad
				rank > 1
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_courtier_slander_event
				value = yes
				days = 3650
			}
		}
	}

	# Oh no!!
	option = {
		name = murder_ongoing.3301.a
		trait = intellect_bad_1
		trait = intellect_bad_2
		trait = intellect_bad_3
		scope:scheme = { add_scheme_progress = scheme_progress_loss }
	}
}

###########################################
# Apply poisonous herbs found while traveling
# by Filippa Gannholm Kirsten
###########################################

murder_ongoing.3302 = {
	type = character_event
	title = murder_ongoing.3302.t
	desc = murder_ongoing.3302.desc
	theme = murder_scheme
	left_portrait = {
		character = root
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:target
		animation = toast_goblet
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	trigger = {
		has_variable = poisonous_herbs
		scope:scheme ?= {
			scheme_type = murder #Only available for murder
			scheme_agent_charges < opportunity_cap_value
		}
	}
	weight_multiplier = {
		base = 0.75
		modifier = {
			has_trait = lifestyle_herbalist
			add = 0.5
		}
	}
	immediate = {
		var:poisonous_herbs = {
			save_scope_as = herb_location
		}
	}
	#Excellent
	option = {
		name = murder_ongoing.3302.a
		scope:scheme = { 
			change_opportunities = 2
			add_scheme_modifier = {
				type = scheme_poisonous_herbs_modifier
			}
		}
	}
	after = {
		remove_variable = poisonous_herbs
	}
}
