﻿el_squared_distance_camp = 45000
el_squared_distance_max_travel = 250000
el_landed_cd_adventurer = 365
el_landed_cd_adventurer_nope = 180
el_landed_max_contract = 3  ## modifier la valeur du amount de el_landed_max_contract_trigger
el_landed_contract_chosse_divisor = 2
el_landed_contract_chosse_treshold = 40

el_landed_medium_gold_value = {
	value = medium_gold_value
	divide = 2
}

el_landed_chance_success_intelect = {
	value = 0
	if = {
		limit = {  has_trait =  intellect_good_1 } 
		add = 5
	}
	if = {
		limit = {  has_trait = intellect_good_2 } 
		add = 10
	}
	if = {
		limit = {  has_trait = intellect_good_3 } 
		add = 15
	}
	if = {
		limit = {  has_trait = intellect_bad_1 } 
		add = -5
	}
	if = {
		limit = {  has_trait = intellect_bad_2 } 
		add = -10
	}
	if = {
		limit = {  has_trait = intellect_bad_3 } 
		add = -15
	}
	if = {
		limit = {  has_trait = shrewd } 
		add = 10
	}
	if = {
		limit = {  has_trait = dull } 
		add = -10
	}
	if = {
		limit = {  has_trait = inbred } 
		add = -15
	}	
}

el_landed_el_landed_chance_success_education_diplomacy = {
	value = 0
	if = {
		limit = { has_trait = education_diplomacy_2 }
		add = 2
	}
	else_if = {
		limit = { has_trait = education_diplomacy_3 }
		add = 4
	}
	else_if = {
		limit = { has_trait = education_diplomacy_4 }
		add = 7
	}
	else_if = {
		limit = { has_trait = education_diplomacy_5 }
		add = 10
	}
}

el_landed_el_landed_chance_success_education_martial = {
	value = 0
	if = {
		limit = { has_trait = education_martial_2 }
		add = 2
	}
	else_if = {
		limit = { has_trait = education_martial_3 }
		add = 4
	}
	else_if = {
		limit = { has_trait = education_martial_4 }
		add = 7
	}
	else_if = {
		limit = { has_trait = education_martial_5 }
		add = 10
	}
}

el_landed_el_landed_chance_success_education_stewardship = {
	value = 0
	if = {
		limit = { has_trait = education_stewardship_2 }
		add = 2
	}
	else_if = {
		limit = { has_trait = education_stewardship_3 }
		add = 4
	}
	else_if = {
		limit = { has_trait = education_stewardship_4 }
		add = 7
	}
	else_if = {
		limit = { has_trait = education_stewardship_5 }
		add = 10
	}
}

el_landed_el_landed_chance_success_education_intrigue = {
	value = 0
	if = {
		limit = { has_trait = education_intrigue_2 }
		add = 2
	}
	else_if = {
		limit = { has_trait = education_intrigue_3 }
		add = 4
	}
	else_if = {
		limit = { has_trait = education_intrigue_4 }
		add = 7
	}
	else_if = {
		limit = { has_trait = education_intrigue_5 }
		add = 10
	}
}

el_landed_el_landed_chance_success_education_learning = {
	value = 0
	if = {
		limit = { has_trait = education_learning_2 }
		add = 2
	}
	else_if = {
		limit = { has_trait = education_learning_3 }
		add = 4
	}
	else_if = {
		limit = { has_trait = education_learning_4 }
		add = 7
	}
	else_if = {
		limit = { has_trait = education_learning_5 }
		add = 10
	}
}

el_landed_chance_success_train_chance_trait = {
	value = scope:calc_value.martial
	multiply = 2.5
}

el_landed_chance_success_train_chance_bonus = {
	value = scope:calc_value.prowess
	divide = 1.5
}

