﻿##################################
# Popular Opinion Republic Events#
##################################
namespace = republic_popular_opinion_event

### Tier: severe negative - capital popular_opinion -51 and below
republic_popular_opinion_event.1001 = {
	type = character_event
	title = republic_popular_opinion_event.1001.t
	desc = republic_popular_opinion_event.1001.desc
	theme = republic

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = worry
		camera = camera_body_left_slight
	}
	right_portrait = {
		character = scope:relation_01
		animation = disapproval
		camera = camera_body
	}

	
	trigger = {
		government_has_flag = government_is_republic
		is_healthy = yes
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
			in_army = no
			travel = no
		}
		OR = {
			any_relation = {
				type = friend
				type = lover
				this != liege
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
			any_close_or_extended_family_member = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
			any_spouse = {
				this != root.liege
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
		}
	}

	immediate = {
		location = { save_scope_as = event_location_01 }
		every_relation = {
			type = friend
			type = lover
			limit = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
				}
			add_to_list = relation_candidates
		}
		every_close_or_extended_family_member = {
			limit = {
				this != root
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
			}
			add_to_list = relation_candidates
		}
		every_spouse = {
			limit = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
			}
			add_to_list = relation_candidates
		}
		random_in_list = {
			list = relation_candidates
			weight = {
				base = 1
				modifier = {
					add = 30
					has_relation_soulmate = root
				}
				modifier = {
					add = 15
					OR = {
						has_relation_friend = root
						has_relation_lover = root
						is_primary_heir_of = root
					}
				}
				modifier = {
					add = 5
					OR = {
						is_child_of = root
						is_grandchild_of = root
					}
				}
				modifier = {
					factor = 1.5
					opinion = {
						target = root
						value >= 50
					}
				}
				modifier = {
					factor = 0.5
					opinion = {
						target = root
						value < 0
					}
				}
			}
			save_scope_as = relation_01
		}
		if = {
			limit = {
				can_employ_court_position_type = bodyguard_court_position
				short_term_gold >= medium_gold_value
			}
			create_character = {
				template = bodyguard_court_position_template
				location = scope:event_location_01
				culture = root.culture
				faith = root.faith
				save_scope_as = hired_bodyguard
				after_creation = { add_character_flag = created }
			}
		}
	}
	
	## "You are right. We need to hold our heads high."
	option = {
		name = republic_popular_opinion_event.1001.a
		trigger = {
			NOT = { has_trait = craven } 
		}
		add_character_modifier = {
			modifier = gdp_head_held_high_modifier
			years = 5
		}

		stress_and_fulfillment_impact = {
			# Gain
			humble = minor_stress_impact_gain
			# Loss
			arrogant = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = humble
			}
		}
	}
	
	## "Might be a good time to get myself a bodyguard."
	option = {
		name = republic_popular_opinion_event.1001.b
		trigger = {
			can_employ_court_position_type = bodyguard_court_position
		}
		remove_short_term_gold = medium_gold_value
		add_courtier = scope:hired_bodyguard
		scope:hired_bodyguard = { remove_character_flag = created }
		appoint_court_position = {
			recipient = scope:hired_bodyguard
			court_position = bodyguard_court_position
		}

		stress_and_fulfillment_impact = {
			# Gain
			trusting = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = trusting
			}
			modifier = {
				factor = 0
				NOT = { short_term_gold >= medium_gold_value }
			}
		}
	}
	
	## "The mob are going to kill us all!"
	option = {
		name = republic_popular_opinion_event.1001.c
		add_character_modifier = {
			modifier = gdp_fear_of_the_mob_modifier
			years = 5
		}

		stress_and_fulfillment_impact = {
			# Loss
			paranoid = major_stress_impact_loss
			craven = major_stress_impact_loss
		}

		ai_chance = { base = 100 }
	}
	
	## "They won't find me easy prey."
	option = {
		name = republic_popular_opinion_event.1001.d
		trigger = {
			OR = {
				has_trait = brave
				has_trait = wrathful
				has_lifestyle = martial_lifestyle
			}
		}
		add_character_modifier = {
			modifier = gdp_training_for_the_worst_modifier
			years = 5
		}

		stress_and_fulfillment_impact = {
			# Loss
			diligent = minor_stress_impact_loss
			brave = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
		}

		ai_chance = { base = 100 }
	}

	after = {
		scope:hired_bodyguard = {
			silent_disappear_ai_if_not_hired_with_flag = yes
		}
	}
}

### Tier: mild negative - capital popular_opinion -50 to -1
scripted_effect patrician_aggrandizement_signorial_opinion_effect = {
	every_vassal = {
		limit = {
			this != root
			this.domicile ?= {
				is_domicile_type = merchant_company
			}
			this = {
				government_has_flag = government_is_republic
			}
			this.house ?= {
				OR = {
					has_house_aspiration_parameter = republic_aggrandizement
					has_house_aspiration_parameter = republic_signorial
				}
			}
		}
		custom = custom.every_patrician_aggrandizement_signorial
		this = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 20
			}
		}
	}
}

