﻿namespace = KoH_holy_orders

#KoH Holy Order Event
#Courtesy of KoH
#Make top title the holder of the b_ title so it leases out
#A character needs to be alive in the Holy Order title or it won't work

#Even with these events Holy Orders still cannot hold counties like in CK2. This mostly impacts the Teutonic Order

#Orders
#Knights Hospitaller 	-- 1099
#Templar Order		    -- 1119 -Destroyed in 1307
#Knights of Calatrava   -- 1164
#Knights of Santiago	-- 1171
#Teutonic Order			-- 1192
	#- Teutonic State	-- 1225 (Baltics)

#Assassins				-- 1090 -Destroyed in 1275

#To do
#Additional bookmarks: 1194

#1099 

#Hospitaler Order

KoH_holy_orders.108 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.109 = { 
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.110 = {
	type = character_event
	hidden = yes
	
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}


#1124

#Templar Order
KoH_holy_orders.104 = {
	type = character_event
	hidden = yes
	
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.105 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.106 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.107 = {
	type = character_event
	hidden = yes
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#1166

#Templar Order
KoH_holy_orders.1 = {
	type = character_event
	hidden = yes
	
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.2 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}
#Kerake for hospitaler WILL NOT WORK UNTIL NEW BARONY
#KoH_holy_orders.3 = {
#	type = character_event
#	title = KoH_holy_orders.3.t
#	desc = KoH_holy_orders.3.d
#	
#	hidden = yes
#
#	immediate = {
#		faith = {
#			random_faith_holy_order = {
#				limit = {
#					leader = {
#						this = character:231000
#					}
#				}
#				save_scope_as = holy_order
#			}
#		}
#		title:b_kerake = {
#			lease_out_to = scope:holy_order
#		}
#	}
#}

#Calatrava Order
KoH_holy_orders.5 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#KoH_holy_orders.6 = {
#	type = character_event
#	title = KoH_holy_orders.6.t
#	desc = KoH_holy_orders.6.d
#	
#	hidden = yes
#
#	immediate = {
#		faith = {
#			random_faith_holy_order = {
#				limit = {
#					leader = {
#						this = character:73153
#					}
#				}
#				save_scope_as = holy_order
#			}
#		}
#		title:b_valeria = {
#			lease_out_to = scope:holy_order
#		}
#		title:b_cabaneros = {
#			lease_out_to = scope:holy_order
#		}
#		title:b_almader = {
#			lease_out_to = scope:holy_order
#		}
#	}
#}

##Setting Up Knights of Santiago 
##Formed in 1171
#KoH_holy_orders.7 = {
#	type = character_event
#	
#	
#	
#	hidden = yes
#
#	left_portrait = {
#		character = root
#		animation = personality_bold
#	}
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_santiago
#				}
#			}
#			save_scope_as = leader
#		}
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_mora.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_mora = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_mora
#			save_scope_as = santiago_holy_order
#		}
#
#		set_global_variable = {
#			name = santiago_holy_order_title
#			value = scope:santiago_holy_order.title
#		}
#	
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:santiago_holy_order_title = {
#			copy_title_history = title:d_knights_santiago
#		}
#		title:b_mentesa = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		title:b_altotajo = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_zurita = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_huete = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_mora.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_mentesa.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_altotajo.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_zurita.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_huete.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}

#Assassins

KoH_holy_orders.102 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.103 = {
	type = character_event
	hidden = yes

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}


##1186

#Templar Order
KoH_holy_orders.111 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.112 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
KoH_holy_orders.113 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.114 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.115 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.116 = {
	type = character_event
	hidden = yes

	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

##1204
#Start with .117
#Teutonic Order exists by this date but I don't have a barony to give them as the Templar Order has Acre. They weren't very relevant yet by this time anyway

#Templar Order
KoH_holy_orders.117 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.118 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_ascalon.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_ascalon = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_ascalon
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_ascalon.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
KoH_holy_orders.119 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alcaniz.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alcaniz = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alcaniz
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_alcaniz.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.120 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		
		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.121 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.122 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}


##1220

#Templar Order - Capital Acre
KoH_holy_orders.123 = {
	type = character_event
	
	
	
	hidden = yes
	
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_ascalon = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_ascalon.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 

KoH_holy_orders.124 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_baniyassyria = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_baniyassyria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.125 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.126 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.127 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.128 = {
	type = character_event
	
	
	
	hidden = yes
	

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic Order
#Hungary
KoH_holy_orders.129 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marosvasarhely.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marosvasarhely = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marosvasarhely
			save_scope_as = teuton_holy_order
		}

		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:teuton_holy_order_title = {
			copy_title_history = title:d_teutonic_order
		}
		
		title:b_balvanyos = {
			lease_out_to = scope:teuton_holy_order
		}

		create_holy_order_effect = yes

		title:b_marosvasarhely.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_balvanyos.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

##1229 

#Templar Order - Capital Acre
KoH_holy_orders.176 = {
	type = character_event
	
	
	
	hidden = yes
	

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_ascalon = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_ascalon.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 

KoH_holy_orders.177 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_baniyassyria = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_baniyassyria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.178 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.179 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.180 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.181 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.182 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.183 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
	
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}


##1241


#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.130 = {
	type = character_event
	
	
	
	hidden = yes
	

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened. Made under Antioch instead of Jerusalem

KoH_holy_orders.131 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.132 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.133 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.134 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.135 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.136 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.137 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}


##1267


#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.138 = {
	type = character_event
	
	
	
	hidden = yes
	
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened

KoH_holy_orders.139 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.140 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.141 = {
	type = character_event
	
	
	
	hidden = yes


	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.144 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.145 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}

		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

##1285


#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.146 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened

KoH_holy_orders.147 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.148 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.149 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.150 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}
	
		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.151 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

##1310

#Templar Order
#Pretty much gone by 1310. Needs to still 'exist' for the sake of the script as Holy Orders are made based on the order of the religion file. Will just place them in Portugal as that's where they ended up due to the King of Portugal's protection and renamed themselves to the Order of Christ

KoH_holy_orders.152 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mafra.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mafra = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_mafra
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_mafra.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order
#Now setup like Teutonic Order and Assassins as they now hold Rhodes

KoH_holy_orders.153 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = hospit
		}

		scope:hospit = {

			add_character_modifier = {
				modifier = koh_hospit
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Hospit_Knights
				men_at_arms = {
					type = teutonic_knights #Generic name for Holy Order units
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.154 = {
	type = character_event
	
	hidden = yes
	
	immediate = {
		get_title = title:b_lindos
		create_dynamic_title = {
			tier = kingdom
			name = "Hospitaller_Rhodes"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_knights_hospitaler.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_knights_hospitaler
			set_color_from_title = title:d_knights_hospitaler
			copy_title_history = title:d_knights_hospitaler
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_lindos.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_lindos
			save_scope_as = hospitaller_holy_order
		}

		scope:hospitaller_holy_order = {
			set_coa = d_knights_hospitaler
		}
		
		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_lindos.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_lindos = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_hospit_castle = yes
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.155 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.156 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.157 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.158 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {	
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

##1337
#Templar need characters added

#Templar Order
#Pretty much gone by 1310. Needs to still 'exist' for the sake of the script as Holy Orders are made based on the order of the religion file. Will just place them in Portugal as that's where they ended up due to the King of Portugal's protection and renamed themselves to the Order of Christ

KoH_holy_orders.159 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mafra.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mafra = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_mafra
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_mafra.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order
#Now setup like Teutonic Order and Assassins as they now hold Rhodes

KoH_holy_orders.160 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = hospit
		}

		scope:hospit = {

			add_character_modifier = {
				modifier = koh_hospit
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Hospit_Knights
				men_at_arms = {
					type = teutonic_knights #Generic name for Holy Order units
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.161 = {
	type = character_event
	
	hidden = yes
	
	immediate = {

		
		get_title = title:b_lindos
		create_dynamic_title = {
			tier = kingdom
			name = "Hospitaller_Rhodes"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_knights_hospitaler.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_knights_hospitaler
			set_color_from_title = title:d_knights_hospitaler
			copy_title_history = title:d_knights_hospitaler
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_lindos.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_lindos
			save_scope_as = hospitaller_holy_order
		}

		scope:hospitaller_holy_order = {
			set_coa = d_knights_hospitaler
		}
		
		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_lindos.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_lindos = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_hospit_castle = yes
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.162 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.163 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.164 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			#every_vassal = {
			#	every_courtier = {
			#		add_trait = order_member
			#		add_trait = education_martial_4
			#		set_character_faith = faith:catholic
			#	}
			#	add_trait = order_member
			#	add_trait = education_martial_4
			#	set_character_faith = faith:catholic
			#}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.165 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}


##1144


#Templar Order
KoH_holy_orders.166 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.167 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.168 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.169 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

##1194

#Templar Order
KoH_holy_orders.170 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.171 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
KoH_holy_orders.172 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.173 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.174 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.175 = {
	type = character_event
	
	
	
	hidden = yes
	
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#1297

#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.184 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_paphos.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_paphos = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_paphos
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_paphos.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened

KoH_holy_orders.185 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_kantara.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_kantara = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_kantara
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_kantara.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.186 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.187 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.188 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.189 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

#1258


#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.190 = {
	type = character_event
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened. Made under Antioch instead of Jerusalem

KoH_holy_orders.191 = {
	type = character_event
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.192 = {
	type = character_event
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.193 = {
	type = character_event
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.194 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.195 = {
	type = character_event
	
	hidden = yes
	
	
	immediate = {
		get_title = title:b_masyaf
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_masyaf.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_masyaf
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_masyaf.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_masyaf = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.196 = {
	type = character_event
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.197 = {
	type = character_event
	
	hidden = yes
	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"

		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

##1171




#1166

##Templar Order
#KoH_holy_orders.198 = {
#	type = character_event
#	hidden = yes
#	
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_templar
#				}
#			}
#			save_scope_as = leader
#		}
#	}
#	
#	option = {
#		name = KoH_holy_orders.1.a
#		
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_towerdavid = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_towerdavid
#			save_scope_as = templar_holy_order
#		}
#		
#		set_global_variable = {
#			name = templar_holy_order_title
#			value = scope:templar_holy_order.title
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:templar_holy_order_title = {
#			copy_title_history = title:d_knights_templar
#		}
#
#		title:b_acre = {
#			lease_out_to = scope:templar_holy_order
#		}
#
#	
#		title:b_towerdavid.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_acre.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		create_holy_order_effect = yes
#	}
#}
#
##Hospitaler Order
#
#KoH_holy_orders.199 = {
#	type = character_event
#	hidden = yes
#
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_hospitaler
#				}
#			}
#			save_scope_as = leader
#		}
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_bethgibelin = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_bethgibelin
#			save_scope_as = hospitaller_holy_order
#		}
#
#		set_global_variable = {
#			name = hospitaller_holy_order_title
#			value = scope:hospitaller_holy_order.title
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			} 
#		}
#		global_var:hospitaller_holy_order_title = {
#			copy_title_history = title:d_knights_hospitaler
#		}
#		
#		title:b_amioun = {
#			lease_out_to = scope:hospitaller_holy_order
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_bethgibelin.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_amioun.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
##Kerake for hospitaler WILL NOT WORK UNTIL NEW BARONY
##KoH_holy_orders.3 = {
##	type = character_event
##	title = KoH_holy_orders.3.t
##	desc = KoH_holy_orders.3.d
##	
##	hidden = yes
##
##	immediate = {
##		faith = {
##			random_faith_holy_order = {
##				limit = {
##					leader = {
##						this = character:231000
##					}
##				}
##				save_scope_as = holy_order
##			}
##		}
##		title:b_kerake = {
##			lease_out_to = scope:holy_order
##		}
##	}
##}
#
##Calatrava Order
#KoH_holy_orders.200 = {
#	type = character_event
#	hidden = yes
#
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_calatrava
#				}
#			}
#			save_scope_as = leader #73153 #207510
#		}
#
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_calatrava = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_calatrava
#			save_scope_as = calatrava_holy_order
#		}
#
#		title:b_valeria = { 
#			lease_out_to = scope:calatrava_holy_order 
#		} 
#		title:b_cabaneros = { 
#			lease_out_to = scope:calatrava_holy_order 
#		} 
#		title:b_almader = { 
#			lease_out_to = scope:calatrava_holy_order
#		}
#
#		set_global_variable = {
#			name = calatrava_holy_order_title
#			value = scope:calatrava_holy_order.title
#		}
#	
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:calatrava_holy_order_title = {
#			copy_title_history = title:d_knights_calatrava
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_calatrava.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_valeria.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_cabaneros.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_almader.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
#
#KoH_holy_orders.201 = {
#	type = character_event
#	title = KoH_holy_orders.6.t
#	desc = KoH_holy_orders.6.d
#	
#	hidden = yes
#
#	immediate = {
#		faith = {
#			random_faith_holy_order = {
#				limit = {
#					leader = {
#						this = character:73153
#					}
#				}
#				save_scope_as = holy_order
#			}
#		}
#		title:b_valeria = {
#			lease_out_to = scope:holy_order
#		}
#		title:b_cabaneros = {
#			lease_out_to = scope:holy_order
#		}
#		title:b_almader = {
#			lease_out_to = scope:holy_order
#		}
#	}
#}
#
##Setting Up Knights of Santiago 
##Formed in 1171
#KoH_holy_orders.202 = {
#	type = character_event
#	
#	
#	
#	hidden = yes
#
#	left_portrait = {
#		character = root
#		animation = personality_bold
#	}
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_santiago
#				}
#			}
#			save_scope_as = leader
#		}
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_mora.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_mora = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_mora
#			save_scope_as = santiago_holy_order
#		}
#
#		set_global_variable = {
#			name = santiago_holy_order_title
#			value = scope:santiago_holy_order.title
#		}
#	
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:santiago_holy_order_title = {
#			copy_title_history = title:d_knights_santiago
#		}
#		title:b_mentesa = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		title:b_altotajo = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_zurita = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_huete = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_mora.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_mentesa.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_altotajo.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_zurita.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_huete.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
#
##Assassins
#
#KoH_holy_orders.203 = {
#	type = character_event
#	hidden = yes
#
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_hashshashin
#				}
#			}
#			save_scope_as = asssassin
#		}
#
#		scope:asssassin = {
#
#			add_character_modifier = {
#				modifier = koh_assassins
#			}
#
#			add_gold = 100 #So that they have some money to lend out
#			add_piety_level = 2
#			add_gold = holy_order_starting_gold
#
#			every_vassal = {
#				every_courtier = {
#					add_trait = order_member
#					add_trait = education_intrigue_4
#					set_character_faith = faith:nizari
#				}
#				add_trait = order_member
#				add_trait = education_intrigue_4
#				set_character_faith = faith:nizari
#											  
#			}
#
#			every_courtier = {
#				add_trait = order_member
#				add_trait = education_intrigue_4
#				set_character_faith = faith:nizari
#											  
#			}
#			spawn_army = {
#				uses_supply = no
#				inheritable = yes
#				name = Assassins
#				men_at_arms = {
#					type = crossbowmen
#					stacks = 10
#				}
#				men_at_arms = {
#					type = bowmen
#					stacks = 15
#				}
#				location = capital_province
#			}
#		}
#	}
#}
#
#KoH_holy_orders.204 = {
#	type = character_event
#	hidden = yes
#
#	
#	immediate = {
#		get_title = title:b_alamut
#		create_dynamic_title = {
#			tier = kingdom
#			name = "Order_of_Hashshashin"
#		}
#		create_title_and_vassal_change = {
#			type = created
#			save_scope_as = change
#			add_claim_on_loss = no
#		}
#		scope:new_title = {
#			set_landless_title = yes
#			
#			set_no_automatic_claims = yes
#			set_definitive_form = yes
#			set_can_be_named_after_dynasty = no
#			change_title_holder = {
#				holder = title:d_hashshashin.holder
#				change = scope:change
#			}
#			add_title_law = holy_order_succession_law
#		}
#		resolve_title_and_vassal_change = scope:change
#		scope:new_title = { 
#			set_coa = d_hashshashin
#			set_color_from_title = title:d_hashshashin
#			copy_title_history = title:d_hashshashin
#		}
#
#		create_character = {
#			template = holy_order_leader_character
#			location = title:b_alamut.title_province
#			save_scope_as = leader
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_alamut
#			save_scope_as = assassin_holy_order
#		}
#
#		scope:assassin_holy_order = {
#			set_coa = d_hashshashin
#		}
#
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_alamut.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_alamut = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		give_assassins_castle = yes
#	}
#}

##1324

#Templar Order
#Pretty much gone by 1310. Needs to still 'exist' for the sake of the script as Holy Orders are made based on the order of the religion file. Will just place them in Portugal as that's where they ended up due to the King of Portugal's protection and renamed themselves to the Order of Christ

KoH_holy_orders.205 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mafra.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mafra = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_mafra
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_mafra.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order
#Now setup like Teutonic Order and Assassins as they now hold Rhodes

KoH_holy_orders.206 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = hospit
		}

		scope:hospit = {

			add_character_modifier = {
				modifier = koh_hospit
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Hospit_Knights
				men_at_arms = {
					type = teutonic_knights #Generic name for Holy Order units
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.207 = {
	type = character_event
	
	hidden = yes
	
	immediate = {
		get_title = title:b_lindos
		create_dynamic_title = {
			tier = kingdom
			name = "Hospitaller_Rhodes"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_knights_hospitaler.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_knights_hospitaler
			set_color_from_title = title:d_knights_hospitaler
			copy_title_history = title:d_knights_hospitaler
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_lindos.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_lindos
			save_scope_as = hospitaller_holy_order
		}

		scope:hospitaller_holy_order = {
			set_coa = d_knights_hospitaler
		}
		
		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_lindos.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_lindos = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_hospit_castle = yes
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.208 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.209 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.210 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.211 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {	
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}


##1211

#Templar Order
KoH_holy_orders.212 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.213 = {
	type = character_event
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_ascalon.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_ascalon = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_ascalon
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_ascalon.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
KoH_holy_orders.214 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alcaniz.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alcaniz = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alcaniz
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_alcaniz.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.215 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		
		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.216 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.217 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic Order
#Hungary
KoH_holy_orders.218 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marosvasarhely.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marosvasarhely = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marosvasarhely
			save_scope_as = teuton_holy_order
		}

		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:teuton_holy_order_title = {
			copy_title_history = title:d_teutonic_order
		}
		
		title:b_balvanyos = {
			lease_out_to = scope:teuton_holy_order
		}

		create_holy_order_effect = yes

		title:b_marosvasarhely.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_balvanyos.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}


#1166

#Templar Order
KoH_holy_orders.219 = {
	type = character_event
	hidden = yes
	
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_towerdavid = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_towerdavid
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}

		title:b_acre = {
			lease_out_to = scope:templar_holy_order
		}

	
		title:b_towerdavid.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order

KoH_holy_orders.220 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_bethgibelin = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_bethgibelin
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}
		
		title:b_amioun = {
			lease_out_to = scope:hospitaller_holy_order
		}

		create_holy_order_effect = yes

		title:b_bethgibelin.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
KoH_holy_orders.221 = {
	type = character_event
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.222 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.223 = {
	type = character_event
	hidden = yes

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

##1186

##Templar Order
#KoH_holy_orders.224 = {
#	type = character_event
#	hidden = yes
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_templar
#				}
#			}
#			save_scope_as = leader
#		}
#	}
#	
#	option = {
#		name = KoH_holy_orders.1.a
#		
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_towerdavid.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_towerdavid = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_towerdavid
#			save_scope_as = templar_holy_order
#		}
#		
#		set_global_variable = {
#			name = templar_holy_order_title
#			value = scope:templar_holy_order.title
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:templar_holy_order_title = {
#			copy_title_history = title:d_knights_templar
#		}
#
#		title:b_acre = {
#			lease_out_to = scope:templar_holy_order
#		}
#
#	
#		title:b_towerdavid.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_acre.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		create_holy_order_effect = yes
#	}
#}
#
##Hospitaler Order
#
#KoH_holy_orders.225 = {
#	type = character_event
#	hidden = yes
#
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_hospitaler
#				}
#			}
#			save_scope_as = leader
#		}
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_bethgibelin.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_bethgibelin = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_bethgibelin
#			save_scope_as = hospitaller_holy_order
#		}
#
#		set_global_variable = {
#			name = hospitaller_holy_order_title
#			value = scope:hospitaller_holy_order.title
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			} 
#		}
#		global_var:hospitaller_holy_order_title = {
#			copy_title_history = title:d_knights_hospitaler
#		}
#		
#		title:b_amioun = {
#			lease_out_to = scope:hospitaller_holy_order
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_bethgibelin.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_amioun.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
#
##Calatrava Order
#KoH_holy_orders.226 = {
#	type = character_event
#	hidden = yes
#
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_calatrava
#				}
#			}
#			save_scope_as = leader #73153 #207510
#		}
#
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_calatrava = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_calatrava
#			save_scope_as = calatrava_holy_order
#		}
#
#		title:b_valeria = { 
#			lease_out_to = scope:calatrava_holy_order 
#		} 
#		title:b_cabaneros = { 
#			lease_out_to = scope:calatrava_holy_order 
#		} 
#		title:b_almader = { 
#			lease_out_to = scope:calatrava_holy_order
#		}
#
#		set_global_variable = {
#			name = calatrava_holy_order_title
#			value = scope:calatrava_holy_order.title
#		}
#	
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:calatrava_holy_order_title = {
#			copy_title_history = title:d_knights_calatrava
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_calatrava.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_valeria.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_cabaneros.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_almader.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
#
##Setting Up Knights of Santiago 
##Formed in 1171
#KoH_holy_orders.227 = {
#	type = character_event
#	hidden = yes
#	
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_knights_santiago
#				}
#			}
#			save_scope_as = leader
#		}
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_mora.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_mora = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_mora
#			save_scope_as = santiago_holy_order
#		}
#
#		set_global_variable = {
#			name = santiago_holy_order_title
#			value = scope:santiago_holy_order.title
#		}
#	
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		global_var:santiago_holy_order_title = {
#			copy_title_history = title:d_knights_santiago
#		}
#		title:b_mentesa = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		title:b_altotajo = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_zurita = {
#			lease_out_to = scope:santiago_holy_order
#		}
#		title:b_huete = {
#			lease_out_to = scope:santiago_holy_order
#		}
#
#		create_holy_order_effect = yes
#
#		title:b_mora.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_mentesa.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_altotajo.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_zurita.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#
#		title:b_huete.title_province = {
#			# Walls & Towers.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = curtain_walls_01 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = curtain_walls_01
#			}
#			# Barracks.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = barracks_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = barracks_05
#			}
#			# Military Camps.
#			if = {
#				limit = {
#					NOT = { has_building_or_higher = military_camps_05 }
#				}
#				# If it doesn't have a free building slot, give it one.
#				if = {
#					limit = { free_building_slots = 0 }
#					add_province_modifier = extra_building_slot
#				}
#				# Add the building.
#				add_building = military_camps_05
#			}
#		}
#	}
#}
#
##Assassins
#
#KoH_holy_orders.228 = {
#	type = character_event
#	hidden = yes
#
#	immediate = {
#		every_living_character = {
#			limit = {
#				any_held_title = {
#					this = title:d_hashshashin
#				}
#			}
#			save_scope_as = asssassin
#		}
#
#		scope:asssassin = {
#
#			add_character_modifier = {
#				modifier = koh_assassins
#			}
#
#			add_gold = 100 #So that they have some money to lend out
#			add_piety_level = 2
#			add_gold = holy_order_starting_gold
#
#			every_vassal = {
#				every_courtier = {
#					add_trait = order_member
#					add_trait = education_intrigue_4
#					set_character_faith = faith:nizari
#				}
#				add_trait = order_member
#				add_trait = education_intrigue_4
#				set_character_faith = faith:nizari
#			}
#
#			every_courtier = {
#				add_trait = order_member
#				add_trait = education_intrigue_4
#				set_character_faith = faith:nizari
#			}
#			spawn_army = {
#				uses_supply = no
#				inheritable = yes
#				name = Assassins
#				men_at_arms = {
#					type = crossbowmen
#					stacks = 10
#				}
#				men_at_arms = {
#					type = bowmen
#					stacks = 15
#				}
#				location = capital_province
#			}
#		}
#	}
#}
#
#KoH_holy_orders.229 = {
#	type = character_event
#	hidden = yes
#
#	immediate = {
#		get_title = title:b_alamut
#		create_dynamic_title = {
#			tier = kingdom
#			name = "Order_of_Hashshashin"
#		}
#		create_title_and_vassal_change = {
#			type = created
#			save_scope_as = change
#			add_claim_on_loss = no
#		}
#		scope:new_title = {
#			set_landless_title = yes
#			set_no_automatic_claims = yes
#			set_definitive_form = yes
#			set_can_be_named_after_dynasty = no
#			change_title_holder = {
#				holder = title:d_hashshashin.holder
#				change = scope:change
#			}
#			add_title_law = holy_order_succession_law
#		}
#		resolve_title_and_vassal_change = scope:change
#		scope:new_title = { 
#			set_coa = d_hashshashin
#			set_color_from_title = title:d_hashshashin
#			copy_title_history = title:d_hashshashin
#		}
#
#		create_character = {
#			template = holy_order_leader_character
#			location = title:b_alamut.title_province
#			save_scope_as = leader
#		}
#
#		create_holy_order = {
#			leader = scope:leader
#			capital = title:b_alamut
#			save_scope_as = assassin_holy_order
#		}
#
#		scope:assassin_holy_order = {
#			set_coa = d_hashshashin
#		}
#
#		hidden_effect = {
#			if = {
#				limit = { NOT = { title:b_alamut.holder = scope:leader } }
#				create_title_and_vassal_change = {
#					type = leased_out
#					save_scope_as = change
#					add_claim_on_loss = no
#				}
#				title:b_alamut = {
#					change_title_holder_include_vassals = {
#						holder = scope:leader
#						change = scope:change
#					}
#				}
#				resolve_title_and_vassal_change = scope:change
#			}
#		}
#
#		hidden_effect = {
#			scope:leader = {
#				add_gold = 100 #So that they have some money to lend out
#				add_piety_level = 2
#				add_gold = holy_order_starting_gold
#				every_courtier = {
#					add_trait = order_member
#				}
#			}
#		}
#		give_assassins_castle = yes
#	}
#}

##1250

#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.230 = {
	type = character_event
	
	
	
	hidden = yes
	

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_acre.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_acre = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_acre
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_acre.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened. Made under Antioch instead of Jerusalem

KoH_holy_orders.231 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_amioun.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_amioun = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_amioun
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_amioun.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.232 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.233 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins

KoH_holy_orders.234 = {
	type = character_event
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_hashshashin
				}
			}
			save_scope_as = asssassin
		}

		scope:asssassin = {

			add_character_modifier = {
				modifier = koh_assassins
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_intrigue_4
					set_character_faith = faith:nizari
				}
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_intrigue_4
				set_character_faith = faith:nizari
											  
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Assassins
				men_at_arms = {
					type = crossbowmen
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
		}
	}
}

KoH_holy_orders.235 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_alamut
		create_dynamic_title = {
			tier = kingdom
			name = "Order_of_Hashshashin"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_hashshashin.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_hashshashin
			set_color_from_title = title:d_hashshashin
			copy_title_history = title:d_hashshashin
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_alamut.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_alamut
			save_scope_as = assassin_holy_order
		}

		scope:assassin_holy_order = {
			set_coa = d_hashshashin
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_alamut.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_alamut = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		give_assassins_castle = yes
	}
}

#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.236 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.237 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}

#1295

#Templar Order - Capital Acre
#Weakened

KoH_holy_orders.238 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_templar
				}
			}
			save_scope_as = leader
		}
	}
	
	option = {
		name = KoH_holy_orders.1.a
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_paphos.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_paphos = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_paphos
			save_scope_as = templar_holy_order
		}
		
		set_global_variable = {
			name = templar_holy_order_title
			value = scope:templar_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:templar_holy_order_title = {
			copy_title_history = title:d_knights_templar
		}
	
		title:b_paphos.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		create_holy_order_effect = yes
	}
}

#Hospitaler Order - In Tripoli. 
#Weakened

KoH_holy_orders.239 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_hospitaler
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_kantara.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_kantara = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_kantara
			save_scope_as = hospitaller_holy_order
		}

		set_global_variable = {
			name = hospitaller_holy_order_title
			value = scope:hospitaller_holy_order.title
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			} 
		}
		global_var:hospitaller_holy_order_title = {
			copy_title_history = title:d_knights_hospitaler
		}

		create_holy_order_effect = yes

		title:b_kantara.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Calatrava Order
#Calatrava recovered

KoH_holy_orders.240 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_calatrava
				}
			}
			save_scope_as = leader #73153 #207510
		}

		hidden_effect = {
			if = {
				limit = { NOT = { title:b_calatrava.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_calatrava = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_calatrava
			save_scope_as = calatrava_holy_order
		}

		title:b_valeria = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_cabaneros = { 
			lease_out_to = scope:calatrava_holy_order 
		} 
		title:b_almader = { 
			lease_out_to = scope:calatrava_holy_order
		}

		set_global_variable = {
			name = calatrava_holy_order_title
			value = scope:calatrava_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:calatrava_holy_order_title = {
			copy_title_history = title:d_knights_calatrava
		}

		create_holy_order_effect = yes

		title:b_calatrava.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_valeria.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_cabaneros.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_almader.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Setting Up Knights of Santiago 
#Formed in 1171
KoH_holy_orders.241 = {
	type = character_event
	
	
	
	hidden = yes
	
	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_knights_santiago
				}
			}
			save_scope_as = leader
		}
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_mora.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_mora = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
		create_holy_order = {
			leader = scope:leader
			capital = title:b_mora
			save_scope_as = santiago_holy_order
		}

		set_global_variable = {
			name = santiago_holy_order_title
			value = scope:santiago_holy_order.title
		}
	
		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		global_var:santiago_holy_order_title = {
			copy_title_history = title:d_knights_santiago
		}
		title:b_mentesa = {
			lease_out_to = scope:santiago_holy_order
		}

		title:b_altotajo = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_zurita = {
			lease_out_to = scope:santiago_holy_order
		}
		title:b_huete = {
			lease_out_to = scope:santiago_holy_order
		}

		create_holy_order_effect = yes

		title:b_mora.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_mentesa.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_altotajo.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_zurita.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}

		title:b_huete.title_province = {
			# Walls & Towers.
			if = {
				limit = {
					NOT = { has_building_or_higher = curtain_walls_01 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = curtain_walls_01
			}
			# Barracks.
			if = {
				limit = {
					NOT = { has_building_or_higher = barracks_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = barracks_05
			}
			# Military Camps.
			if = {
				limit = {
					NOT = { has_building_or_higher = military_camps_05 }
				}
				# If it doesn't have a free building slot, give it one.
				if = {
					limit = { free_building_slots = 0 }
					add_province_modifier = extra_building_slot
				}
				# Add the building.
				add_building = military_camps_05
			}
		}
	}
}

#Assassins
#No longer has any holdings at this point due to the Mongols and never regain political power


#Teutonic State
#Now in Baltics. Using same system as the Assassins as Teutonic State holds land
#With this the 'Holy Order' hired by the player would be vassal of the Teutonic State

KoH_holy_orders.242 = {
	type = character_event
	
	
	
	hidden = yes

	immediate = {
		every_living_character = {
			limit = {
				any_held_title = {
					this = title:d_teutonic_order
				}
			}
			save_scope_as = teuton
		}

		scope:teuton = {

			add_character_modifier = {
				modifier = koh_teutons
			}

			add_gold = 100 #So that they have some money to lend out
			add_piety_level = 2
			add_gold = holy_order_starting_gold

			every_vassal = {
				every_courtier = {
					add_trait = order_member
					add_trait = education_martial_4
					set_character_faith = faith:catholic
				}
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}

			every_courtier = {
				add_trait = order_member
				add_trait = education_martial_4
				set_character_faith = faith:catholic
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = Teutonic_Knights
				men_at_arms = {
					type = teutonic_knights
					stacks = 10
				}
				men_at_arms = {
					type = bowmen
					stacks = 15
				}
				location = capital_province
			}
			
		}
	}
}

KoH_holy_orders.243 = {
	type = character_event
	
	
	
	hidden = yes

	
	immediate = {
		get_title = title:b_marienburg
		create_dynamic_title = {
			tier = kingdom
			name = "The_State_of_the_Teutonic_Order"
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_landless_title = yes
			
			set_no_automatic_claims = yes
			set_definitive_form = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = title:d_teutonic_order.holder
				change = scope:change
			}
			add_title_law = holy_order_succession_law
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = { 
			set_coa = d_teutonic_order
			set_color_from_title = title:d_teutonic_order
			copy_title_history = title:d_teutonic_order
			
		}

		create_character = {
			template = holy_order_leader_character
			location = title:b_marienburg.title_province
			save_scope_as = leader
		}

		create_holy_order = {
			leader = scope:leader
			capital = title:b_marienburg
			save_scope_as = teuton_holy_order
		}

		scope:teuton_holy_order = {
			set_coa = d_teutonic_order
		}
		
		set_global_variable = {
			name = teuton_holy_order_title
			value = scope:teuton_holy_order.title
		}
		
		hidden_effect = {
			if = {
				limit = { NOT = { title:b_marienburg.holder = scope:leader } }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				title:b_marienburg = {
					change_title_holder_include_vassals = {
						holder = scope:leader
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}

		hidden_effect = {
			scope:leader = {
				add_gold = 100 #So that they have some money to lend out
				add_piety_level = 2
				add_gold = holy_order_starting_gold
				every_courtier = {
					add_trait = order_member
				}
			}
		}
		

		
		give_teuton_castle = yes
	}
}


