﻿japan_demand_administrative_ai_score_value = {
	value = -15
	scope:attacker = {
		if = {
			limit = { current_strength_with_allies_fifty_percent_value > scope:defender.current_strength_with_allies_value }
			add = 25
		}
		if = {
			limit = { ai_boldness >= medium_positive_ai_value }
			add = 5
		}
		if = {
			limit = { ai_boldness >= very_high_positive_ai_value }
			add = 5
		}
	}
}

japan_demand_administrative_war_influence_value = {
	value = 0
	scope:attacker = {
		every_held_title = {
			limit = {
				is_landless_type_title = no
				is_noble_family_title = no
			}
			add = medium_influence_gain
		}
	}
}

japan_demand_administrative_war_prestige_value = {
	value = 0
	scope:attacker = {
		every_held_title = {
			limit = {
				is_landless_type_title = no
				is_noble_family_title = no
			}
			add = minor_prestige_value
		}
	}
}

japan_imperial_expansion_war_influence_value = {
	value = 0
	scope:attacker = {
		every_held_title = {
			limit = {
				is_landless_type_title = no
				is_noble_family_title = no
			}
			add = medium_influence_gain
		}
	}
}

japan_imperial_expansion_war_prestige_value = {
	value = 0
	scope:attacker = {
		every_held_title = {
			limit = {
				is_landless_type_title = no
				is_noble_family_title = no
			}
			add = minor_prestige_value
		}
	}
}

japan_imperial_expansion_ai_score_value = {
	value = 25
	scope:attacker = {
		if = {
			limit = { current_strength_with_allies_fifty_percent_value > scope:defender.current_strength_with_allies_value }
			add = 25
		}
		if = {
			limit = { ai_boldness >= medium_positive_ai_value }
			add = 5
		}
		if = {
			limit = { ai_boldness >= very_high_positive_ai_value }
			add = 5
		}
	}
}

japan_imperial_reconquest_ai_score_value = {
	value = 25
	scope:attacker = {
		if = {
			limit = { current_strength_with_allies_fifty_percent_value > scope:defender.current_strength_with_allies_value }
			add = 25
		}
		if = {
			limit = { ai_boldness >= medium_positive_ai_value }
			add = 5
		}
		if = {
			limit = { ai_boldness >= very_high_positive_ai_value }
			add = 5
		}
	}
}

japan_imperial_reconquest_war_prestige_value = {
	value = 0
	scope:defender = {
		every_held_title = {
			limit = { empire = title:e_japan }
			add = minor_prestige_value
		}
	}
}

japan_imperial_reconquest_war_influence_value = {
	value = 0
	scope:defender = {
		every_held_title = {
			limit = { empire = title:e_japan }
			add = minor_influence_value
		}
	}
}

house_aspiration_shared_ai_score_value = {
	value = 0
	if = {
		limit = { house = { has_variable = recently_changed_aspiration } }
		add = -1000
	}
	if = {
		limit = { has_variable = recently_changed_aspiration }
		add = -1000
	}
	# Does not want to mess with House Bloc
	if = {
		limit = {
			exists = house
			exists = house.house_confederation
			exists = house.house_confederation.leading_house
			house.house_confederation.leading_house != house
			house.house_confederation.leading_house = { has_same_house_aspiration_as = root.house }
		}
		add = -50
	}
	# Specially if cohesion is high
	if = {
		limit = {
			house.house_confederation ?= { cohesion >= 50 }
		}
		add = -50
	}
}

