﻿rabble_rouser_task_uplift_camp = {
	court_position_types = { 
		rabble_rouser_court_position 
	}
	is_shown = {
		NOR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
	}
	is_valid_showing_failures_only = {
	}
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	on_start = {
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = yes
			}
		}
		custom_tooltip = increased_rouse_rabble_defense_tt
		# custom_tooltip = increased_provoke_vassals_defense_tt
	}

	on_monthly = {
		if = {
			limit = { scope:liege.var:rabble_rouser_is_pacifying_the_masses = no }
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = yes
			}
		}
	}

	on_end = { 
		# remove_character_flag = blocked_from_leaving # Removing travel block
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = no
			}
		}
	}

	scaling_employer_modifiers = {
		terrible = {
			county_opinion_add = 1
			provisions_gain_mult = 0.1
		}
		poor = {
			county_opinion_add = 3
			provisions_gain_mult = 0.15
		}
		average = {
			county_opinion_add = 5
			provisions_gain_mult = 0.2
		}
		good = {
			county_opinion_add = 7
			provisions_gain_mult = 0.25
		}
		excellent = {
			county_opinion_add = 10
			provisions_gain_mult = 0.3
		}
	}

	ai_will_do = {
		value = {
			add = 25
			add = ai_sociability
		}
	}
}

rabble_rouser_task_rouse_rabble = {
	court_position_types = { 
		rabble_rouser_court_position
	}
	is_shown = {
	}
	is_valid_showing_failures_only = {
	}
	cost = {
		round = no
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
			}
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = {
					value = monthly_court_position_task_cost
					desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
					format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
				}
			}
		}
	}

	employee_modifier = {
		monthly_prestige = minor_court_position_task_prestige_salary
	}

	base_employer_modifier = {
		max_rouse_rabble_schemes_add = 1
	}

	# Set Rousing Rabble variable on start
	on_start = { 
		# add_character_flag = blocked_from_leaving # Stop character from traveling
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_rousing_rabble
				value = yes
			}
		}
		custom_tooltip = allow_rouse_rabble_scheme_tt
	}

	# If it's fallen off while still working, reapply when we can; this can happen if say a Liege dies
	on_monthly = {
		if = {
			limit = { scope:liege.var:rabble_rouser_is_rousing_rabble = no }
			set_variable = {
				name = rabble_rouser_is_rousing_rabble
				value = yes
			}
		}
	}

	on_end = { 
		# remove_character_flag = blocked_from_leaving # Removing travel block
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_rousing_rabble
				value = no
			}
		}
	}

	ai_will_do = {
		value = 0
		if = {
			limit = {
				scope:liege = {
					OR = {
						is_at_war = yes
					}
				}
			}
			add = 100
		}
		if = {
			limit = {
				scope:liege = {
					OR = {
						has_trait = brave
						has_trait = gregarious
						has_trait = diplomat
						has_trait = schemer
						has_trait = lifestyle_wayfarer
						has_trait = lifestyle_reveler
						has_trait = lifestyle_traveler
						has_trait = peasant_leader
						has_trait = populist_leader
						has_trait = ambitious
					}
				}
			}
			add = 50
		}

		if = {
			limit = {
				scope:liege = {
					OR = {
						has_trait = craven
						has_trait = lazy
						has_trait = shy
						has_trait = fickle
						has_trait = reclusive
						has_trait = infirm
					}
				}
			}
			add = -50
		}
	}
}

rabble_rouser_task_provoke_vassals = {
	court_position_types = { 
		rabble_rouser_court_position
	}
	is_shown = {
	}
	is_valid_showing_failures_only = {
	}
	cost = {
		round = no
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
			}
			add = {
				value = monthly_court_position_task_cost
				multiply = 2
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = {
					value = monthly_court_position_task_cost
					multiply = 2
					desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
					format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
				}
			}
		}
	}
	employee_modifier = {
		monthly_prestige = minor_court_position_task_prestige_salary
	}
	
	base_employer_modifier = {
		max_provoke_vassals_schemes_add = 1
	}

	# Set Rousing Rabble variable on start
	on_start = { 
		# add_character_flag = blocked_from_leaving # Stop character from traveling
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_provoking_vassals
				value = yes
			}
		}
		custom_tooltip = allow_provoke_vassals_scheme_tt
	}

	# If it's fallen off while still working, reapply when we can; this can happen if say a Liege dies
	on_monthly = {
		if = {
			limit = { scope:liege.var:rabble_rouser_is_provoking_vassals = no }
			set_variable = {
				name = rabble_rouser_is_provoking_vassals
				value = yes
			}
		}
	}

	on_end = { 
		# remove_character_flag = blocked_from_leaving # Removing travel block
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_provoking_vassals
				value = no
			}
		}
	}

	ai_will_do = {
		value = 0
		if = {
			limit = {
				scope:liege = {
					OR = {
						is_at_war = yes
					}
				}
			}
			add = 100
		}
		if = {
			limit = {
				scope:liege = {
					OR = {
						has_trait = brave
						has_trait = gregarious
						has_trait = diplomat
						has_trait = schemer
						has_trait = lifestyle_wayfarer
						has_trait = lifestyle_reveler
						has_trait = lifestyle_traveler
						has_trait = peasant_leader
						has_trait = populist_leader
						has_trait = ambitious
					}
				}
			}
			add = 50
		}

		if = {
			limit = {
				scope:liege = {
					OR = {
						has_trait = craven
						has_trait = lazy
						has_trait = shy
						has_trait = fickle
						has_trait = reclusive
						has_trait = infirm
					}
				}
			}
			add = -50
		}
	}
}

rabble_rouser_task_pacify_the_masses = {
	court_position_types = { 
		rabble_rouser_court_position 
	}
	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
	}
	is_valid_showing_failures_only = {
	}
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	on_start = {
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = yes
			}
		}
		custom_tooltip = increased_rouse_rabble_defense_tt
		# custom_tooltip = increased_provoke_vassals_defense_tt
	}

	on_monthly = {
		if = {
			limit = { scope:liege.var:rabble_rouser_is_pacifying_the_masses = no }
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = yes
			}
		}
	}

	on_end = { 
		# remove_character_flag = blocked_from_leaving # Removing travel block
		scope:liege = {
			set_variable = {
				name = rabble_rouser_is_pacifying_the_masses
				value = no
			}
		}
	}

	scaling_employer_modifiers = {
		terrible = {
			character_capital_county_monthly_development_growth_add = 0.01
			county_opinion_add = 1
		}
		poor = {
			character_capital_county_monthly_development_growth_add = 0.03
			county_opinion_add = 3
		}
		average = {
			character_capital_county_monthly_development_growth_add = 0.05
			county_opinion_add = 5
		}
		good = {
			character_capital_county_monthly_development_growth_add = 0.07
			county_opinion_add = 7
		}
		excellent = {
			character_capital_county_monthly_development_growth_add = 0.1
			county_opinion_add = 10
		}
	}

	ai_will_do = {
		value = {
			add = 25
			add = ai_sociability
		}
	}
}
