﻿namespace = ecumenical_council_events_josh

##########################################
## ecumenical_council_events_josh.0001 - Murder At Compline
## ecumenical_council_events_josh.0010 - A Saintly Celebration
## ecumenical_council_events_josh.0011 - Like Thunder - (A Giant)
## ecumenical_council_events_josh.0012 - A Bishops Ring
## ecumenical_council_events_josh.0013 - A Crime of Fashion
## ecumenical_council_events_josh.0020 - The Beacon of Fervor
## ecumenical_council_events_josh.0021 - In the Light
## ecumenical_council_events_josh.0022 - United in Faith
## ecumenical_council_events_josh.0023 - Pray for Me
## ecumenical_council_events_josh.0024 - In the Unknown
## ecumenical_council_events_josh.0025 - A Theologian Too Many
##########################################

# Murder intent event - Murder At Compline
ecumenical_council_events_josh.0001 = {
	type = activity_event
	title = ecumenical_council_events_josh.0001.t
	desc = ecumenical_council_events_josh.0001.desc
	theme = ecumenical_council
	override_background = corridor_night
	left_portrait = {
		character = root
		animation = map_rage
		camera = camera_event_center_close_to_right
	}
	right_portrait = {
		character = scope:murder_target
		animation = prayer
		camera = camera_event_very_left
	}
	cooldown = { years = 5 }
	
	trigger = {
		has_activity_intent = murder_attendee_intent
		scope:activity = { 
			any_attending_character = { this = root.intent_target }
		}
	}
	
	immediate = {
		intent_target ?= { save_scope_as = murder_target }
	}
	
	option = { # Attempt to murder
		name = ecumenical_council_events_josh.0001.a
		flavor = ecumenical_council_events_josh.0001.a.flavor
		reason = activity_intent
		duel = {
			skills = { intrigue prowess }
			target = scope:murder_target
			10 = { # target is killed
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0001.a.toast.success
					left_icon = root.intent_target
					right_icon = root
				}
				desc = ecumenical_council_events_josh.0001.a.tt	
				scope:murder_target = {
					death = {
						death_reason = death_strangled
						killer = root
					}
				}
				stress_and_fulfillment_impact = {
					vengeful = medium_stress_impact_loss
					sadistic = medium_stress_impact_loss
				}		
			}
			10 = { # target survives
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = ecumenical_council_events_josh.0001.a.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ecumenical_council_events_josh.0001.a.toast.failure
					left_icon = root.intent_target
					right_icon = root
					add_stress = medium_stress_gain
					if = { # Check if they are already your rival or nemesis
    					limit = {
        					scope:murder_target = {
            					NOR = {
                					has_relation_rival = root
               						has_relation_nemesis = root
           						}
        					}
    					}
						set_relation_rival = scope:murder_target
					}
    			}
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 2
			}
			modifier = {
				has_trait = sadistic
				factor = 2
			}
			modifier = {
				has_trait = vengeful
				factor = 2
			}
			modifier = {
				intrigue >= high_skill_rating
				factor = 1.5
			}
		}
	}

	option = { # Let the opportunity pass
		name = ecumenical_council_events_josh.0001.b
		add_piety = medium_piety_gain
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = just
				factor = 2
			}
			modifier = {
				has_trait = compassionate
				factor = 2
			}
			modifier = {
				has_trait = forgiving
				factor = 2
			}
		}
	}
}

