﻿# Form the actual Mongol Empire...
form_the_greatest_khan_empire_effect = {
	save_scope_as = gok

	hidden_effect = {
		if = {
			limit = {
				culture = culture:mongol
			}
			#Create the title
			create_title_and_vassal_change = {
				type = created
				save_scope_as = title_change
				add_claim_on_loss = no
			}
	
			title:e_mongol_empire = {
				change_title_holder = {
					holder = scope:gok
					change = scope:title_change
				}
				save_scope_as = gok_title
			}
			resolve_title_and_vassal_change = scope:title_change
	
			assert_if = {
				limit = { NOT = { exists = title:e_mongol_empire } }
				text = "Mongol Empire title was not created!"
			}
		}
		else = {
			#You never know if they've switched government in the meantime just to ruin this whole thing...
			if = {
				limit = {
					government_has_flag = government_is_nomadic
					exists = domicile
				}
				create_dynamic_title = {
					tier = empire
					name = GREATEST_OF_KHANS_TITLE_DOMICILE_NAME
					adj = GREATEST_OF_KHANS_TITLE_DOMICILE_NAME_ADJ
					article = article_CONFEDERATION_CULTURE_NAME
				}
				scope:new_title = {
					save_scope_as = gok_title
				}
			}
			else = {
				create_dynamic_title = {
					tier = empire
					name = GREATEST_OF_KHANS_TITLE_NAME
					adj = GREATEST_OF_KHANS_TITLE_NAME_ADJ
					article = article_CONFEDERATION_CULTURE_NAME
				}
				scope:new_title = {
					save_scope_as = gok_title
				}
			}
			
			scope:gok_title = {
				set_color_from_title = root.capital_county
				set_definitive_form = yes
				set_can_be_named_after_dynasty = no
				set_can_use_nomadic_naming = no
			}
			
			create_title_and_vassal_change = {
				type = created
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:gok_title = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
			scope:gok_title = {
				if = {
					limit = {
						exists = root.house
					}
					set_coa = root.house
				}
				else = {
					generate_coa = yes
				}
			}
			assert_if = {
				limit = { NOT = { exists = scope:gok_title } }
				text = "Greatest of Khan's title was not created!"
			}
		}
		
		if = {
			limit = { NOT = { has_realm_law = single_heir_succession_kurultai_law } }
			add_realm_law_skip_effects = single_heir_succession_kurultai_law
		}

		set_primary_title_to = scope:gok_title
		every_held_title = {
			limit = {
				tier = tier_empire
				NOT = { this = scope:gok_title }
			}
			scope:gok = {
				destroy_title = prev
			}
		}
		if = {
			limit = {
				exists = capital_county.empire
				capital_county.empire = {
					NOT = {
						exists = holder
					}
				}
			}
			capital_county.empire = {
				save_scope_as = old_gok_empire
				every_in_de_jure_hierarchy = {
					limit = {
						tier = tier_kingdom
					}
					set_de_jure_liege_title = scope:gok_title
				}
			}
		}
	}
	
	
	spawn_gok_troops_effect = yes

	set_global_variable = {
		name = mongol_empire_has_spawned
		value = yes
	}
}

spawn_gok_troops_effect = {
	#Cultural MaA armies
	random_list = {
		#Mangudai armies
		2 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_cultural_parameter = unlock_maa_mangudai
					}
				}
				trigger_else = {
					culture = {
						has_cultural_parameter = unlock_maa_mangudai
					}
				}
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = mangudai
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mangudai
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = mangudai
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mangudai
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
		#Cataphract archers armies
		2 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_cultural_parameter = unlock_maa_cataphract_archers
					}
				}
				trigger_else = {
					culture = {
						has_cultural_parameter = unlock_maa_cataphract_archers
					}
				}
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = cataphract_archers
					stacks = gok_maa_smallish_value
				}
				men_at_arms = {
					type = cataphract_archers
					stacks = gok_maa_smallish_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = cataphract_archers
					stacks = gok_maa_smallish_value
				}
				men_at_arms = {
					type = cataphract_archers
					stacks = gok_maa_smallish_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
		#Maturkan warriors armies
		1 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_cultural_parameter = unlock_maa_maturkan_warriors
					}
				}
				trigger_else = {
					culture = {
						has_cultural_parameter = unlock_maa_maturkan_warriors
					}
				}
				
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = maturkan_warriors
					stacks = gok_maa_large_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = maturkan_warriors
					stacks = gok_maa_large_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
		#Mulathamun
		2 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_cultural_parameter = unlock_maa_mulaththamun
					}
				}
				trigger_else = {
					culture = {
						has_cultural_parameter = unlock_maa_mulaththamun
					}
				}
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mulaththamun
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mulaththamun
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mulaththamun
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = mulaththamun
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
		#Camel cavalry
		1 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_innovation = innovation_war_camels
					}
				}
				trigger_else = {
					culture = {
						has_innovation = innovation_war_camels
					}
				}
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = camel_rider
					stacks = gok_maa_large_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = camel_rider
					stacks = gok_maa_large_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
		#Generic fallback
		1 = {
			trigger = {
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						NOR = {
							has_cultural_parameter = unlock_maa_mangudai
							has_cultural_parameter = unlock_maa_cataphract_archers
							has_cultural_parameter = unlock_maa_maturkan_warriors
							has_cultural_parameter = unlock_maa_mulaththamun
							has_innovation = innovation_war_camels
						}
					}
				}
				trigger_else = {
					culture = {
						NOR = {
							has_cultural_parameter = unlock_maa_mangudai
							has_cultural_parameter = unlock_maa_cataphract_archers
							has_cultural_parameter = unlock_maa_maturkan_warriors
							has_cultural_parameter = unlock_maa_mulaththamun
							has_innovation = innovation_war_camels
						}
					}
				}
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = heavy_horse_archers
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
			spawn_army = {
				uses_supply = no
				inheritable = yes
				name = gok_event_troops
				men_at_arms = {
					type = nomadic_riders
					stacks = gok_nomadic_riders_large_value
				}
				men_at_arms = {
					type = horse_archers
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = heavy_horse_archers
					stacks = gok_maa_medium_value
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = gok_maa_largish_value
				}
				men_at_arms = {
					type = nomad_lancers
					stacks = gok_maa_smallish_value
				}
				location = capital_province
				origin = capital_province
			}
		}
	}
	#Siege weapon armies
	#Bombards
	if = {
		limit = {
			OR = {
				any_maa_regiment = {
					is_maa_type = bombard
				}
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_innovation = innovation_gunpowder
					}
				}
				culture = {
					has_innovation = innovation_gunpowder
				}
				#Any neighbor
				any_land_neighboring_realm_with_tributaries_owner = {
					culture = {
						has_innovation = innovation_gunpowder
					}
				}
				#Any culture in same empire as realm
				any_culture_global = {
					any_culture_empire = {
						any_de_jure_county = {
							OR = {
								holder.top_suzerain = root
								holder.top_liege = root
							}
						}
					}
					has_innovation = innovation_gunpowder
				}
			}
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = bombard
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = bombard
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = bombard
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = bombard
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
	}
	#Trebuchets
	else_if = {
		limit = {
			OR = {
				any_maa_regiment = {
					is_maa_type = trebuchet
				}
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_innovation = innovation_trebuchet
					}
				}
				culture = {
					has_innovation = innovation_trebuchet
				}
				#Any neighbor
				any_land_neighboring_realm_with_tributaries_owner = {
					culture = {
						has_innovation = innovation_trebuchet
					}
				}
				#Any culture in same kingdom as realm
				any_culture_global = {
					any_culture_kingdom = {
						any_de_jure_county = {
							OR = {
								holder.top_suzerain = root
								holder.top_liege = root
							}
						}
					}
					has_innovation = innovation_trebuchet
				}
			}
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = trebuchet
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = trebuchet
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = trebuchet
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = trebuchet
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
	}
	#Mangonels
	else_if = {
		limit = {
			OR = {
				any_maa_regiment = {
					is_maa_type = mangonel
				}
				trigger_if = {
					limit = {
						exists = domicile.domicile_culture
					}
					domicile.domicile_culture = {
						has_innovation = innovation_mangonel
					}
				}
				culture = {
					has_innovation = innovation_mangonel
				}
				#Any neighbor
				any_land_neighboring_realm_with_tributaries_owner = {
					culture = {
						has_innovation = innovation_mangonel
					}
				}
				#Any culture in same kingdom as realm
				any_culture_global = {
					any_culture_kingdom = {
						any_de_jure_county = {
							OR = {
								holder.top_suzerain = root
								holder.top_liege = root
							}
						}
					}
					has_innovation = innovation_mangonel
				}
			}
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = mangonel
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = mangonel
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = mangonel
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = mangonel
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
	}
	#Onagers (sorry)
	else = {
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = onager
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = onager
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
		spawn_army = {
			uses_supply = no
			inheritable = yes
			name = gok_event_troops
			men_at_arms = {
				type = nomadic_riders
				stacks = gok_nomadic_riders_small_value
			}
			men_at_arms = {
				type = horse_archers
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = heavy_horse_archers
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = steppe_raiders
				stacks = gok_maa_medium_value
			}
			men_at_arms = {
				type = nomad_lancers
				stacks = gok_maa_small_value
			}
			men_at_arms = {
				type = onager
				stacks = gok_maa_smallish_value
			}
			men_at_arms = {
				type = onager
				stacks = gok_maa_smallish_value
			}
			location = capital_province
			origin = capital_province
		}
	}
}

mpo_gok_war_of_defiance_cleanup_effect = {
	scope:defender = {
		remove_character_modifier = aspiring_great_khan_modifier
	}
}

