#namespace = tgp_genpei_character
#
#scripted_effect save_genpei_scopes_effect = {
#	# Fujiwara
#	character:japanese_fujiwara_460 ?= { save_scope_as = tadamichi_fujiwara } # Father of Motofusa
#	character:japanese_fujiwara_461 ?= { save_scope_as = motozane_fujiwara } # Brother of Motofusa, last true Kampaku
#	character:japanese_fujiwara_497 ?= { save_scope_as = hidehira_fujiwara } # Oshu Fujiwara leader
#	character:japanese_fujiwara_511 ?= { save_scope_as = motofusa_fujiwara } # Fujiwara leader
#	# Minamoto
#	character:japanese_minamoto_seiwa_9 ?= { save_scope_as = yoshitomo_minamoto } # Father of Yoritomo, killed in Heiji rebellion
#	character:japanese_minamoto_seiwa_10 ?= { save_scope_as = yoritomo_minamoto } # Kawachi Minamoto leader, first Shogun
#	character:japanese_minamoto_seiwa_139 ?= { save_scope_as = yoshitsune_minamoto } # Brother of Yoritomo, famous general
#	character:japanese_minamoto_seiwa_207 ?= { save_scope_as = yoshinaka_minamoto } # Yoshinaka, cousin of Yoritomo, and rival
#	character:japanese_minamoto_seiwa_205 ?= { save_scope_as = yoshikata_minamoto } # Father of Yoshinaka
#	character:japanese_minamoto_seiwa_59 ?= { save_scope_as = yorimasa_minamoto } # Settsu Minamoto leader, first seppuku-er
#	# Taira
#	character:japanese_taira_kanmu_34 ?= { save_scope_as = kiyomori_taira } # Ise Taira leader
#	character:japanese_taira_kanmu_68 ?= { save_scope_as = noriko_taira } # daughter of Kiyomori, wife of Norihito
#	# Yamato
#	character:japanese_yamato_54 ?= { save_scope_as = norihito_tenno } # Emperor Takakura
#	character:japanese_yamato_51 ?= { save_scope_as = go_shirakawa } # Father of Takakura
#	title:k_chrysanthemum_throne.holder ?= { save_scope_as = current_emperor }
#	#Get old emperor
#	scope:new_emperor.primary_title.previous_holder ?= {
#		save_scope_as = old_emperor
#	}
#}
#
######################################
## Minamoto Events
######################################
#
## (Kawachi) Minamoto Yoritomo
#
##Initial Event, explaining the situation
#tgp_genpei_character.1000 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.1000.t
#	desc = tgp_genpei_character.1000.desc
# 	window = big_event_window
#	theme = war
#	left_portrait = {
#		character = root
#		animation = anger
#	}
#	center_portrait = {
#		character = scope:yorimasa_minamoto
#		animation = war_over_win
#	}
#	right_portrait = {
#		character = scope:yoshinaka_minamoto
#		animation = disapproval
#	}
#	lower_center_portrait = scope:kiyomori_taira
#	lower_left_portrait = scope:norihito_tenno
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_scope_as = ruler
#		save_genpei_scopes_effect = yes
#	}
#	#Option A) #Choose to go your own way
#	option = { 
#		name = tgp_genpei_character.1000.a
#		custom_tooltip = tgp_genpei_character.1000.a.flavor
#		add_martial_lifestyle_xp = medium_lifestyle_xp
#		ai_chance = {
#			base = 0
#		}
#	}
#	#Option B) #Try to reconcile with your dynasty, to create a united front
#	option = { 
#		name = tgp_genpei_character.1000.b
#		flavor = tgp_genpei_character.1000.b.flavor
#		reverse_add_opinion = {
#			target = scope:yorimasa_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		reverse_add_opinion = {
#			target = scope:yoshinaka_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:yoshinaka_minamoto.house
#				VALUE = house_relation_improve_minor_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:yoshinaka_minamoto
#				TITLE = scope:dummy_gender
#			}
#		}
#		#Kiyomori players will want to fight Yoritomo, so we need ai to choose this
#		ai_chance = {
#			base = 100
#		}
#	}
#}
#
##After Kiyomori puts his grandson on the throne, a chance to get block leadership
#tgp_genpei_character.1010 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.1010.t
#	desc = {
#		desc = tgp_genpei_character.1010.desc.intro
#		first_valid = {
#			#You are bloc leader
#			triggered_desc = {
#				trigger = {
#					 house.house_confederation.leading_house.house_head ?= this
#				}
#				desc = tgp_genpei_character.1010.desc.blocboss	
#			}
#			#You are not bloc leader
#			desc = tgp_genpei_character.1010.desc.notblocboss
#		}
#	}
# 	window = big_event_window
#	theme = war
#	left_portrait = {
#		character = scope:ruler
#		animation = anger
#		camera = camera_body
#	}
#	center_portrait = {
#		character = scope:minamoto_ruler
#		animation = disapproval 
#	}
#	right_portrait = {
#		character = scope:kiyomori_taira
#		animation = war_over_win
#	}
#	lower_center_portrait = scope:yoshinaka_minamoto
#	lower_left_portrait = scope:new_emperor
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_scope_as = ruler
#		save_genpei_scopes_effect = yes
#
#		#find Minamoto 
#		top_liege ?= {
#			random_noble_family = {
#				limit = {
#					holder = {
#						this != root
#						dynasty ?= dynasty:japanese_minamoto_seiwa
#						house ?= {
#							exists = house_confederation
#							confederation.leading_house ?= house
#							NOT = { house_confederation = root.top_liege.house.house_confederation }
#						}
#					}
#				}
#				alternative_limit = {
#					holder = {
#						this != root 
#						dynasty ?= dynasty:japanese_minamoto_seiwa
#						house ?= {
#							exists = house_confederation
#							NOT = { house_confederation = root.top_liege.house.house_confederation }
#						}
#					}
#				}
#				holder = {
#					save_scope_as = minamoto_ruler
#					house = { save_scope_as = minamoto_house }
#				}
#			}
#		}
#	}
#	#Option A) #Rally the bloc, so you can become bloc leader
#	option = { 
#		name = tgp_genpei_character.1010.a
#		flavor = tgp_genpei_character.1010.a.flavor
#		custom_tooltip = tgp_genpei_character.1010.a.tt
#		#Boost relations with other houses in bloc so you can take leadership
#		hidden_effect = {
#			house.house_confederation = {
#				every_confederation_member_house = {
#					# Exclude self and leader
#					limit = {
#						NOR = {
#							this = root.house
#							this = root.house.house_confederation.leading_house
#						}
#					}
#					#Boost relations with other houses in bloc
#					change_house_relation_effect = {
#						HOUSE = root.house
#						VALUE = house_relation_improve_major_value
#						REASON = historical
#						CHAR = root
#						TARGET_CHAR = house_head
#						TITLE = scope:dummy_gender
#					}
#				}
#			}
#		}
#		#Make things bad with your bloc head since you're going to steal his bloc
#		house = {
#			change_house_relation_effect = {
#				HOUSE = house_confederation.leading_house
#				VALUE = house_relation_damage_minor_value
#				REASON = conflict 
#				CHAR = root
#				TARGET_CHAR = house_confederation.leading_house.house_head
#				TITLE = scope:dummy_gender
#			}
#		}
#		add_martial_lifestyle_xp = medium_lifestyle_xp
#		ai_chance = {
#			base = 75
#		}
#	}
#	#Option B) #Try to make nice with Kiyomori 
#	option = { 
#		name = tgp_genpei_character.1010.b
#		flavor = tgp_genpei_character.1010.b.flavor
#		add_character_modifier = {
#			modifier = confident_strategist
#			years = 5
#		}
#		reverse_add_opinion = {
#			target = scope:kiyomori_taira
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:kiyomori_taira.house
#				VALUE = house_relation_improve_minor_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:kiyomori_taira
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 25
#		}
#	}
#}
#
## (Kiso) Minamoto Yoshinaka
#
##Starting event for Yoshinaka that sets the given circumstances/objectives/obstacles/stakes 
#tgp_genpei_character.1090 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.1090.t
#	desc = tgp_genpei_character.1090.desc
# 	window = big_event_window
#	theme = war
#	override_background = bp3_hills_winter
#	left_portrait = {
#		character = root
#		animation = throne_room_one_handed_passive_1
#		camera = camera_body
#	}
#	right_portrait = {
#		character = scope:yoritomo_minamoto
#		animation = disapproval
#		camera = camera_event_right_pointing_left
#	}
#	lower_center_portrait = scope:kiyomori_taira
#	lower_left_portrait = scope:yoshikata_minamoto
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_scope_as = ruler
#		save_genpei_scopes_effect = yes
#	}
#	#Option A) #Choose to go your own way
#	option = { 
#		name = tgp_genpei_character.1090.a
#		flavor = tgp_genpei_character.1090.a.flavor
#		add_martial_lifestyle_xp = medium_lifestyle_xp
#		ai_chance = {
#			base = 75
#		}
#	}
#	#Option B) #Try to reconcile with your dynasty, to create a united front
#	option = { 
#		name = tgp_genpei_character.1090.b
#		reverse_add_opinion = {
#			target = scope:yorimasa_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		reverse_add_opinion = {
#			target = scope:yoritomo_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:yoritomo_minamoto.house
#				VALUE = house_relation_improve_minor_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:yoritomo_minamoto
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 25
#		}
#	}
#}
#
##After Kiyomori puts his grandson on the throne, a chance to align with Yoritomo or break up block leadership.
#scripted_effect tgp_yoshinaka_new_house_bloc_effect = {
##Create new bloc and steal members of Yoritomo's bloc
#	if = { # LEAVE OLD BLOC IF NECESSARY
#		limit = { is_confederation_member = yes }
#		house = {
#			set_variable = {
#				name = bloc_leaving_reason
#				value = flag:reason_events
#				days = 4
#			}
#			tgp_leave_house_bloc_effect = {
#				OPINION = flag:yes
#				TRUCE = flag:no
#			}
#		}
#	}
#	# CREATE NEW BLOC 
#	house = {
#		if = {
#			limit = {
#				NOT = { exists = house_confederation }
#			}
#			tgp_create_house_bloc_effect = { TYPE = none }
#		}
#	}
#	#Then steal members from the Yoritomo's bloc (only if they like him, and order by opinion)
#	scope:yoritomo_minamoto.house.house_confederation = {
#		save_scope_value_as = {
#			name = half_of_bloc
#			value = {
#				value = member_count 
#				multiply = 0.5
#			}
#		}
#
#		ordered_confederation_member_house = {
#			limit = {
#				#exclude self
#				NOR = {
#					this = root.house
#					this = house_confederation.leading_house
#				}
#			}
#			order_by = "house_head.opinion(root)"
#			max = scope:half_of_bloc
#			#always put this when there is a max or it will be unhappy who knows why
#			check_range_bounds = no
#			hidden_effect = {
#				set_variable = {
#					name = bloc_leaving_reason
#					value = flag:reason_events
#					days = 4
#				}
#				# LEAVE OLD BLOC
#				tgp_leave_house_bloc_effect = {
#					OPINION = flag:no
#					TRUCE = flag:yes
#				}
#			}
#			tgp_join_house_bloc_effect = {
#				INVITER = root.house
#				OPINION = flag:yes
#			}
#			custom_tooltip = {
#				text = join_house_bloc_yoshinaka_tt
#			}
#		}
#	}
#}
#tgp_genpei_character.1095 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.1095.t
#	desc = tgp_genpei_character.1095.desc
# 	window = big_event_window
#	theme = war
#	override_background = bp3_hills_winter
#	left_portrait = {
#		character = root
#		animation = throne_room_one_handed_passive_1
#		camera = camera_body
#	}
#	right_portrait = {
#		character = scope:yoritomo_minamoto
#		animation = disapproval
#		camera = camera_event_right_pointing_left
#	}
#	lower_right_portrait = scope:current_emperor
#	lower_center_portrait = scope:kiyomori_taira
#	lower_left_portrait = scope:yoshikata_minamoto 
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_scope_as = ruler
#		save_genpei_scopes_effect = yes
#	}
#	#Option A) #Go your own way
#	option = { 
#		name = tgp_genpei_character.1095.a
#		flavor = tgp_genpei_character.1095.a.flavor
#		add_martial_lifestyle_xp = medium_lifestyle_xp
#		
#		#If you're not the bloc leader, create new bloc and steal members of Yoritomo's bloc
#		if = {
#			limit = {
#				house.house_confederation.leading_house.house_head != root
#			}
#			#effect to create new bloc and steal members of Yoritomo's bloc
#			tgp_yoshinaka_new_house_bloc_effect = yes
#		}
#		custom_tooltip = tgp_genpei_character.1010.a.tt
#		#Boost relations with other houses in bloc so they are happy to roll with your decisions 
#		hidden_effect = {
#			house.house_confederation = {
#				every_confederation_member_house = {
#					# Exclude self and leader
#					limit = {
#						NOR = {
#							this = root.house
#							this = root.house.house_confederation.leading_house
#						}
#					}
#					#Boost relations with other houses in bloc
#					change_house_relation_effect = {
#						HOUSE = root.house
#						VALUE = house_relation_improve_minor_value
#						REASON = historical
#						CHAR = root
#						TARGET_CHAR = house_head
#						TITLE = scope:dummy_gender
#					}
#				}
#			}
#		}
#		
#		ai_chance = {
#			base = 0
#		}
#	}
#	#Option B) #Try to reconcile with your dynasty, to create a united front
#	option = { 
#		name = tgp_genpei_character.1095.b
#		flavor = tgp_genpei_character.1095.b.flavor
#		if = {
#			limit = {
#				has_relation_rival = scope:yoritomo_minamoto
#			}
#			remove_relation_rival = scope:yoritomo_minamoto
#		}
#		reverse_add_opinion = {
#			target = scope:yorimasa_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		reverse_add_opinion = {
#			target = scope:yoritomo_minamoto
#			modifier = attempts_of_a_united_minamoto_clan
#			opinion = 50
#		}
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:yoritomo_minamoto.house
#				VALUE = house_relation_improve_minor_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:yoritomo_minamoto
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 100
#		}
#	}
#}
#
## (Kawachi) Minamoto Yoshitsune
#
##Initial Event, explaining the situation
#tgp_genpei_character.1100 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.1100.t
#	desc = tgp_genpei_character.1100.desc
# 	window = big_event_window
#	theme = battle
#	override_background = { reference = army_camp }
#	left_portrait = {
#		character = root
#		animation = chudan_no_kamae
#	}
#	center_portrait = {
#		character = scope:hidehira_fujiwara
#		animation = war_over_tie
#	}
#
#	lower_left_portrait = scope:yoritomo_minamoto
#	lower_center_portrait = scope:yorimasa_minamoto
#	lower_right_portrait = scope:kiyomori_taira
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#		show_as_tooltip = { #There for context
#			set_relation_friend = { reason = friend_generic_history target = scope:hidehira_fujiwara }
#		}
#	}
#
#	option = { #Remain loyal to the Fujiwara Court
#		name = tgp_genpei_character.1100.a
#		add_trait = loyal
#		add_piety = minor_piety_value
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:hidehira_fujiwara.house
#				VALUE = house_relation_improve_medium_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:hidehira_fujiwara
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = { #Be more Minamoto Alligned
#		name = tgp_genpei_character.1100.b
#		dynasty = {
#			add_dynasty_prestige = medium_dynasty_prestige_gain
#			dynast = {
#				if = {
#					limit = {
#						is_ai = no
#					}
#					reverse_add_opinion = {
#						target = root
#						modifier = stood_with_minamoto_clan
#						opinion = 50
#					}
#				}
#				add_opinion = {
#					target = root
#					modifier = stood_with_minamoto_clan
#					opinion = 50
#				}
#			}
#		}
#		house = {
#			change_house_relation_effect = {
#				HOUSE = root.dynasty.dynast.house
#				VALUE = house_relation_improve_medium_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = root.dynasty.dynast
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 25
#		}
#	}
#
#	option = { #Go full adventurer; winning duels makes you stronger
#		name = tgp_genpei_character.1100.c
#		set_variable = {
#			name = ushiwakamaru_duels_won
#			value = 0
#		}
#		add_character_modifier = {
#			modifier = tgp_japan_ushiwakamaru
#			years = -1
#		}
#		give_nickname = nick_ushiwakamaru
#		custom_tooltip = stay_duelist_adventurer
#		ai_chance = {
#			base = 25
#		}
#	}
#}
#
#################################
## Taira Clan Events
#################################
#
## Kiyomori Taira
#
##Initial Event, setup up ambitions to put grandson on throne
#tgp_genpei_character.2000 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.2000.t
#	desc = tgp_genpei_character.2000.desc
#	theme = crown
#	override_background = { reference = tgp_asia_throne_room }
#	left_portrait = {
#		character = root
#		animation = personality_bold
#		camera = camera_body_right
#	}
#	center_portrait = {
#		character = scope:noriko_taira
#		animation = flirtation
#	}
#	right_portrait = {
#		character = scope:norihito_tenno
#		animation = holding_hu
#	}
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#
#		title:k_chrysanthemum_throne.holder ?= {
#			save_scope_as = current_emperor
#		}
#
#		random_courtier = {
#			limit = {
#				wet_nurse_validity_trigger = { EMPLOYER = scope:current_emperor }
#			}
#			save_scope_as = wet_nurse
#		}
#		if = {
#			limit = {
#				NOT = {
#					exists = scope:wet_nurse
#				}
#			}
#			create_character = {
#				template = bp2_wet_nurse_template 
#				location = root.location 
#				save_scope_as = wet_nurse
#			}
#		}
#	}
#	#Option A) Maintain the Status Quo, not upsetting any clans
#	option = { 
#		name = tgp_genpei_character.2000.a
#		every_vassal = {
#			custom = every_non_taira_vassal
#			limit = {
#				dynasty != root.dynasty
#			}
#			add_opinion = {
#				target = root
#				modifier = respected_status_quo
#				opinion = 15
#			}
#		}
#		stress_impact = {
#			ambitious = minor_stress_impact_gain
#			brave = minor_stress_impact_gain
#			arrogant = minor_stress_impact_gain
#			patient = medium_stress_impact_loss
#			craven = minor_stress_impact_loss
#		}
#		ai_chance = {
#			base = 25
#		}
#	}
#
#	#Option B) Slander him
#	option = { 
#		name = tgp_genpei_character.2000.b
#		flavor = tgp_genpei_character.2000.b.flavor
#		add_intrigue_lifestyle_xp = medium_lifestyle_experience
#		add_prestige = minor_prestige_loss
#		if = {
#			limit = {
#				NOT = {
#					any_scheme = { 
#						scheme_type = slander
#						scheme_target_character = scope:norihito_tenno  
#					}
#				}	
#			}
#			#If we don't have a scheme, let's scheme with a boost
#			start_scheme = {
#				type = slander
#				target_character = scope:norihito_tenno
#			}		
#		}
#		custom_tooltip = {
#			text = tgp_japan_yearly_events.1200.b.tt
#			random_scheme = {
#				limit = { 
#					scheme_type = slander
#					scheme_target_character = scope:norihito_tenno
#				}
#				add_scheme_modifier = {  type = bided_my_time }
#			}
#		}
#		stress_impact = {
#			arrogant = minor_stress_impact_gain
#			brave = minor_stress_impact_gain
#			patient = minor_stress_impact_loss
#			vengeful = medium_stress_impact_loss
#			ambitious = minor_stress_impact_loss
#		}
#		ai_chance = {
#			base = 75
#		}
#	}
#
#	#Option B) Get wet nurse for family
#	option = { 
#		name = tgp_genpei_character.2000.c
#		flavor = tgp_genpei_character.2000.c.flavor
#		trigger = {
#			scope:wet_nurse = {
#				would_be_valid_for_court_position = {
#					employer = scope:norihito_tenno
#					court_position = court_physician_court_position
#				}
#			}
#		}
#		remove_short_term_gold = minor_gold_value	 
#		#give wetnurse
#		court_position_grant_effect = { 
#			POS = wet_nurse 
#			CANDIDATE = scope:wet_nurse 
#			EMPLOYER = scope:norihito_tenno 
#		}
#		scope:norihito_tenno = {
#			add_opinion = {
#				target = root
#				modifier = sent_me_support
#				opinion = 15
#			}
#		}
#		ai_chance = {
#			base = 25
#		}
#	}
#}
#
##Replacing Current Emperor with a Relative
#tgp_genpei_character.2010 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.2010.t
#	desc = tgp_genpei_character.2010.desc
#	theme = intrigue
#	left_portrait = {
#		character = root
#		animation = interested
#		camera = camera_body_right
#	}
#	center_portrait = {
#		character = scope:previous_emperor
#		animation = crying
#	}
#	right_portrait = {
#		character = scope:go_shirakawa
#		animation = disapproval 
#	}
#	lower_left_portrait = scope:new_emperor
#	lower_center_portrait = scope:fujiwara_ruler
#	lower_right_portrait = scope:minamoto_ruler
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#		this = character:japanese_taira_kanmu_34
#		title:k_chrysanthemum_throne.holder ?= {
#			any_child = {
#				is_available_child = yes
#				trigger_if = {
#					limit = { is_male = yes }
#					faith_dominant_gender_male_or_equal = yes
#				}
#				trigger_else = { 
#					faith_dominant_gender_female_or_equal = yes 
#				}
#			}
#		}
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#		title:k_chrysanthemum_throne.holder ?= {
#			save_scope_as = previous_emperor
#			#find new emperor (ideally our grandson)
#			ordered_child = {
#				limit = {
#					is_available_child = yes
#					is_close_or_extended_family_of = scope:kiyomori_taira
#					OR = {
#						AND = {
#							faith_dominant_gender_male_or_equal = yes
#							is_male = yes
#						}
#						faith_dominant_gender_female_or_equal = yes
#					}
#				}
#				order_by = age
#				save_scope_as = new_emperor
#			}
#		}
#		#find Minamoto 
#		top_liege = {
#			random_noble_family = {
#				limit = {
#					holder = {
#						dynasty ?= dynasty:japanese_minamoto_seiwa
#						house ?= {
#							exists = house_confederation
#							confederation.leading_house ?= house
#							NOT = { house_confederation = root.top_liege.house.house_confederation }
#						}
#					}
#				}
#				alternative_limit = {
#					holder = {
#						dynasty ?= dynasty:japanese_minamoto_seiwa
#						house ?= {
#							exists = house_confederation
#							NOT = { house_confederation = root.top_liege.house.house_confederation }
#						}
#					}
#				}
#				holder = {
#					save_scope_as = minamoto_ruler
#					house = { save_scope_as = minamoto_house }
#				}
#			}
#		}
#		#find Fujiwara
#		random_vassal = {
#			limit = {
#				is_house_head = yes
#				house = house:house_fujiwara_matsudono
#				confederation.leading_house ?= house
#			}
#			alternative_limit = {
#				is_house_head = yes
#				house = house:house_fujiwara_matsudono
#			}
#			save_scope_as = fujiwara_ruler
#		}
#	}
#	#Option A) Replace the Emperor - Incur the Wrath of other major powers
#	option = {
#		name = tgp_genpei_character.2010.a
#		#Under no circumstances would an action like that be seen just
#		add_tyranny = 50 
#		add_dread = 30
#		#depose him!
#		scope:previous_emperor = { 
#			depose_effect = { 
#				DEPOSER = scope:new_emperor 
#			} 
#		}
#
#		scope:previous_emperor = {
#			if = {
#				limit = { is_ai = yes }
#				add_opinion = {
#					target = root
#					modifier = forced_my_abdication_opinion
#				}
#			}
#			if = {
#				limit = { can_set_relation_rival_trigger = { CHARACTER = root } }
#				set_relation_rival = {
#					target = root
#					reason = rival_forced_my_abdication_reason
#				}
#			}
#		}
#		
#		add_hook = {
#			target = scope:new_emperor
#			type = strong_influence_hook
#		}
#		
#		add_character_modifier = {
#			modifier = tgp_japan_control_over_emperor
#			years = 25
#		}
#
#		custom_tooltip = minamoto_clan_will_respond_to_our_actions
#		if = {
#			limit = {
#				exists = scope:minamoto_ruler
#			}
#			#Have the Yamatos join up with the Minamotos
#			scope:previous_emperor.house ?= {
#				if = {
#					limit = { exists = house_confederation }
#					set_variable = {
#						name = bloc_leaving_reason
#						value = flag:reason_events
#						days = 4
#					}
#					tgp_leave_house_bloc_effect = {
#						OPINION = flag:yes
#						TRUCE = flag:no
#					}
#				}
#				tgp_join_house_bloc_effect = {
#					INVITER = scope:minamoto_ruler.house
#					OPINION = flag:yes
#				}
#			}
#		}
#		
#		stress_impact = {
#			patient = minor_stress_impact_gain
#			arrogant = medium_stress_impact_loss
#			ambitious = minor_stress_impact_loss
#		}
#		#Might be forcing it, but this happening most of the time would be ideal
#		ai_chance = { 
#			base = 100
#		}
#		#Trigger event for Yoritomo to gain bloc leadership
#		scope:yoritomo_minamoto ?= {
#			trigger_event = {
#				id = tgp_genpei_character.1010
#				days = { 6 13 }
#			}
#		}
#		#Trigger event for Yoshinaka to support Yoritomo or gain bloc leadership
#		scope:yoshinaka_minamoto ?= {
#			trigger_event = {
#				id = tgp_genpei_character.1095
#				days = { 30 35 }
#			}
#		}
#	}
#	#Option B) Make common cause with the Fujiwara to eliminate the Minamoto
#	option = { 
#		name = tgp_genpei_character.2010.b
#		flavor = tgp_genpei_character.2010.b.flavor
#		add_prestige = minor_prestige_value
#		add_intrigue_lifestyle_xp = medium_lifestyle_experience
#		#Make things good with fujiwara
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:fujiwara_ruler.house
#				VALUE =  house_relation_improve_medium_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:fujiwara_ruler
#				TITLE = scope:dummy_gender
#			}
#		}
#		#Make things bad with minamoto 
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:minamoto_ruler.house
#				VALUE = house_relation_damage_major_value
#				REASON = conflict 
#				CHAR = root
#				TARGET_CHAR = scope:minamoto_ruler
#				TITLE = scope:dummy_gender
#			}
#		}
#		stress_impact = {
#			ambitious = medium_stress_impact_gain 
#			patient  = minor_stress_impact_loss	
#		}
#		ai_chance = {
#			base = 20
#		}
#	}
#	#Option C) Make common cause with the Minamoto to eliminate the Fujiwara (get bonus to becoming shogun)
#	option = { 
#		name = tgp_genpei_character.2010.c
#		flavor = tgp_genpei_character.2010.c.flavor		
#		add_prestige = minor_prestige_value
#		add_martial_lifestyle_xp = medium_lifestyle_experience
#		#Make things good with minamoto
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:minamoto_ruler.house
#				VALUE =  house_relation_improve_medium_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:minamoto_ruler
#				TITLE = scope:dummy_gender
#			}
#		}
#		#Make things bad with fujiwara  
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:fujiwara_ruler.house
#				VALUE = house_relation_damage_major_value
#				REASON = conflict 
#				CHAR = root
#				TARGET_CHAR = scope:fujiwara_ruler
#				TITLE = scope:dummy_gender
#			}
#		}
#		stress_impact = {
#			arrogant = medium_stress_impact_gain 
#			patient  = minor_stress_impact_loss	
#		}
#		ai_chance = {
#			base = 20
#		}
#	}
#	#Option D) #Reignite your friendship with Go Shirakawa 
#	option = { 
#		name = tgp_genpei_character.2010.d
#		flavor = tgp_genpei_character.2010.d.flavor
#		add_diplomacy_lifestyle_xp = medium_lifestyle_experience
#		add_piety = medium_piety_gain
#		if = {
#		#If we have a scheme, boost it!
#			limit = {
#				NOT = {
#					any_scheme = { 
#						scheme_type = befriend
#						scheme_target_character = scope:go_shirakawa  
#					}
#				}	
#			}
#			#If we don't have a scheme, let's scheme with a boost
#			start_scheme = {
#				type = befriend
#				target_character = scope:go_shirakawa
#			}			
#		}
#		custom_tooltip = {
#			text = tgp_japan_yearly_events.1200.c.tt
#			random_scheme = {
#				limit = { 
#					scheme_type = befriend
#					scheme_target_character = scope:go_shirakawa
#				}
#				add_scheme_modifier = { type = settled_differences_modifier }
#			}
#		}
#		stress_impact = {
#			ambitious = minor_stress_impact_loss
#			patient = medium_stress_impact_loss
#		}
#		ai_chance = {
#			base = 10
#			modifier = {
#				factor = 0
#				has_trait = impatient
#				has_trait = paranoid
#				has_trait = arrogant
#				has_trait = shy
#			}
#		}
#	}
#}
#
#################################
## Fujiwara Related Events
################################
#
## Fujiwara Motofusa
#
## Initial EventWar being inevitable in Japan. Slander Kiyomori 2)Ally with Go Shirakawa or 3) Ally with Northern Fujiwara
#tgp_genpei_character.3000 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.3000.t
#	desc = tgp_genpei_character.3000.desc
#	window = big_event_window
#	theme = crown
#	left_portrait = {
#		character = scope:motofusa_fujiwara
#		animation = sadness
#	}
#
#	lower_left_portrait = scope:kiyomori_taira 
#	lower_center_portrait = scope:go_shirakawa
#	lower_right_portrait = scope:hidehira_fujiwara
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#	}
#	#Option A) Slander Kiyomori
#	option = { 
#		name = tgp_genpei_character.3000.a
#		flavor = tgp_genpei_character.3000.a.flavor
#
#		trigger = {
#			scope:kiyomori_taira ?= { is_alive = yes }
#		}
#
#		change_influence = medium_influence_loss
#		add_intrigue_lifestyle_xp = medium_lifestyle_experience
#		add_prestige = minor_prestige_gain
#		scope:kiyomori_taira = {
#			every_vassal_or_below = {
#				limit = { has_vassal_stance = courtly }
#				custom = every_courtly_vassal
#				add_opinion = {
#					modifier = admiration_opinion
#					target = scope:motofusa_fujiwara
#					opinion = 30
#				}
#			}
#		}
#		stress_impact = {
#			arrogant = minor_stress_impact_loss
#		}
#		ai_chance = {
#			base = 90
#		}
#	}
#	#Option B) #Send a letter to the retired Emperor
#	option = { 
#		name = tgp_genpei_character.3000.b
#		flavor = tgp_genpei_character.3000.b.flavor
#
#		trigger = {
#			scope:go_shirakawa ?= {
#				is_alive = yes
#				NOT = { house.house_confederation = root.house.house_confederation }
#			}
#		}
#		
#		custom_tooltip = send_letter_to_go_shirakawa
#
#		scope:go_shirakawa = {
#			show_as_tooltip = {
#				random_list = {
#					1 = {
#						add_prestige = major_prestige_gain
#					}
#					1 = {
#						house = {
#							tgp_join_house_bloc_effect = {
#								INVITER = scope:motofusa_fujiwara.house
#								OPINION = flag:no
#							}
#						}
#						set_relation_friend = { reason = friend_generic_history target = scope:motofusa_fujiwara }
#					}
#				}
#			}
#			trigger_event = {
#				id = tgp_genpei_character.3010
#				days = 1
#			}
#		} 
#
#		ai_chance = {
#			base = 10
#		}
#	}
#
#	#Option C) Improve relations with northern Fujiwara.
#	option = { 
#		name = tgp_genpei_character.3000.c
#		flavor = tgp_genpei_character.3000.c.flavor
#
#		trigger = {
#			exists = scope:hidehira_fujiwara
#			scope:hidehira_fujiwara ?= { is_alive = yes }
#		}
#
#		add_prestige = medium_prestige_loss
#		#Make things good with northern Fujiwara
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:hidehira_fujiwara.house
#				VALUE =  house_relation_improve_medium_value
#				REASON = friend
#				CHAR = root
#				TARGET_CHAR = scope:hidehira_fujiwara
#				TITLE = scope:dummy_gender
#			}
#		}
#		#Make things bad with the Taira  
#		house = {
#			change_house_relation_effect = {
#				HOUSE = scope:kiyomori_taira.house
#				VALUE = house_relation_damage_major_value
#				REASON = conflict 
#				CHAR = root
#				TARGET_CHAR = scope:kiyomori_taira
#				TITLE = scope:dummy_gender
#			}
#		}
#		ai_chance = {
#			base = 90
#		}
#	} 
#}
#
##Letter asking Go-Shirakawa for support
#tgp_genpei_character.3010 = {
#	type = letter_event
#	opening = tgp_genpei_character.3010.opening
#	desc = tgp_genpei_character.3010.desc
#		
#	sender = {
#		character = scope:motofusa_fujiwara
#		animation = beg
#	}
#
#	option = {
#		name = tgp_genpei_character.3010.a
#
#		add_prestige = major_prestige_gain
#
#		reverse_add_opinion = {
#			target = scope:motofusa_fujiwara
#			modifier = insulted_opinion
#			opinion = -25
#		}
#
#		ai_chance = {
#			base = 0
#		}
#	}
#
#	option = {
#		name = tgp_genpei_character.3010.b
#
#		house = {
#			tgp_join_house_bloc_effect = {
#				INVITER = scope:motofusa_fujiwara.house
#				OPINION = flag:no
#			}
#		}
#
#		set_relation_friend = { reason = friend_generic_history target = scope:motofusa_fujiwara }
#
#		ai_chance = {
#			base = 100
#		}
#	}
#}
#
## Fujiwara Hidehira
#
## Initial Event
#tgp_genpei_character.3100 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.3100.t
#	desc = tgp_genpei_character.3100.desc
#	theme = crown
#	left_portrait = {
#		character = root
#		animation = war_over_win
#	}
#	right_portrait = {
#		character = scope:yoshitsune_minamoto
#		animation = marshal
#	}
#	lower_right_portrait = scope:kiyomori_taira
#	lower_center_portrait = scope:motofusa_fujiwara
#	override_background = { reference = study }
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#	}
#
#	option = { # Accept your position as the Governor of the North
#		name = tgp_genpei_character.3100.a
#
#		domicile = {
#			add_domicile_building = japanese_manor_main_04
#		}
#
#		ai_chance = {
#			base = 25
#		}
#	}
#
#	option = { # Become more active in the Genpei Conflict about to break out
#		name = tgp_genpei_character.3100.b
#
#		show_as_tooltip = {
#			add_character_modifier = {
#				modifier = tgp_japan_fujiwara_hidehira_back_in_town
#				years = 25
#			}
#		}
#
#		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
#
#		add_intrigue_lifestyle_xp = medium_lifestyle_xp
#
#		ai_chance = {
#			base = 75
#		}
#	}
#}
#
#################################
## Yamato Events
#################################
#
## Go-Shirakawa Starting Event
#tgp_genpei_character.4000 = {
#	type = character_event
#	window = big_event_window
#	title = tgp_genpei_character.4000.t
#	desc = tgp_genpei_character.4000.desc
#	theme = crown
#	left_portrait = {
#		character = root
#		animation = sadness
#	}
#	right_portrait = {
#		character = scope:norihito_tenno
#		animation = holding_hu
#	}
#	lower_left_portrait = scope:yoritomo_minamoto
#	lower_right_portrait = scope:kiyomori_taira
#
#	trigger = {
#		has_tgp_dlc_trigger = yes
#	}
#
#	immediate = {
#		save_genpei_scopes_effect = yes
#	}
#
#	option = { # Be more active, opposing the Taira
#		name = tgp_genpei_character.4000.a
#
#		set_relation_rival = {
#			target = scope:kiyomori_taira
#			reason = rival_historical
#		}
#
#		change_influence = massive_influence_value
#
#		top_liege = {
#			every_vassal = {
#				custom = every_non_taira_vassal
#				limit = {
#					dynasty != scope:kiyomori_taira.dynasty
#					this != root
#				}
#				add_opinion = {
#					target = root
#					modifier = spoke_against_taira_rule
#					opinion = 25
#				}
#			}
#		}
#
#		ai_chance = {
#			base = 25
#		}
#	}
#
#	option = { # Bide your time, wait for an opportunity first
#		name = tgp_genpei_character.4000.b
#
#
#
#		stress_impact = {
#			impatient = major_stress_impact_gain
#		}
#
#		ai_chance = {
#			base = 75
#		}
#	}
#}
#