decisions = {

	###for bug in V1.7
	fix_csm_bug = {
		only_playable = yes
		is_high_prio = yes
		ai = no
		
		potential = {
			had_character_flag = { flag = visiting_mount_market days = 3 }
		}
		allow = { always = yes }
		effect = { clr_character_flag = visiting_mount_market }
	}
	

	csm_info_decision = {
		only_playable = yes
		is_high_prio = yes
		ai = no
		
		potential = {
			has_global_flag = csm_initialized
			ai = no
			has_artifact = csm_info_book
		}
		
		allow = {
			always = yes
			NOT = { has_character_flag = reading_csm_info_book }
		}
		
		effect = { 
			hidden_tooltip = {
				set_character_flag = reading_csm_info_book
				long_character_event = { id = csmm.301 }
			}
		}
	}

	employ_stable_master = {
		only_playable = yes
		is_high_prio = yes
		
		potential = {
			has_global_flag = csm_initialized
			has_character_flag = has_mount
			has_stable_master_trigger = no
		}
		
		allow = {
			wealth = 50
			prestige = 100
			is_adult = yes
			war = no
			csm_is_inaccessible_or_incapable_trigger = no
			hidden_tooltip = { NOT = { has_character_flag = employing_stable_master } }
		}
		
		effect = {
			custom_tooltip = {
				text = employ_stable_master_effect
				set_character_flag = employing_stable_master
				character_event = { id = csm.100 }
			}
		}
		
		ai_will_do = { factor = 0.8 }
		ai_check_interval = 24
	}

	
	mount_market = {
		only_playable = yes
		
		ai = no
		
		potential = { 
			has_global_flag = csm_initialized 
			NOT = { has_global_flag = gender_based_breeding }
		}
		
		allow = {
			is_adult = yes
			csm_is_inaccessible_or_incapable_trigger = no
			hidden_tooltip = { NOT = { has_character_flag = visiting_mount_market } }
		}
	
		effect = {
			custom_tooltip = {
				text = mount_market_effect
				set_character_flag = visiting_mount_market
				character_event = { id = csm.010 }
			}
		}
	}
	
	ride_glitterhoof = {
		only_playable = yes
		is_high_prio = yes
		
		potential = {
			NOT = { has_character_flag = ride_glitterhoof_decision_blocker }
			NOT = {
				has_game_rule = {
					name = supernatural_events
					value = off
				}
			}
			trait = lunatic
			any_courtier = { 
				trait = horse 
				culture = horse
			}
		}
		
		allow = {
			is_adult = yes
			war = no
			csm_is_inaccessible_or_incapable_trigger = no
			custom_tooltip = {
				text = ride_glitterhoof_allow
				any_courtier = { 
					trait = horse 
					culture = horse
				}
			}
			custom_tooltip = {
				text = ride_glitterhoof_allow2
				NOT = { has_global_flag = glitterhoof_alive }
			}
			hidden_tooltip = {
				OR = {
					ai = no
					AND = {
						ai = yes
						higher_tier_than = count
						prestige = 300
						demesne_size = 3
						immortal = no
					}
				}
			}
		}
		
		effect = {
			custom_tooltip = { 
				text = ride_glitterhoof_effect
				set_character_flag = ride_glitterhoof_decision_blocker
				character_event = { id = csm.104 days = 1 }
			}
		}
		
		
		ai_will_do = { factor = 1 }
		ai_check_interval = 60
	}
	
	tame_bucephalus = {
		only_playable = yes
		is_high_prio = yes
		
		potential = {
			has_global_flag = bucephalus_ready
			can_reach_greek_mounts_trigger = yes
			OR = {
				has_character_flag = bucephalus_spawner
				top_liege = { has_character_flag = bucephalus_spawner }
			}
		}
		
		allow = {
			prestige = 200
			is_adult = yes
			war = no
			csm_is_inaccessible_or_incapable_trigger = no
			custom_tooltip = { 
				text = tame_bucephalus_allow 
				NOT = { has_global_flag = bucephalus_busy }
				OR = {
					ai = no
					had_global_flag = { flag = bucephalus_ready days = 30 }
				}
			}
			custom_tooltip = {
				text = tame_bucephalus_allow2
				NOT = { has_character_modifier = bucephalus_timer }
			}
		}
		
		effect = {
			hidden_tooltip = { 
				set_global_flag = bucephalus_busy 
				add_character_modifier = { modifier = bucephalus_timer years = 1 hidden = yes }
			}
			prestige = -200
			custom_tooltip = {
				text = tame_bucephalus_effect
				character_event = { id = csm.202 days = 20 random = 8 }
			}
		}
		
		ai_check_interval = 12
		ai_will_do = {
			factor = 1 
			modifier = {
				factor = 0.5
				tier = count
			}
		}
	}
	
	
	ai_mount_decision = {
		only_playable = yes
		is_high_prio = yes
	
		potential = {
			NOT = { has_global_flag = gender_based_breeding }
			ai = yes
			is_adult = yes
			csm_is_inaccessible_or_incapable_trigger = no
			OR = {
				higher_tier_than = baron
				is_patrician = yes
			}
		}
		
		allow = {
			NOT = { has_character_modifier = ai_mount_decision_timer }
			OR = {
				AND = {
					NOT = { government = nomadic_government }
					OR = {
						wealth = 150
						AND = {
							tier = count
							wealth = 100
						}
					}
				}
				AND = {
					government = nomadic_government
					prestige = 250
				}
			}
			has_mount_trigger = no
		}
		
		effect = {
			add_character_modifier = { modifier = ai_mount_decision_timer years = 8 hidden = yes }
			if = {
				limit = { government = nomadic_government }
				character_event = { id = csmm.201 }
			}
			else = { character_event = { id = csmm.200 } } 
		}
		
		ai_will_do = {
			factor = 0.2
			modifier = {
				factor = 0.5
				war = yes
			}
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }
				OR = {
					wealth = 250
					monthly_income = 22
				}
			}
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }
				OR = {
					wealth = 300
					monthly_income = 33
				}
			}
			modifier = {
				factor = 3
				NOT = { government = nomadic_government }
				OR = {
					wealth = 500
					monthly_income = 55
				}
			}
			modifier = {
				factor = 3
				NOT = { government = nomadic_government }
				tier = king
			}
			modifier = {
				factor = 5
				NOT = { government = nomadic_government }
				tier = emperor
			}
			modifier = {
				factor = 1.5
				independent = yes
			}
			
			#nomads
			modifier = {
				factor = 0.5
				government = nomadic_government
				prestige < 400
			}
			modifier = {
				factor = 5
				government = nomadic_government
				prestige > 650
			}
		}
		ai_check_interval = 36
	}
	
	ai_mount_equipment_decision = {
		only_playable = yes
		is_high_prio = yes
	
		potential = {
			has_character_flag = has_mount
			ai = yes
			is_adult = yes
			csm_is_inaccessible_or_incapable_trigger = no
			OR = {
				higher_tier_than = baron
				is_patrician = yes
			}
		}
		
		allow = {
			NOT = { has_character_modifier = ai_mount_equipment_decision_timer }
			NAND = {
				has_active_mount_armor_trigger = yes
				any_artifact = {
					count = 2
					has_artifact_flag = mount_addon 
				}
			}
			OR = {
				wealth = 200
				AND = {
					wealth = 100
					monthly_income = 15
				}
			}
		}
		
		effect = {
			add_character_modifier = { modifier = ai_mount_equipment_decision_timer years = 3 hidden = yes }
			character_event = { id = csmm.202 } 
		}
		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 0.5
				war = yes
			}
			modifier = {
				factor = 2
				OR = {
					wealth = 250
					monthly_income = 22
				}
			}
			modifier = {
				factor = 2
				OR = {
					wealth = 300
					monthly_income = 33
				}
			}
			modifier = {
				factor = 5
				OR = {
					wealth = 500
					monthly_income = 55
				}
			}
			modifier = {
				factor = 2
				independent = yes
			}
		}
		ai_check_interval = 24
	}
	
	ai_upgrade_equipment_decision = {
		only_playable = yes
		is_high_prio = yes
	
		potential = {
			has_character_flag = has_mount
			ai = yes
			is_adult = yes
			csm_is_inaccessible_or_incapable_trigger = no
		}
		allow = {
			NOT = { has_character_modifier = ai_mount_equipment_decision_timer }
			OR = {
				any_artifact = {
					has_artifact_flag = mount_armor
					quality < 3
				}
				AND = {
					OR = {
						can_buy_greek_items_trigger = yes #greek cataphract armor
						can_buy_frankish_items_trigger = yes #frankish horse armor
					}
					any_artifact = {
						has_artifact_flag = mount_armor
						has_artifact_flag = horse_armor
						quality < 4
					}
				}
				AND = {
					any_artifact = {
						count = 2
						has_artifact_flag = mount_addon
					}
					any_artifact = {
						has_artifact_flag = mount_addon
						NOT = { original_owner = { character = ROOT } }
					}
				}
			}
			wealth = 50
		}
		effect = {
			add_character_modifier = { modifier = ai_mount_equipment_decision_timer years = 5 hidden = yes }
			character_event = { id = csmm.203 } 
		}
		ai_will_do = {
			factor = 0.75
			modifier = {
				factor = 0.5
				war = yes
			}
			modifier = {
				factor = 2
				independent = yes
			}
		}
		ai_check_interval = 24
	}
	
}




