﻿### MINISTER OF PERSONNEL
task_manage_talent = {
	default_task = yes
	position = minister_personnel
	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_manage_talent.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		### Find characters tooltip
		desc = task_manage_talent_character_effect_desc
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_manage_talent_effect_desc_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_manage_talent_effect_desc_bureaucrats_bonus
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_manage_talent_effect_desc_family_business_bonus
		}
		### Opinion
		desc = task_manage_talent_opinion_effect_desc
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_manage_talent_opinion_effect_desc_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_manage_talent_opinion_effect_desc_bureaucrats_bonus
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_manage_talent_opinion_effect_desc_family_business_bonus
		}
	}

	on_start_task = {
	}

	on_cancel_task = {
	}

	# Prestige Gain + Modifiers
	council_owner_modifier = {
		name = task_manage_talent
		courtier_and_guest_opinion = 1
		scale = task_manage_talent_opinion_total_scale_value
	}

	monthly_on_action = tgp_minister_manage_talent_on_action

	ai_will_do = {
		value = 1 # Always a good backup
		if = {
			limit = { court_positions_currently_filled < 10 }
			add = 500
		}
	}
}

task_bestow_royal_favor_minister_of_personnel = {
	position = minister_personnel
	clone = task_bestow_royal_favor
}

### MINISTER OF RITES
task_culture_minister = {
	position = councillor_court_chaplain
	clone = task_kurultai_culture_1
}

### MINISTER OF JUSTICE
task_justify_rule = {
	default_task = yes
	position = minister_justice
	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_justify_rule.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		### Legitimacy gain
		desc = task_justify_rule_effect_desc
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_justify_rule_effect_desc_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_justify_rule_effect_desc_bureaucrats_bonus
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_justify_rule_effect_desc_family_business_bonus
		}
		### Tyranny reduction
		desc = task_justify_rule_tyranny_effect_desc
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_justify_rule_tyranny_effect_desc_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_justify_rule_tyranny_effect_desc_bureaucrats_bonus
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_justify_rule_tyranny_effect_desc_family_business_bonus
		}
	}

	council_owner_modifier = {
		name = task_justify_rule
		legitimacy_gain_mult = 0.01
		scale = task_justify_rule_total_scale_value
	}

	council_owner_modifier = {
		name = task_justify_rule
		tyranny_loss_mult = 0.01
		scale = task_justify_rule_tyranny_total_scale_value
	}

	monthly_on_action = task_domestic_affairs_side_effects

	on_monthly = {
		if = {
			limit = {
				current_month = 1
				liege = { tyranny > 0 }
			}
			liege = {
				add_tyranny = task_justify_rule_tyranny_total_scale_value
			}
		}
	}

	ai_will_do = {
		value = 1 # Always a good backup
		if = { # Get rid of tyranny
			limit = {
				scope:councillor_liege = {
					OR = {
						AND = { # Somewhat rational characters prefer this
							ai_rationality > -25
							NOT = { has_trait = arrogant }
							tyranny >= 5
						}
						AND = { # If you're arrogant or deeply irrational, it'll take a long time for you to realize
							OR = {
								ai_rationality <= -25
								has_trait = arrogant
							}
							tyranny >= 15
						}
					}
				}
			}
			add = 500
		}
	}
}

task_fabricate_claim_minister_of_rites = {
	position = minister_justice
	clone = task_fabricate_claim
}

### MINISTER OF WORKS
task_great_projects = {
	default_task = yes
	position = minister_works

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_great_project.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		desc = task_great_projects_effect_desc
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_great_projects_effect_desc_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_great_projects_erudition_bonus_desc
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_great_projects_family_business_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
				}
				desc = task_collect_taxes_extra_taxes
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					liege = {
						any_sub_realm_county = {
							steward_task_county_corruption_county_trigger = yes
						}
					}	
				}
				desc = task_collect_taxes_county_corruption
			}
		}
	}

	council_owner_modifier = {
		name = task_collect_taxes_modifier
		great_project_build_speed = -0.05
		scale = task_great_projects_total_scale_value
	}

	monthly_on_action = task_collect_taxes_side_effects

	ai_will_do = {
		value = 1 # Always a good backup
		
		if = { # Very greedy rulers prefer this over increasing Acceptance, in most cases
			limit = {
				scope:councillor_liege.ai_greed > 0
			}
			add = {
				value = scope:councillor_liege.ai_greed
				divide = 5
			}
		}
		
		if = {
			# Wealth Focused characters like this
			limit = {
				scope:councillor_liege = {
					has_focus = stewardship_wealth_focus
				}
			}
			add = 15
		}
		
		if = {
			# And those with the Tax Man perk
			limit = {
				scope:councillor_liege = {
					has_perk = tax_man_perk
				}
			}
			add = 15
		}
		if = {
			limit = {
				scope:councillor_liege.primary_title.tier >= tier_duchy
				scope:councillor_liege.gold < 100
			}
			add = 500
		}
		else_if = {
			limit = {
				scope:councillor_liege.gold < 10
			}
			add = 500
		}
		if = { # Conquerors want more money
			limit = {
				scope:councillor_liege = {
					has_variable = conqueror
				}
			}
			add = 500
		}
	}
}

task_develop_county_minister_of_works = {
	position = minister_works
	clone = task_develop_county
}

### GRAND MARSHAL
task_lead_troops = {
	default_task = yes
	position = minister_grand_marshal

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_lead_troops.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}
	
	is_shown = {
		scope:councillor_liege = { tgp_has_access_to_ministry_trigger = yes }
	}

	effect_desc = {
		### Additive command modifiers
		desc = task_lead_troops_effect_desc
		desc = task_lead_troops_effect_martial_bonus
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_lead_troops_effect_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_lead_troops_effect_erudition_bonus_desc
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_lead_troops_effect_family_business_bonus_desc
		}
		
		### Multiplicative command modifiers
		desc = task_lead_troops_mult_effect_desc
		desc = task_lead_troops_mult_effect_martial_bonus
		# Disciples tooltip
		triggered_desc = {
			trigger = {
				num_of_relation_disciple > 0
			}
			desc = task_lead_troops_mult_effect_disciple_bonus
		}
		# Bureaucrats tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_lead_troops_mult_effect_erudition_bonus_desc
		}
		# Family Business tooltip
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_lead_troops_mult_effect_family_business_bonus_desc
		}
	}
	
	# Percentaged based modifiers
	councillor_modifier = {
		name = minister_grand_marshal_modifier
		hard_casualty_modifier = -0.01
		enemy_hard_casualty_modifier = 0.01
		#maa_damage_mult = 0.01
		#maa_pursuit_add = 1
		advantage = 1
		scale = task_lead_troops_total_scale_value
	}

	monthly_on_action = organize_the_levies_marshal_task_side_effects

	ai_will_do = {
		value = 1 # Always a good backup
	}
}

task_train_commanders_grand_marshal = {
	position = minister_grand_marshal
	clone = task_train_commanders
}