# A Saintly Celebration
ecumenical_council_events_josh.0010 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0010.t
	desc = ecumenical_council_events_josh.0010.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = priest_good
	}
	center_portrait = {
		trigger = { exists = scope:guest_1 }
		character = scope:guest_1
		animation = drink
		camera = camera_event_right_to_the_right
	}
	right_portrait = {
		trigger = { exists = scope:guest_2 }
		character = scope:guest_2
		animation = toast
	}
	lower_right_portrait = {
		trigger = { exists = scope:monthly_saint }
		character = scope:monthly_saint
		animation = divine_gesture_3
	}

	cooldown = { years = 5 }
	
	trigger = {
		is_clergy = yes
		# Only offer this commemoration when the celebrant's faith has a
		# registered saint who can be selected for the service.
		faith = {
			any_saint = { always = yes }
		}
	}

	override_effect_2d = {
		reference = legend_glow
	}
	
	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = involved_activity.activity_host			
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						has_trait = gregarious
					}
					modifier = {
						add = 10
						has_trait = lifestyle_reveler
					}
				}
				save_scope_as = guest_1
			}
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = involved_activity.activity_host
						this = scope:guest_1					
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						has_trait = gregarious
					}
					modifier = {
						add = 10
						has_trait = lifestyle_reveler
					}
				}
				save_scope_as = guest_2
			}
		}


		# Select someone this celebrant's own faith actually venerates.
		# Fixed historical character IDs cannot reliably supply a scope
		# to an event in NEOW's year 2555, and may not be saints of this faith.
		faith = {
			random_saint = {
				save_scope_as = monthly_saint
			}
		}
	}
	
	option = { # Dedicate the mass
		name = ecumenical_council_events_josh.0010.a
		add_piety = medium_piety_gain
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
			compassionate = medium_stress_impact_loss
			forgiving = medium_stress_impact_loss
			zealous = medium_stress_impact_loss
		}
		involved_activity = {
		    every_attending_character = {
		        custom = every_ruler_guest_scope_tt
		        limit = {
		        	is_available_quick = {
						advanced_ruler = yes
					}
		        	this != root
		        }
				change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		    }
		}
		
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Hold a sermon
		name = ecumenical_council_events_josh.0010.b
		add_piety = minor_piety_gain
		add_learning_lifestyle_xp = medium_lifestyle_experience
		stress_and_fulfillment_impact = {
			base = minor_stress_gain
			impatient = medium_stress_impact_gain
			wrathful = minor_stress_impact_gain
			patient = minor_stress_impact_loss
		}	
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = patient
				factor = 2
			}
			modifier = {
				has_trait = impatient
				factor = 0
			}
			modifier = {
				has_trait = wrathful
				factor = 0
			}									
		}
	}
	
	option = { # Just add a psalm instead
		name = ecumenical_council_events_josh.0010.c
		add_piety = minor_piety_gain
		stress_and_fulfillment_impact = {
			base = minor_stress_loss
			gregarious = minor_stress_impact_loss
			temperate = minor_stress_impact_loss
		}
		involved_activity = {
		    every_attending_character = {
		        custom = every_guest_scope_tt
		        limit = {
		        	this != root
		        }
		        add_opinion = {
		            target = ROOT
		            modifier = thankful_opinion
		            opinion = 15
		        }
		    }
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = temperate
				factor = 2
			}					
		}
	}
}

# Sounds Like Thunder - (A Giant is among us)
ecumenical_council_events_josh.0011 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0011.t
	desc = ecumenical_council_events_josh.0011.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:guest_giant
		animation = preaching_no_book
	}

	cooldown = { years = 5 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				has_trait = giant
				NOR = {
					this = root
					this = involved_activity.activity_host			
				}
			}
    	}
    }
	
	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					has_trait = giant
					NOR = {
						this = root
						this = involved_activity.activity_host			
					}
				}
				save_scope_as = guest_giant
			}
    	}
	}
	
	option = { # Use the Giant as a part of the choir
		name = ecumenical_council_events_josh.0011.a
		flavor = ecumenical_council_events_josh.0011.a.flavor
		add_piety = minor_piety_gain
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		involved_activity = {
		    every_attending_character = {
		        custom = every_guest_scope_tt
		        add_opinion = {
		            target = ROOT
		            modifier = thankful_opinion
		            opinion = 5
		        }
		    }
		}			
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = humble
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}			
		}

	}
	
	option = { # Use the Giant to improve your chances in debate
		name = ecumenical_council_events_josh.0011.b
		flavor = ecumenical_council_events_josh.0011.b.flavor
		add_prestige = minor_prestige_gain
		if = {
			limit = {
				is_in_guest_subset = { name = conservative }
			}
			ecumenical_council_become_conservative_effect = { CHARACTER = scope:guest_giant }
		}
		else_if = {
			limit = {
				OR = {
					this = involved_activity.activity_host
					is_in_guest_subset = { name = innovator }
				}
			}
			ecumenical_council_become_innovator_effect = { CHARACTER = scope:guest_giant }
		}
		duel = {
			skill = diplomacy
			target = scope:guest_giant
			10 = { # Giant becomes convinced supporter
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0011.b.toast.success
					left_icon = scope:guest_giant
					right_icon = root
				  	progress_towards_friend_effect = {
						REASON = friend_giant_support_at_council_reason
						CHARACTER = scope:guest_giant
						OPINION = default_friend_opinion
					}
				}
				desc = ecumenical_council_events_josh.0011.b.tt
			}
			10 = { # Giant agrees but wants something in return
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = ecumenical_council_events_josh.0011.b.tt2
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0011.b.toast.failure
					left_icon = scope:guest_giant
					right_icon = root
					scope:guest_giant = {
						add_hook = {
							target = root
							type = favor_hook
						}
					}
    			}
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}
	}

	option = { # Leave the giant as a guest
		name = ecumenical_council_events_josh.0011.c
		flavor = ecumenical_council_events_josh.0011.c.flavor
		trigger = {
			NOR = {
				has_trait = gregarious
				has_trait = compassionate
			}
		}
		custom_tooltip = {
			text = ecumenical_council_events_josh.0011.c.tt
		}
		scope:guest_giant = {
			add_opinion = {
				target = ROOT
				modifier = thankful_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = shy
				factor = 2
			}
		}
	}

	option = { # Leave the giant as a guest — gregarious/compassionate
		name = ecumenical_council_events_josh.0011.c
		flavor = ecumenical_council_events_josh.0011.c.flavor
		trigger = {
			OR = {
				has_trait = gregarious
				has_trait = compassionate
			}
		}
		custom_tooltip = {
			text = ecumenical_council_events_josh.0011.c.tt
		}
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		scope:guest_giant = {
			add_opinion = {
				target = ROOT
				modifier = thankful_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = compassionate
				factor = 2
			}
		}
	}
}