mpo_find_powerful_opponent_for_gurkhan_effect = {
	#Ok we're going to save all the valid options to a list and then pick the strongest of them
	#Neighbors
	every_land_neighboring_realm_with_tributaries_owner = {
		limit = {
			mpo_gok_coalition_member_trigger = yes
		}
		add_to_list = potential_gok_opponents
	}
	#All valid suzerains of neighbors
	every_land_neighboring_realm_with_tributaries_owner = {
		limit = {
			is_tributary = yes
			top_suzerain = {
				mpo_gok_coalition_member_trigger = yes
			}
		}
		top_suzerain = {
			add_to_list = potential_gok_opponents
		}
	}
	#People who hate you
	every_relation = {
		type = rival
		limit = {
			is_ruler = yes
			mpo_gok_coalition_member_trigger = yes
		}
		add_to_list = potential_gok_opponents
	}
	#Those within same de jure empire
	capital_county ?= {
		empire = {
			every_de_jure_county = {
				limit = {
					holder.top_Liege = {
						mpo_gok_coalition_member_trigger = yes
					}
				}
				holder.top_liege = {
					add_to_list = potential_gok_opponents
				}
			}
			every_de_jure_county = {
				limit = {
					holder.top_suzerain = {
						mpo_gok_coalition_member_trigger = yes
					}
				}
				holder.top_suzerain = {
					add_to_list = potential_gok_opponents
				}
			}
		}
	}
	#Those with capital within range
	#Have to do a fallback in case everyone's military strength hasn't been calc'd yet
	if = {
		limit = {
			any_independent_ruler = {
				current_military_strength > 0
			}
		}
		every_independent_ruler = {
			limit = {
				highest_held_title_tier >= tier_duchy
				exists = root.capital_county
				realm_to_title_distance_squared = {
					target = root.capital_county
					value <= squared_distance_almost_massive
				}
				
				mpo_gok_coalition_member_trigger = yes
			}
			add_to_list = potential_gok_opponents
		}
	}
	else = {
		every_independent_ruler = {
			limit = {
				highest_held_title_tier >= tier_duchy
				exists = root.capital_county
				realm_to_title_distance_squared = {
					target = root.capital_county
					value <= squared_distance_almost_massive
				}
				mpo_gok_coalition_member_trigger = yes
			}
			add_to_list = potential_gok_opponents
		}
	}
	#Ideally we find someone at least half as strong as the Gurkhan...
	if = {
		limit = {
			NOT = {
				any_in_list = {
					list = potential_gok_opponents
					#THIS SHOULD CHECK THEIR STRENGTH IS MORE THAN HALF ROOT'S
					confederation_worthy_foe_strength_ratio_value_root <= 2
				}
			}
		}
		#expand search radius
		if = {
			limit = {
				any_independent_ruler = {
					current_military_strength > 0
				}
			}
			every_independent_ruler = {
				limit = {
					highest_held_title_tier >= tier_duchy
					exists = root.capital_county
					realm_to_title_distance_squared = {
						target = root.capital_county
						value <= squared_distance_massive
					}
					
					mpo_gok_coalition_member_trigger = yes
				}
				add_to_list = potential_gok_opponents
			}
		}
		else = {
			every_independent_ruler = {
				limit = {
					highest_held_title_tier >= tier_duchy
					exists = root.capital_county
					realm_to_title_distance_squared = {
						target = root.capital_county
						value <= squared_distance_massive
					}
					mpo_gok_coalition_member_trigger = yes
				}
				add_to_list = potential_gok_opponents
			}
		}
	}
	if = {
		limit = {
			any_in_list = {
				list = potential_gok_opponents
				current_military_strength > 0
			}
		}
		ordered_in_list = {
			list = potential_gok_opponents
			limit = {
				NOT = {
					this = root
				}
			}
			order_by = current_military_strength
			add_to_list = anti_gok_coalition_members
			save_scope_as = gok_opponent 
		}
	}
	else = {
		ordered_in_list = {
			list = potential_gok_opponents
			limit = {
				NOT = {
					this = root
				}
			}
			order_by = sub_realm_size
			add_to_list = anti_gok_coalition_members
			save_scope_as = gok_opponent 
		}
	}
}

gok_war_of_defiance_heir_transfer_effect = {
	if = {
		limit = {
			has_variable = fought_for_gok_alone
		}
		save_scope_value_as = {
		 	name = fought_for_gok_alone_value
		 	value = var:fought_for_gok_alone
		}
		primary_heir = {
			set_variable = {
				name = fought_for_gok_alone
				value = scope:fought_for_gok_alone_value
			}
		}
	}
}

mpo_gok_offer_submission_effect = {
	#Give tribute/troops before potentially losing title
	scope:recipient = {
		#Payments from demand payments
		#Costs more for those who aren't paying increased taxes
		if = {
			limit = {
				NOR = {
					government_has_flag = government_is_feudal
					government_has_flag = government_is_nomadic
					government_has_flag = government_is_herder
				}
			}
			if = {	
				limit = {
					scope:send_tribute = yes
				}
				pay_short_term_gold = {
					target = scope:actor
					gold = monumental_gold_value
				}
			}
			else_if = {	
				limit = {
					NOT = { scope:low_obligations = yes }
				}
				pay_short_term_gold = {
					target = scope:actor
					gold = major_gold_value
				}
			}
		}
		else_if = {
			limit = {
				government_has_flag = government_is_nomadic
				scope:actor = {
					government_has_flag = government_is_nomadic
				}
				scope:send_tribute = yes
			}
			pay_herd = {
				target = scope:actor
				value = domicile.massive_herd_value
			}
		}
		else_if = {
			limit = {
				scope:send_tribute = yes
			}
			pay_short_term_gold = {
				target = scope:actor
				gold = massive_gold_value
			}
		}
		#special soldiers
		#Pay some gold or herd to signify giving them up
		if = {
			limit = {
				OR = {
					scope:send_army = yes
					scope:send_siege_weapons = yes
				}
			}
			if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				domicile = {
					change_herd = medium_herd_loss
				}
			}
			else_if = {
				limit = {
					government_has_flag = government_is_tribal
				}
				add_prestige = medium_prestige_loss
			}
			else = {
				remove_short_term_gold = medium_gold_value
			}
		}
		if = {
			limit = {
				scope:send_army = yes
			}
			scope:actor = {
				gok_spawn_subjugated_quality_army_effect = { CHARACTER = scope:recipient }
			}
		}
		if = {
			limit = {
				scope:send_siege_weapons = yes
			}
			scope:actor = {
				gok_spawn_subjugated_siege_army_effect = { CHARACTER = scope:recipient }
			}
		}
	}

	#If emperor... loses titles
	if = {
		limit = {
			scope:recipient = {
				highest_held_title_tier >= tier_empire
			}
		}
		scope:recipient = {
			hidden_effect = {
				every_vassal = {
					limit = {
						highest_held_title_tier = tier_kingdom
					}
					create_title_and_vassal_change = {
						type = swear_fealty
						save_scope_as = change
					}
					change_liege = {
						liege = scope:actor
						change = scope:change
					}
					add_opinion = {
						modifier = became_vassal
						target = scope:actor
						opinion = 10
					}
					resolve_title_and_vassal_change = scope:change
				}
			}
			#Have to grant them a kingdom if they don't have any...
			if = {
				limit = {
					NOT = {
						any_held_title = {
							tier = tier_kingdom
						}
					}
				}
				if = {
					limit = {
						capital_county.kingdom ?= {
							NOT = {
								exists = holder
							}
						}
					}
					create_title_and_vassal_change = {
						type = created
						save_scope_as = change
						add_claim_on_loss = no
					}
					capital_county.kingdom = {
						change_title_holder = {
							holder = scope:recipient
							change = scope:change
						}
					}
					resolve_title_and_vassal_change = scope:change
				}
				else = {
					primary_title = {
						save_scope_as = old_title
					}
					hidden_effect = {
						#create some bullshit kingdom
						create_dynamic_title = {
							tier = kingdom
							name = GOK_SUBJECT_TITLE_NAME
							adj = GOK_SUBJECT_TITLE_NAME_ADJ
							article = article_CONFEDERATION_CULTURE_NAME
						}
						scope:new_title = {
							set_color_from_title = scope:recipient.capital_county
							set_definitive_form = yes
							generate_coa = yes
						}
						create_title_and_vassal_change = {
							type = created
							save_scope_as = change
							add_claim_on_loss = no
						}
						scope:new_title = {
							change_title_holder = {
								holder = scope:recipient
								change = scope:change
							}
						}
						resolve_title_and_vassal_change = scope:change
					}
				}
			}
			every_held_title = {
				limit = {
					tier >= tier_empire
				}
				scope:recipient = {
					destroy_title = prev
				}
			}
		}
	}
	
	create_title_and_vassal_change = {
		type = swear_fealty
		save_scope_as = change
	}
	scope:recipient = {
		change_liege = {
			liege = scope:actor
			change = scope:change
		}
		hidden_effect = {
			add_opinion = {
				modifier = became_vassal
				target = scope:actor
				opinion = 10
			}
		}
	}
	resolve_title_and_vassal_change = scope:change

	#If GoK is a pluralist, they always get religious freedom
	scope:recipient = {
		if = {
			limit = {
				#Actor is still nomadic or pluralist and thus doesn't care about religion
				scope:actor = {
					faith = {
						has_doctrine = doctrine_pluralism_pluralistic
					}
				}
				OR = {
					government_has_flag = government_is_feudal
					government_has_flag = government_is_clan
				}
			}
			hidden_effect = {
				if = {
					limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
					vassal_contract_set_obligation_level = { type = religious_rights level = 1 }
				}
			}
			custom_tooltip = religious_protection_tt
		}
	}

	# Special terms for feudal contracts
	scope:recipient = {
		if = {
			limit = {
				government_has_flag = government_is_feudal
			}
			if = {
				limit = {
					scope:send_tribute = yes
				}
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = feudal_government_taxes level = 3 }
						vassal_contract_set_obligation_level = { type = feudal_government_levies level = 3 }
					}
				}
				custom_tooltip = high_obligations_taxes
				custom_tooltip = high_obligations_levies
			}
			else_if = {
				limit = { scope:low_obligations = yes }
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = feudal_government_taxes level = 1 }
						vassal_contract_set_obligation_level = { type = feudal_government_levies level = 1 }
					}
				}
				custom_tooltip = low_obligations_taxes
				custom_tooltip = low_obligations_levies
			}
			else = {
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = feudal_government_taxes level = 2 }
						vassal_contract_set_obligation_level = { type = feudal_government_levies level = 2 }
					}
				}
				custom_tooltip = normal_obligations_taxes
				custom_tooltip = normal_obligations_levies
			}
		}
		else_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			if = {
				limit = {
					scope:send_tribute = yes
				}
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = nomad_government_herd level = 3 }
					}
				}
				custom_tooltip = high_obligations_herds
			}
			else_if = {
				limit = { scope:low_obligations = yes }
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = nomad_government_herd level = 1 }
					}
				}
				custom_tooltip = low_obligations_herds
			}
			else = {
				hidden_effect = {
					if = {
						limit = { is_independent_ruler = no } # To avoid errors during tooltip generation (prior to the contract being generated)
						vassal_contract_set_obligation_level = { type = nomad_government_herd level = 2 }
					}
				}
				custom_tooltip = normal_obligations_herds
			}
		}
	}

	# Struggle catalysts.
	hidden_effect = {
		fp3_struggle_apply_independent_vassalage_catalyst_effect = {
			NEW_LIEGE = scope:actor
			NEW_VASSAL = scope:recipient
		}
	}
}

