﻿namespace = fp3_clan

########EVENT INDEX############
#fp3_clan.8015 - Scandalous Scion
#fp3_clan.8016 - Hammam Havoc
#fp3_clan_8017 - A Questionable Position
####################

###################################
# Scandalous Scion
# By Ola Jentzsch
###################################
scripted_trigger fp3_scandalous_scion_trigger = {
	NOT = { liege ?= root }
	is_available_ai_adult = yes
	is_landed = no
	age < 45
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
	ai_sociability > low_negative_ai_value
	ai_compassion < low_positive_ai_value
	NOR = {
		is_child_of = root
		this = root
	}
	any_parent = {
		is_available_ai_adult = yes
		NOT = { is_close_family_of = root }
	}
}

fp3_clan.8015 = {
	type = character_event
	title = fp3_clan.8015.t
	desc = fp3_clan.8015.desc

	theme = martial

	left_portrait = {
		character = scope:scandalous_scion
		animation = dismissal
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = craven
					has_trait = shy
					ai_boldness <= low_positive_ai_value
				}
			}
			animation = shame
		}
		outfit_tags = {
			military_outfit
		}
	}
	right_portrait = {
		character = scope:concerned_parent
		animation = stress
	}
	lower_left_portrait = root

	override_background = { reference = throne_room }

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed = yes
		government_has_flag = government_is_clan
		is_available_adult = yes
		is_house_head = yes

		#culture = { has_cultural_tradition = tradition_futuwaa }

		house = {
			any_house_member = {
				fp3_scandalous_scion_trigger = yes
			}
		}
	}

	cooldown = { years = 10 }

	immediate = {
		house = {
			random_house_member = {
				limit = {
					fp3_scandalous_scion_trigger = yes
				}
				save_scope_as = scandalous_scion
				random_parent = {
					limit = {
						is_available_ai_adult = yes
						NOT = { is_close_family_of = root }
					}
					save_scope_as = concerned_parent
				}
			}
		}
	}

	option = {
		name = fp3_clan.8015.a

		add_courtier = scope:scandalous_scion

		scope:scandalous_scion = {
			add_character_modifier = {
				modifier = fp3_better_company_modifier
				years = 10
			}
		}

		scope:concerned_parent = {
			add_opinion = {
				target = root
				opinion = 25
				modifier = fp3_grateful_for_discretion_opinion
			}
		}

		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:scandalous_scion
			VALUE = minor_unity_gain
			DESC = clan_unity_scandalous_scion_desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		stress_impact = {
			paranoid = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_greed = -0.5
				ai_sociability = 1
			}
		}
	}

	option = {
		name = fp3_clan.8015.b

		scope:concerned_parent = {
			add_opinion = {
				target = root
				opinion = -20
				modifier = disappointed_opinion
			}
		}

		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:scandalous_scion
			VALUE = minor_unity_loss
			DESC = clan_unity_scandalous_scion_ignored_problem_desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		stress_impact = {
			generous = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_greed = -0.5
				ai_sociability = -1
			}
		}
	}
}

###################################
# Hammam Havoc
# By Ola Jentzsch
###################################
scripted_trigger fp3_scandalous_traits_trigger = {
	OR = {
		has_trait = deviant
		has_trait = drunkard
		has_trait = rakish
		has_trait = hashishiyah
	}
}

scripted_trigger fp3_suitable_for_islamic_bathhouse_events_trigger = {
	OR = { #checking for adherence to Islamic / Zoroastrian gender norms
		AND = {
			root = { is_male = yes }
			is_male = yes
		}
		AND = {
			root = { is_female = yes }
			is_female = yes
		}
	}
}