# A Bishops Ring - by JosH
ecumenical_council_events_josh.0012 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0012.t
	desc = ecumenical_council_events_josh.0012.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = villain
		camera = camera_event_center_pointing_right
	}
	right_portrait = {
		character = scope:guest_bishoplover
		animation = wedding_happy_cry
		camera = camera_event_center_pointing_left
	}
	artifact = {
		target = scope:bishop_ring_artifact
		position = lower_right_portrait
	}
	lower_center_portrait = {
		character = scope:guest_bishop
		animation = divine_gesture_3
	}

	cooldown = { years = 10 }
	
	trigger = {
    	# Host character's faith must shun or criminalize same-gender relations
 		involved_activity.activity_host.rite = {
 		    OR = {
 		        rite_has_doctrine = doctrine_homosexuality_shunned
 		        rite_has_doctrine = doctrine_homosexuality_crime
 		    }
 		}

    	# There must be at least one matching pair among attendees
    	involved_activity = {
    		any_attending_character = {
				is_ai = yes
				attracted_to_same_gender_trigger = yes
				might_cheat_on_every_partner_trigger = yes
				this != root
				this != involved_activity.activity_host
				save_temporary_scope_as = guest_bishoplover_temp
			}

			any_attending_character = {
  				is_ai = yes
  				is_clergy = yes
  				attracted_to_same_gender_trigger = yes
				might_cheat_on_every_partner_trigger = yes
				this != root
				this != involved_activity.activity_host
				this != scope:guest_bishoplover_temp
  				# Same-sex only
  				OR = {
      				AND = {
         				is_male = yes
         				scope:guest_bishoplover_temp = { is_male = yes }
    				}
      				AND = {
        				is_female = yes
        				scope:guest_bishoplover_temp = { is_female = yes }
      				}
  				}
			}
	    }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.25
			is_ai = yes
		}
	}		
	
	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					attracted_to_same_gender_trigger = yes
					is_ai = yes
					might_cheat_on_every_partner_trigger = yes
					this != root
					this != involved_activity.activity_host
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						has_trait = lifestyle_reveler
					}
					modifier = {
						add = 10
						has_trait = lustful
					}
				}				
				save_scope_as = guest_bishoplover
			}
			random_attending_character = {
				limit = {
					is_ai = yes
					is_clergy = yes
					attracted_to_same_gender_trigger = yes
					might_cheat_on_every_partner_trigger = yes
					this != root
					this != involved_activity.activity_host
					this != scope:guest_bishoplover
					# Same-sex only
						OR = {
							AND = {
								is_male = yes
								scope:guest_bishoplover = { is_male = yes }
							}
							AND = {
								is_female = yes
								scope:guest_bishoplover = { is_female = yes }
							}
						}
					}

				weight = {
					base = 1
					modifier = {
						add = 5
						has_trait = lifestyle_reveler
					}
					modifier = {
						add = 10
						has_trait = lustful
					}
				}
				save_scope_as = guest_bishop
			
				# Make the secret before the accusation
				scope:guest_bishoplover = {
					had_sex_with_effect = { 
						CHARACTER = scope:guest_bishop
						PREGNANCY_CHANCE = pregnancy_chance
					}
					random_secret = {
						limit = {
							secret_type = secret_homosexual
						}
						save_scope_as = bishoplover_homosexual_secret
					}
				}

				
				# Create the Bishop ring
				hidden_effect_new_object = {
					if = {
						limit = {
							NOT = {
								any_character_artifact = { has_variable = bishop_ring }
							}
						} 									 	
						create_artifact_ring_effect = {
							OWNER = scope:guest_bishop
							SMITH = scope:guest_bishop
						}
						scope:newly_created_artifact = { 
							set_artifact_name = ecumenical_council_events_josh.0012.bishopringname
							set_artifact_description = ecumenical_council_events_josh.0012.bishopringdesc
							save_scope_as = bishop_ring_artifact
							set_variable = bishop_ring 
						}
					}
					else = {
						random_character_artifact = { 
							limit = {
								has_variable = bishop_ring
							}
							save_scope_as = bishop_ring_artifact
						}
					}
				}
			}
		}
	}
	
	option = { # Get the ring for yourself instead
		name = ecumenical_council_events_josh.0012.b
		scope:bishop_ring_artifact = { set_owner = root }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				has_trait = generous
				factor = 0
			}
		}
	}

	option = { # Get a strong hook on them.
		name = ecumenical_council_events_josh.0012.c
		add_hook = { 
			type = strong_blackmail_hook
			target = scope:guest_bishoplover
			secret = scope:bishoplover_homosexual_secret
			years = 3
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			modifier = {
				has_trait = compassionate
				factor = 0
			}
			modifier = {
				has_trait = forgiving
				factor = 0
			}
		}
	}
}