targeted_decisions = {
	
	sell_mount_decision = {
		ai = no
		filter = self
		third_party_filter = artifacts
		third_party = FROM
		show_third_party_potential = yes
		#show_third_party_score = yes
		
		potential = { 
			NOT = { has_global_flag = gender_based_breeding }
			has_mount_trigger = yes 
		}
		allow = {
			is_adult = yes
			war = no
			csm_is_inaccessible_or_incapable_trigger = no
		}
		
		third_party_potential = {
			FROMFROM = {
				show_scope_change = no
				is_mount_trigger = yes
				custom_tooltip = {
					text = sell_mount_decision_allow1 
					NOT = { artifact_type = foal }
				}
				custom_tooltip = {
					text = sell_mount_decision_allow2
					NOT = { has_artifact_flag = unique }
				}
			}
		}
		
		third_party_score = {
			factor = 10
			
			##quality
			additive_modifier = {
				value = 30
				FROMFROM = { 
					show_scope_change = no
					quality == 2
				}
			}
			additive_modifier = {
				value = 60
				FROMFROM = { 
					show_scope_change = no
					quality == 3
				}
			}
			additive_modifier = {
				value = 150
				FROMFROM = { 
					show_scope_change = no
					quality == 4
				}
			}
			additive_modifier = {
				value = 210
				FROMFROM = {
					show_scope_change = no
					quality == 5
				}
			}
			
			additive_modifier = {
				value = 20
				FROMFROM = {
					show_scope_change = no
					has_artifact_flag = elephant
				}
			}
			
			
			##traits
			additive_modifier = {
				value = 50
				FROMFROM = { is_fair_mount_trigger = yes }
			}
			additive_modifier = {
				value = 50
				FROMFROM = { is_robust_mount_trigger = yes }
			}
			additive_modifier = {
				value = 50
				FROMFROM = { is_fertile_mount_trigger = yes }
			}
			additive_modifier = {
				value = 50
				FROMFROM = { is_powerful_mount_trigger = yes }
			}
			additive_modifier = {
				value = 50
				FROMFROM = { is_swift_mount_trigger = yes }
			}
			
			##rare breed
			modifier = {
				factor = 1.5
				FROMFROM = { is_breeding_only_trigger = yes }			
			}
			
			##health related
			additive_modifier = {
				value = 25
				custom_tooltip = {
					text = sell_mount_decision_score_1
					FROMFROM = { 
						OR = {
							has_artifact_flag = mount_health_7
							has_artifact_flag = mount_health_8
						}
					}	
				}
			}
			additive_modifier = {
				value = 50
				custom_tooltip = {
					text = sell_mount_decision_score_2
					FROMFROM = { 
						OR = {
							has_artifact_flag = mount_health_9
							has_artifact_flag = mount_health_10
						}
					}	
				}
			}
			additive_modifier = {
				value = -25
				custom_tooltip = {
					text = sell_mount_decision_score_3
					FROMFROM = { has_artifact_flag = mount_health_3 }
				}
			}
			additive_modifier = {
				value = -50
				custom_tooltip = {
					text = sell_mount_decision_score_4
					FROMFROM = { 
						OR = {
							has_artifact_flag = mount_health_2
							has_artifact_flag = mount_health_1
						}
					}	
				}
			}
			
			
		}
		
		effect = {
			wealth = local_third_party_score
			
			hidden_tooltip = {
				FROMFROM = {
					trigger_switch = {
						on_trigger = has_artifact_flag
						
						irish = { event_target:ireland_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						spanish = { event_target:spain_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						barbary = { event_target:africa_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						steppes = { event_target:steppes_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						arabian = { event_target:arabia_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						moorish = { event_target:andalus_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						jurchen = { event_target:steppes_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						mongol = { event_target:steppes_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						bactrian = { event_target:bactria_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						indian = { event_target:india_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						african = { event_target:africa_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						tibetan = { event_target:tibet_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						scandinavian = { event_target:scandinavia_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						russian = { event_target:russia_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						samian = { event_target:sami_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						frankish = { event_target:france_mount_province = { change_variable = { which = available_mounts value = 1 } } }
						
						fallback = {
							random_province = {
								limit = { has_province_flag = mount_province }
								change_variable = { which = available_mounts value = 1 }
							}
						}
					}
					unsafe_destroy_artifact = yes
				}
				FROM = { check_mount_flags_effect = yes }
			}
		}
	}
	
	grant_commander_mount = {
		only_playable = yes
		filter = home_court
		ai_target_filter  = home_court
		
		from_potential = {
			OR = {
				ai = no
				AND = {
					ai = yes
					has_character_flag = has_mount
				}
			}
		}
		potential = { has_minor_title = title_commander }
		allow = {
			FROM = { wealth = 150 }
			is_landed = no
			is_heir = no
			has_education_martial_trigger = yes
			custom_tooltip = {
				text = grant_commander_mount_allow
				NOT = { has_character_flag = has_mount_commander }
			}
			hidden_tooltip = {
				FROM = {
					OR = {
						ai = no
						AND = {
							ai = yes
							opinion = { who = ROOT value = 5 }
							OR = {
								higher_tier_than = count
								AND = {
									tier = count
									OR = {
										prestige = 500
										demesne_size = 3
									}
								}
							}
						}
					}
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = grant_commander_mount_effect
				FROM = {
					set_character_flag = grant_commander_mount_block
					character_event = { id = csm.105 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 1.5
				age < 40
				martial = 10
			}
			modifier = {
				factor = 2
				age < 40
				martial = 16
			}
			modifier = {
				factor = 2
				age < 40
				FROM = { opinion = { who = ROOT value = 20 } }
			}
			modifier = {
				factor = 2
				age < 40
				dynasty = FROM
			}
		}
		
	}
	
	
	
	
}


offmap_decisions = {

	chinese_horse_decision = {
		only_playable = yes
		button_name = offmap_boons

		from_potential = {
			has_dlc = "Jade Dragon"
			has_global_flag = csm_initialized
			NOT = { has_global_flag = gender_based_breeding }
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
	
		allow = {
			FROM = {
				trigger_if = { 
					limit = { offmap_china = { has_status = china_golden_age } }
					offmap_china = { has_status = china_golden_age }
					has_offmap_currency = { offmap = offmap_china value = 500 }
				}
				trigger_else_if = { 
					limit = { 
						offmap_china = { 
							OR = {
								has_status = china_famine
								has_status = china_plague
							}
						} 
					}
					offmap_china = {
						OR = {
							has_status = china_famine
							has_status = china_plague
						}
					}
					has_offmap_currency = { offmap = offmap_china value = 1000 }
				}
				trigger_else = {
					has_offmap_currency = { offmap = offmap_china value = 750 }
				}
				csm_is_inaccessible_or_incapable_trigger = no
				custom_tooltip = {
					text = china_offmap_boon_decisions_enabled_trigger_cd_tt
					NOT = { has_character_modifier = jd_china_boon_cd }
				}
			}
			offmap_china = {
				NOR = {
					has_status = china_civil_war
					has_status = china_mongol_invasion
					has_status = china_jurchen_invasion
				}	
				custom_tooltip = {
					text = china_offmap_decisions_enabled_trigger_war_tt #"Is at peace with ยงY[From.GetTitledFirstName]ยง!"
					NOT = { governor = { war_with = FROM } }
				}
				governor = {
					show_scope_change = no
					is_within_diplo_range = FROM
					hidden_trigger  = { NOT = { character = FROM } } #Governor cannot use boon/tributes decisions
				}
			}	
		}

		effect = {
			FROM = {
				show_scope_change = no
				
				sound_effect = china_grace_spend
				
				if = {
					limit = { offmap_china = { has_status = china_golden_age } }
					add_offmap_currency = {
						offmap = offmap_china
						value = -500
					}
				}
				else_if = {
					limit = {
						offmap_china = {
							OR = {
								has_status = china_famine
								has_status = china_plague
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = -1000
					}
					custom_tooltip = {
						text = chinese_horse_decision_effect1
					}
				}
				else = { 
					add_offmap_currency = {
						offmap = offmap_china
						value = -750
					}
				}
				
				custom_tooltip = {
					text = chinese_horse_decision_effect2
					FROM = { set_china_boon_cd_effect = yes }
					offmap_china = { governor = { character_event = { id = csm.102 } } }
				}
			}
		}

		ai_will_do = {
			factor = 0.2
			
			modifier = {
				factor = 0.5
				offmap_china = {
					OR = {
						has_status = china_famine
						has_status = china_plague
					}
				}
			}
			modifier = {
				factor = 1.5
				offmap_china = { has_status = china_golden_age }
			}
			
			modifier = {
				factor = 2
				tier = duke
			}
			modifier = {
				factor = 3
				tier = king
			}
			modifier = {
				factor = 4
				tier = emperor
			}
			modifier = {
				factor = 1.5
				trait = greedy
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
		}
		ai_check_interval = 36
	}
}