##########################################
# COUNCILLOR TITLES
##########################################

#	attribute: This attribute is added to the ruler's for governance purposes
#	viceroy: This is the Viceroy title for de jure Kingdoms
#	allow: conditions for the character to hold the title
#	gain_effect: fires when the title is granted
#	lose_effect: fires when a title is lost through most causes
#	retire_effect: fires when a title is lost due to the character stepping down, or getting a different liege
#	death_effect: fires when a title is lost due to the character dying
#	The other fields are all character modifiers.
 
job_chancellor = {
	is_chancellor = yes
	is_voter = yes
	attribute = diplomacy
	dignity = 0.33
	opinion_effect = 25
	
	monthly_salary = 0.1
	monthly_prestige = 0.75
	
	allow = {
		can_be_chancellor_trigger = yes
	}
	dismiss_trigger = {
		FROM = {
			NOT = { 
				AND = {
					has_law = succession_voting_power_1
					ROOT = { is_powerful_vassal = yes }
				}
			}
			conditional_tooltip = {
				trigger = {
					has_character_flag = swapping_councillors
				}
				custom_tooltip = {
					text = not_swapping_tt
					hidden_tooltip = {
						NOT = {
							has_character_flag = swapping_councillors
						}
					}
				}
			}
		}
	}
	gain_effect = {
	}
	lose_effect = {
		if = {
			limit = {
				FROM = {
					NOT = {
						has_character_flag = swapping_councillors
					}
				}

				NOT = { trait = incapable }
				NOT = { trait = sick_incapable }
			}
			opinion = { who = FROM modifier = opinion_fired_from_council }
			opinion = { who = FROM modifier = opinion_recently_fired }
		}
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
	}
	retire_effect = {
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
		if = {
			limit = {
				NOT = {
					age = 65
				}
				health = 10
				NOT = {
					is_sick_or_injured_trigger = yes
				}
				can_be_councilmember_king_trigger = yes
			}
			
			FROM = { 
				opinion = { who = ROOT modifier = opinion_resigned_from_council }
			}
		}
	}
	
	action = action_statecraft
	action = action_improve_relations
	action = action_fabricate_claims
	action = action_clan_sentiment # Replaces Fabricate Claims for Nomads
	action = action_sow_dissent

	lift_fow = yes
}

job_marshal = {
	is_marshal = yes
	is_voter = yes
	attribute = martial
	dignity = 0.33
	opinion_effect = 25
	
	monthly_salary = 0.1
	monthly_prestige = 0.75
	
	allow = {
		can_be_marshal_trigger = yes
	}
	dismiss_trigger = {
		FROM = {
			NOT = { 
				AND = {
					has_law = succession_voting_power_1
					ROOT = { is_powerful_vassal = yes }
				}
			}
			conditional_tooltip = {
				trigger = {
					has_character_flag = swapping_councillors
				}
				custom_tooltip = {
					text = not_swapping_tt
					hidden_tooltip = {
						NOT = {
							has_character_flag = swapping_councillors
						}
					}
				}
			}
		}
	}
	gain_effect = {
		if = {
			limit = {
				FROM = { 
					has_law = succ_byzantine_elective 
					any_courtier_or_vassal = { 
						attribute_diff = { character = PREVPREV attribute = martial value = 5 } #Check if any other vassal or courtier has higher martial than current character. And check that said vassal or courtier would be a viable marshal.
						can_be_marshal_trigger = yes
						NOT = {
							character = ROOT
						}
					}
				}
			}
			if = {
				limit = {
					NOT = {  
						martial = 2
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -10 } }
			}
			else_if = {
				limit = {
					martial = 2
					NOT = {  
						martial = 4
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -5 } }
			}
			else_if = {
				limit = {
					martial = 4
					NOT = {  
						martial = 6
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -4 } }
			}
			else_if = {
				limit = {
					martial = 6
					NOT = {  
						martial = 8
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -3 } }
			}
			else_if = {
				limit = {
					martial = 8
					NOT = {  
						martial = 10
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -2 } }
			}
			else_if = {
				limit = {
					martial = 10
					NOT = {  
						martial = 12
					}
				}
				FROM = { change_variable = { which = byzantine_credibility_appointed_sycophant value = -1 } }
			}
		}
	}
	lose_effect = {
		if = {
			limit = {
				FROM = {
					NOT = {
						has_character_flag = swapping_councillors
					}
				}

				NOT = { trait = incapable }
				NOT = { trait = sick_incapable }
			}
			opinion = { who = FROM modifier = opinion_fired_from_council }
			opinion = { who = FROM modifier = opinion_recently_fired }
			character_event = { id = HFP.20806 days = 1 }
		}
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
	}
	retire_effect = {
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}

		if = {
			limit = {
				NOT = {
					age = 65
				}
				health = 10
				NOT = {
					is_sick_or_injured_trigger = yes
				}
				can_be_councilmember_king_trigger = yes
			}
			
			FROM = { 
				opinion = { who = ROOT modifier = opinion_resigned_from_council }
			}
		}
	}
	
	action = action_organize_army
	action = action_assist_arrest
	action = action_train_troops
	action = action_train_troops_nomadic
	action = action_advance_mil_tech
	action = action_organize_raid # Replaces action_advance_mil_tech for Tribes
	
	lift_fow = yes
}