# A Crime of Fashion

scripted_trigger fashion_criminal_trigger = {
	is_clergy = yes
	NOR = { 
		this = root
		this = involved_activity.activity_host
	}
}

ecumenical_council_events_josh.0013 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0013.t
	desc = ecumenical_council_events_josh.0013.desc
	theme = ecumenical_council
	override_background = pam_gothic_cathedral_interior
	left_portrait = {
		character = scope:fashion_criminal
		animation = disbelief
		camera = camera_event_center_moved_left
	}
	right_portrait = {
		character = root
		animation = condemnation
	}

	cooldown = { years = 5 }
	
	trigger = {
    	involved_activity.activity_host.rite = { #check for iconoclasm
			has_tenet_status = {
				tenet = tenet_aniconism
				status = core
			}
		}

		involved_activity = { # Check if we have an ok fashion_criminal 
			any_attending_character = {
				fashion_criminal_trigger = yes
				OR = {
					piety_level <= 1
					num_sinful_traits >= 1
					has_trait = cynical
					has_trait = arrogant
					has_trait = eccentric
				}
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					fashion_criminal_trigger = yes		
				}
				weight = {
					base = 1 

					modifier = { add = 60 piety_level <= 0 }
					modifier = { add = 30 piety_level <= 1 }

					modifier = { add = 20 num_sinful_traits >= 1 }
					modifier = { add = 60 num_sinful_traits >= 2 }

					modifier = { add = 20 has_trait = cynical }
					modifier = { add = 30 has_trait = arrogant }
					modifier = { add = 20 has_trait = eccentric }

					modifier = { add = -30 piety_level >= 3 }
					modifier = { add = -40 num_virtuous_traits >= 2 }
					modifier = { add = -30 has_trait = zealous }
				}
				save_scope_as = fashion_criminal
			}
    	}
	}
	
	option = { # Make them remove the vestment
		name = ecumenical_council_events_josh.0013.a
		add_piety = minor_piety_gain
		scope:fashion_criminal = {
			add_piety = -100
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = just
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 2
			}
			modifier = {
				has_trait = arrogant
				factor = 2
			}
		}
	}
	 
	option = { # Try to remove attendee from the council
		name = ecumenical_council_events_josh.0013.b
		duel = {
			skill = learning
			target = scope:fashion_criminal
			10 = { # Other attendees agree and finds this just
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				desc = ecumenical_council_events_josh.0013.b.toast.success
				add_piety = medium_piety_gain
				add_prestige = minor_prestige_gain
				stress_and_fulfillment_impact = {
                    zealous = minor_stress_impact_loss
                    just = minor_stress_impact_loss
                }
                scope:fashion_criminal = {
					remove_from_activity = involved_activity
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0013.b.toast.success
					left_icon = scope:fashion_criminal
					right_icon = root
				}	
			}
			10 = { # The attendee manages to stay
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = ecumenical_council_events_josh.0013.b.toast.failure
				progress_towards_rival_effect = {
					REASON = fashion_criminal_at_council_reason
					CHARACTER = scope:fashion_criminal
					OPINION = default_rival_opinion
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ecumenical_council_events_josh.0013.b.toast.failure
					left_icon = scope:fashion_criminal
					right_icon = root
    			}
			}
		}
				
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 2
			}
			modifier = {
				has_trait = diplomat
				factor = 2
			}
			modifier = {
				has_trait = forgiving
				factor = 0
			}
		}
	}
}

# Fervor intent - The Beacon of Fervor
ecumenical_council_events_josh.0020 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0020.t
	desc = {
		desc = ecumenical_council_events_josh.0020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:faith_battle_memory
				}
				desc = ecumenical_council_events_josh.0020.desc_battle_memory
			}
			desc = ecumenical_council_events_josh.0020.desc.fallback
		}
	}
	
	theme = ecumenical_council
	left_portrait = {
		character = scope:host
		animation = priest_good
		camera = camera_event_crowd
	}
	center_portrait = {
		character = root
		animation = zealous_superior
		camera = camera_event_center_moved_left
		triggered_animation = { # check if we should use battle variant
			trigger = {
				exists = scope:faith_battle_memory
			}
			animation = sword_coup_degrace
		}
	}
	right_portrait = {
		character = scope:applauding_character
		animation = throne_room_applaud_1
		camera = camera_event_very_right_fov35
	}

	cooldown = { years = 15 }
	
	trigger = {
		has_activity_intent = fervor_intent		
	}
	
	immediate = {
		random_memory = { # Finding a battle against a heathen
			limit = {
				OR = {
					has_memory_type = battle_won_memory
					has_memory_type = battle_lost_memory
				}
				any_memory_participant = {
					faith = {
						faith_hostility_level = {
							target = root.faith
							value >= faith_hostile_level
						}
					}
				}
			}
			save_scope_as = faith_battle_memory
		}
		involved_activity = { # Finding a good bystander
			random_attending_character = {
				limit = {
					NOR = { 
						this = root
						this = involved_activity.activity_host
					}
				}
				save_scope_as = applauding_character
			}
		}
		if = { 
			limit = {
				root = involved_activity.activity_host
			}

			involved_activity = { # Finding a spokesperson if you are the host
				ordered_attending_character = {
					limit = {
						is_clergy = yes
						this != root
					}
					order_by = piety_level
					save_scope_as = host
				}
			}
		}
		else = {
			involved_activity.activity_host = {
				save_scope_as = host
			}
		}
	}
	
	option = {
		name = ecumenical_council_events_josh.0020.a
		flavor = ecumenical_council_events_josh.0020.a.flavor
		add_piety = medium_piety_gain
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		faith = {
			change_fervor = {
				value = slight_fervor_gain
				desc = fervor_gain_council_beacon
			}
		}
		
		ai_chance = {
			base = 10
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}
	}
	option = {
		name = ecumenical_council_events_josh.0020.b
		add_piety = major_piety_gain
		add_prestige = medium_prestige_gain		
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 2
			}
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 2
			}
			modifier = {
				has_trait = zealous
				factor = 0.1
			}
		}
	}
}

