﻿#Events handling Steal Back Artifact ongoing

namespace = steal_back_artifact_ongoing

######################
#
#	FREE-STANDING EVENTS
#	1000-4999
######################


# Bribing the antiquarian to purposefully lower security
	#by Bianca Savazzi

scripted_effect steal_back_artifact_ongoing_1001_effect = {
	random_list = {
		1 = {
			#Lustful characters likes beautiful people
			modifier = {
				add = 20
				scope:antiquarian = { has_trait = lustful }
				has_character_flag = chose_beauty_option_1001
			}
			# The random beauty's attractiveness makes the antiquarian more likely to agree
			modifier = {
				add = {
					value = scope:random_beauty.attraction 
				}
				has_character_flag = chose_beauty_option_1001
			}

			# Greedy characters far more likely to accept any bribe
			modifier = {
				add = {
					value = ai_greed
					if = {
						limit = {
							ai_greed > 0
						}
						multiply = 0.5
					}
				}
			}
			# Bonus for greedy characters recieving gold
			modifier = {
				add = 20
				scope:antiquarian = { has_trait = greedy }
				has_character_flag = chose_gold_option_1001
			}
							
			send_interface_toast = {
				title = steal_back_artifact_ongoing_notification.1001.success
				left_icon = scope:antiquarian
				scope:antiquarian = {
					add_opinion = {
						target = root
						modifier = gift_opinion
						opinion = 20
					}
				}
				scope:scheme = {
					add_scheme_progress = scheme_progress_gain
				}
			}	
		}
		1 = {
			# Honorful characters are less likely to accept bribes
			modifier = {
				add = {
					value = ai_honor
					if = {
						limit = {
							ai_honor > 0
						}
						multiply = 0.5
					}
				}
			}
			send_interface_toast = {
				title = steal_back_artifact_ongoing_notification.1001.failure
				left_icon = scope:antiquarian
				scope:antiquarian = {
					add_opinion = {
						target = root
						modifier = tried_to_bribe_opinion
						opinion = -25
					}
				}
				scope:scheme = {
					add_scheme_modifier = {
						type = scheme_modifier_failed_bribery
						years = 5
					}
				}
			}
		}
	}
	#Flag cleanup
	remove_character_flag = chose_gold_option_1001
	remove_character_flag = chose_beauty_option_1001
}