job_treasurer = {
	is_treasurer = yes
	is_voter = yes
	attribute = stewardship
	dignity = 0.2
	opinion_effect = 25
	
	monthly_salary = 0.1
	monthly_prestige = 0.75
	
	allow = {
		can_be_treasurer_trigger = yes
	}
	dismiss_trigger = {
		FROM = {
			NOT = { 
				AND = {
					has_law = succession_voting_power_1
					ROOT = { is_powerful_vassal = yes }
				}
			}
			conditional_tooltip = {
				trigger = {
					has_character_flag = swapping_councillors
				}
				custom_tooltip = {
					text = not_swapping_tt
					hidden_tooltip = {
						NOT = {
							has_character_flag = swapping_councillors
						}
					}
				}
			}
		}
	}
	gain_effect = {
	}
	lose_effect = {
		if = {
			limit = {
				FROM = {
					NOT = {
						has_character_flag = swapping_councillors
					}
				}

				NOT = { trait = incapable }
				NOT = { trait = sick_incapable }
			}
			opinion = { who = FROM modifier = opinion_fired_from_council }
			opinion = { who = FROM modifier = opinion_recently_fired }
		}
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
	}
	retire_effect = {
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}

		if = {
			limit = {
				NOT = {
					age = 65
				}
				health = 10
				NOT = {
					is_sick_or_injured_trigger = yes
				}
				can_be_councilmember_king_trigger = yes
			}
			
			FROM = { 
				opinion = { who = ROOT modifier = opinion_resigned_from_council }
			}
		}
	}
	
	action = action_administer_realm
	action = action_squeeze_peasants
	action = action_collect_tribute # Replaces action_squeeze_peasants for Nomads
	action = action_settle_tribe # Replaces action_squeeze_peasants for Tribes
	action = action_oversee_construction
	action = action_advance_eco_tech
	action = action_build_legend # Replaces action_advance_eco_tech for Tribes
	
	lift_fow = yes
}

job_spymaster = {
	is_spymaster = yes
	is_voter = yes
	attribute = intrigue
	dignity = 0.1
	opinion_effect = 25
	
	monthly_salary = 0.1
	
	allow = {
		can_be_spymaster_trigger = yes
	}
	dismiss_trigger = {
		FROM = {
			NOT = { 
				AND = {
					has_law = succession_voting_power_1
					ROOT = { is_powerful_vassal = yes }
				}
			}
			conditional_tooltip = {
				trigger = {
					has_character_flag = swapping_councillors
				}
				custom_tooltip = {
					text = not_swapping_tt
					hidden_tooltip = {
						NOT = {
							has_character_flag = swapping_councillors
						}
					}
				}
			}
		}
	}
	gain_effect = {
	}
	lose_effect = {
		if = {
			limit = {
				FROM = {
					NOT = {
						has_character_flag = swapping_councillors
					}
				}

				NOT = { trait = incapable }
				NOT = { trait = sick_incapable }
			}
			opinion = { who = FROM modifier = opinion_fired_from_council }
			opinion = { who = FROM modifier = opinion_recently_fired }
		}
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
	}
	retire_effect = {
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}

		if = {
			limit = {
				NOT = {
					age = 65
				}
				health = 10
				NOT = {
					is_sick_or_injured_trigger = yes
				}
				can_be_councilmember_king_trigger = yes
			}
			
			FROM = { 
				opinion = { who = ROOT modifier = opinion_resigned_from_council }
			}
		}
	}
	
	action = action_uncover_plots
	action = action_uncover_plots_offmap	# Replaces action_uncover_plots if mystics is activated.
	action = action_sabotage_province
	action = action_organize_spies
	action = action_organize_spies_mystics
	action = action_study_technology

	lift_neighbor_fow = yes
}

job_spiritual = {
	is_spiritual = yes
	is_voter = yes
	attribute = learning
	dignity = 0.15
	opinion_effect = 25
	
	monthly_salary = 0.1
	monthly_piety = 0.5
	
	allow = {
		can_be_spiritual_trigger = yes
	}
	dismiss_trigger = {
		FROM = {
			OR = {
				NOT = { religion_group = muslim }
				NOT = { religion = ROOT }
			}
			NOT = { 
				AND = {
					has_law = succession_voting_power_1
					ROOT = { is_powerful_vassal = yes }
				}
			}
			conditional_tooltip = {
				trigger = {
					has_character_flag = swapping_councillors
				}
				custom_tooltip = {
					text = not_swapping_tt
					hidden_tooltip = {
						NOT = {
							has_character_flag = swapping_councillors
						}
					}
				}
			}
		}
	}
	gain_effect = {
	}
	lose_effect = {
		if = {
			limit = {
				FROM = {
					NOT = {
						has_character_flag = swapping_councillors
					}
				}

				NOT = { trait = incapable }
				NOT = { trait = sick_incapable }
			}
			opinion = { who = FROM modifier = opinion_fired_from_council }
			opinion = { who = FROM modifier = opinion_recently_fired }
		}
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}
	}
	retire_effect = {
		if = {
			limit = { has_character_flag = relic_hunter }
			character_event = { id = MNM.9034 }
		}

		if = {
			limit = {
				NOT = {
					age = 65
				}
				health = 12
				NOT = {
					is_sick_or_injured_trigger = yes
				}
				can_be_councilmember_king_trigger = yes
			}
			
			FROM = { 
				opinion = { who = ROOT modifier = opinion_resigned_from_council }
			}
		}
	}
	
	
	action = action_hunt_heretics
	action = action_inquisition
	action = action_advance_cul_tech
	action = action_improve_rel_relations
	action = action_charity
	action = action_build_zeal # Tribal replacement for 'action_advance_cul_tech'
	
	lift_fow = yes
}