# In the Light
ecumenical_council_events_josh.0021 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0021.t
	desc = ecumenical_council_events_josh.0021.desc
	theme = ecumenical_council
	override_background = pam_gothic_cathedral_interior
	widget = { gui = event_window_widget_vfx_stained_glass_foreground container = foreground_shader_vfx_container }
	
	left_portrait = {
		character = scope:council_opponent
		animation = disapproval
		camera = camera_event_horse_left_facing_left_very_far
	}
	center_portrait = {
		character = root
		animation = preaching_no_book
		camera = camera_event_right_pointing_right
	}

	cooldown = { years = 5 }
	
	trigger = {
    	has_activity_intent = clerical_appointment_intent
		involved_activity = {
			any_attending_character = {
				is_in_guest_subset = {
					name = conservative
				}
				count >= 2
			}
		}
    }

    weight_multiplier = {
		base = 1
		modifier = {
			factor = 10
			has_activity_intent = clerical_appointment_intent
		}
	}

	
	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					NOR = { 
						this = root
						this = involved_activity.activity_host
					}
					is_in_guest_subset = {
						name = conservative
					}
				}
				save_scope_as = council_opponent
			}
			# The 3 conservatives who like us most, matching the option's "Up to 3" tooltip
			ordered_guest_subset = {
				name = conservative
				order_by = "opinion(root)"
				max = 3
				check_range_bounds = no
				limit = {
					NOR = {
						this = root
						this = involved_activity.activity_host
						is_in_list = picked_conservatives
					}
				}
				add_to_list = picked_conservatives
			}
		}
	}
	
	option = {
		name = ecumenical_council_events_josh.0021.a
		custom_tooltip = {
  			text = ecumenical_council_events_josh.0021.a.ct
  		}
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		ecumenical_council_become_innovator_effect = { CHARACTER = scope:council_opponent }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = impatient
				factor = 2
			}
		}
	}
	option = {
		name = ecumenical_council_events_josh.0021.b
		custom_tooltip = {
  			text = ecumenical_council_events_josh.0021.b.ct
  		}
		every_in_list = {
			list = picked_conservatives
			ecumenical_council_become_innovator_effect = { CHARACTER = this }
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = patient
				factor = 2
			}
		}
	}
	option = {
		name = ecumenical_council_events_josh.0021.c
		trigger = {
			OR = {
				is_clergy = yes
				has_theological_agent_puppet_trigger = yes
				is_theological_agent_puppet_trigger = yes
			}
		}
		custom_tooltip = {
			text = ecumenical_council_events_josh.0021.c.ct
		}
		if = {
			limit = {
				is_clergy = yes
			}
			pam_boost_clerical_appointment_score_effect = { CHARACTER = this VALUE = 50 }
		}
		else = {
			pam_boost_clerical_appointment_score_effect = { CHARACTER = puppet:theological_agent_puppet VALUE = 50 }
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 2
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
}

# Alliance - United in Faith 
ecumenical_council_events_josh.0022 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0022.t
	desc = ecumenical_council_events_josh.0022.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = war_over_tie
	
	}
	center_portrait = {
		character = scope:alliance_target
		animation = war_defender
		camera = camera_event_center_pointing_left
	}
	right_portrait = {
		character = scope:host
		animation = acknowledging_crozier
		camera = camera_event_very_right_fov35
	}

	cooldown = { years = 5 }
	
    trigger = {
		exists = scope:host
		has_activity_intent = alliance_intent
		intent_target ?= {
			is_ruler = yes
			NOT = { this = root }
			NOT = { is_allied_to = root }
		}
    }
	
	immediate = {
		intent_target ?= { save_scope_as = alliance_target } 
		involved_activity.activity_host = { save_scope_as = host }
		involved_activity = {
			random_attending_character = {
				limit = {
					NOR = { 
						this = root
						this = involved_activity.activity_host
					}
				}
				save_scope_as = council_opponent
			}
		}
	}
	
	option = { # Let the Church bless our alliance.
		name = ecumenical_council_events_josh.0022.a
		flavor = ecumenical_council_events_josh.0022.a.flavor
		
		if = {
		      limit = { scope:alliance_target.primary_title.tier = tier_county }
		      root = { add_piety = medium_piety_loss }
		}
		else_if = {
		      limit = { scope:alliance_target.primary_title.tier= tier_duchy }
		      root = { add_piety = major_piety_loss }
		}
		else_if = {
		      limit = { scope:alliance_target.primary_title.tier = tier_kingdom }
		      root = { add_piety = massive_piety_loss }
		}
		else_if = {
		      limit = { scope:alliance_target.primary_title.tier >= tier_empire }
		      root = { add_piety = massive_piety_loss }
		}

		scope:alliance_target = {
			add_opinion = {
				target = root
				modifier = event_negotiated_alliance_opinion
			}
			save_scope_as = recipient
		}
		
		custom_tooltip = negotiate_alliance_effect_tooltip	

		create_alliance = {
			target = scope:alliance_target
			allied_through_owner = root
			allied_through_target = scope:alliance_target
		}

		ai_chance = {
			base = 100
		}
	}
	option = { #The alliance will be built on mutual understanding
		name = ecumenical_council_events_josh.0022.b
		flavor = ecumenical_council_events_josh.0022.b.flavor
		duel = {
			skill = diplomacy
			target = scope:alliance_target
			10 = { # Convince the target to ally with you
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				desc = ecumenical_council_events_josh.0022.b.toast.success
				scope:alliance_target = {
					add_opinion = {
						target = root
						modifier = event_negotiated_alliance_opinion
					}
					save_scope_as = recipient
				}
				
				custom_tooltip = negotiate_alliance_effect_tooltip	

				create_alliance = {
					target = scope:alliance_target
					allied_through_owner = root
					allied_through_target = scope:alliance_target
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0022.b.toast.success
					left_icon = scope:alliance_target
					right_icon = root
				}
			}
			10 = { # The target feels you are overstepping
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = ecumenical_council_events_josh.0022.b.toast.failure
				progress_towards_rival_effect = {
					REASON = alliance_target_at_council_reason
					CHARACTER = scope:alliance_target
					OPINION = default_rival_opinion
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ecumenical_council_events_josh.0022.b.toast.failure
					left_icon = scope:alliance_target
					right_icon = root
    			}
			}
		}
		ai_chance = {
			base = 100
		}
	}
	option = { #A council is not the place.
		name = ecumenical_council_events_josh.0022.c
		add_piety = minor_piety_gain
		
		ai_chance = {
			base = 100
		}
	}
}