scripted_effect patrician_agitation_communal_opinion_effect = {
	every_vassal = {
		limit = {
			this != root
			this.domicile ?= {
				is_domicile_type = merchant_company
			}
			this = {
				government_has_flag = government_is_republic
			}
			this.house ?= {
				OR = {
					has_house_aspiration_parameter = republic_agitation
					has_house_aspiration_parameter = republic_communal
				}
			}
		}
		custom = custom.every_patrician_agitation_communal
		this = {
			add_opinion = {
				target = root
				modifier = disrespect_opinion
				opinion = -20
			}
		}
	}
}

republic_popular_opinion_event.1002 = {
	type = character_event
	title = republic_popular_opinion_event.1002.t
	desc = {
		desc = republic_popular_opinion_event.1002.desc_1
		desc = republic_popular_opinion_event.1002.desc_2
		desc = republic_popular_opinion_event.1002.desc_3
	}
	override_background = bp1_relaxing_room_western
	theme = republic
	
	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = stress
	}

	trigger = {
		government_has_flag = government_is_republic
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
			in_army = no
			travel = no
		}
	}

	immediate = {
		location = { save_scope_as = event_location_01 }
		save_scope_as = patrician_ambition_display_ruler
	}

	option = {
		name = republic_popular_opinion_event.1002.a

		add_character_modifier = {
			modifier = gdp_champion_of_the_state_modifier
			years = 20
		}

		if = {
			limit = {
				gdp_is_assembly_head_trigger = yes
			}
			patrician_aggrandizement_signorial_opinion_effect = yes
			patrician_agitation_communal_opinion_effect = yes
		}
		else_if = {
			limit =  {
				liege = {
					gdp_is_assembly_head_trigger = yes
				}
			}
			liege = {
				if = {
					limit = { 
						this != root 
						gdp_is_assembly_head_trigger = yes
					}
					add_opinion = {
						target = root
						modifier = political_ally_opinion
						opinion = 20
					}
				}
				patrician_aggrandizement_signorial_opinion_effect = yes
				patrician_agitation_communal_opinion_effect = yes
			}
		}

		stress_and_fulfillment_impact = {
			# Gain
			craven = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			# Loss
			ambitious = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				add = 300
				house ?= {
					OR = {
						has_house_aspiration_parameter = republic_aggrandizement
						has_house_aspiration_parameter = republic_signorial
					}
				}
			}
			modifier = {
				factor = 0.25
				OR = {
					has_trait = craven
					has_trait = shy
				}
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1002.b

		add_character_modifier = {
			modifier = gdp_champion_of_the_people_modifier
			years = 20
		}

		liege = {
			if = {
				limit = { this != root }
				add_opinion = {
					target = root
					modifier = political_enemy_opinion
					opinion = -20
				}
			}
			every_vassal = {
				limit = {
					this != root
					this.domicile ?= {
						is_domicile_type = merchant_company
					}
					this = {
						AND = {
							government_has_flag = government_is_republic
						}
					}
					this.house ?= {
						OR = {
							has_house_aspiration_parameter = republic_agitation
							has_house_aspiration_parameter = republic_communal
						}
					}
				}
				custom = custom.every_patrician_agitation_communal
				this = {
					add_opinion = {
						target = root
						modifier = pleased_opinion
						opinion = 20
					}
				}
			}

			every_vassal = {
				limit = {
					this != root
					this.domicile ?= {
						is_domicile_type = merchant_company
					}
					this = {
						AND = {
							government_has_flag = government_is_republic
						}
					}
					this.house ?= {
						OR = {
							has_house_aspiration_parameter = republic_aggrandizement
							has_house_aspiration_parameter = republic_signorial
						}
					}
				}
				custom = custom.every_patrician_aggrandizement_signorial
				this = {
					add_opinion = {
						target = root
						modifier = disrespect_opinion
						opinion = -20
					}
				}
			}
		}

		stress_and_fulfillment_impact = {
			# Gain
			craven = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			# Loss
			ambitious = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				add = 300
				house ?= {
					OR = {
						has_house_aspiration_parameter = republic_agitation
						has_house_aspiration_parameter = republic_communal
					}
				}
			}
			modifier = {
				factor = 0.25
				OR = {
					has_trait = craven
					has_trait = shy
				}
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1002.c
		
		stress_and_fulfillment_impact = {
			# Gain
			ambitious = medium_stress_impact_gain
			# Loss
			temperate = minor_stress_impact_loss
			craven = major_stress_impact_loss
			shy = major_stress_impact_loss
			calm = minor_stress_impact_loss
			cynical = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0.25
				has_trait = ambitious
			}
		}
	}
}