house_aspiration_ceremony_ai_score_value = {
	value = 0
	root ?= {
		house = { # Reluctance to change
			if = {
				limit = {
					has_house_aspiration_parameter = ceremony_cheaper_feasts
					has_house_aspiration_parameter = determination_spymaster_task_support_schemes_efficiency
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = ceremony_marriage_acceptance
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = ceremony_marriage_acceptance
					}
				}
				add = 50
			}
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = ep2_activities_legacy_2 }
				add = 5
			}
			if = {
				limit = { has_dynasty_perk = glory_legacy_1 }
				add = 5
			}
		}
		# Kampaku
		if = { 
			limit = {
				government_allows = administrative
				is_independent_ruler = yes
			}
			add = 15
		}
		# Traits
		if = {
			limit = { has_trait = lifestyle_poet }
			add = 5
		}
		if = {
			limit = { has_trait = arrogant }
			add = 5
		}
		else_if = {
			limit = { has_trait = humble }
			add = -5
		}
		if = {
			limit = { has_trait = ambitious }
			add = 5
		}
		else_if = {
			limit = { has_trait = content }
			add = -5
		}
		if = {
			limit = { has_trait = gregarious }
			add = 5
		}
		else_if = {
			limit = { has_trait = shy }
			add = -5
		}
		# Skills
		add = {
			value = diplomacy
			divide = 2
		}
		# AI Values
		if = {
			limit = { ai_sociability > 0 }
			add = {
				value = ai_sociability
				multiply = 0.5
			}
		}
		# Government
		if = {
			limit = { government_has_flag = government_is_japan_feudal }
			add = -10
		}
		# History
		house = {
			if = {
				limit = {
					years_from_game_start < 5
					trigger_if = {
						limit = { game_start_date = 867.1.1 }
						OR = {
							# Fujiwara
							dynasty:japanese_fujiwara.dynasty_founder.house ?= this
							house:house_fujiwara_kyo_ke = this # Kyo Fujiwara
							house:house_fujiwara_nan_ke = this # Southern Fujiwara
							house:house_fujiwara_shiki_ke = this # Ceremonial Fujiwara
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							# Fujiwara
							dynasty:japanese_fujiwara.dynasty_founder.house ?= this # Fujiwara
							house:house_fujiwara_koichijo = this # Koichijo Fujiwara
							house:house_fujiwara_manatsu = this # Manatsu Fujiwara
							house:house_fujiwara_nakamikado = this # Nakamikado Fujiwara
							house:house_fujiwara_nan_ke = this # Southern Fujiwara
							house:house_fujiwara_ononomiya = this # Ononomiya Fujiwara
							house:house_fujiwara_sesonji = this # Sesonji Fujiwara
							house:house_fujiwara_shiki_ke = this # Ceremonial Fujiwara
							house:house_fujiwara_takaie = this # Takaie Fujiwara
							house:house_fujiwara_yamakage = this # Yamakage Fujiwara
							house:house_fujiwara_yoshikado = this # Yoshikado Fujiwara
							house:house_fujiwara_yoshiyo = this # Yoshiyo Fujiwara
							# Other
							dynasty:japanese_koremune.dynasty_founder.house ?= this # Koremune
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1178.10.1 }
						OR = {	
							# Fujiwara
							dynasty:japanese_fujiwara.dynasty_founder.house ?= this # Fujiwara
							house:house_fujiwara_hamuro = this # Hamuro Fujiwara
							house:house_fujiwara_kajuji = this # Kajuji Fujiwara
							house:house_fujiwara_kasannoin = this # Kasannoin Fujiwara
							house:house_fujiwara_kujo = this # Kujo Fujiwara
							house:house_fujiwara_matsudono = this # Matsudono Fujiwara
							house:house_fujiwara_mikohida = this # Mikohida Fujiwara
							house:house_fujiwara_oinomikado = this # Oinomikado Fujiwara
							house:house_fujiwara_rokujo = this # Rokujo Fujiwara
							house:house_fujiwara_shijo = this # Shijo Fujiwara
							house:house_fujiwara_yoshikado = this # Yoshikado Fujiwara
							# Minamoto
							dynasty:japanese_minamoto_uda.dynasty_founder.house ?= this # Uda Minamoto
							# Taira
							house:house_taira_takamune = this # Takamune Taira
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_determination_ai_score_value = {
	value = 0
	root ?= {
		house = { # Reluctance to change
			if = {
				limit = {
					has_house_aspiration_parameter = unlocks_japanese_manor_watch_house
					has_house_aspiration_parameter = determination_spymaster_task_support_schemes_efficiency
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = unlocks_japanese_manor_watch_house
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = unlocks_japanese_manor_watch_house
					}
				}
				add = 50
			}
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = guile_legacy_1 }
				add = 5
			}
		}
		# Skills
		add = {
			value = intrigue
			divide = 2
		}
		# Traits
		if = {
			limit = { has_trait = deceitful }
			add = 5
		}
		else_if = {
			limit = { has_trait = honest }
			add = -5
		}
		if = {
			limit = { has_trait = ambitious }
			add = 5
		}
		else_if = {
			limit = { has_trait = content }
			add = -5
		}
		if = {
			limit = { has_trait = patient }
			add = 5
		}
		else_if = {
			limit = { has_trait = impatient }
			add = -5
		}
		# AI Values
		if = {
			limit = { ai_honor < 0 }
			add = {
				value = ai_honor
				multiply = -0.5
			}
		}
		# Government
		if = {
			limit = { government_has_flag = government_is_japan_feudal }
			add = 5
		}
		# History
		house = {
			if = {
				limit = {
					trigger_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							# Minamoto
							house:house_minamoto_watanabe ?= this # Watanabe Minamoto
							# Taira
							house:house_taira_satsuma ?= this # Satsuma Taira
							# Other
							dynasty:japanese_abiru.dynasty_founder.house ?= this # Abiru
							dynasty:japanese_kikuchi.dynasty_founder.house ?= this # Kikuchi
							dynasty:japanese_kimotsuki.dynasty_founder.house ?= this # Kimotsuki
							dynasty:japanese_omiwa.dynasty_founder.house ?= this # Omiwa
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1178.10.1 }
						OR = {
							# Fujiwara
							house:house_fujiwara_ashikaga ?= this # Fujiwara Ashikaga
							# Taira
							dynasty:japanese_taira_kanmu.dynasty_founder.house ?= this # Kanmu Taira
							house:house_taira_kawagoe ?= this # Kawagoe Taira
							house:house_taira_oba ?= this # Oba Taira
							house:house_taira_satsuma ?= this # Satsuma Taira
							# Minamoto
							house:house_minamoto_hitachi ?= this # Satake Minamoto
							# Other
							dynasty:japanese_ito.dynasty_founder.house ?= this # Ito
							dynasty:japanese_osada.dynasty_founder.house ?= this # Osada
							dynasty:japanese_saeki_sanyo.dynasty_founder.house ?= this # Saeki
							dynasty:japanese_senoo.dynasty_founder.house ?= this # Seno'o
							house:house_tachibana_tokai ?= this # Tachibana Tokai
							dynasty:japanese_taguchi.dynasty_founder.house ?= this # Taguchi
							dynasty:japanese_yuasa.dynasty_founder.house ?= this # Yuasa
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_humility_ai_score_value = {
	value = 0
	root ?= {
		house = { # Reluctance to change
			if = {
				limit = {
					has_house_aspiration_parameter = unlocks_japanese_manor_shrine
					has_house_aspiration_parameter = humility_take_the_vows_bonus
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = unlocks_japanese_manor_shrine
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = unlocks_japanese_manor_shrine
					}
				}
				add = 50
			}
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = erudition_legacy_1 }
				add = 5
			}
		}
		# Skills
		add = {
			value = learning
			divide = 2
		}
		# Traits
		if = {
			limit = { has_trait = devoted }
			add = 5
		}
		if = {
			limit = { has_trait = zealous }
			add = 5
		}
		else_if = {
			limit = { has_trait = cynical }
			add = -5
		}
		if = {
			limit = { has_trait = content }
			add = 5
		}
		else_if = {
			limit = { has_trait = ambitious }
			add = -5
		}
		if = {
			limit = { has_trait = patient }
			add = 5
		}
		else_if = {
			limit = { has_trait = impatient }
			add = -5
		}
		# AI Values
		if = {
			limit = { ai_zeal > 0 }
			add = {
				value = ai_zeal
				multiply = 0.5
			}
		}
		# Government
		if = {
			limit = { government_has_flag = government_is_japan_feudal }
			add = -5
		}
		# History
		house = {
			if = {
				limit = {
					years_from_game_start < 5
					trigger_if = {
						limit = { game_start_date = 867.1.1 }
						OR = {
							house:house_nakatomi_onakatomi ?= this # Onakatomi
							dynasty:japanese_koremune.dynasty_founder.house ?= this # Koremune
							dynasty:japanese_tomo.dynasty_founder.house ?= this # Tomo
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							house:house_fujiwara_koichijo ?= this # Koichijo Fujiwara
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_prosperity_ai_score_value = {
	value = 0
	root ?= {
		house = { # Reluctance to change
			if = {
				limit = {
					has_house_aspiration_parameter = unlocks_japanese_manor_brewery
					has_house_aspiration_parameter = improved_stewardship_court_position_efficiency
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = unlocks_japanese_manor_brewery
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = unlocks_japanese_manor_brewery
					}
				}
				add = 50
			}
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = law_legacy_1 }
				add = 5
			}
		}
		# Skills
		add = stewardship
		# Traits
		if = {
			limit = { has_trait = greedy }
			add = 5
		}
		else_if = {
			limit = { has_trait = generous }
			add = -5
		}
		if = {
			limit = { has_trait = diligent }
			add = 5
		}
		else_if = {
			limit = { has_trait = lazy }
			add = -5
		}
		if = {
			limit = { has_trait = content }
			add = 5
		}
		else_if = {
			limit = { has_trait = ambitious }
			add = -5
		}
		# AI Values
		if = {
			limit = { ai_greed > 0 }
			add = {
				value = ai_greed
				multiply = 0.5
			}
		}
		# History
		house = {
			if = {
				limit = {
					years_from_game_start < 5
					trigger_if = {
						limit = { game_start_date = 867.1.1 }
						OR = {
							# Fujiwara
							house:house_fujiwara_manatsu ?= this # Manatsu Fujiwara
							house:house_fujiwara_uona ?= this # Uona Fujiwara
							# Minamoto
							dynasty:japanese_minamoto_montoku.dynasty_founder.house ?= this # Montoku Minamoto
							dynasty:japanese_minamoto_saga.dynasty_founder.house ?= this # Saga Minamoto
							# Other
							dynasty:japanese_kiyohara.dynasty_founder.house ?= this # Kiyohara
							dynasty:japanese_tachibana.dynasty_founder.house ?= this # Tachibana
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							# Taira
							house:house_taira_echigo ?= this # Echigo Taira
							# Other
							dynasty:japanese_kimiko.dynasty_founder.house ?= this # Kiyohara
							dynasty:japanese_kiyohara.dynasty_founder.house ?= this # Kiyohara
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1178.10.1 }
						OR = {
							# Fujiwara
							dynasty:japanese_fujiwara_oshu.dynasty_founder.house ?= this # Oshu Fujiwara
							# Minamoto
							house:house_minamoto_oshu_ishikawa ?= this # Oshu Ishikawa Minamoto
							# Taira
							house:house_taira_shibuya ?= this # Shibuya Taira
							# Other
							house:house_fujiwara_hizume ?= this # Hizume
							dynasty:japanese_kikuchi.dynasty_founder.house ?= this # Kikuchi
							dynasty:japanese_kimotsuki.dynasty_founder.house ?= this # Kimotsuki
							dynasty:japanese_kono.dynasty_founder.house ?= this # Kono
							dynasty:japanese_kusakabe.dynasty_founder.house ?= this # Kusakabe
							dynasty:japanese_okawa.dynasty_founder.house ?= this # Owaka
							dynasty:japanese_ouchi.dynasty_founder.house ?= this # Ouchi
							dynasty:japanese_sato.dynasty_founder.house ?= this # Sato
							dynasty:japanese_tagawa.dynasty_founder.house ?= this # Tagawa
							house:house_omiwa_usuki ?= this # Usuki
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_service_ai_score_value = {
	value = 0
	root ?= {
		house = {	
			if = { # Reluctance to change
				limit = {
					has_house_aspiration_parameter = unlocks_japanese_manor_archive
					has_house_aspiration_parameter = service_house_cheaper_influence_candidacy_investments
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = unlocks_japanese_manor_archive
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = unlocks_japanese_manor_archive
					}
				}
				add = 50
			}
		}
		# Ceremonial Liege
		if = {
			limit = { tgp_is_in_ceremonial_house_trigger = yes }
			add = 25
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = ep3_administrative_legacy_1 }
				add = 5
			}
			if = {
				limit = { has_dynasty_perk = erudition_legacy_1 }
				add = 5
			}
			if = {
				limit = { has_dynasty_perk = law_legacy_1 }
				add = 5
			}
		}
		# Skills
		add = {
			value = stewardship
			add = learning
			divide = 2
		}
		# Traits
		if = {
			limit = { has_trait = humble }
			add = 5
		}
		else_if = {
			limit = { has_trait = arrogant }
			add = -5
		}
		if = {
			limit = { has_trait = diligent }
			add = 5
		}
		else_if = {
			limit = { has_trait = lazy }
			add = -5
		}
		if = {
			limit = { has_trait = content }
			add = 5
		}
		else_if = {
			limit = { has_trait = ambitious }
			add = -5
		}
		# AI Values
		if = {
			limit = { ai_honor > 0 }
			add = {
				value = ai_honor
				multiply = 0.25
			}
			add = {
				value = ai_boldness
				multiply = -0.25
			}
		}
		# Government
		if = {
			limit = {	
				NOT = { government_allows = administrative }
			}
			add = -25
		}
		# History
		house = {
			if = {
				limit = {
					years_from_game_start < 5
					trigger_if = {
						limit = { game_start_date = 867.1.1 }
						OR = {
							# Minamoto
							dynasty:japanese_minamoto_ninmyo.dynasty_founder.house ?= this # Ninmyo Minamoto
							# Other
							dynasty:japanese_ariwara.dynasty_founder.house ?= this # Ariwara
							dynasty:japanese_harusumi.dynasty_founder.house ?= this # Harusumi
							dynasty:japanese_ki.dynasty_founder.house ?= this # Ki
							dynasty:japanese_kudara.dynasty_founder.house ?= this # Kudara
							dynasty:japanese_oe.dynasty_founder.house ?= this # Oe
							dynasty:japanese_shimada.dynasty_founder.house ?= this # Shimada
							dynasty:japanese_sugawara.dynasty_founder.house ?= this # Sugawara
							dynasty:japanese_yamato.dynasty_founder.house ?= this # Yamato
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							# Fujiwara
							house:house_fujiwara_kajuji ?= this # Kajuji
							# Minamoto
							dynasty:japanese_minamoto_daigo.dynasty_founder.house ?= this # Daigo Minamoto
							dynasty:japanese_minamoto_murakami.dynasty_founder.house ?= this # Murakami Minamoto
							dynasty:japanese_minamoto_sanjo.dynasty_founder.house ?= this # Sanjo Minamoto
							dynasty:japanese_minamoto_uda.dynasty_founder.house ?= this # Uda Minamoto
							# Other
							dynasty:japanese_ki.dynasty_founder.house ?= this # Ki
							dynasty:japanese_oe.dynasty_founder.house ?= this # Oe
							dynasty:japanese_sugawara.dynasty_founder.house ?= this # Sugawara
							dynasty:japanese_tachibana.dynasty_founder.house ?= this # Tachibana
							dynasty:japanese_yamato.dynasty_founder.house ?= this # Yamato
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1178.10.1 }
						OR = {
							dynasty:japanese_yamato.dynasty_founder.house ?= this # Yamato
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_strength_ai_score_value = {
	value = 0
	root ?= {
		house = {
			if = { # Reluctance to change
				limit = {
					has_house_aspiration_parameter = unlocks_japanese_manor_armory
					has_house_aspiration_parameter = strength_train_with_troops_decision
				}
				add = 10
			}
			if = { # Attraction to conformity
				limit = {
					house_confederation.leading_house ?= {
						NOT = { this = root.house }
						has_house_aspiration_parameter = unlocks_japanese_manor_armory
						house_head.military_power > root.military_power
					}
				}
				add = 5
			}
			if = { # Stubbornness of leader
				limit = {
					house_confederation.leading_house ?= {
						this = root.house
						has_house_aspiration_parameter = unlocks_japanese_manor_armory
					}
				}
				add = 50
			}
		}
		# Dynasty Perks
		dynasty = {
			if = {
				limit = { has_dynasty_perk = warfare_legacy_1 }
				add = 5
			}
		}
		# Skills
		add = martial
		# Traits
		if = {
			limit = { has_trait = brave }
			add = 5
		}
		else_if = {
			limit = { has_trait = craven }
			add = -5
		}
		if = {
			limit = { has_trait = ambitious }
			add = 5
		}
		else_if = {
			limit = { has_trait = content }
			add = -5
		}
		if = {
			limit = { has_trait = vengeful }
			add = 5
		}
		else_if = {
			limit = { has_trait = forgiving }
			add = -5
		}
		# AI Values
		if = {
			limit = { ai_boldness > 0 }
			add = {
				value = ai_boldness
				multiply = 0.5
			}
		}
		# Government
		if = {
			limit = {
				government_allows = administrative
				NOT = { vassal_contract_has_flag = japan_administrative_military_appointment }
			}
			add = -10
		}
		# History
		house = {
			if = {
				limit = {
					years_from_game_start < 5
					trigger_if = {
						limit = { game_start_date = 867.1.1 }
						OR = {
							# Other
							dynasty:japanese_abe.dynasty_founder.house ?= this # Abe
							dynasty:japanese_ono.dynasty_founder.house ?= this # Ono
							dynasty:japanese_yoshimine.dynasty_founder.house ?= this # Yoshimine
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1066.9.15 }
						OR = {
							# Minamoto
							house:house_minamoto_kawachi ?= this # Kawachi Minamoto
							house:house_minamoto_mino ?= this # Mino Minamoto
							house:house_minamoto_settsu ?= this # Settsu Minamoto
							house:house_minamoto_shinano ?= this # Shinano Minamoto
							house:house_minamoto_yamato ?= this # Yamato Minamoto
							# Taira
							house:house_taira_boso ?= this # Boso Taira
							house:house_taira_chichibu ?= this # Chichibu Taira
							house:house_taira_hitachi ?= this # Daijo Taira
							house:house_taira_miura ?= this # Miura Taira
							house:house_taira_iwaki ?= this # Iwaki Taira
						}
					}
					trigger_else_if = {
						limit = { game_start_date = 1178.10.1 }
						OR = {
							# Minamoto
							house:house_minamoto_ishikawa ?= this # Ishikawa Minamoto
							house:house_minamoto_kai ?= this # Kai Minamoto (Takeda)
							house:house_minamoto_kawachi ?= this # Kawachi Minamoto
							house:house_minamoto_kiso ?= this # Kiso Minamoto (Shinano)
							house:house_minamoto_kozuke ?= this # Kozuke Minamoto (Nitta)
							dynasty:japanese_minamoto_seiwa.dynasty_founder.house ?= this # Seiwa Minamoto
							house:house_minamoto_toki ?= this # Toki Minamoto
							house:house_minamoto_settsu ?= this # Settsu Minamoto
							house:house_minamoto_yamamoto ?= this # Yamamoto Minamoto
							house:house_minamoto_yamato ?= this # Yamato Minamoto
							# Taira
							house:house_taira_chiba ?= this # Chiba Taira
							house:house_taira_kazusa ?= this # Kazusa Taira
							house:house_taira_miura ?= this # Miura Taira
						}
					}
					trigger_else = { always = no }
				}
				add = house_aspiration_bookmark_ai_score_value
			}
		}
		#
		add = house_aspiration_shared_ai_score_value
		# If you already have an aspiration, never sidegrade
		if = {
			limit = {
				has_japanese_house_aspiration_trigger = yes
			}
			multiply = 0
		}
	}
}

house_aspiration_bookmark_ai_score_value = 100

# Imperial Policies Japan
#TODO_CD_TGP_AJ; double check if these values are enough
tgp_religious_reform_law_faith_conversion_mult_value = 2
tgp_disarmament_law_increased_cb_cost_value = 0.5

tgp_japan_shogunate_ritsuryo_county_current_value = {
	value = 0
	title:e_japan = {
		every_de_jure_county = {
			limit = {
				holder = { has_government = japan_administrative_government }
			}
			add = 1
		}
	}
}

japan_administrative_province_military_max_value = 4
japan_administrative_province_trade_max_value = 4

house_aspiration_level_1_cost_value = 1000
house_aspiration_level_2_cost_value = 2500
house_aspiration_level_3_cost_value = 5000

determination_cohesion_reward_agent_join_value = 75

bloc_leader_change_aspiration_cohesion_value = {
	value = cohesion
	multiply = -0.33
}

tgp_bloc_war_defeat_cohesion_victory_value = {
	value = 10
	max = {
		value = 100
		subtract = cohesion
	}
	min = 0
}
tgp_bloc_war_defeat_cohesion_defeat_value = {
	value = cohesion
	divide = 3
	multiply = -1
	max = 0
}
tgp_bloc_war_member_transfer_value = {
	value = 0
	house.house_confederation = {
		leading_house = { save_temporary_scope_as = leading_house_temp }
		every_confederation_member_house = {
			limit = {
				house_head = {
					tgp_bloc_war_transfer_trigger = { BLOC_LEADER = scope:leading_house_temp.house_head }
				}
			}
			add = 1
		}
	}
}

# Bloc war
japan_bloc_war_ai_score_value = {
	value = 10
	scope:attacker = {
		# Personality
		if = {
			limit = { ai_boldness >= medium_positive_ai_value }
			add = 5
		}
		if = {
			limit = { ai_boldness >= very_high_positive_ai_value }
			add = ai_boldness
		}
		# Cohesion
		if = {
			limit = { house.house_confederation.cohesion < 50 }
			add = 10
		}
		if = {
			limit = { house.house_confederation.cohesion < 25 }
			add = 10
		}
	}
	# Gained Bloc members
	scope:defender.house.house_confederation = {
		every_confederation_member_house = {
			limit = {
				house_head = {
					tgp_bloc_war_transfer_trigger = { BLOC_LEADER = scope:defender } #Unop scope:defender is the house head of the leading house in this case
				}
			}
			add = 5
		}
	}
	# TODO_CD_JP_TGP AWAITING CODE SUPPORT
	# Military Power
	#scope:attacker = {
	#	if = {
	#		limit = { tgp_confederation_military_power < scope:defender.tgp_confederation_military_power_three_quarters }
	#		multiply = 0
	#	}
	#	else_if = {
	#		limit = { tgp_confederation_military_power_half > scope:defender.tgp_confederation_military_power }
	#		add = 25
	#	}
	#}
}

# Bloc Expansion
japan_install_bloc_member_ai_score_value = {
	value = 10
	scope:attacker = {
		if = {
			limit = {
				exists = house
				house.house_confederation.leading_house ?= this.house
			}
			add = 10
		}
		if = {
			limit = { ai_boldness >= medium_positive_ai_value }
			add = 5
		}
		if = {
			limit = { ai_boldness >= very_high_positive_ai_value }
			add = ai_boldness
		}
		# TODO_CD_TGP_JP AWAITING CODE SUPPORT
		# Military Power
		#if = {
		#	limit = {
		#		exists = scope:defender.house.house_confederation
		#		tgp_confederation_military_power < scope:defender.tgp_confederation_military_power_three_quarters
		#	}
		#	multiply = 0
		#}
		#else_if = {
		#	limit = {
		#		exists = scope:defender.house.house_confederation
		#		tgp_confederation_military_power_half > scope:defender.tgp_confederation_military_power
		#	}
		#	add = 25
		#}
	}
}

assume_house_bloc_leadership_interaction_prestige_level_value = {
	value = prestige_level
	subtract = 2
}

house_eradicated_killed_members_value = {
	value = 0
	scope:winner = {
		every_killed_character = {
			limit = {
				death_reason = death_eradicated
				killer = scope:winner
				house = scope:loser.house
			}
			add = 1
		}
	}
}

house_eradicated_all_members_value = {
	value = 0
	every_house_member = {
		add = 1
	}
}

house_eradicated_duration_value = {
		value = 100
		multiply = house_eradicated_killed_members_value
		divide = house_eradicated_all_members_value
}