# Pray for Me
ecumenical_council_events_josh.0023 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0023.t
	desc = ecumenical_council_events_josh.0023.desc
	theme = ecumenical_council
	left_portrait = {
		character = scope:prayer_opponent
		animation = priest_corrupt
		camera = camera_event_center_pointing_right
	}
	center_portrait = {
		character = root
		animation = prayer
		camera = camera_event_center_pointing_right
	}

	right_portrait = {
		character = scope:host
		animation = prayer_crossing
		camera = camera_event_right
	}

	cooldown = { years = 5 }
	
	trigger = {
		exists = scope:host
		has_activity_intent = spiritual_intent
		NOT = { root = involved_activity.activity_host }
		involved_activity = {
			any_attending_character = {
				NOR = {
					this = root
					this = involved_activity.activity_host
				}
			}
		}
    }

	
	immediate = {	
		involved_activity.activity_host = { save_scope_as = host }
		involved_activity = {
			random_attending_character = {
				limit = {
					NOR = { 
						this = root
						this = involved_activity.activity_host
					}
				}
				weight = { # trying to pick someone that are against you
					base = 1
					opinion_modifier = {
						opinion_target = root
						multiplier = 0.25
					}
					modifier = {
						add = 100
						has_relation_rival = root
					}
				}
				save_scope_as = prayer_opponent
			}
		}
	}
	
	# A sizable donation, to keep me in your prayers
	option = {
		name = ecumenical_council_events_josh.0023.a
		pay_short_term_gold = {
			target = scope:host
			gold = minor_gold_value
		}
		change_spiritual_fulfillment = medium_spiritual_fulfillment_value
		
		ai_chance = {
			base = 50
			modifier = {
				has_trait = generous
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = greedy
					gold <= root.minor_gold_value
				}
				factor = 0
			}
		}
	}
	
	# No one pushes me aside...
	option = {
		name = ecumenical_council_events_josh.0023.b
		duel = {
			skills = { diplomacy intrigue }
			target = scope:prayer_opponent
			10 = { # You are more interesting
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				desc = ecumenical_council_events_josh.0023.b.tt
				send_interface_toast = {
					type = event_toast_effect_good
					title = ecumenical_council_events_josh.0023.b.toast.success
					left_icon = root.host
					right_icon = root
				}
				change_spiritual_fulfillment = minor_spiritual_fulfillment_value		
			}
			10 = { # Prayer opponent shifts the focus
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = ecumenical_council_events_josh.0023.b.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ecumenical_council_events_josh.0023.b.toast.failure
					left_icon = root.host
					right_icon = root
					add_stress = medium_stress_gain
					add_piety = medium_piety_loss
    			}
			}
		}		
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = arrogant
				factor = 2
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}
	}
	
	# Opt out - It is better to step aside and be pious.
	option = {
		name = ecumenical_council_events_josh.0023.c
		add_piety = miniscule_piety_gain
		add_stress = miniscule_stress_loss
		change_spiritual_fulfillment = miniscule_spiritual_fulfillment_value
		
		ai_chance = {
			base = 100
		}
	}
}