steal_back_artifact_ongoing.1001 = {
	type = character_event
	title = steal_back_artifact_ongoing.1001.t
	desc = steal_back_artifact_ongoing.1001.desc
	theme = generic_intrigue_scheme
	left_portrait = scope:antiquarian
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		exists = scope:scheme 
		scope:scheme = {
			NOT = { has_variable = had_event_steal_back_artifact_ongoing_1001 }
		}
		scope:target = {
			employs_court_position = antiquarian_court_position
			any_court_position_holder = {
		        type = antiquarian_court_position
				is_available_healthy_ai_adult = yes
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_steal_back_artifact_ongoing_1001
				value = yes
				days = 3650
			}
		}
		scope:target = {
			random_court_position_holder = {
				type = antiquarian_court_position
				limit = { is_available_ai_adult = yes }
				save_scope_as = antiquarian
			}
		}

		# Saving the scope of a random artifact for option B 
		if = {
			limit = {
				any_character_artifact = {
					ep1_artifact_durability_higher_equal_percent_trigger = { PERCENT = 0.51 } #don't give something that's too crummy
					artifact_can_be_gift_to_trigger = { RECIPIENT = scope:antiquarian }
				}
			}
			random_character_artifact = {
				limit = {
					ep1_artifact_durability_higher_equal_percent_trigger = { PERCENT = 0.51 }
					artifact_can_be_gift_to_trigger = { RECIPIENT = scope:antiquarian }
				}
				save_scope_as = artifact_to_trade
			}
		}

		# Saving the scope of a random beauty for option C 
		if = {
			limit = {
				scope:scheme = { 
					any_scheme_agent_character = {
						is_ai = yes
						has_trait = beauty_good
						scope:antiquarian = { is_attracted_to_gender_of = prev }
					}
				}
			}
			scope:scheme = { 
				random_scheme_agent_character = {
					limit = {
						is_adult = yes
						has_trait = beauty_good
						scope:antiquarian = { is_attracted_to_gender_of = prev }
					}
					save_scope_as = random_beauty
				}
			}
		}
		else_if = { # courtier back-up to make the option more often available 
			limit = {
				any_courtier = {
					is_ai = yes
					has_trait = beauty_good
					scope:antiquarian = { is_attracted_to_gender_of = prev }
				}
			}
			random_courtier = {
				limit = {
					is_adult = yes
					has_trait = beauty_good
					scope:antiquarian = { is_attracted_to_gender_of = prev }
				}
				save_scope_as = random_beauty
			}
		}
	}

	option = { #Gold
		name = steal_back_artifact_ongoing.1001.a
		custom_tooltip = steal_back_artifact_ongoing.1001.a.tt
		remove_short_term_gold = medium_gold_value

		stress_impact = {
			greedy = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -45
				has_trait = greedy
			}
		}
		hidden_effect = {
			add_character_flag = {
				flag = chose_gold_option_1001
			}
			steal_back_artifact_ongoing_1001_effect = yes
		}
	}

	option = { #artifact
		name = steal_back_artifact_ongoing.1001.b
		trigger = {
			exists = scope:artifact_to_trade
		}
		custom_tooltip = steal_back_artifact_ongoing.1001.b.tt

		scope:artifact_to_trade = { 
			set_owner = scope:antiquarian
		}

		send_interface_toast = {
			title = steal_back_artifact_ongoing_notification.1001.success
			left_icon = scope:antiquarian
			scope:antiquarian = {
				add_opinion = {
					target = root
					modifier = gift_opinion
					opinion = 20
				}
			}
			scope:scheme = {
				add_scheme_progress = scheme_progress_gain
			}
		}

		ai_chance = {
			base = 10
			modifier = {
				add = 100
				has_trait = just
			}
		}
	}

	option = { #beautiful person
		name = steal_back_artifact_ongoing.1001.c
		trigger = {
			exists = scope:random_beauty
		}
		custom_tooltip = steal_back_artifact_ongoing.1001.c.tt

		ai_chance = {
			base = 0
			modifier = {
				add = 50
				scope:target = { has_trait = lustful }
			}
		}

		# Random beauty's reaction to being thrust into seducing the target
		if = {
			limit = {
				scope:random_beauty = {
					OR = {
						has_trait = seducer 
						has_trait = lustful
						scope:antiquarian.attraction >= medium_positive_attraction 
					}
					is_attracted_to_gender_of = scope:antiquarian 
				}
			}
			# Minor penalty, like a "ugh" reaction from someone used to seduce people or that the target is attractive
			scope:random_beauty = {
				add_opinion = {
					modifier = annoyed_opinion
					target = root
					opinion = -10
				}
			}
		}
		else = {
			# Penalty for not finding the target attractive and not being the type to seduce on command
			scope:random_beauty = {
				add_opinion = {
					modifier = disgusted_opinion
					target = root
					opinion = -30
				}
				# Grossed out and leaves your court if courtier
				if = {
					limit = {
						is_courtier_of = root
						is_landed = no
						scope:scheme = { #Unop: You need to be in the scheme to call scheme_is_character_agent
							NOT = { scheme_is_character_agent = prev }
						}
					}
					select_and_move_to_pool_effect = yes
				}
			}
		}

		#Scheme might be revealed as a consequence
		if = {
			limit = {
				scope:scheme = { 
					root = { 
						NOT = { is_agent_exposed_in_scheme = scope:scheme } 
					} 
				}
			}
			random_list = {
				1 = {
					# Scheme owner is exposed
					scope:scheme = {
						expose_scheme_agent = root
					}
				}
				1 = {
					# Agent is exposed (only if not already exposed)
					trigger = {
						scope:scheme = { 
							NOT = { scheme_is_character_agent = scope:random_beauty }
							scope:random_beauty = { 
								NOT = { is_agent_exposed_in_scheme = scope:scheme } 
							}
						}
					}
					scope:scheme = {
						expose_scheme_agent = scope:random_beauty
					}
				}
				1 = {
					# Nothing happens (based on the intrigue of the agent)
					modifier = {
						add = {
							value = scope:random_beauty.intrigue
							multiply = 5 # High since its an AI character that the player have most likely not invested in 
						}
					}
				}
			}
		}

		hidden_effect = {
			add_character_flag = {
				flag = chose_beauty_option_1001
			}
			steal_back_artifact_ongoing_1001_effect = yes
		}
	}

	option = { #do nothing
		name = steal_back_artifact_ongoing.1001.d
		
		ai_chance = {
			base = 10
		}
	}
}

#steal_back_artifact_ongoing.1002 = {
#	type = character_event
#	title = steal_back_artifact_ongoing.1002.t
#	desc = steal_back_artifact_ongoing.1002.desc
#	theme = generic_intrigue_scheme
#
#	left_portrait = scope:agent
#	
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		exists = scope:scheme 
#		scope:scheme = {
#			NOT = { has_variable = had_event_steal_back_artifact_ongoing_1002 }
#
#			any_scheme_agent_character = { 
#				count > 0
#			}
#		}
#	}
#
#	immediate = {
#		scope:scheme = {
#			set_variable = {	
#				name = had_event_steal_back_artifact_ongoing_1002
#				value = yes
#				days = 3650
#			}
#			random_scheme_agent_character = { 
#			# Opinion outcome has a higher impact if the agent picked is of interest
#				weight = {
#					base = 1
#					modifier = {
#						add = 10
#						is_of_major_interest_to_root_trigger = yes
#					}
#					modifier = {
#						add = 5
#						is_of_minor_interest_to_root_trigger = yes
#					}
#				}
#				save_scope_as = agent
#			}
#		}
#	}
#
#	option = { # micromanage
#		name = steal_back_artifact_ongoing.1002.a
#		scope:agent = {
#			add_opinion = { 
#				modifier = annoyed_opinion
#				target = root
#				opinion = -30
#			}
#		}
#		add_character_modifier = {
#			modifier = micromanaging_modifier
#			years = 5
#		}
#		scope:scheme = {
#			add_scheme_progress = scheme_progress_gain
#		}
#		stress_impact = {
#			lazy = major_stress_impact_gain
#		}
#		ai_chance = {
#			base = 5
#			modifier = {
#				add = 45
#				OR = {
#					has_trait = ambitious
#					has_trait = diligent
#				}
#			}
#		}
#	}
#
#	option = { #Do nothing
#		name = steal_back_artifact_ongoing.1002.b
#
#		scope:agent = {
#			add_opinion = {
#				modifier = trust_opinion
#				target = root
#				opinion = 15
#			}
#		}
#
#		ai_chance = {
#			base = 5
#			modifier = {
#				add = 45
#				has_trait = lazy
#			}
#		}
#	}
#}