### Tier: strong positive - capital popular_opinion 50 and above
republic_popular_opinion_event.1003 = {
	type = character_event
	title = republic_popular_opinion_event.1003.t
	desc = republic_popular_opinion_event.1003.desc
	theme = republic

	override_background = gdp_artisan_street

	left_portrait = {
		character = root
		animation = laugh
		camera = camera_event_crowd
	}

	right_portrait = {
		character = scope:craftsman_character
		animation = donkey_petting
		camera = camera_event_center_pointing_forward_fov35
	}

	trigger = {
	}

	immediate = {
		location = { save_scope_as = event_location_01 }
		create_character = {
			template = craftman_carnival_character
			culture = root.location.culture
			faith = root.location.faith
			location = root.location

			save_scope_as = craftsman_character
			
		}
	}

	option = {
		name = republic_popular_opinion_event.1003.a
		custom_tooltip = republic_popular_opinion_event.1003.tt
		add_character_modifier = { 
			modifier = gdp_guild_sponsored_feast_modifier
			desc = republic_popular_opinion_event.1003.tt
		}

		stress_and_fulfillment_impact = {
			# Gain
			shy = minor_stress_impact_gain
			# Loss
			gregarious = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0.25
				has_trait = shy
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1003.b
		add_short_term_gold = medium_gold_value
		add_character_modifier = {
			modifier = gdp_broken_trust_modifier
			years = 20
		}

		stress_and_fulfillment_impact = {
			# Gain
			generous = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			# Loss
			greedy = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
			callous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0.25
				OR = {
					has_trait = generous
					has_trait = honest
					has_trait = compassionate
				}
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1003.c
		if = {
			limit = {
				is_attracted_to_gender_of = scope:craftsman_character
				can_set_relation_lover_trigger = { CHARACTER = scope:craftsman_character }
			}
			set_relation_lover = { reason = lover_citizen_chance_meeting target = scope:craftsman_character }
			add_courtier = scope:craftsman_character
		}
		else = {
			set_relation_friend = { reason = friend_citizen_chance_meeting target = scope:craftsman_character }
			add_courtier = scope:craftsman_character
		}

		stress_and_fulfillment_impact = {
			# Gain
			callous = minor_stress_impact_gain
			# Loss
			compassionate = minor_stress_impact_loss
			shy = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0.25
				has_trait = callous
			}
		}
	}

	after = {
		scope:craftsman_character = {
			if = {
				limit = {
					NOR = {
						liege_or_court_owner = root
						has_relation_lover = root
						has_relation_friend = root
					}
				}
				silent_disappearance_effect = yes
			}
		}
	}
}

### Tier: mild positive - capital popular_opinion 25 to 49
republic_popular_opinion_event.1004 = {
	type = character_event
	title = republic_popular_opinion_event.1004.t
	desc = republic_popular_opinion_event.1004.desc
	theme = republic

	override_background = gdp_artisan_street

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:relation_01
		animation = drink_goblet
	}

	trigger = {
		government_has_flag = government_is_republic
		is_healthy = yes
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
			in_army = no
			travel = no
		}
		OR = {
			any_relation = {
				type = friend
				type = lover
				this != root.liege
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
			any_close_or_extended_family_member = {
				this != root.liege
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
			any_spouse = {
				this != root.liege
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
			}
		}
	}

	immediate = {
		location = { save_scope_as = event_location_01 }
		every_relation = {
			type = friend
			type = lover
			limit = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
				}
			add_to_list = relation_candidates
		}
		every_close_or_extended_family_member = {
			limit = {
				this != root
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
			}
			add_to_list = relation_candidates
		}
		every_spouse = {
			limit = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				this != root.liege
			}
			add_to_list = relation_candidates
		}
		random_in_list = {
			list = relation_candidates
			weight = {
				base = 1
				modifier = {
					add = 30
					has_relation_soulmate = root
				}
				modifier = {
					add = 15
					OR = {
						has_relation_friend = root
						has_relation_lover = root
						is_primary_heir_of = root
					}
				}
				modifier = {
					add = 5
					OR = {
						is_child_of = root
						is_grandchild_of = root
					}
				}
				modifier = {
					factor = 1.5
					opinion = {
						target = root
						value >= 50
					}
				}
				modifier = {
					factor = 0.5
					opinion = {
						target = root
						value < 0
					}
				}
			}
			save_scope_as = relation_01
		}
	}

	option = {
		name = republic_popular_opinion_event.1004.a
		add_character_modifier = {
			modifier = gdp_toast_to_adventure_modifier
			years = 30
		}

		stress_and_fulfillment_impact = {
			# Gain
			craven = minor_stress_impact_gain
			content = minor_stress_impact_gain
			# Loss
			brave = minor_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = content
				}
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1004.b
		add_character_modifier = {
			modifier = gdp_toast_to_romance_modifier
			years = 30
		}

		stress_and_fulfillment_impact = {
			# Gain
			chaste = minor_stress_impact_gain
			# Loss
			lustful = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = chaste
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1004.c
		add_character_modifier = {
			modifier = gdp_toast_to_glory_modifier
			years = 30
		}

		stress_and_fulfillment_impact = {
			# Gain
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			# Loss
			arrogant = minor_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = shy
				}
			}
		}
	}

	option = {
		name = republic_popular_opinion_event.1004.d
		add_character_modifier = {
			modifier = gdp_toast_to_relations_modifier
			years = 30
		}

		stress_and_fulfillment_impact = {
			# Gain
			callous = minor_stress_impact_gain
			# Loss
			compassionate = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
			content = minor_stress_impact_loss
			shy = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = callous
			}
		}
	}
}