# In the Unknown
ecumenical_council_events_josh.0024 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0024.t
	desc = ecumenical_council_events_josh.0024.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = pondering
		camera = camera_event_center_close_to_right
	}
	center_portrait = {
		character = scope:tenet_target_a
		animation = debating
		camera = camera_event_very_right_fov35
	}

	right_portrait = {
		character = scope:tenet_target_b
		animation = page_flipping
		camera = camera_event_center_pointing_forward_fov35
	}

	cooldown = { years = 5 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				NOR = {
					this = root
					this = involved_activity.activity_host
				}
				ecumenical_shareable_unknown_tenet_for_root_trigger = yes
				save_temporary_scope_as = ecumenical_tenet_teacher_a
				any_character_tenet = {
					save_temporary_scope_as = ecumenical_tenet_candidate
					NOT = { root = { knows_tenet = scope:ecumenical_tenet_candidate } }
					root.faith.main_rite = {
						has_tenet_status = {
							tenet = scope:ecumenical_tenet_candidate
							status = unknown
						}
					} 
					save_temporary_scope_as = tenet_a_temp
				}
			}
			any_attending_character = {
				NOR = {
					this = root
					this = involved_activity.activity_host
					this = scope:ecumenical_tenet_teacher_a
				}
				ecumenical_shareable_unknown_tenet_for_root_trigger = yes
				save_temporary_scope_as = ecumenical_tenet_teacher_b
				any_character_tenet = {
					NOT = {
						this = scope:tenet_a_temp
					}
				}
			}
		}
    }

	
	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = involved_activity.activity_host
					}
					ecumenical_shareable_unknown_tenet_for_root_trigger = yes
				}
				save_scope_as = tenet_target_a
				random_character_tenet = {
					knowledge_filter = known
					limit = {
						save_temporary_scope_as = ecumenical_tenet_candidate
						NOT = { root = { knows_tenet = scope:ecumenical_tenet_candidate } }
						root.faith.main_rite = {
							has_tenet_status = {
								tenet = scope:ecumenical_tenet_candidate
								status = unknown
							}
						}
					}
					save_scope_as = tenet_target_a_shareable_tenet
				}
			}
    	}
    	involved_activity = {
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = involved_activity.activity_host
						this = scope:tenet_target_a
					}
					ecumenical_shareable_unknown_tenet_for_root_trigger = yes
				}
				save_scope_as = tenet_target_b
				random_character_tenet = {
					knowledge_filter = known
					limit = {
						save_temporary_scope_as = ecumenical_tenet_candidate
						NOT = { root = { knows_tenet = scope:ecumenical_tenet_candidate } }
						root.faith.main_rite = {
							has_tenet_status = {
								tenet = scope:ecumenical_tenet_candidate
								status = unknown
							}
						}
						NOT = {
							this = scope:tenet_target_a_shareable_tenet
						}
					}
					save_scope_as = tenet_target_b_shareable_tenet
				}
			}
    	}

	}
	
	# What is the discussion about?
	option = {
		name = ecumenical_council_events_josh.0024.a
		add_known_tenet = scope:tenet_target_a_shareable_tenet
		scope:tenet_target_a = {
			add_opinion = {
				modifier = friendliness_opinion
				target = root
				opinion = 20
			}
		}
		if = {
			limit = { faith = { has_tenet_popularity_trigger = yes } }
			if = {
				limit = {
					OR = {
						faith.religious_head ?= root
						highest_held_title_tier >= tier_empire
					}
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_a_shareable_tenet
						change = medium_tenet_popularity_gain
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						highest_held_title_tier >= tier_kingdom
						exists = clerical_elector_title
						is_ai = no
					}
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_a_shareable_tenet
						change = minor_tenet_popularity_gain
					}
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier >= tier_duchy
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_a_shareable_tenet
						change = miniscule_tenet_popularity_gain
					}
				}
			}
		}
		
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = -0.5
				ai_energy = 0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 200
				any_desired_tenet = {
					this = scope:tenet_target_a_shareable_tenet
				}
			}
			modifier = {
				factor = 0
				any_undesired_tenet = {
					this = scope:tenet_target_a_shareable_tenet
				}
			}
		}
	}
	
	# That book seems interesting.
	option = {
		name = ecumenical_council_events_josh.0024.b
		add_known_tenet = scope:tenet_target_b_shareable_tenet	
		scope:tenet_target_b = {
			add_opinion = {
				modifier = friendliness_opinion
				target = root
				opinion = 20
			}
		}
		if = {
			limit = { faith = { has_tenet_popularity_trigger = yes } }
			if = {
				limit = {
					OR = {
						faith.religious_head ?= root
						highest_held_title_tier >= tier_empire
					}
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_b_shareable_tenet
						change = medium_tenet_popularity_gain
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						highest_held_title_tier >= tier_kingdom
						exists = clerical_elector_title
						is_ai = no
					}
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_b_shareable_tenet
						change = minor_tenet_popularity_gain
					}
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier >= tier_duchy
				}
				faith = {
					change_tenet_popularity = {
						target = scope:tenet_target_b_shareable_tenet
						change = miniscule_tenet_popularity_gain
					}
				}
			}
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = -0.5
				ai_energy = 0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 200
				any_desired_tenet = {
					this = scope:tenet_target_b_shareable_tenet
				}
			}
			modifier = {
				factor = 0
				any_undesired_tenet = {
					this = scope:tenet_target_b_shareable_tenet
				}
			}
		}
	}
	
	# God has already shown me the path.
	option = {
		name = ecumenical_council_events_josh.0024.c
		add_piety = minor_piety_gain
		change_spiritual_fulfillment = minor_spiritual_fulfillment_value
		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_zeal = 0.5
				ai_energy = -0.5
				ai_honor = 0.5
			}
		}
	}
}

