##############################################################################
# Groogy got bored a weekend again and made bunch of stuff
#
# Range ZE.15000 - ZE.15999
# New Horse Chancellor Events
#	ZE.15000 - ZE.15010
##############################################################################

## Written by Henrik "Groogy" Hansson

namespace = ZE

### Horse Chancellor
character_event = {
	id = ZE.15000
	desc = EVTDESC6317
	border = GFX_event_normal_frame_religion
	portrait = event_target:glitterhoof

	picture = {
		picture = GFX_evt_horse_friend
		trigger = { is_nomadic = yes }
	}
	picture = {
		picture = GFX_evt_courier
		trigger = { is_nomadic = no }
	}

	is_triggered_only = yes # on_five_year_pulse, random_events, lunatic_events

	ai = no # To save performance
	only_playable = yes
	has_dlc = "Conclave"
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		always = no # Disabled in CK2Plus
		trait = lunatic

		NOT = {
			has_game_rule = {
				name = silly_events
				value = off
			}
		}

		any_voter = {
			has_job_title = job_chancellor
			NOT = { race = horse }

			trigger_if = {
				limit = {
					ai = yes
					liege = { ai = yes }
				}

				has_game_rule = {
					name = silly_events
					value = unrestricted
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				any_courtier = {
					race = horse
					is_voter = no
				}
			}

			random_courtier = {
				limit = { race = horse }
				save_event_target_as = glitterhoof
			}
		}
		else = {
			create_character = {
				name = "Glitterhoof"
				female = 50
				age = 16
				religion = ROOT
				culture = horse
				race = horse
				dynasty = none
				add_trait = horse
				add_trait = imbecile
				add_trait = stubborn
				add_trait = attractive
				add_trait = strong
			}

			new_character = {
				save_event_target_as = glitterhoof
			}
		}
	}

	option = {
		name = EVTOPTA6317
		tooltip_info = lunatic

		job_chancellor = {
			show_scope_change = no

			opinion = {
				name = opinion_fired_from_council
				who = ROOT
				years = 5
			}

			character_event = { id = 6318 }
			remove_title = job_chancellor
		}

		event_target:glitterhoof = {
			show_scope_change = no

			give_job_title = job_chancellor

			opinion = {
				name = opinion_my_master
				who = ROOT
				years = 100
			}

			reverse_opinion = {
				name = opinion_my_horse
				who = ROOT
				years = 100
			}
		}

		if = {
			limit = { has_dlc = "Jade Dragon" }

			character_event = {
				id = JD.60008 # Protect your horse
				months = 1
			}
		}

		if = {
			limit = { trait = immortal }

			character_event = {
				id = ZE.15002
				days = 10
			}
		}
	}
}

character_event = {
	id = ZE.15002
	desc = EVTDESCZE15002
	border = GFX_event_normal_frame_religion

	picture = {
		picture = GFX_evt_horse_friend
		trigger = { is_nomadic = yes }
	}
	picture = {
		picture = GFX_evt_courier
		trigger = { is_nomadic = no }
	}

	is_triggered_only = yes

	trigger = {
		trait = lunatic
		trait = immortal
	}

	option = {
		name = EVTOPTAZE15002

		event_target:glitterhoof = {
			show_scope_change = no

			add_trait = immortal
		}
	}

	option = {
		name = EVTOPTBZE15002
	}
}