########################################################
# MINOR TITLES
# Characters can have any number of these
########################################################
#	grant_limit: Max number of holders.
#	realm_in_name: Append the name of the country after the title (Queen [of Sweden])
#	allowed_to_hold: conditions for the character to hold the title
#	allowed_to_grant: conditions for a ruler to grant the title
#	regent: This is the title for regents (not really "minor")
#	gain_effect: fires when the title is granted
#	lose_effect: fires when a title is lost if dismissal_trigger evaluates to false
#	message: should fire a message to the its owner when set
#	The other fields are all character modifiers.

title_court_mage = {
	is_high_prio = yes
	attribute = learning
    dignity = 5
    realm_in_name = yes
	grant_limit = 1
	opinion_effect = 10
	monthly_salary = 0.2
	monthly_prestige = 0.5
	
	allowed_to_grant = {
		OR = {
			has_global_flag = magical_age_restored
			AND = {
				any_demesne_title = { title = k_britain }
				has_global_flag = merlin_appeared
				NOT = { has_global_flag = merlin_killed }
			}
			culture_group = elven
		}
		OR = {
			AND = {
				culture_group = elven
				higher_tier_than = COUNT
			}
			higher_tier_than = DUKE
			is_patrician = yes
		}
		NOR = {
			is_tribal = yes
			is_nomadic = yes
			religion_group = indian_group 
		}
		OR = {
			ai = no
			has_game_rule = {
				name = supernatural_events
				value = unrestricted
			}
		}
		NOT = {
			has_game_rule = {
				name = supernatural_events
				value = off
			}
		}
	}
	
	allowed_to_hold = {
		custom_tooltip = { text = court_mage_tooltip }
		hidden_tooltip = {
			OR = {
				primary_title = { temporary = no }
				NOT = {
					primary_title = {
						always = yes
					}
				}
			}
		}
		age = 35
		learning = 10
		OR = {
			trait = wizard
			trait = sorcerer
		}
		
		is_adult = yes
		prisoner = no
		NOT = { trait = in_hiding }
		NOT = { trait = incapable }
	}

	revoke_trigger = {
	}
	
	gain_effect = {
	}
	lose_effect = {
	}
	retire_effect = {
	}

	message = yes
}

title_mages_guild_apprentice = {
	is_high_prio = yes
	attribute = learning
    dignity = 1
    realm_in_name = no
	grant_limit = 1
	opinion_effect = 25
	monthly_salary = 0
	monthly_prestige = 0.1
	
	allowed_to_grant = {
		society_member_of = mages_guild
		is_landed = yes
		hidden_trigger = {
			NOT = { has_character_flag = is_merlin }
			NOT = { has_character_flag = is_morgana }
			NOT = { has_character_flag = is_lotl }
			OR = {
				ai = no
				NOR = {
					has_character_flag = took_apprentice
					trait = arbitrary
					trait = paranoid
					trait = slothful
				}
			}
		}
	}
	
	allowed_to_hold = {
		age > 5
		is_adult = no
		is_in_society = no

		NOT = { trait = in_hiding }
		NOT = { trait = incapable }
		prisoner = no
		
		NOR = {
			trait = apprentice_wizard
			trait = apprentice_sorcerer
		}
		
		hidden_trigger = {
			liege = { society_member_of = mages_guild }
			OR = {
				FROM = { ai = no }
				ai = yes
			}
			OR = {
				FROM = { ai = no }
				is_smart_trigger = yes
				NOR = {
					health_traits = 0
					trait = slow
					trait = imbecile
					trait = inbred
				}
			}
		}
	}

	revoke_trigger = {
		always = no
	}
	
	gain_effect = {
		if = {
			limit = { FROM = { trait = wizard } }
			add_trait = apprentice_wizard
		}
		if = {
			limit = { FROM = { trait = sorcerer } }
			add_trait = apprentice_sorcerer
		}
		set_guardian = FROM
		
		FROM = {
			if = {
				limit = { NOT = { has_character_flag = took_apprentice } }
				set_character_flag = took_apprentice
			}
			#if = {
			#	limit = { has_quest = quest_mages_guild_find_apprentice }
			#	character_event = { id = MNM.1409 }
			#}
		}
	}
	lose_effect = {
	}
	retire_effect = {
	}

	message = yes
}