# A Theologian Too Many
ecumenical_council_events_josh.0025 = { 
	type = activity_event
	title = ecumenical_council_events_josh.0025.t
	desc = ecumenical_council_events_josh.0025.desc
	theme = ecumenical_council
	left_portrait = {
		character = root
		animation = dismissal
		camera = camera_event_center_close_to_right
	}

	right_portrait = {
		character = scope:theologian
		animation = holding_staff
		camera = camera_event_center_pointing_left
	}

	cooldown = { years = 5 }
	
	trigger = {
		religion = religion:christianity_religion
		NOR = {
			involved_activity.activity_host.faith = {
				OR = {
					this = faith:miaphysitism 
					this = faith:armenian_apostolic
					has_tenet = tenet_miaphysitism
				}
			}
			faith = {
				OR = {
					this = faith:miaphysitism 
					this = faith:armenian_apostolic
					has_tenet = tenet_miaphysitism
				}
			}
		}
    }

	
	immediate = {
		# Make a Theologian of a different Christian religion
		create_character = {
			template = virtuous_priest_character_template
			dynasty = none
			location = root.location
			culture = culture:ethiopian
			faith = faith:miaphysitism
			rite = faith:miaphysitism.main_rite
			trait = cleric
			save_scope_as = theologian
		}
	}
	
	# Entrance will come at a cost...
	option = {
		name = ecumenical_council_events_josh.0025.a
		flavor = ecumenical_council_events_josh.0025.a.flavor
		add_internal_flag = special
		show_as_unavailable = { always = yes }
		trigger = {
			intrigue >= high_skill_rating
		}
		scope:theologian = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
			if = {
				limit = {
					NOT = { involved_activity = root.involved_activity }
				}
				add_to_activity = root.involved_activity
			}
		}
		ai_chance = { # Not for AI
			base = 0
		}
	}

	# "Your teachings are a disgrace!"
	option = {
		name = ecumenical_council_events_josh.0025.b
		add_internal_flag = special
		show_as_unavailable = { always = yes }
		trigger = {
			has_activity_intent = fervor_intent
		}
		add_piety = minor_piety_gain
		faith = {
			change_fervor = {
				value = trivial_fervor_gain
				desc = fervor_gain_ecumenical_council_0025_b
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 2
			}
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = compassionate
				factor = 0
			}
		}
	}
	
	# Fascinating. Let's have our own council instead.
	option = {
		name = ecumenical_council_events_josh.0025.c
		add_courtier = scope:theologian
		start_scheme = {
			type = study_faith
			target_character = scope:theologian
		}
	
		ai_chance = { # Not for AI
			base = 0
		}
	}

	# Politely show him how to leave.
	option = {
		name = ecumenical_council_events_josh.0025.d
		add_piety = minor_piety_gain
		add_stress = minor_stress_loss

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 0.1
			}
			modifier = {
				has_trait = compassionate
				factor = 2
			}
		}
	}
	after = {
		scope:theologian = {
			if = {
				limit = {
					NOT = { involved_activity ?= root.involved_activity }
				}
				silent_disappear_ai_if_not_hired = yes
			}
		}
	}
}