mpo_gok_offer_submission_refusal_effect = {
	save_scope_as = actor
	start_war = {
		cb = mpo_gok_onslaught_cb
		target = scope:recipient
		target_title = scope:recipient.primary_title
	}
	custom_tooltip = gok_on_victory_tt
	show_as_tooltip = {
		rightfully_imprison_character_less_verbose_effect = { 
			TARGET = scope:recipient
			IMPRISONER = scope:actor
		}
	}
	custom_tooltip = gok_ruin_additional_destruction_tt
	custom_tooltip = gok_gain_dread_tt
	if = {
		limit = {
			government_has_flag = government_is_nomadic
			scope:recipient.capital_county = {
				any_county_province = {
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
		}
		custom_tooltip = gok_gain_herd_tt
	}
	else = {
		custom_tooltip = gok_gain_gold_tt
	}
	if = {
		limit = {
			scope:send_army = yes
		}
		save_scope_as = requested_quality_army
		custom_tooltip = gok_cb_event_troops_quality_tt
	}
	else_if = {
		limit = {
			scope:send_siege_weapons = yes
		}
		save_scope_as = requested_siege_army
		custom_tooltip = gok_cb_event_troops_siege_tt
	}
	else = {
		custom_tooltip = gok_cb_event_troops_tt
	}
	
	custom_tooltip = gok_offer_submission_acceptance_bonus_tt
	scope:recipient.primary_title = {
		set_variable = {
			name = refused_submission
			value = yes
		}
	}
}

gok_spawn_subjugated_siege_army_effect = {
	$CHARACTER$ = { save_scope_as = army_giver }
	custom_tooltip = gok_siege_army_gain_tt
	if = {
		limit = {
			exists = $CHARACTER$.primary_title
		}
		$CHARACTER$.primary_title = {
			save_scope_as = army_origin_realm
		}
	}
	else = {
		$CHARACTER$.location.county.kingdom = {
			save_scope_as = army_origin_realm
		}
	}
	hidden_effect = {
		#TGP Cannon
		if = {
			limit = {#Bombards
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_gunpowder
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_gunpowder
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = cannon
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Non-TGP Bombard
		else_if = {
			limit = {#Bombards
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_gunpowder
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_gunpowder
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = bombard
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Siege Towers
		else_if = {
			limit = {
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_trebuchet
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_trebuchet
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = siege_tower
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Trebuchets
		else_if = {
			limit = {
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_trebuchet
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_trebuchet
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = trebuchet
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Cloud Ladder
		else_if = {
			limit = {
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_mangonel
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_mangonel
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = cloud_ladder
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Mangonel
		else_if = {
			limit = {
				OR = {
					$CHARACTER$.culture = {
						has_innovation = innovation_mangonel
					}
					$CHARACTER$.capital_county.culture ?= {
						has_innovation = innovation_mangonel
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = mangonel
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		#Ballista - but not the Byz one
		else_if = {
			limit = {
				OR = {
					$CHARACTER$.culture = {
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
					$CHARACTER$.capital_county.culture ?= {
						OR = {
							has_cultural_pillar = heritage_chinese
							has_cultural_pillar = heritage_korean
							has_cultural_pillar = heritage_japonic
						}
					}
				}
			}
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = ballista
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
		else = {
			random_list = {
				#Heavy Infantry
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_quilted_armor
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_quilted_armor
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = heavy_infantry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_heavy_infantry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = armored_footmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Pikemen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = pikemen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_pikemen_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = pikemen_unit
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Crossbowmen
				1 = {
					trigger = {
						OR = {
							$CHARACTER$.culture = {
								has_innovation = innovation_advanced_bowmaking
							}
							$CHARACTER$.capital_county.culture ?= {
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_type = {
								target = crossbowmen
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = crossbowmen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Cavalry
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = light_cavalry
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_light_cavalry_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_horsemen
							stacks = gok_subjugated_army_maa_value_very_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Bowmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = archers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_archer_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = bowmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
				#Light Footmen
				1 = {
					modifier = {
						$CHARACTER$ = {
							number_maa_regiments_of_base_type = {
								type = skirmishers
								value > 0
							}
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.culture = {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					modifier = {
						$CHARACTER$.capital_county.culture ?= {
							culture_specializes_in_skirmisher_maa = yes
						}
						add = 10
					}
					spawn_army = {
						name = gok_subjugated_army_name_subject_troops
						inheritable = yes
						uses_supply = no
						
						men_at_arms = {
							type = light_footmen
							stacks = gok_subjugated_army_maa_value_small
						}
						men_at_arms = {
							type = onager
							stacks = gok_subjugated_army_maa_value_small
						}
						location = scope:gok.capital_province
						origin = $CHARACTER$.capital_province
					}
				}
			}
		}
	}
}

gok_spawn_subjugated_quality_army_effect = {
	$CHARACTER$ = {
		save_scope_as = army_giver
	}
	custom_tooltip = gok_quality_army_gain_tt
	if = {
		limit = {
			exists = $CHARACTER$.primary_title
		}
		$CHARACTER$.primary_title = {
			save_scope_as = army_origin_realm
		}
	}
	else = {
		$CHARACTER$.location.county.kingdom = {
			save_scope_as = army_origin_realm
		}
	}
	hidden_effect = {
		random_list = {
			#Paiks
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_bamboo_bows
							}
							capital_county.culture = {
								has_innovation = innovation_bamboo_bows
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = paiks
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Sahel Horsemen
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_sahel_horsemen
							}
							capital_county.culture = {
								has_innovation = innovation_sahel_horsemen
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = sahel_horsemen
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#WAR ELEPHANTS... I mean, come on
			200 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_elephantry
							}
							capital_county.culture = {
								has_innovation = innovation_elephantry
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = war_elephant
						stacks = gok_subjugated_army_maa_value_very_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#BALLISTA ELEPHANTS... I mean, come on
			200 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = { 
								has_innovation = innovation_elephantry 
								has_innovation = innovation_advanced_bowmaking
							}
							capital_county.culture = {
								has_innovation = innovation_elephantry 
								has_innovation = innovation_advanced_bowmaking
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = ballista_elephant
						stacks = gok_subjugated_army_maa_value_very_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Abudrar
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_abudrar
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_abudrar
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = abudrar
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Ayyar
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_ayyar
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_ayyar
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = ayyar
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Druzhina
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_druzhina
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_druzhina
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_druzhina
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = druzhina
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Chausseurs
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_desert_tactics
							}
							capital_county.culture = {
								has_innovation = innovation_desert_tactics
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = chasseur
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Guinean Uplanders
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_guinea_warrior
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_guinea_warrior
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = guinea_warrior
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Khandayat
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_khandayat
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_khandayat
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = khandayat
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Lenkas
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_garudas
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_garudas
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = garudas
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Mountaineers
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_mountaineer
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_mountaineer
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = mountaineer
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Mulathanum
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_mulaththamun
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_mulaththamun
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = mulaththamun
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Nile Archers
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_archers_of_the_nile
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_archers_of_the_nile
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = archers_of_the_nile
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Palace Guards
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_palace_guards
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_palace_guards
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = palace_guards
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Sarawit
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_sarawit
							}
							capital_county.culture = {
								has_innovation = innovation_sarawit
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = sarawit
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Shomer
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_shomer
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_shomer
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = shomer
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Zbrojnosh
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_zbrojnosh
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_zbrojnosh
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = zbrojnosh
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Bondi
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_bondi
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_bondi
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = bondi
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Vigmen
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_vigmen
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_vigmen
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = vigmen
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Tarkhans
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_tarkhan
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_tarkhan
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = tarkhan
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Tawashi
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_tawashi
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_tawashi
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = tawashi
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Zupin Spearmen
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_zupin_warrior
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_zupin_warrior
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = zupin_warrior
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Cho ko nu
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_repeating_crossbow
							}
							capital_county.culture = {
								has_innovation = innovation_repeating_crossbow
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = shenbigong
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Palatini
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_legionnaires
							}
							capital_county.culture = {
								has_innovation = innovation_legionnaires
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = praetorian
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Vaulter Infantry
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_pole_vault
							}
							capital_county.culture = {
								has_innovation = innovation_pole_vault
							}
						}
					}
				}

				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = guanch_vaulter
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#WARBAND
			#Bush Hunters
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_bush_hunter
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_bush_hunter
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_bush_hunter
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = bush_hunter
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Horn Warriors
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_horn_warrior
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_horn_warrior
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_horn_warrior
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = horn_warrior
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Metsanvartija
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_metsanvartija
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_metsanvartija
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_metsanvartija
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = metsanvartija
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}

			#Greeks
			300 = {
				trigger = {
					OR = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_cataphract
								}
							}
						}
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_cataphract
							}
						}
					}
					scope:army_giver = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_cataphract
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_cataphract
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_greek_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = cataphract
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_ballistrai
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_ballistrai
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_ballistrai
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_ballistrai
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_greek_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = ballistrai
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_skoutatoi
								}
							}
						}
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_skoutatoi
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_skoutatoi
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_skoutatoi
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_greek_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = skoutatoi
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_akritai
								}
								any_county_province = {
									terrain = mountains
								}
							}
						}
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_akritai
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_akritai
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_akritai
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_greek_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = akritai
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Armenians
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_ayrudzi
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_ayrudzi
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_ayrudzi
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_ayrudzi
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = ayrudzi
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Georgians
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_monaspa
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_monaspa
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_monaspa
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_monaspa
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = monaspa
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Cataphract archers
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_cataphract_archers
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_cataphract_archers
								}
							}
						}
					}
					scope:army_giver = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = cataphract_archers
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Konni folk get konni
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_hussar
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_hussar
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_hussar
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_hussar
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = hussar
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Varangians
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_cultural_parameter = unlock_maa_varangian_veterans
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_varangian_veterans
								}
							}
						}
					}
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = varangian_veterans
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Horse archers
			2 = {
				trigger = {
					OR = {
						scope:army_giver = {
							capital_county = {
								culture = {
									culture_has_archer_cavalry_maa = yes
								}
							}
						}
						scope:army_giver = {
							any_vassal = {
								OR = {
									culture = { culture_has_archer_cavalry_maa = yes }
									mpo_can_recruit_nomad_maa_trigger = yes
								}
							}
						}
						scope:army_giver = {
							OR = {
								culture = { culture_has_archer_cavalry_maa = yes }
								mpo_can_recruit_nomad_maa_trigger = yes
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									culture_has_archer_cavalry_maa = yes
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else_if = {
					limit = {
						scope:army_giver = {
							OR = {
								culture = { culture_has_archer_cavalry_maa = yes }
								mpo_can_recruit_nomad_maa_trigger = yes
							}
						}
					}
					scope:army_giver = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				else_if = {
					limit = {
						scope:army_giver = {
							any_vassal = {
								OR = {
									culture = { culture_has_archer_cavalry_maa = yes }
									mpo_can_recruit_nomad_maa_trigger = yes
								}
							}
						}
					}
					scope:army_giver = {
						random_vassal = {
							limit = {
								OR = {
									culture = { culture_has_archer_cavalry_maa = yes }
									mpo_can_recruit_nomad_maa_trigger = yes
								}
							}
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = horse_archers
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Crossbowmen
			5 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								OR = {
									has_innovation = innovation_advanced_bowmaking
									has_innovation = innovation_repeating_crossbow
								}
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									OR = {
										has_innovation = innovation_advanced_bowmaking
										has_innovation = innovation_repeating_crossbow
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_type = {
							target = crossbowmen
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_archer_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_archer_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = crossbowmen
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Norman knights
			100 = {
				trigger = {
					OR = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_conrois
						}
						scope:army_giver.capital_county = {
							culture = {
								has_cultural_parameter = unlock_maa_conrois
							}
						}
					}
				}
				modifier = {
					OR = {
						culture = {
							has_cultural_parameter = unlock_maa_conrois
						}
						top_liege = {
							any_vassal = {
								highest_held_title_tier >= tier_county
								culture = {
									has_cultural_parameter = unlock_maa_conrois
								}
							}
						}
						capital_county = {
							culture = {
								has_cultural_parameter = unlock_maa_conrois
							}
						}
					}
					add = 18
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_conrois
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = conrois
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Longbowmen
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_longbowmen
							}
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_longbowmen
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_longbowmen
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = longbowmen
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Picchieri
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_pike_columns
							}
							capital_county = {
								culture = {
									has_innovation = innovation_pike_columns
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_pike_columns
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = picchieri
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Goedendag
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_adaptive_militia
							}
							capital_county = {
								culture = {
									has_innovation = innovation_adaptive_militia
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_adaptive_militia
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = goedendag
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Caballeros
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_caballeros
							}
							capital_county = {
								culture = {
									has_innovation = innovation_caballeros
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_caballeros
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = caballero
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Hobbies
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_hobbies
							}
							capital_county = {
								culture = {
									has_innovation = innovation_hobbies
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_hobbies
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = hobelar
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Schiltron
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_rectilinear_schiltron
							}
							capital_county = {
								culture = {
									has_innovation = innovation_rectilinear_schiltron
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_rectilinear_schiltron
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = schiltron
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Valets
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_valets
							}
							capital_county = {
								culture = {
									has_innovation = innovation_valets
								}
							}
						}
					}
					scope:army_giver = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_valets
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = gendarme
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#landsknecht
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_zweihanders
							}
							capital_county = {
								culture = {
									has_innovation = innovation_zweihanders
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_zweihanders
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = greek_anarchy_war_crusaders_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = landsknecht
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Huscarls
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_huscarls
							}
							capital_county = {
								culture = {
									has_cultural_parameter = unlock_maa_huscarls
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_huscarls
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = huscarl
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Camels
			3 = {
				trigger = {
					OR = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_war_camels
								}
								any_county_province = {
									OR = {
										terrain = drylands
										terrain = desert
									}
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_war_camels
								}
								any_county_province = {
									OR = {
										terrain = drylands
										terrain = desert
									}
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = {
								save_scope_as = army_culture
							}
						}
					}
				}
				else = {
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = camel_rider
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Heavy cav
			3 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_innovation = innovation_arched_saddle
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_arched_saddle
								}
							}
						}
					}
					scope:army_giver = {
						highest_held_title_tier >= tier_kingdom
					}
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = heavy_cavalry
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_heavy_cavalry_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_heavy_cavalry_maa = yes
					}
					add = 2
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_arched_saddle
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_noble_army_name
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = armored_horsemen
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Heavy Infantry
			1 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_innovation = innovation_quilted_armor
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_quilted_armor
								}
							}
						}
					}
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = heavy_infantry
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_heavy_infantry_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_heavy_infantry_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = armored_footmen
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Pikemen
			1 = {
				trigger = {
					scope:army_giver = {
						capital_county = {
							any_county_province = {
								terrain = mountains
							}
						}
					}
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = pikemen
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_pikemen_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_pikemen_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = pikemen_unit
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Archers
			1 = {
				trigger = {
					scope:army_giver = {
						capital_county = {
							any_county_province = {
								terrain = forest
							}
						}
					}
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = archers
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_archer_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_archer_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = bowmen
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Light Horsemen
			1 = {
				trigger = {
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = light_cavalry
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_light_cavalry_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_light_cavalry_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = light_horsemen
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Light Footmen
			1 = {
				trigger = {
					OR = {
						scope:army_giver = {
							NOT = {
								government_has_flag = government_is_nomadic
							}
						}
						scope:army_giver = {
							capital_county = {
								NOT = {
									any_county_province = {
										OR = {
											has_holding_type = nomad_holding
											has_holding_type = herder_holding
										}
									}
								}
							}
						}
					}
				}
				modifier = {
					$CHARACTER$ = {
						number_maa_regiments_of_base_type = {
							type = skirmishers
							value > 0
						}
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.culture = {
						culture_specializes_in_skirmisher_maa = yes
					}
					add = 2
				}
				modifier = {
					$CHARACTER$.capital_county.culture ?= {
						culture_specializes_in_skirmisher_maa = yes
					}
					add = 2
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					inheritable = yes
					uses_supply = no
					
					men_at_arms = {
						type = light_footmen
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Steppe Raiders
			2 = {
				trigger = {
					scope:army_giver = {
						mpo_can_recruit_nomad_maa_trigger = yes
					}
				}
				scope:army_giver.culture = { save_scope_as = army_culture }

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = steppe_raiders
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Heavy Horse Archers
			10 = {
				trigger = {
					scope:army_giver = {
						exists = domicile
						domicile = {
							has_domicile_parameter = unlock_maa_heavy_horse_archers
						}
					}
				}
				scope:army_giver.culture = { save_scope_as = army_culture }

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = heavy_horse_archers
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Nomad Lancers
			2 = {
				trigger = {
					scope:army_giver = {
						mpo_can_recruit_nomad_maa_trigger = yes
						highest_held_title_tier >= tier_duchy
					}
				}
				scope:army_giver.culture = { save_scope_as = army_culture }

				spawn_army = {
					name = mpo_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = nomad_lancers
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Mangudai
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_mangudai
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_mangudai
							}
						}
						
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_mangudai
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = mangudai
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Maturkan Warriors
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_maa_maturkan_warriors
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_maa_maturkan_warriors
							}
						}
						
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_maa_maturkan_warriors
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = maturkan_warriors
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Emishi Horse Archers
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_cultural_parameter = unlock_emishi_horse_archers_units
							}
							capital_county.culture = {
								has_cultural_parameter = unlock_emishi_horse_archers_units
							}
						}
						
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_cultural_parameter = unlock_emishi_horse_archers_units
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}

				spawn_army = {
					name = greek_anarchy_war_nomad_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = emishi_horse_archers
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Mounted Samurai
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_mounted_samurai_units }
					}
				}
				scope:army_giver.capital_county.culture = { save_scope_as = army_culture }

				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = japanese_horse_archers
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Warrior Monks
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_warrior_monk_units }
					}
				}
				scope:army_giver.capital_county.culture = { save_scope_as = army_culture }				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = warrior_monks
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Fire Lancers
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = { has_cultural_parameter = unlock_fire_lancers_units }
							capital_county.culture = { has_cultural_parameter = unlock_fire_lancers_units }
						}
						highest_held_title_tier >= tier_kingdom
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = { has_cultural_parameter = unlock_fire_lancers_units }
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {	
					scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = fire_lancers
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Gakgung archers
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_maa_gakgung_archers }
					}
				}
				scope:army_giver.culture = {
					save_scope_as = army_culture
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = gakgung_archers
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Pesilat Warriors
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_maa_pesilat }
					}
				}
				scope:army_giver.capital_county.culture = { save_scope_as = army_culture }
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = pesilat_warriors
						stacks = gok_subjugated_army_maa_value_very_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Samurai
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_infantry_samurai_units }
						NOT = {
							culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
						}
					}
				}
				scope:army_giver.capital_county.culture = { save_scope_as = army_culture }

				spawn_army = {
					name = gok_noble_army_name
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = samurai
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Zhanmadao Infantry
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_zhanmadao }
						OR = {
							vassal_contract_has_flag = celestial_province_military
							vassal_contract_has_flag = celestial_province_celestial
						}
						NOT = {
							culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							valid_for_maa_trigger = { PARAMETER = unlock_zhanmadao }
							OR = {
								vassal_contract_has_flag = celestial_province_military
								vassal_contract_has_flag = celestial_province_celestial
							}
							NOT = {
								culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
							}
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {	
					culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = zhanmadao_infantry
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Tiefutu
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_maa_tiefutu }
						NOT = {
							culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
						}
						culture = {
							has_innovation = innovation_arched_saddle
						}
						highest_held_title_tier >= tier_kingdom
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							valid_for_maa_trigger = { PARAMETER = unlock_maa_tiefutu }
							NOT = {
								culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
							}
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {	
					culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = tiefutu
						stacks = gok_subjugated_army_maa_value_small
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Burenjia
			100 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_burenjia }
						NOT = {
							culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							valid_for_maa_trigger = { PARAMETER = unlock_burenjia }
							NOT = {
								culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
							}
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {	
					culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = burenjia
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Rocket carts
			100 = {
				trigger = {
					OR = {
						scope:army_giver = {
							culture = {
								has_innovation = innovation_rocket_cart
							}
						}
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_rocket_cart
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							culture = {
								has_innovation = innovation_rocket_cart
							}
						}
					}
					scope:army_giver.culture = { save_scope_as = army_culture }
				}
				else_if = {
					limit = {
						scope:army_giver = {
							capital_county = {
								culture = {
									has_innovation = innovation_rocket_cart
								}
							}
						}
					}
					scope:army_giver = {
						capital_county = {
							culture = { save_scope_as = army_culture }
						}
					}
				}
				else = {
					culture = {
						save_scope_as = army_culture
					}
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = rocket_carts
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Shenbigong
			100 = {
				trigger = {
					scope:army_giver = {
						OR = {
							culture = {
								has_innovation = innovation_repeating_crossbow
							}
							capital_county = {
								culture = {
									has_innovation = innovation_repeating_crossbow
								}
							}
						}
					}
				}
				if = {
					limit = {
						scope:army_giver.culture = {
							has_innovation = innovation_repeating_crossbow
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {
					scope:army_giver.capital_county = {
						culture = {
							save_scope_as = army_culture
						}
					}
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = shenbigong
						stacks = gok_subjugated_army_maa_value_large
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
			#Mubarizun
			50 = {
				trigger = {
					scope:army_giver = {
						valid_for_maa_trigger = { PARAMETER = unlock_maa_mubarizun }
						NOT = {
							culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
						}
					}
				}
				if = {
					limit = {
						scope:army_giver = {
							valid_for_maa_trigger = { PARAMETER = unlock_maa_mubarizun }
							NOT = {
								culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
							}
						}
					}
					scope:army_giver.culture = {
						save_scope_as = army_culture
					}
				}
				else = {	
					culture = { save_scope_as = army_culture }
				}
				spawn_army = {
					name = gok_subjugated_army_name_subject_troops
					uses_supply = no
					inheritable = yes
					
					men_at_arms = {
						type = mubarizun
						stacks = gok_subjugated_army_maa_value_medium
					}
					location = scope:gok.capital_province
					origin = $CHARACTER$.capital_province
				}
			}
		}
	}
}

gok_realm_devastation_effect = {
	#Minor issues targeting the general realm, but REALLY focus in on the capital area for revenge
	add_to_list = defender_realm_vassals
	#defender domain specifically targeted
	every_in_list = {
		list = target_titles
		limit = {
			tier = tier_county
			is_landless_type_title = no
		}
		add_to_list = devastation_area
	}
	#and area of capital
	capital_county.duchy = {
		every_de_jure_county = {
			limit = {
				holder = {
					top_liege = scope:defender
					NOR = {
						is_ai = no
						is_at_war_with = scope:defender
					}
				}
			}
			add_to_list = devastation_area
		}
	}
	every_vassal_or_below = {
		add_to_list = defender_realm_vassals
	}
	#is this violent retribution for refusing the khan's generosity?
	if = {
		limit = {
			exists = scope:khans_retribution_target
		}
		scope:attacker = {
			custom_tooltip = gok_gain_dread_tt
		}
		custom_tooltip = gok_ruin_additional_destruction_tt
		if = {
			limit = {
				government_has_flag = government_is_nomadic
				scope:defender.capital_county = {
					any_county_province = {
						OR = {
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
				}
			}
			scope:attacker = {
				custom_tooltip = gok_gain_herd_tt
			}
		}
		else = {
			scope:attacker = {
				custom_tooltip = gok_gain_gold_tt
			}
		}
		hidden_effect = {
			scope:attacker = {
				#First off, gain dread
				add_dread = gok_retribution_dread_value
				#Gain herd or gold
				if = {
					limit = {
						government_has_flag = government_is_nomadic
						scope:defender.capital_county = {
							any_county_province = {
								OR = {
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
					}
					domicile = {
						change_herd = gok_retribution_herd_value
					}
				}
				else = {
					add_short_term_gold = gok_retribution_gold_value
				}
			}
			#Tank control everywhere
			every_sub_realm_county = {
				limit = {
					NOT = {
						is_in_list = devastation_area
					}
				}
				change_county_control = massive_county_control_loss
				change_development_level = {
					subtract = development_level
					multiply = 0.2
					floor = yes
				}
			}
			#Destroy the holdings
			every_in_list = {
				list = devastation_area
				limit = {
					any_county_province = {
						has_holding = yes
						is_county_capital = no
					}
				}
				every_county_province = {
					limit = {
						has_holding = yes
						is_county_capital = no
					}
					random = {
						chance = 50
						remove_holding = yes
						add_to_list = destroyed_holdings
					}
					
				}
			}

			scope:attacker = {
				save_scope_as = mongol_emperor
			}
			#Kick the shit out of capital area
			every_in_list = {
				list = devastation_area
				save_scope_as = county
				
				change_county_control = massive_county_control_loss
				holder = {
					send_interface_message = {
						type = event_war_bad
						title = mongols_sieged_county.t
						left_icon = scope:mongol_emperor
						right_icon = scope:county

						scope:county = {
							change_development_level = {
								subtract = scope:county.development_level
								multiply = 0.5
								floor = yes
							}
							every_county_province = {
								limit = {
									has_holding = yes
									num_buildings >= 2
								}
								destroy_random_building_variable_effect = yes
								destroy_random_building_effect = yes
							}
							every_county_province = {
								limit = {
									has_holding = yes
									num_buildings >= 2
								}
								destroy_random_building_variable_effect = yes
								destroy_random_building_effect = yes
							}
							every_county_province = {
								limit = {
									has_holding = yes
									num_buildings >= 2
								}
								destroy_random_building_variable_effect = yes
								destroy_random_building_effect = yes
							}
						}
						
					}
				}
				
				hidden_effect = {
					mpo_gok_civilian_slaughter_totalling_effect = yes
				}
				if = {
					limit = {
						culture = {
							cultural_acceptance = {
								target = scope:attacker.culture
								value > 0
							}
						}
					}
					culture = {
						change_cultural_acceptance = {
							target = scope:attacker.culture
							value = major_cultural_acceptance_loss
							desc = gok_sacking_cultural_acceptance
						}
					}
				}
			}
			if = {
				limit = {
					"list_size(destroyed_holdings)" > 1
				}
				#Holding notification
				save_scope_value_as = {
				 	name = destroyed_holdings
				 	value = "list_size(destroyed_holdings)"
				}
				#Send notification message
				if = {
					limit = {
						scope:defender = {
							trigger_if = {
								limit = {
									highest_held_title_tier >= tier_kingdom
								}
								sub_realm_size >= 2
							}
							trigger_else = {
								highest_held_title_tier >= tier_duchy
								sub_realm_size >= 5
							}
						}
					}
					every_player = {
						limit = {
							OR = {
								in_diplomatic_range = scope:defender
								this = scope:defender
							}
						}
						send_interface_message = {
							type = msg_gok_destruction
							title = gok_destruction.t
							left_icon = scope:gok
							desc = gok_destruction.tooltip
						}
					}
				}
				#Be more discerning with rulers that aren't significant
				else = {
					every_player = {
						limit = {
							OR = {
								this = scope:attacker
								this = scope:defender
								has_any_scripted_relation = scope:defender
								is_close_or_extended_family_of = scope:defender
								is_consort_of = scope:defender
								is_allied_to = scope:defender
							}
						}
						send_interface_message = {
							type = msg_gok_destruction
							title = gok_destruction.t
							left_icon = scope:gok
							desc = gok_destruction.tooltip
						}
					}
				}
			}
			#Slaughter notification
			if = {
				limit = {
					"list_size(gok_slaughter_victims)" > 1
				}
				save_scope_value_as = {
				 	name = gok_slaughter_value
				 	value = "list_size(gok_slaughter_victims)"
				}
				if = {
					limit = {
						scope:defender = {
							trigger_if = {
								limit = {
									highest_held_title_tier >= tier_kingdom
								}
								sub_realm_size >= 2
							}
							trigger_else = {
								highest_held_title_tier >= tier_duchy
								sub_realm_size >= 5
							}
						}
					}
					every_player = {
						limit = {
							OR = {
								this = scope:attacker
								this = scope:defender
								in_diplomatic_range = scope:defender
								has_any_scripted_relation = scope:defender
								is_close_or_extended_family_of = scope:defender
								is_consort_of = scope:defender
								is_allied_to = scope:defender
							}
						}
						send_interface_message = {
							type = msg_gok_slaughter
							title = gok_slaughter.t
							left_icon = scope:gok
							desc = gok_slaughter.tooltip
						}
					}
					every_player = {
						every_in_list = {
							list = gok_slaughter_victims
							limit = {
								OR = {
									has_any_scripted_relation = prev
									is_close_or_extended_family_of = prev
									is_consort_of = prev
									is_allied_to = prev
								}
							}
							save_scope_as = victim
							prev = {
								send_interface_message = {
									type = msg_gok_slaughter
									title = gok_slaughter_victim.t
									left_icon = scope:victim
									desc = gok_slaughter_victim.tooltip
								}
							}
						}
					}
				}
				else = {
					every_player = {
						limit = {
							OR = {
								this = scope:attacker
								this = scope:defender
								has_any_scripted_relation = scope:defender
								is_close_or_extended_family_of = scope:defender
								is_consort_of = scope:defender
								is_allied_to = scope:defender
							}
						}
						send_interface_message = {
							type = msg_gok_slaughter
							title = gok_slaughter.t
							left_icon = scope:gok
							desc = gok_slaughter.tooltip
						}
					}
					every_player = {
						every_in_list = {
							list = gok_slaughter_victims
							limit = {
								OR = {
									has_any_scripted_relation = prev
									is_close_or_extended_family_of = prev
									is_consort_of = prev
									is_allied_to = prev
								}
							}
							save_scope_as = victim
							prev = {
								send_interface_message = {
									type = msg_gok_slaughter
									title = gok_slaughter_victim.t
									left_icon = scope:victim
									desc = gok_slaughter_victim.tooltip
								}
							}
						}
					}
				}
			}
			hidden_effect = {
				every_in_list = {
					list = gok_slaughter_victims
					death = {
						death_reason = death_gok_slaughter
					}
				}
			}
		}
	}
	else = {
		every_sub_realm_county = {
			custom = custom.every_taken_county
			change_county_control = medium_county_control_loss
			change_development_level = {
				subtract = development_level
				multiply = 0.1
				floor = yes
			}
		}
	}
}

mpo_gok_civilian_slaughter_totalling_effect = {
	every_in_list = {
		list = devastation_area
		if = {
			limit = {
				this = holder.capital_county
			}
			holder = {
				if = {
					limit = {
						NOR = {
							this = scope:defender
							is_ai = no
						}
					}
					add_to_list = potential_victims
				}
				every_courtier_or_guest = {
					add_to_list = potential_victims
				}
			}
			#Local pool characters
			every_pool_character = {
				province = prev.holder.capital_province
				add_to_list = potential_victims
			}
		}
	}
	scope:defender = {
		#ai landless house heads in the capital
		every_vassal = {
			limit = {
				is_ai = yes
				is_landless_administrative = yes
				domicile ?= {
					domicile_location.county = {
						this = scope:defender.capital_county
					}
				}
			}
			add_to_list = potential_victims
		}
		#Courtiers of landless house heads in the capital
		every_vassal = {
			limit = {
				is_landless_administrative = yes
				domicile ?= {
					domicile_location.county = {
						this = scope:defender.capital_county
					}
				}
			}
			every_courtier_or_guest = {
				add_to_list = potential_victims
			}
		}
	}
	ordered_in_list = {
		order_by = {
			value = 1
			#I suppose they would probably try to avoid killing their own
			if = {
				limit = {
					NOT = {
						faith = scope:attacker.faith
					}
				}
				add = 1
			}
			if = {
				limit = {
					NOT = {
						culture = scope:attacker.culture
					}
				}
				add = 1
			}
		}
		list = potential_victims
		max = {
			value = "list_size(potential_victims)"
			divide = 2
		}
		add_to_list = gok_slaughter_victims
	}
}

gok_retribution_cleanup_effect = {
	if = {	
		limit = {
			exists = scope:khans_retribution_target
		}
		scope:defender = {
			every_held_title = {
				limit = {
					has_variable = refused_submission
				}
				remove_variable = refused_submission
			}
			every_vassal_or_below = {
				limit = {
					any_held_title = {
						has_variable = refused_submission
					}
				}
				remove_variable = refused_submission
			}
		}
	}
}

gok_world_conquest_generic_rewards_effect = {
	custom_tooltip = gok_gain_hegemony
	hidden_effect = {
		#CENGIZ KHAGANATE
		if = {
			limit = {
				culture = {
					has_cultural_pillar = language_turkic
				}
				OR = {
					has_nickname = nick_cengiz_khan
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_cengiz_khan
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_CENGIZ
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_CENGIZ_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#YEKHE KHAGANATE
		else_if = {
			limit = {
				culture = {
					has_cultural_pillar = language_mongolic
				}
				OR = {
					has_nickname = nick_yekhe_khagan
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_yekhe_khagan
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_YEKHE
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_YEKHE_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#DORT YONLUG KHAGANATE
		else_if = {
			limit = {
				culture = {
					has_cultural_pillar = language_turkic
				}
				OR = {
					has_nickname = nick_dort_yonlug_khagan
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_dort_yonlug_khagan
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_DORT_YONLUG
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_DORT_YONLUG_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#MAR SARGIS KHAGANATE
		else_if = {
			limit = {
				faith = faith:nestorian
				OR = {
					has_nickname = nick_mar_sargis
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_mar_sargis
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_MAR_SARGIS
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_MAR_SARGIS_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#XORMUSTA KHAGANATE
		else_if = {
			limit = {
				OR = {
					faith = faith:nestorian
					faith.religion = faith:manichean.religion
				}
				OR = {
					has_nickname = nick_xormuzta
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_xormuzta
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_XORMUZTA
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_XORMUZTA_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#CIHANGIR KHAGANATE
		else_if = {
			limit = {
				faith.religion = religion:islam_religion
				capital_province ?= {
					OR = {
						geographical_region = world_middle_east
						geographical_region = world_asia_minor
						geographical_region = world_steppe_tarim
						geographical_region = world_steppe_central
					}
				}
				current_date >= 1250
				OR = {
					has_nickname = nick_cihangir
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_cihangir
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_CIHANGIR
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_CIHANGIR_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#AKHSHUNWAR KHAGANATE
		else_if = {
			limit = {
				culture = {
					OR = {
						has_cultural_pillar = language_iranian
						has_cultural_pillar = language_scythian
					}
				}
				OR = {
					has_nickname = nick_akhshunwar
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_akhshunwar
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_AKHSHUNWAR
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_AKHSHUNWAR_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#TENGRI KHAGANATE
		else_if = {
			limit = {
				NOR = {
					faith.religion = religion:christianity_religion
					faith.religion = religion:islam_religion
				}
				OR = {
					has_nickname = nick_tengri_khagan
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_tengri_khagan
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_TENGRI
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_TENGRI_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#CHINGGISID KHAGANATE
		else_if = {
			limit = {
				NOT = {
					culture = {
						has_cultural_pillar = language_turkic
					}
				}
				OR = {
					has_nickname = nick_genghis_khan
					primary_title = {
						any_past_holder = {
						 	has_nickname = nick_genghis_khan
						}
					}
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_CHINGGIS
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_CHINGGIS_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		#FALLBACK OPTIONS
		else_if = {
			limit = {
				culture = {
					has_cultural_pillar = heritage_turkic
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_TURKIC
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_TURKIC_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		else_if = {
			limit = {
				culture = {
					has_cultural_pillar = heritage_mongolic
				}
			}
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME_MONGOLIC
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_MONGOLIC_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		else = {
			#Create a hegemony for the GoK!
			create_dynamic_title = {
				tier = hegemony
				name = GREATEST_OF_KHANS_HEGEMONY_NAME
				adj = GREATEST_OF_KHANS_HEGEMONY_NAME_ADJ
				article = article_CONFEDERATION_CULTURE_NAME
			}
		}
		scope:new_title = {
			save_scope_as = gok_hegemony
		}
		scope:gok_hegemony = {
			set_color_from_title = root.capital_county.kingdom
			set_can_be_named_after_dynasty = no
			set_can_use_nomadic_naming = no
			set_definitive_form = yes
		}
		
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:gok_hegemony = {
			change_title_holder = {
				holder = root
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:gok_hegemony = {
			generate_coa = yes
		}
		save_scope_value_as = {
			name = gok_empire_crumble_date
			value = global_var:gok_empire_crumble_date
		}
	}
		
	#Give the GoK hegemony all of the steppe as de jure
	hidden_effect = {
		situation:the_great_steppe ?= {
			every_situation_county = {
				limit = {
					holder.top_liege ?= root
				}
				empire = {
					add_to_list = steppe_empires
				}
			}
		}
		every_in_list = {
			list = steppe_empires
			limit = {
				#Check Chinese empires aren't swapped
				NAND = {
					exists = hegemony
					OR = {
						this = title:e_zhongyuan
						this = title:e_yongliang
						this = title:e_jingyang
						this = title:e_liangyi
						this = title:e_lingnan
					}
				}
			}
			set_de_jure_liege_title = scope:gok_hegemony
		}
	}
	
	if = {
		limit = {
			exists = dynasty
		}
		dynasty = {
			add_dynasty_prestige = monumental_dynasty_prestige_gain
		}
	}

	if = {
		limit = {
			has_education_martial_trigger = yes
			NOT = {
				has_trait = education_martial_5
			}
		}
		remove_trait = education_martial_1
		remove_trait = education_martial_2
		remove_trait = education_martial_3
		remove_trait = education_martial_4
		custom_tooltip = {
			text = gain_5th_lvl_education_martial_tt
			add_trait = education_martial_5
		}
		
	}
	else_if = {
		limit = {
			has_education_diplomacy_trigger = yes
			NOT = {
				has_trait = education_diplomacy_5
			}
		}
		remove_trait = education_diplomacy_1
		remove_trait = education_diplomacy_2
		remove_trait = education_diplomacy_3
		remove_trait = education_diplomacy_4
		custom_tooltip = {
			text = gain_5th_lvl_education_diplomacy_tt
			add_trait = education_diplomacy_5
		}
	}
	else_if = {
		limit = {
			has_education_stewardship_trigger = yes
			NOT = {
				has_trait = education_stewardship_5
			}
		}
		remove_trait = education_stewardship_1
		remove_trait = education_stewardship_2
		remove_trait = education_stewardship_3
		remove_trait = education_stewardship_4
		custom_tooltip = {
			text = gain_5th_lvl_education_stewardship_tt
			add_trait = education_stewardship_5
		}
	}
	else_if = {
		limit = {
			has_education_intrigue_trigger = yes
			NOT = {
				has_trait = education_intrigue_5
			}
		}
		remove_trait = education_intrigue_1
		remove_trait = education_intrigue_2
		remove_trait = education_intrigue_3
		remove_trait = education_intrigue_4
		custom_tooltip = {
			text = gain_5th_lvl_education_intrigue_tt
			add_trait = education_intrigue_5
		}
	}
	else_if = {
		limit = {
			has_education_learning_trigger = yes
			NOT = {
				has_trait = education_learning_5
			}
		}
		remove_trait = education_learning_1
		remove_trait = education_learning_2
		remove_trait = education_learning_3
		remove_trait = education_learning_4
		custom_tooltip = {
			text = gain_5th_lvl_education_learning_tt
			add_trait = education_learning_5
		}
	}
	else = {
		add_trait = shrewd
	}
}

gok_upgrade_realm_and_government_effect = {
	if = {
		limit = {
			exists = scope:realm_culture_1
		}
		culture = {
			get_random_innovation_from = scope:realm_culture_1
		}
	}
	if = {
		limit = {
			exists = scope:realm_culture_2
		}
		culture = {
			get_random_innovation_from = scope:realm_culture_2
		}
	}
	if = {
		limit = {
			exists = scope:realm_culture_3
		}
		culture = {
			get_random_innovation_from = scope:realm_culture_3
		}
	}

	capital_county = {
		if = {
			limit = {
				any_county_province = {
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			add_county_modifier = {
				modifier = great_khans_capital_modifier
				years = 30
			}
		}
		custom_tooltip = gok_capital_holdings_switch_tt

		hidden_effect = {
			every_county_province = {
				limit = {
					has_holding = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				set_holding_type = castle_holding
				add_building = castle_02
				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_high_medieval
						}
					}
					add_building = castle_03
				}
				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_late_medieval
						}
					}
					add_building = castle_04
				}
			}
			random_county_province = {
				limit = {
					has_holding = no
				}
				save_scope_as = capital_prov_1
				set_holding_type = church_holding

				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_high_medieval
						}
					}
					add_building = temple_03
				}
				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_late_medieval
						}
					}
					add_building = temple_02
				}
			}
			random_county_province = {
				limit = {
					exists = scope:capital_prov_1
					has_holding = no
					NOT = {
						this = scope:capital_prov_1
					}
				}
				set_holding_type = city_holding

				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_high_medieval
						}
					}
					add_building = city_03
				}
				if = {
					limit = {
						any_culture_global = {
							has_cultural_era_or_later = culture_era_late_medieval
						}
					}
					add_building = city_02
				}
			}
		}
	}
	custom_tooltip = gok_every_held_title_gains_castles
	custom_tooltip = gok_some_nomad_vassals_holdings_switch
	hidden_effect = {
		every_held_title = {
			limit = {
				tier = tier_county
				any_county_province = {
					is_county_capital = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			every_county_province = {
				limit = {
					is_county_capital = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				set_holding_type = castle_holding
			}
		}
		every_realm_county = {
			limit = {
				any_county_province = {
					is_county_capital = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				holder = {
					is_in_list = switching_vassals
				}
			}
			every_county_province = {
				limit = {
					is_county_capital = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				set_holding_type = castle_holding
				#holder is a high lord, upgrade their castle a bit
				if = {
					limit = {
						county.holder = {
							highest_held_title_tier >= tier_duchy
						}
						this = county.holder.capital_province
					}
					if = {
						limit = {
							any_culture_global = {
								has_cultural_era_or_later = culture_era_high_medieval
							}
						}
						add_building = castle_02
					}
					if = {
						limit = {
							any_culture_global = {
								has_cultural_era_or_later = culture_era_late_medieval
							}
						}
						add_building = castle_03
					}
				}
			}
			#Holder is a king, give capital some extra holdings
			if = {
				limit = {
					holder = {
						highest_held_title_tier >= tier_kingdom
					}
					this = holder.capital_county
				}
				random_county_province = {
					limit = {
						has_holding = no
					}
					save_scope_as = capital_prov_1
					begin_create_holding = church_holding
				}
				random_county_province = {
					limit = {
						exists = scope:capital_prov_1
						has_holding = no
						NOT = {
							this = scope:capital_prov_1
						}
					}
					begin_create_holding = city_holding
				}
			}
		}
	}
}

gok_final_decision_list_setup = {
	#Switching vassals to feudalism or clan
	every_vassal_or_below = {
		limit = {
			gok_gov_switch_valid_vassal_trigger = yes
			mpo_greatest_of_khans_0030_willing_nomad_vassal = yes
		}
		add_to_list = switching_vassals
	}
	save_scope_value_as = {	
		name = switching_vassals_value
		value = "list_size(switching_vassals)"
	}
	#Switching vassals TO nomadism
	every_vassal_or_below = {
		limit = {
			NOR = {
				government_has_flag = government_is_nomadic
				government_has_flag = government_is_herder
			}
			gok_gov_switch_valid_vassal_trigger = yes
		}
		#ones willing to switch can remain in power
		if = {
			limit = {
				OR = {
					has_trait = nomadic_philosophy
					culture = {
						has_cultural_tradition = tradition_horse_lords
					}
					culture = {
						has_cultural_tradition = tradition_devoted_horsemanship
					}
					AND = {
						highest_held_title_tier >= tier_kingdom
						mpo_greatest_of_khans_0030_dominated_sedentary_vassal = yes
					}
					AND = {
						highest_held_title_tier >= tier_duchy
						mpo_greatest_of_khans_0030_willing_sedentary_vassal = yes
					}
					highest_held_title_tier = tier_county
				}
			}
			add_to_list = sedentary_to_nomad_vassals
		}
		#The others must go
		else = {
			add_to_list = city_state_vassals
		}
	}
	save_scope_value_as = {	
		name = sedentary_to_nomad_vassals_value
		value = "list_size(sedentary_to_nomad_vassals)"
	}
	save_scope_value_as = {	
		name = city_state_vassals_value
		value = "list_size(city_state_vassals)"
	}
	#counties that will be switched from non-nomadic to nomadic
	every_realm_county = {
		limit = {
			NOR = {
				#Already nomadic
				any_county_province = {
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				#Holder is invalid for switching
				holder = { gok_gov_switch_valid_vassal_trigger = no }
				#De jure kingdom capital (probably important)
				this = kingdom.title_capital_county
				AND = {
					holder = {
						is_in_list = city_state_vassals
					}
					this = holder.capital_county
				}
			}
		}
		add_to_list = burned_to_nomadism
	}
	save_scope_value_as = {	
		name = burned_to_nomadism_value
		value = "list_size(burned_to_nomadism)"
	}
}

### GoK will automatically declare DEVASTATING wars
gok_war_target_evaluation_and_declaration_effect = {
	save_scope_as = actor
	if = {
		limit = {
			mpo_offer_submission_or_ruin_shown_actor_trigger = yes
			mpo_offer_submission_or_ruin_valid_actor_trigger = yes
		}
		# Set the Mongol Emperor as reference point
		save_scope_as = mongol_emperor
		add_character_flag = {
			flag = free_mongol_cb
			days = 14
		}
		# Select a new target
		random_neighboring_top_liege_realm_owner = {
			limit = {
				NOT = { is_at_war_with = scope:mongol_emperor }
				NOT = { is_allied_to = scope:mongol_emperor }
				NOT = { this = scope:mongol_emperor }
				NOT = { top_liege = scope:mongol_emperor }
				save_temporary_scope_as = truce_check
				NOT = {
					scope:mongol_emperor = {
						any_truce_target = {
							this = scope:truce_check
						}
					}
				}
				trigger_if = { # We don't want the Byzantine empire to get annihilated immediately
					limit = {
						OR = {
							has_primary_title = title:e_byzantium
							has_primary_title = title:e_latin_empire
						}
					}
					OR = {
						 # This is not the 'historical' Mongol Empire, all bets are off
						NOT = {
							scope:mongol_emperor = {
								any_held_title = {
									this = title:e_mongol_empire
								}
							}
						}
						current_year < 1178
						current_year >= 1279 # Roughly when the mongols should fracture historically
						scope:mongol_emperor = {
							completely_controls_region = special_mongol_empire_golden_horde_region # Controls all of Russia and the Steppe
						}
						any_realm_county = { # Byzantium is expansionist
							count >= 50
							title_province = {
								OR = {
									geographical_region = special_mongol_empire_conquest_region_prio_5
									geographical_region = special_mongol_empire_conquest_region_prio_4
									geographical_region = special_mongol_empire_conquest_region_prio_3
									geographical_region = special_mongol_empire_conquest_region_prio_2
									geographical_region = special_mongol_empire_conquest_region_prio_1
									geographical_region = special_mongol_empire_conquest_region_prio_1_alpha
								}
							}
						}
					}
				}
				save_temporary_scope_as = recipient
				mpo_offer_submission_or_ruin_shown_recipient_trigger = yes
				mpo_offer_submission_or_ruin_valid_recipient_trigger = yes
			}
			weight = {
				base = 0
				modifier = {
					add = mongol_invasion_target_character_weight
					always = yes
				}
				#Should only attack China when very strong
				modifier = {
					factor = 0.1
					primary_title = title:h_china
					current_military_strength >= scope:mongol_emperor.half_current_military_strength
				}
			}
			save_temporary_scope_as = next_invasion_target
			primary_title = {
				save_temporary_scope_as = next_invasion_title_target
			}
		}
		if = {
			limit = {
				exists = scope:next_invasion_target
			}
			if = {
				limit = { # Declare war on every same-tier count or duke in same empire
					scope:next_invasion_target = {
						OR = {
							highest_held_title_tier = tier_county
							highest_held_title_tier = tier_duchy
						}
					}
				}
				scope:next_invasion_title_target = {
					add_to_temporary_list = all_titles_to_declare_on
					empire = {
						every_in_de_jure_hierarchy = { # Find all other same-tier titles in same de jure empire
							continue = {
								tier > tier_county
								# Stop searching if you hit the Mongol Emperor's territory at any point
								trigger_if = {
									limit = { exists = holder }
									NOT = { holder = scope:mongol_emperor }
									NOT = { holder.top_liege = scope:mongol_emperor }
								}
							}
							limit = {
								exists = this
								OR = {
									tier = tier_county
									tier = tier_duchy
								}
								exists = holder
								holder = {
									is_independent_ruler = yes
									NOT = { this = scope:mongol_emperor }
									NOT = { top_liege = scope:mongol_emperor }
									NOT = { is_at_war_with = scope:mongol_emperor }
									NOT = { is_allied_to = scope:mongol_emperor }
									NOT = { is_at_war_with = scope:mongol_emperor }
									save_temporary_scope_as = truce_check
									NOT = {
										scope:mongol_emperor = {
											any_truce_target = {
												this = scope:truce_check
											}
										}
									}
									save_temporary_scope_as = recipient
									mpo_offer_submission_or_ruin_shown_recipient_trigger = yes
									mpo_offer_submission_or_ruin_valid_recipient_trigger = yes
									in_diplomatic_range = scope:mongol_emperor
								}
							}

							add_to_temporary_list = all_titles_to_declare_on
						}
					}
					every_in_list = {
						list = all_titles_to_declare_on
						limit = {
							holder = {
								# An extra check to make sure we haven't snuck any Mongol territory in
								NOT = { this = scope:mongol_emperor }
								NOT = { top_liege = scope:mongol_emperor }
		
								# Standard conditions
								NOT = { is_at_war_with = scope:mongol_emperor }
								NOT = {
									is_in_list = has_been_sent_subjugation_offer
								}
								save_temporary_scope_as = truce_check

								save_temporary_scope_as = recipient
								mpo_offer_submission_or_ruin_shown_recipient_trigger = yes
								mpo_offer_submission_or_ruin_valid_recipient_trigger = yes
								in_diplomatic_range = scope:mongol_emperor
							}
							NOT = {
								scope:mongol_emperor = {
									any_truce_target = {
										this = scope:truce_check
									}
								}
							}
						}
						holder = {
							add_to_list = title_holders_declared_on
						}
					}
					every_in_list = {
						list = title_holders_declared_on
						save_scope_as = recipient
						scope:mongol_emperor = {
							run_interaction = {
								interaction = mpo_offer_submission_or_ruin
								actor = scope:mongol_emperor
								recipient = scope:recipient
								send_threshold = decline
							}
						}
					}
				}
			}	
			else = {
				scope:next_invasion_target = {
					save_scope_as = recipient
				}
				scope:mongol_emperor = {
					run_interaction = {
						interaction = mpo_offer_submission_or_ruin
						actor = scope:mongol_emperor
						recipient = scope:recipient
						send_threshold = decline
					}
				}
			}
		}
	}
}

mpo_add_golden_lineage_effect = {
	add_trait = golden_lineage
	if = {
		limit = {
			exists = dynasty
		}
		custom_tooltip = descendants_gain_golden_lineage
		hidden_effect = {
			dynasty = {
				every_dynasty_member = {
					custom = custom
					limit = {
						any_ancestor = {
							this = $CHARACTER$
						}
					}
					add_trait = golden_lineage
				}
			}
		}
	}
	every_child = {
		limit = {
			NOR = {
				has_trait = bastard
				has_trait = legitimized_bastard
			}
			NOT = {
				has_trait = golden_lineage
			}
		}
		add_trait = golden_lineage
		if = {
			limit = {
				is_male = yes
			}
			every_child = {
				add_trait = golden_lineage
			}
		}
	}
}

mpo_gok_onslaught_admin_vassal_reorganization = {
	#Make a list of admin vassals high enough tier to survive
	every_vassal_or_below = {
		limit = {
			is_landed = yes
			#This should be duke or count based on gov type
			highest_held_title_tier >= main_administrative_tier
			government_allows = administrative
		}
		add_to_list = protected_admin_vassals
	}
	#Make a list of admin vassals that must be moved or purged
	every_vassal_or_below = {
		limit = {
			is_landed = yes
			highest_held_title_tier < main_administrative_tier
			government_allows = administrative
			highest_held_title_tier > tier_barony
			NOT = {
				any_liege_or_above = {
					is_in_list = protected_admin_vassals
				}
			}
		}
		add_to_list = vulnerable_admin_vassals
	}
	#Make a list of the highest surviving admin in their vassalship chain
	every_in_list = {
		list = protected_admin_vassals
		limit = {
			OR = {
				liege = scope:defender
				liege = {
					NOT = {
						government_allows = administrative
					}
				}
			}
		}
		add_to_list = top_protected_admins
	}
	#Find a liege for every vulnerable we can
	every_in_list = {
		list = vulnerable_admin_vassals
		#Move de jure vulnerable vassals to empires
		if = {
			limit = {
				capital_county.empire.holder ?= {
					is_in_list = top_protected_admins
				}
			}
			capital_county.empire.holder = {
				save_scope_as = landless_admin_liege
			}
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
				add_claim_on_loss = yes
			}
			change_liege = {
				liege = scope:landless_admin_liege
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			remove_from_list = vulnerable_admin_vassals
		}
		#Move de jure vulnerable vassals to kingdoms
		if = {
			limit = {
				capital_county.kingdom.holder ?= {
					is_in_list = top_protected_admins
				}
			}
			capital_county.kingdom.holder = {
				save_scope_as = landless_admin_liege
			}
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
				add_claim_on_loss = yes
			}
			change_liege = {
				liege = scope:landless_admin_liege
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			remove_from_list = vulnerable_admin_vassals
		}
		#Move de jure vulnerable vassals to duchies
		if = {
			limit = {
				capital_county.duchy.holder ?= {
					is_in_list = top_protected_admins
				}
			}
			capital_county.duchy.holder = {
				save_scope_as = landless_admin_liege
			}
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
				add_claim_on_loss = yes
			}
			change_liege = {
				liege = scope:landless_admin_liege
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			remove_from_list = vulnerable_admin_vassals
		}
		#Move landed vulnerable neighbors
		else_if = {
			limit = {
				is_landed = yes
				any_sub_realm_county = {
					any_neighboring_county = {
						holder = {
							OR = {
								is_in_list = top_protected_admins
								any_liege_or_above = {
									is_in_list = top_protected_admins
								}
							}
						}
					}
				}
			}
			save_scope_as = vulnerable_neighbor
			ordered_in_list = {
				order_by = current_military_strength
				list = top_protected_admins
				limit = {
					any_sub_realm_county = {
						any_neighboring_county = {
							holder = {
								OR = {
									this = scope:vulnerable_neighbor
									any_liege_or_above = {
										this = scope:vulnerable_neighbor
									}
								}
							}
						}
					}
				}
				save_scope_as = landless_admin_liege
			}
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
				add_claim_on_loss = yes
			}
			change_liege = {
				liege = scope:landless_admin_liege
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			remove_from_list = vulnerable_admin_vassals
		}
		#Move landless to random top tiers in list
		else_if = {
			limit = {
				is_landless_administrative = yes
				#Lower tier than potential liege
				any_in_list = {
					list = top_protected_admins
					highest_held_title_tier > prev.highest_held_title_tier
				}
			}
			ordered_in_list = {
				list = top_protected_admins
				order_by = highest_held_title_tier
				save_scope_as = landless_admin_liege
			}
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
				add_claim_on_loss = yes
			}
			change_liege = {
				liege = scope:landless_admin_liege
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			remove_from_list = vulnerable_admin_vassals
		}
	}
}

gok_government_change_story_end_effect = {			
	if = {
		limit = {
			any_owned_story = {
				story_type = story_greatest_of_khans
			}
		}
		custom_tooltip = gok_ending_warning_offer_sub_or_ruin
		custom_tooltip = gok_ending_warning_onslaught
		custom_tooltip = gok_ending_warning_end_decision
		hidden_effect = {
			every_owned_story = {
				limit = { story_type = story_greatest_of_khans }
				end_story = yes
			}
			trigger_event = {
				id = mpo_greatest_of_khans.0041
				days = 3
			}
		}
	}
}