fp3_clan.8016 = {
	type = character_event
	title = fp3_clan.8016.t
	desc = {
		desc = fp3_clan.8016.opening_desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:scandalous_clan_member = {
						has_trait = deviant
					}
				}
				desc = fp3_clan.8016.deviant_desc
			}
			triggered_desc = {
				trigger = {
					scope:scandalous_clan_member = {
						has_trait = drunkard
					}
				}
				desc = fp3_clan.8016.drunkard_desc
			}
			triggered_desc = {
				trigger = {
					scope:scandalous_clan_member = {
						has_trait = rakish
					}
				}
				desc =  fp3_clan.8016.rakish_desc
			}
			triggered_desc = {
				trigger = {
					scope:scandalous_clan_member = {
						has_trait = hashishiyah
					}
				}
				desc =  fp3_clan.8016.hashishiyah_desc
			}
		}
		desc = fp3_clan.8016.ending_desc
	}

	theme = faith

	left_portrait = {
		character = root
		animation = disbelief
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = craven
					has_trait = shy
					has_trait = paranoid
					stress > medium_stress
				}
			}
			animation = worry
		}
	}
	right_portrait = {
		character = scope:chaplain
		animation = eyeroll
	}
	lower_left_portrait = scope:scandalous_clan_member

	override_background = { reference = bath_house }
	override_effect_2d = {
		reference = smoke
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		is_available_adult = yes
		is_dynast = yes
		government_has_flag = government_is_clan

		faith = {
			OR = {
				has_doctrine_parameter = deviancy_illegal
				has_doctrine_parameter = deviancy_shunned
			}
		}

		house = {
			any_house_unity_member = {
				this != root
				is_available_ai_adult = yes
				fp3_scandalous_traits_trigger = yes
				fp3_suitable_for_islamic_bathhouse_events_trigger = yes
			}
		}

		exists = cp:councillor_court_chaplain
		cp:councillor_court_chaplain = {
			is_available_healthy_ai_adult = yes
			fp3_scandalous_traits_trigger = no
			fp3_suitable_for_islamic_bathhouse_events_trigger = yes
		}
	}

	cooldown = { years = 10 }

	immediate = {
		house = {
			random_house_unity_member = {
				limit = {
					this != root
					is_available_ai_adult = yes
					fp3_scandalous_traits_trigger = yes
					fp3_suitable_for_islamic_bathhouse_events_trigger = yes
				}
				save_scope_as = scandalous_clan_member
			}
		}

		cp:councillor_court_chaplain = { save_scope_as = chaplain }

		hidden_effect = {
			scope:scandalous_clan_member = {
				set_location = { location = root.location }
			}
		}
		add_character_flag = is_naked
		scope:chaplain = {
			add_character_flag = is_naked
		}
	}

	option = {
		name = fp3_clan.8016.a

		add_piety = medium_piety_gain

		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:scandalous_clan_member
			VALUE = minor_unity_loss
			DESC = clan_unity_denouncement.desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		scope:scandalous_clan_member = {
			denounce_effect = { ACTOR = root RECIPIENT = scope:scandalous_clan_member }
		}

		scope:chaplain = {
			add_opinion = {
				target = root
				opinion = 20
				modifier = pleased_opinion
			}
		}

		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -0.9
				ai_vengefulness = 0.5
				ai_zeal = 1
			}
		}
	}

	option = {
		name = fp3_clan.8016.b

		scope:chaplain = {
			add_opinion = {
				target = root
				opinion = -20
				modifier = disappointed_opinion
			}
		}

		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:scandalous_clan_member
			VALUE = minor_unity_gain
			DESC = clan_unity_denouncement_refusal.desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		stress_impact = {
			zealous = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = -0.5
				ai_rationality = 0.8
				ai_sociability = 0.5
			}
		}
	}
	after = {
		remove_character_flag = is_naked
		scope:chaplain = {
			remove_character_flag = is_naked
		}
	}
}