el_landed_chance_success_train_knight = {
	value = 50
	add = {
		value = {
			add = {
				value = martial
				subtract = high_skill_rating
				multiply = 3.5
				divide = 2
			}
			add = {	
				value = prowess
				subtract = high_skill_rating
				multiply = 3.5
				divide = 2				
			}
		}
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_martial
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_mercenaries
		}
		add = 5
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_brigands
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_chance_success_tutor_child = {
	value = 50
	add = {
		value = learning
		subtract = high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_learning
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_scholars
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_chance_success_des_nei = {
	value = 50
	add = {
		value = {
			add = {
				value = intrigue
				subtract = high_skill_rating
				multiply = 3.5
				divide = 2
			}
			add = {	
				value = prowess
				subtract = high_skill_rating
				multiply = 3.5
				divide = 2				
			}
		}
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_intrigue
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_mercenaries
		}
		add = 5
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_brigands
		}
		add = 5
	}
	if = {
		limit = {
			has_trait = gallowsbait
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_chance_success_regale_court = {
	value = 50
	add = {
		value = diplomacy
		subtract = high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_diplomacy
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_explorers
		}
		add = 5
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_legitimists
		}
		add = 10
	}
	if = {
		limit = {
			has_trait = lifestyle_reveler
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_chance_success_imp_dom = {
	value = 50
	add = {
		value = stewardship
		subtract = high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_stewardship
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_scholars
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_chance_success_con_nei = {
	value = 50
	add = {
		value = learning
		subtract = very_high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_learning
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_scholars
		}
		add = 5
	}
	if = {
		limit = {
			 has_trait = theologian
		}
		add = 5
	}
	if = {
		limit = {
			exists = scope:el_landed_con_nei_fin
		}
		add = {
			value = 0
			add = scope:el_employer.faith.fervor
			subtract = scope:el_landed_con_nei_fin.faith.fervor
			multiply = 0.3
		}		
		if = {
			limit = {
				NOT = { scope:el_landed_con_nei_fin.faith = { has_doctrine_parameter = unreformed } }
			}
			add = -10
		}
		if = {
			limit = {
				scope:el_landed_con_nei_fin= { has_trait = cynical } 
			}
			add =  10
		}
	}
	if = {
		limit = {
			NOT = { exists = scope:el_landed_con_nei_fin }
		}
		add = {
			value = -5
		}
	}
	min = 0
	max = 100
}

el_landed_chance_success_sup_fac = {
	value = 50
	add = {
		value = martial
		subtract = high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_martial
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_mercenaries
		}
		add = 5
	}
	if = {
		limit = {
			max_military_strength <= 250
		}
		add = -15
	}
	else_if = {
		limit = {
			max_military_strength > 250
			max_military_strength <= 500
		}
		add = -5
	}
	else_if = {
		limit = {
			max_military_strength > 500
			max_military_strength <= 1000
		}
		add = 0
	}
	else_if = {
		limit = {
			max_military_strength > 1000
			max_military_strength <= 2000
		}
		add = 5	
	}
	else_if = {
		limit = {
			max_military_strength > 2000
		}
		add = 10
	}
	min = 0
	max = 100
}

el_landed_chance_success_find_sec = {
	value = 50
	add = {
		value = intrigue
		subtract = high_skill_rating
		multiply = 3.5
	}
	add = {
		value = el_landed_chance_success_intelect
	}
	add = {
		value = el_landed_el_landed_chance_success_education_intrigue
	}
	if = {
		limit = {
			has_realm_law = camp_purpose_brigands
		}
		add = 5
	}
	if = {
		limit = {
			has_focus = intrigue_adventurer_focus
		}
		add = 2
	}
	if = {
		limit = {
			has_perk = digging_for_dirt_perk 
		}
		add = 5
	}
	min = 0
	max = 100
}

el_landed_sup_fac_levie_maa_value = {
	value = 0
	if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength <= 250
		}
		add = 200
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 250
			scope:el_adventurer_fin.max_military_strength <= 500
		}
		add = 350
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 500
			scope:el_adventurer_fin.max_military_strength <= 1000
		}
		add = 750
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 1000
			scope:el_adventurer_fin.max_military_strength <= 2000
		}
		add = 1000
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 2000
		}
		add = 1500
	}
}

el_landed_sup_fac_levie_discont_value = {
	value = 0
	if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength <= 250
		}
		add = 5
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 250
			scope:el_adventurer_fin.max_military_strength <= 500
		}
		add = 10
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 500
			scope:el_adventurer_fin.max_military_strength <= 1000
		}
		add = 20
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 1000
			scope:el_adventurer_fin.max_military_strength <= 2000
		}
		add = 30
	}
	else_if = {
		limit = {
			scope:el_adventurer_fin.max_military_strength > 2000
		}
		add = 50
	}
}



el_landed_tutor_child_chance_diplomcacy_calc = {
	value = scope:el_adventurer_fin.diplomacy
}

el_landed_tutor_child_chance_martial_calc = {
	value = scope:el_adventurer_fin.martial
	add = scope:el_adventurer_fin.prowess
	divide = 2
}

el_landed_tutor_child_chance_stewardship_calc = {
	value = scope:el_adventurer_fin.stewardship
}

el_landed_tutor_child_chance_intrigue_calc = {
	value = scope:el_adventurer_fin.intrigue
}

el_landed_tutor_child_chance_learning_calc = {
	value = scope:el_adventurer_fin.learning
}

el_landed_order_select_find_sec_value = {
	value = 1
	if = {
		limit = {
			this = scope:el_employer
		}
		add = 100
	}
	add = highest_held_title_tier
}

el_landed_order_select_distance_value = {
	value = 0
	if = {
		limit = {
			exists = capital_province
		}
		add = {
			value = "capital_province.squared_distance(scope:el_employer.capital_province)"
			multiply = -1
		}
	}
}

el_landed_order_select_child_value = {
	value = 0
	add = age
	if  = {
		limit = {
			exists = scope:el_employer.player_heir
			this = scope:el_employer.player_heir
		}
		add = 50
	}
}