###################################
# A Questionable Position
# By Ola Jentzsch
###################################
#Tax collector acting as muhtasib
fp3_clan.8017 = {
	type = character_event
	title = fp3_clan.8017.t

	desc = {
		desc = fp3_clan.8017.opening_desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:tax_collector = {
						OR = {
							has_trait = diligent
							has_trait = zealous
							has_trait = chaste
							has_trait = just
							has_trait = ambitious
							ai_zeal >= medium_positive_ai_value
						}
					}
				}
				desc = fp3_clan.8017.overly_eager.desc
			}
			triggered_desc = {
				trigger = {
					scope:tax_collector = {
						OR = {
							has_trait = drunkard
							has_trait = greedy
							has_trait = deceitful
							has_trait = arbitrary
							AND = {
								ai_greed >= medium_positive_ai_value
								ai_honor < low_positive_ai_value
							}
						}
					}
				}
				desc = fp3_clan.8017.corrupt.desc
			}
			triggered_desc = {
				trigger = {
					scope:tax_collector = {
						NOT = { ai_compassion >= low_positive_ai_value  }
						OR = {
							has_trait = sadistic
							has_trait = wrathful
							has_trait = callous
							ai_vengefulness >= medium_positive_ai_value
						}
					}
				}
				desc = fp3_clan.8017.cruel.desc
			}
			desc = fp3_clan.8017.generic.desc
		}
		desc = fp3_clan.8017.ending.desc
	}

	theme = realm

	left_portrait = {
		character = root
		animation = disapproval
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = generous
					has_trait = compassionate
					stress > low_stress
				}
			}
			animation = worry
		}
	}
	right_portrait = {
		character = scope:unclan_taxpayer
		animation = stress
	}
	lower_left_portrait = scope:tax_collector

	trigger = {

		has_fp3_dlc_trigger = yes
		is_available_adult = yes
		government_has_flag = government_is_clan

		has_religion = religion:islam_religion

		any_tax_collector = {
			is_in_same_clan_as_trigger = { CHARACTER = root }
			has_religion = religion:islam_religion
			any_tax_collector_vassal = {
				NOT = {
					is_in_same_clan_as_trigger = { CHARACTER = root }
				}
				is_landed = yes
			}
		}
	}

	immediate = {

		random_tax_collector = {
			limit = {
				is_in_same_clan_as_trigger = { CHARACTER = root }
				has_religion = religion:islam_religion
				any_tax_collector_vassal = {
					NOT = {
						is_in_same_clan_as_trigger = { CHARACTER = root }

					}
				}
			}
			random_tax_collector_vassal = {
				limit = {
					NOT = {
						is_in_same_clan_as_trigger = { CHARACTER = root }
					}
					is_landed = yes
				}
				save_scope_as = unclan_taxpayer
			}
			save_scope_as = tax_collector
		}
	}

	option = {
		name = fp3_clan.8017.a
		flavor = fp3_clan_protect_kinsman_flavor

		if = {
			limit = {
				root != house.house_head
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:tax_collector
				VALUE = minor_unity_gain
				DESC = clan_unity_protected_muhtasib_position.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		else = {
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:tax_collector
				VALUE = medium_unity_gain
				DESC = clan_unity_protected_muhtasib_position.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}


		scope:unclan_taxpayer = {
			add_opinion = {
				target = root
				opinion = -20
				modifier = frustrated_opinion
			}
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			zealous = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = just
					has_trait = compassionate
				}
			}
		}
	}

	option = {
		name = fp3_clan.8017.b
		flavor = fp3_clan_accuse_accuser_flavor
		trigger = {
			scope:unclan_taxpayer = { num_sinful_traits = { value > 0 target = root.faith } }
		}

		add_dread = minor_dread_gain

		scope:unclan_taxpayer = {
			add_opinion = {
				target = root
				opinion = -30
				modifier = shamed_me_opinion
			}
		}

		stress_impact = {
			wrathful = medium_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = trusting
					has_trait = compassionate
				}
			}
		}
	}

	option = {
		name = fp3_clan.8017.c

		if = {
			limit = {
				root != house.house_head
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:tax_collector
				VALUE = minor_unity_loss
				DESC = clan_unity_fired_from_muhtasib_position.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		else = {
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:tax_collector
				VALUE = medium_unity_loss
				DESC = clan_unity_fired_from_muhtasib_position.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}

		if = {
			limit = {
				NOT = {
					has_hook_of_type = {
						target = scope:unclan_taxpayer
	 					type = favor_hook
	 				}
	 			}
	 		}
			add_hook = {
 				target = scope:unclan_taxpayer
				type = favor_hook
			}
		}

		stress_impact = {
			trusting = medium_stress_impact_loss
			arrogant = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = -0.9
				ai_rationality = 0.9
				ai_sociability = 0.5
			}
		}
	}

	option = {
		name = fp3_clan.8017.d
		#Low effect opt out that is only needed if the taxpayer is not intimidated because of their sins

		trigger = {
			scope:unclan_taxpayer = { num_sinful_traits = { value = 0 target = root.faith } }
		}

		scope:unclan_taxpayer = {
			add_opinion = {
				target = root
				opinion = -10
				modifier = disappointed_opinion
			}
		}

		stress_impact = {
			trusting = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.4
				ai_greed = 0.6
				ai_compassion = -0.5
			}
		}
	}
}

