﻿#Events related to the Marshal's tasks

namespace = steward_task


####
#0001-0999: Task outcome events
####
#0001-0003: Convince De Jure Territory task outcomes
# by Claudia Baldassi
# 0301 - Culture Changed in County
# by Petter Vilberg


####
#1000-1999: Side effects from Collect Taxes
# by Petter Vilberg
####
### Easing Their Own Burden:
# 1001 - Bandits
# 1002 - Inefficient Census
# 1003 - Lack of Sheriffs
# 1004 - Smuggling Ring
# 1005 - Tax collector catches steward's accounting error
##

# 1101 - Extra Taxes


####
#2000-2999: Side effects from Develop County
# by Petter Vilberg
####
# 2001 - Reduce Construction Speed
# 2002 - Loss of County Opinion
# 2003 - Loss of County Control
# 2004-2008 - Prioritize county development vs. taxation

# 2101 - Efficient Taxation
# 2102 - Increased Control


####
#3000-3199: Side effects from Promote Culture
# by Petter Vilberg
####
# 3001 - Resistance to Settlers
# 3002 - Resistance to Administration

# 3101 - Improve County Opinion
# 3102 - Successful Administration
# 3103 - Increased County Levies

####
# 3200-3399: Side effects from Promote Cultural Acceptance
# by Sean Hughes
####
# 3201 - Reduced Control
# 3202 - Reduced County Taxes
# 3203 - Reduced Development Spread

# 3301 - Rapid Acceptance
# 3302 - Improved County Opinion
# 3303 - Increased County Levies

####
#4000-4999: Side effects from Convince De Jure
# by Claudia Baldassi
####
# 4001 - Diplomatic Blunder
# 4002 - Loss of Prestige

# 4101 - Prestige Gained



##################
# Task Outcome Events
# 0001-0999
##################

#Convince De Jure Territory - reply
# by Claudia Baldassi
steward_task.0001 = {
	type = character_event
	title = steward_task.0001.t
	desc = steward_task.0001.desc
	theme = diplomacy_foreign_affairs_focus
	right_portrait = {
		character = scope:councillor
		animation = schadenfreude
	}
	lower_right_portrait = {
		character = scope:councillor_liege
	}

	immediate = {
		root = {
			save_scope_as = previous_owner
			add_opinion = {
				target = scope:councillor_liege
				modifier = angry_opinion
				opinion = -60
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
				}
				set_relation_potential_rival = scope:councillor_liege
			}
		}
	}

	#Option A: accept
	option = {
		name = steward_task.0001.a
		if = {
			limit = {
				scope:county.holder = {
					is_ai = no
					any_held_title = {
						count <= 1
					}
				}
			}
			scope:county.holder = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					left_icon = root
					right_icon = scope:councillor_liege
					title = steward_task.0001.liege_changed
					custom_tooltip = steward_task.0001.liege_changed.tt
				}
			}
		}
		else_if = {
			limit = {
				scope:county.holder = {
					is_ai = no
					any_held_title = {
						count > 1
					}
				}
			}
			scope:county.holder = {
				send_interface_toast = {
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:councillor_liege
					title = steward_task.0001.liege_changed
					custom_tooltip = steward_task.0001.county_loss.tt
				}
				add_opinion = {
					target = scope:councillor_liege
					modifier = angry_opinion
					opinion = -60
				}
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
					}
					set_relation_potential_rival = scope:councillor_liege
				}
				save_scope_as = previous_holder
			}
		}
		if = {
			limit = {
				exists = scope:county.holder.liege
				scope:county.holder.liege = {
					this != scope:county.holder.top_liege
					is_ai = no
				}
			}
			scope:county.holder.liege = {
				send_interface_toast = {
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:councillor_liege
					title = steward_task.0001.liege_changed
					custom_tooltip = steward_task.0001.county_loss.tt
				}
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
					}
					set_relation_potential_rival = scope:councillor_liege
				}
			}	
		}
		if = {
			limit = {
				exists = scope:county.holder.liege
				exists = scope:county.holder.liege.liege
				scope:county.holder.liege.liege = {
					NOT = {
						this = scope:county.holder.top_liege
						this = scope:county.holder.liege
					}
					is_ai = no
				}
			}
			scope:county.holder.liege.liege = {
				send_interface_toast = {
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:councillor_liege
					title = steward_task.0001.liege_changed
					custom_tooltip = steward_task.0001.county_loss.tt
				}
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
					}
					set_relation_potential_rival = scope:councillor_liege
				}
			}
		}
		create_title_and_vassal_change = {
			type = usurped
			save_scope_as = change
			add_claim_on_loss = yes
		}
		if = {
			limit = {
				scope:county.holder = {
					any_held_title = {
						count <= 1
					}
				}
			}
			scope:county.holder = { #Unop: Fix the missing .holder re-scope
				change_liege = {
					liege = scope:councillor_liege
					change = scope:change
				}
			}
		}
		else = {
			scope:county = {
				change_title_holder = {
					holder = scope:councillor_liege
					change = scope:change
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:councillor_liege = {
			trigger_event = steward_task.0002
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 2
			}
		}
	}

	#Option B: refuse - get penalties
	option = {
		name = steward_task.0001.b
		scope:county = {
			change_county_control = major_county_control_loss
			add_county_modifier = {
				modifier = steward_de_jure_denied_modifier
				years = 10
			}
		}
		scope:councillor_liege = {
			trigger_event = steward_task.0003
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 3
			}
		}
		reverse_add_opinion = {
			target = scope:councillor_liege
			modifier = angry_opinion
			opinion = -60
		}
		scope:county.holder = {
			add_opinion = {
				target = scope:councillor_liege
				modifier = angry_opinion
				opinion = -40
			}
		}
	}
}

# Convince De Jure Accepted
steward_task.0002 = {
	type = character_event
	title = steward_task.0002.t
	desc = steward_task.0002.desc
	theme = diplomacy_foreign_affairs_focus
	right_portrait = {
		character = scope:previous_owner
		animation = sadness
	}
	left_portrait = {
		character = scope:councillor
		animation = schadenfreude
	}

	immediate = {
		show_as_tooltip = {
			scope:previous_owner = {
				add_opinion = {
					target = scope:councillor_liege
					modifier = angry_opinion
					opinion = -60
				}
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
					}
					set_relation_potential_rival = scope:councillor_liege
				}
			}
			if = {
				limit = {
					exists = scope:previous_holder
				}
				scope:previous_holder = {
					add_opinion = {
						target = scope:councillor_liege
						modifier = angry_opinion
						opinion = -60
					}
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
						}
						set_relation_potential_rival = scope:councillor_liege
					}
				}
			}
			if = {
				limit = {
					exists = scope:county.holder.liege
					scope:county.holder.liege = {
						this != scope:county.holder.top_liege
						is_ai = no
					}
				}
				scope:county.holder.liege = {
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
						}
						set_relation_potential_rival = scope:councillor_liege
					}
				}	
			}
			if = {
				limit = {
					exists = scope:county.holder.liege
					exists = scope:county.holder.liege.liege
					scope:county.holder.liege.liege = {
						NOT = {
							this = scope:county.holder.top_liege
							this = scope:county.holder.liege
						}
						is_ai = no
					}
				}
				scope:county.holder.liege.liege = {
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
						}
						set_relation_potential_rival = scope:councillor_liege
					}
				}
			}
		}
	}

	option = {
		name = steward_task.0002.a
	}
}

# Convince De Jure Refused
steward_task.0003 = {
	type = character_event
	title = steward_task.0003.t
	desc = steward_task.0003.desc
	theme = diplomacy_foreign_affairs_focus
	right_portrait = {
		character = scope:previous_owner
		animation = personality_bold
	}
	left_portrait = {
		character = scope:councillor
		animation = shame
	}

	immediate = {
		show_as_tooltip = {
			scope:previous_owner = {
				add_opinion = {
					target = scope:councillor_liege
					modifier = angry_opinion
					opinion = -60
				}
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:councillor_liege }
					}
					set_relation_potential_rival = scope:councillor_liege
				}
			}
			scope:county.holder = {
				add_opinion = {
					target = scope:councillor_liege
					modifier = angry_opinion
					opinion = -40
				}
			}
		}
	}

	option = {
		name = steward_task.0003.a
	}
}


###########
# Promote Culture Events
# 0301-0399
###########


#####################
# Side Effects from Collect Taxes
# 1000 - 1999
#####################
#Easing Their Own Burden - Bandits
steward_task.1001 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		any_sub_realm_county = {
			steward_task_county_corruption_county_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		random_sub_realm_county = {
			limit = {
				steward_task_county_corruption_county_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					holder = root
				}
			}
			save_scope_as = county
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.1001.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_collect_taxes_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = county_corruption_bandits_rampant_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

#Easing Their Own Burden - Inefficient Census
steward_task.1002 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		any_sub_realm_county = {
			steward_task_county_corruption_county_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		random_sub_realm_county = {
			limit = {
				steward_task_county_corruption_county_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					holder = root
				}
			}
			save_scope_as = county
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.1002.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_collect_taxes_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = county_corruption_inefficient_census_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

#Easing Their Own Burden - Lack of Sheriffs
steward_task.1003 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		any_sub_realm_county = {
			steward_task_county_corruption_county_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		random_sub_realm_county = {
			limit = {
				steward_task_county_corruption_county_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					holder = root
				}
			}
			save_scope_as = county
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.1003.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_collect_taxes_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = county_corruption_lack_of_sheriffs_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

#Easing Their Own Burden - Smuggling Ring
steward_task.1004 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		any_sub_realm_county = {
			steward_task_county_corruption_county_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		random_sub_realm_county = {
			limit = {
				steward_task_county_corruption_county_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					holder = root
				}
			}
			save_scope_as = county
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.1004.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_collect_taxes_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = county_corruption_smuggling_ring_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

scripted_trigger is_valid_steward_task_1005_tax_collector = {
	is_available_healthy_ai_adult = yes
	NOT = { this = root.cp:councillor_steward }

	# Tax collector needs to have at least a little ambition to push this issue
	ai_energy > high_negative_ai_value
	
	# Tax collector and steward can't be friends
	NOR = {
		has_relation_friend = root.cp:councillor_steward
		has_relation_best_friend = root.cp:councillor_steward
	}
	OR = {
		opinion = {
			target = root.cp:councillor_steward
			value < low_positive_opinion
		}
		reverse_opinion = {
			target = root.cp:councillor_steward
			value < low_positive_opinion
		}
	}

	# The steward must pay taxes to them
	tax_slot = { any_tax_slot_vassal = { this = root.cp:councillor_steward } }
}

# Tax collector tries collecting taxes in steward's realm
steward_task.1005 = {
	type = character_event
	title = steward_task.1005.t
	desc = steward_task.1005.desc
	theme = stewardship
	override_background = { reference = council_chamber }
	left_portrait = {
		character = scope:steward
		animation = anger
	}
	right_portrait = scope:tax_collector

	cooldown = { years = 20 }

	# Need to have both an AI tax collector and an AI steward
	trigger = {
		is_available = yes
		exists = cp:councillor_steward
		cp:councillor_steward = {
			is_available_healthy_ai_adult = yes
			ai_greed > high_negative_ai_value # Steward needs to be at least a little greedy to care about taxes
		}
		employs_tax_collector = yes
		any_tax_collector = { is_valid_steward_task_1005_tax_collector = yes }

		# Don't trigger if the tax collector/steward rivalry story cycle is already ongoing, that story has its own (more interesting) events
		NOT = { any_owned_story = { type = story_cycle_tax_rivalry } }
	}

	immediate = {
		cp:councillor_steward = { save_scope_as = steward }
		random_tax_collector = {
			limit = { is_valid_steward_task_1005_tax_collector = yes }
			save_scope_as = tax_collector
		}
		# Set these variables for the tax collector and steward rivalry story
		set_variable = {
			name = story_steward
			value = scope:steward
			days = 30
		}
		set_variable = {
			name = story_tax_collector
			value = scope:tax_collector
			days = 30
		}
	}
	

	option = { # Use stewardship to negotiate a solution everyone is happy with
		name = steward_task.1005.a
		trigger = {
			stewardship > low_skill_rating
		}
		duel = {
			skill = stewardship
			value = decent_skill_rating

			5 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.25
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = steward_task.1005.a_success
					left_icon = root
					add_character_modifier = {
						modifier = tax_collector_fair_arbiter_modifier
						years = 20
					}
				}
			}
			5 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.25
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = steward_task.1005.a_failure
					add_character_modifier = {
						modifier = tax_collector_free_rein_modifier
						years = 20
					}
				}
				scope:steward = {
					progress_towards_rival_effect = {
						REASON = rival_taxation_is_theft
						CHARACTER = scope:tax_collector
						OPINION = 0
					}
				}
				create_tax_rivalry_story_effect = yes
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Side with tax collector, get money & negative vassal opinion
		name = steward_task.1005.b
		add_character_modifier = {
			modifier = tax_collector_free_rein_modifier
			years = 20
		}
		scope:steward = {
			progress_towards_rival_effect = {
				REASON = rival_taxation_is_theft
				CHARACTER = scope:tax_collector
				OPINION = 0
			}
		}
		create_tax_rivalry_story_effect = yes
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 0.25
			}
			opinion_modifier = {
				opinion_target = scope:tax_collector
				multiplier = 0.4
			}
		}
	}

	option = { # Side with steward, don't get money or negative vassal opinion
		name = steward_task.1005.c
		# Lose unity, assuming the tax collector is a member of your house
		# Unless the steward is also a member of your house because that would be annoying
		reverse_add_opinion = {
			target = scope:steward
			modifier = feast_sided_with_me_in_my_fight_opinion
			opinion = 10
		}
		scope:tax_collector = {
			progress_towards_rival_effect = {
				REASON = rival_accounting_exposure
				CHARACTER = scope:steward
				OPINION = 0
			}
		}
		create_tax_rivalry_story_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -0.25
			}
			opinion_modifier = {
				opinion_target = scope:steward
				multiplier = 0.4
			}
		}
	}

	after = {
		clean_up_tax_rivalry_story_variables_effect = yes
	}
}


### Good Side Effects


#Extra Taxes
# by Petter Vilberg

steward_task.1101 = {
	hidden = yes

	trigger = {
		exists = scope:councillor
		exists = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = 0.2
			offset = inverted_mediocre_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		random_sub_realm_county = {
			limit = {
				holder = root
			}
			save_scope_as = county
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.1101.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			right_icon = scope:councillor
			tooltip = task_collect_taxes_notification_tooltip

			add_treasury_or_gold = scope:councillor.steward_collect_taxes_bonus_tax_income
			stress_impact = {
				greedy = medium_stress_impact_loss
			}
		}
	}
}


###############
# Side effects from Develop County
#2000-2999
###############

###Bad Side Effects

#Reduce Construction Speed
# by Petter Vilberg
steward_task.2001 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_construction_slowdown_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.2001.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_develop_county_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_construction_slowdown_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


#Loss of County Opinion
# by Petter Vilberg
steward_task.2002 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOR = {
				has_county_modifier = steward_population_mismanaged_modifier
				has_county_modifier = steward_administration_embraced_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.2002.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_develop_county_notification_tooltip
			
			scope:county = {
				add_county_modifier = {
					modifier = steward_population_mismanaged_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


#Loss of County Control
# by Petter Vilberg
steward_task.2003 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			county_control > low_county_control
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.2003.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_develop_county_notification_tooltip

			scope:county = {
				change_county_control = medium_county_control_loss
			}
		}
	}
}

scripted_trigger steward_task_2004_tax_collector_is_valid = {
	# Tax collector needs to be an AI as their actions are entirely simulated
	is_available_ai_adult = yes
	NOT = { this = root.cp:councillor_steward }
	# Tax collector needs at least a little energy to go above and beyond
	ai_energy > low_negative_ai_value
}

# Setup for steward_task.2005/2008
steward_task.2004 = {
	hidden = yes
	cooldown = { years = 5 }

	trigger = {
		exists = cp:councillor_steward
		cp:councillor_steward = {
			is_available_adult = yes
		}
		employs_tax_collector = yes
		any_tax_collector = {
			steward_task_2004_tax_collector_is_valid = yes
		}
		# Don't trigger if the tax collector/steward rivalry story cycle is already ongoing, that story has its own (more interesting) events
		NOT = { any_owned_story = { type = story_cycle_tax_rivalry } }
	}

	immediate = {
		save_scope_as = liege
		random_tax_collector = {
			limit = { steward_task_2004_tax_collector_is_valid = yes }
			save_scope_as = tax_collector
		}
		scope:county.title_province = { save_scope_as = background_terrain_scope } # For event bg in steward_task.2005
		cp:councillor_steward = { save_scope_as = steward }
		# Set these variables for the tax collector and steward rivalry story
		set_variable = {
			name = story_steward
			value = scope:steward
			days = 30
		}
		set_variable = {
			name = story_tax_collector
			value = scope:tax_collector
			days = 30
		}
		# Only trigger steward_task.2005 for player stewards
		if = {
			limit = {
				scope:steward = { is_ai = yes }
			}
			trigger_event = steward_task.2008
		}
		else = {
			scope:steward = { trigger_event = steward_task.2005 }
		}
	}
}

# Calculate whether the liege would prefer long-term gains over short-term gold
scripted_effect steward_task_2005_set_liege_development_preference_effect = {
	set_variable = {
		name = liege_preference_towards_development
		days = 10
		value = {
			value = 0
			add = {
				if = {
					limit = {
						scope:liege = { has_trait = patient }
					}
					value = 100
				}
				else_if = {
					limit = {
						scope:liege = { has_trait = impatient }
					}
					value = -100
				}
			}
			add = {
				value = scope:liege.ai_greed
				multiply = -0.25
			}
			add = {
				value = scope:liege.ai_rationality
				multiply = 0.1
			}
			# Make an exception for ambitious, they favor long-term gains despite their ai greed
			add = {
				if = {
					limit = {
						scope:liege = { has_trait = ambitious }
					}
					value = 25
				}
			}
		}
	}
}

# Determine liege's reaction to the steward's decision for steward_task.2005
scripted_effect steward_task_2005_liege_opinion_effect = {
	# If the liege is a player, then let the liege decide how to react
	if = {
		limit = {
			scope:liege = { is_ai = no }
		}
		if = {
			limit = {
				$DEVELOPMENT$ = yes
			}
			scope:liege = {
				add_character_flag = {
					flag = steward_task_2005_redoubled_development
					days = 1
				}
			}
		}
		else = {
			scope:liege = {
				add_character_flag = {
					flag = steward_task_2005_redoubled_taxation
					days = 1
				}
			}
		}
		scope:liege = { trigger_event = steward_task.2006 }
	}
	# Otherwise, immediately inform the steward how the liege received their decision
	else = {
		# Correctly predicted what the liege would prefer:
		if = {
			limit = {
				OR = {
					AND = {
						$DEVELOPMENT$ = yes
						scope:steward.var:liege_preference_towards_development >= 0
					}
					AND = {
						$DEVELOPMENT$ = no
						scope:steward.var:liege_preference_towards_development <= 0
					}
				}
			}
			scope:steward = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = steward_task.2005.success
					left_icon = scope:liege
					reverse_add_opinion = {
						target = scope:liege
						modifier = pleased_opinion
						opinion = 15
					}
				}
			}
		}
		# Incorrectly predicted what the liege would prefer:
		else_if = {
			limit = {
				OR = {
					AND = {
						$DEVELOPMENT$ = yes
						scope:steward.var:liege_preference_towards_development < 0
					}
					AND = {
						$DEVELOPMENT$ = no
						scope:steward.var:liege_preference_towards_development > 0
					}
				}
			}
			scope:steward = {
				send_interface_toast = {
					type = event_toast_effect_bad
					title = steward_task.2005.failure
					left_icon = scope:liege
					reverse_add_opinion = {
						target = scope:liege
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}
	}
}

# Tax-collector tries collecting more taxes in developing county
steward_task.2005 = {
	type = character_event
	title = steward_task.2005.t
	desc = steward_task.2005.desc
	theme = stewardship
	override_background = {
		reference = terrain_scope
	}
	left_portrait = scope:tax_collector
	right_portrait = {
		character = scope:ledger_slave
		animation = sick
	}

	immediate = {
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		steward_task_2005_set_liege_development_preference_effect = yes
		# Create the ledger slave for fun, but only if the steward is a player (for performance reasons)
		if = {
			limit = { is_ai = no }
			create_character = {
				template = servant_character
				employer = scope:liege
				gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
				save_scope_as = ledger_slave
			}
		}
	}

	option = { # Give more money to liege
		name = steward_task.2005.a
		flavor = steward_task.2005.a.tt
		scope:county = {
			add_county_modifier = {
				modifier = steward_redoubled_taxation_modifier
				years = 15
			}
		}
		hidden_effect = { steward_task_2005_liege_opinion_effect = { DEVELOPMENT = no } }
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = var:liege_preference_towards_development
					multiply = -1
				}
			}
		}
	}

	option = { # Prioritize development
		name = steward_task.2005.b
		flavor = steward_task.2005.b.tt
		scope:county = {
			add_county_modifier = {
				modifier = steward_redoubled_development_modifier
				years = 15
			}
		}
		reverse_add_opinion = {
			target = scope:tax_collector
			modifier = steward_doubted_my_accounting_opinion
		}
		progress_towards_rival_effect = {
			CHARACTER = scope:tax_collector
			REASON = rival_disregarded_accounting
			OPINION = 0
		}
		scope:liege = {
			create_tax_rivalry_story_effect = yes
		}
		hidden_effect = { steward_task_2005_liege_opinion_effect = { DEVELOPMENT = yes } }
		ai_chance = {
			base = 0
			modifier = {
				add = var:liege_preference_towards_development
			}
		}
	}

	option = { # Just ask
		name = steward_task.2005.c
		custom_tooltip = steward_task.2005.c.tt
		scope:liege = {
			trigger_event = steward_task.2007
		}
		ai_chance = {
			base = 0
			# Higher chance if liege is a player and thus this option would trigger an event for them
			modifier = {
				scope:liege = { is_ai = no }
				add = 1000
			}
		}
	}

	after = {
		if = {
			limit = { exists = scope:ledger_slave }
			scope:ledger_slave = {
				silent_disappearance_effect = yes
			}
		}
	}
}

# As a liege, react to your steward's decision (player only)
steward_task.2006 = {
	type = letter_event
	opening = steward_task.2006.opening
	sender = scope:steward
	desc = {
		desc = steward_task.2006.desc_intro
		triggered_desc = {
			trigger = { has_character_flag = steward_task_2005_redoubled_development }
			desc = steward_task.2006.desc_development
		}
		triggered_desc = {
			trigger = { has_character_flag = steward_task_2005_redoubled_taxation }
			desc = steward_task.2006.desc_taxation
		}
	}

	option = { # Praise steward
		name = steward_task.2006.a
		# Add stress depending on what the steward's decision was
		if = {
			limit = { has_character_flag = steward_task_2005_redoubled_development }
			stress_impact = {
				greedy = minor_stress_impact_gain
				impatient = minor_stress_impact_gain
			}
		}
		else_if = {
			limit = { has_character_flag = steward_task_2005_redoubled_taxation }
			stress_impact = {
				generous = minor_stress_impact_gain
				patient = minor_stress_impact_gain
			}
		}
	}

	option = { # Criticize steward
		name = steward_task.2006.b
		# Remove the modifier that they added and replace it with the one you want
		scope:steward = {
			send_interface_message = {
				type = event_steward_bad
				title = steward_task.2006.b_notification
				left_icon = scope:county
				right_icon = scope:liege
				tooltip = task_develop_county_notification_tooltip				
				scope:county = {
					if = {
						limit = { has_county_modifier = steward_redoubled_development_modifier }
						remove_county_modifier = steward_redoubled_development_modifier
						add_county_modifier = {
							modifier = steward_redoubled_taxation_modifier
							years = 15
						}
					}
					else_if = {
						limit = { has_county_modifier = steward_redoubled_taxation_modifier }
						remove_county_modifier = steward_redoubled_taxation_modifier
						add_county_modifier = {
							modifier = steward_redoubled_development_modifier
							years = 15
						}
					}
				}
				# Hide this effect for the liege choosing this option
				if = {
					limit = {
						root != scope:liege
					}		
					reverse_add_opinion = {
						target = scope:liege
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}
		reverse_add_opinion = {
			target = scope:steward
			modifier = stress_upset_councillor
		}
		# Add stress depending on what the steward's decision was
		if = {
			limit = { has_character_flag = steward_task_2005_redoubled_development }
			stress_impact = {
				generous = minor_stress_impact_gain
				patient = minor_stress_impact_gain
			}
		}
		else_if = {
			limit = { has_character_flag = steward_task_2005_redoubled_taxation }
			stress_impact = {
				greedy = minor_stress_impact_gain
				impatient = minor_stress_impact_gain
			}
		}
	}

	after = {	
		clean_up_tax_rivalry_story_variables_effect = yes
	}
}

# As a liege, decide how you want to tax the developing county after your steward asks you
steward_task.2007 = {
	type = letter_event
	opening = steward_task.2006.opening
	sender = scope:steward
	desc = steward_task.2007.desc

	trigger = { is_available = yes }

	option = { # Focus on taxation
		name = steward_task.2007.a
		scope:steward = {
			send_interface_message = {
				type = event_steward_good
				title = steward_task.2005.t
				left_icon = scope:county
				right_icon = scope:liege
				desc = task_develop_county_notification_tooltip				
				scope:county = {
					add_county_modifier = {
						modifier = steward_redoubled_taxation_modifier
						years = 15
					}
				}
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = scope:steward.var:liege_preference_towards_development
					multiply = -1
				}
			}
		}
	}

	option = { # Focus on development
		name = steward_task.2005.b
		scope:steward = {
			send_interface_message = {
				type = event_steward_good
				title = steward_task.2005.t
				left_icon = scope:county
				right_icon = scope:liege
				desc = task_develop_county_notification_tooltip
				scope:county = {
					add_county_modifier = {
						modifier = steward_redoubled_development_modifier
						years = 15
					}
				}
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = scope:steward.var:liege_preference_towards_development
			}
		}
	}

	after = {		
		clean_up_tax_rivalry_story_variables_effect = yes
	}
}

# As a liege, decide how you want to tax the developing county (steward is AI)
steward_task.2008 = {
	type = character_event
	title = steward_task.2005.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						scope:steward = {
							opinion = {
								target = scope:tax_collector
								value <= low_negative_opinion
							}
						}
						scope:tax_collector = {
							opinion = {
								target = scope:steward
								value <= low_negative_opinion
							}
						}
					}
				}
				desc = steward_task.2008.desc_intro_friendly
			}
			desc = steward_task.2008.desc_intro_unfriendly
		}
		desc = steward_task.2008.desc_outro
	}
	theme = stewardship
	override_background = {
		reference = council_chamber
	}
	left_portrait = scope:tax_collector
	right_portrait = {
		character = scope:steward
		animation = dismissal
	}

	immediate = {
		scope:steward = { steward_task_2005_set_liege_development_preference_effect = yes }
		scope:tax_collector = {
			progress_towards_rival_effect = {
				REASON = rival_disregarded_accounting
				CHARACTER = scope:steward
				OPINION = 0
			}
		}
	}

	trigger = {
		is_available = yes
		# Just so this event doesn't trigger for two people who get along
		scope:tax_collector = {
			OR = {
				opinion = {
					target = scope:steward
					value < low_positive_opinion
				}
				reverse_opinion = {
					target = scope:steward
					value < low_positive_opinion
				}
			}
		}
	}

	option = { # Side with tax collector (taxation)
		name = steward_task.2008.a
		scope:county = {
			add_county_modifier = {
				modifier = steward_redoubled_taxation_modifier
				years = 15
			}
		}
		if = {
			limit = {
				is_in_same_clan_as_trigger = { CHARACTER = scope:steward }
				NOT = { is_in_same_clan_as_trigger = { CHARACTER = scope:tax_collector } }
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:steward
				VALUE = minor_unity_loss
				DESC = clan_unity_sided_with_tax_collector.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		create_tax_rivalry_story_effect = yes
		stress_impact = {
			generous = minor_stress_impact_gain
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = scope:steward.var:liege_preference_towards_development
					multiply = -1
				}
			}
		}
	}

	option = { # Side with steward (development)
		name = steward_task.2008.b
		scope:county = {
			add_county_modifier = {
				modifier = steward_redoubled_development_modifier
				years = 15
			}
		}
		if = {
			limit = {
				is_in_same_clan_as_trigger = { CHARACTER = scope:tax_collector }
				NOT = { is_in_same_clan_as_trigger = { CHARACTER = scope:steward } }
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:tax_collector
				VALUE = minor_unity_loss
				DESC = clan_unity_sided_with_steward.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		create_tax_rivalry_story_effect = yes
		stress_impact = {
			greedy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = scope:steward.var:liege_preference_towards_development
				}
			}
		}
	}

	option = { # Opt out
		name = steward_task.2008.c
		reverse_add_opinion = {
			target = scope:steward
			modifier = dismissed_me_opinion
			opinion = -15
		}
		reverse_add_opinion = {
			target = scope:tax_collector
			modifier = dismissed_me_opinion
			opinion = -15
		}
		create_tax_rivalry_story_effect = yes
		stress_impact = {
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = {
				has_trait = lazy
				add = 50
			}
		}
	}

	after = {		
		clean_up_tax_rivalry_story_variables_effect = yes
	}
}

###Good Side Effects

#Efficient Taxation
# by Petter Vilberg
steward_task.2101 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_task_efficient_taxation_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.2101.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_develop_county_notification_tooltip
			
			add_treasury_or_gold = medium_treasury_or_gold_value
			scope:county = {
				add_county_modifier = {
					modifier = steward_task_efficient_taxation_modifier
					days = 3650
				}
			}
		}
	}
}

#Increased Control
# by Petter Vilberg
steward_task.2102 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			county_control < full_county_control
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.2102.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_develop_county_notification_tooltip

			scope:county = {
				change_county_control = medium_county_control_gain
			}
		}
	}
}


###############
# Side effects from Promote Culture
#3000-3299
###############

###Bad Side Effects


#Resistance to Settlers
# by Petter Vilberg
steward_task.3001 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_settler_resistance_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.3001.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_settler_resistance_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


#Resistance to Administration
# by Petter Vilberg
steward_task.3002 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOR = {
				has_county_modifier = steward_population_mismanaged_modifier
				has_county_modifier = steward_administration_embraced_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = event_stewardship_bad
			title = steward_task.3002.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_population_mismanaged_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


###Good Side Effects



#Improve County Opinion
# by Petter Vilberg

steward_task.3101 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOR = {
				has_county_modifier = steward_population_mismanaged_modifier
				has_county_modifier = steward_administration_embraced_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3101.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip
			
			scope:county = {
				add_county_modifier = {
					modifier = steward_administration_embraced_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


#Successful Administration
# by Petter Vilberg

steward_task.3102 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_welcome_administration_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3102.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip
		
			scope:county = {
				add_county_modifier = {
					modifier = steward_welcome_administration_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}


#Increased County Levies
# by Petter Vilberg

steward_task.3103 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_realm_identity_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3103.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_realm_identity_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

###############
# Side effects from Promote Cultural Acceptance
# 3200-3399
###############

### Bad Side Effects

# 3201 - Reduced Control
# by Sean Hughes
steward_task.3201 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.3201.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_promote_culture_notification_tooltip

			scope:county = {
				change_county_control = -25
			}
		}
	}
}

# 3202 - Reduced County Taxes
# by Sean Hughes
steward_task.3202 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_accept_culture_reduced_taxes_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.3202.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_accept_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_accept_culture_reduced_taxes_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

# 3203 - Reduced Development Spread
# by Sean Hughes
steward_task.3203 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county = {
			NOR = {
				has_county_modifier = steward_accept_culture_reduced_development_spread_modifier
				has_county_modifier = steward_accept_culture_increased_development_spread_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.3203.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_accept_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_accept_culture_reduced_development_spread_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

### Good Side Effects

# 3301 - Rapid Acceptance
# by Sean Hughes
steward_task.3301 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		# different culture
		exists = scope:county
		scope:county.culture != root.culture
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3301.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_accept_culture_notification_tooltip
		
			scope:county = {
				culture = {
					change_cultural_acceptance = {
						target = root.culture
						value = 10
						desc = task_accept_culture_acceptance_gain
					}
				}
			}
		}
	}
}

# 3302 - Improved County Opinion
# by Sean Hughes
steward_task.3302 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOT = { has_county_modifier = steward_accept_culture_increased_opinion_modifier }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3302.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_accept_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_accept_culture_increased_opinion_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

# 3303 - Increased County Levies
# by Sean Hughes
steward_task.3303 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
		scope:county = {
			NOR = {
				has_county_modifier = steward_accept_culture_reduced_development_spread_modifier
				has_county_modifier = steward_accept_culture_increased_development_spread_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		cp:councillor_steward = {
			save_scope_as = active_councillor
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.3303.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_accept_culture_notification_tooltip

			scope:county = {
				add_county_modifier = {
					modifier = steward_accept_culture_increased_development_spread_modifier
					days = steward_task_modifier_duration
				}
			}
		}
	}
}

###############
# Side effects from Convince De Jure
#4000-4999
###############

###Bad Side Effects

#Diplomatic Blunder
# by Claudia Baldassi
steward_task.4001 = {
	type = letter_event
	opening = steward_task.4001.opening
	desc = steward_task.4001.desc
	sender = scope:county.holder.top_liege
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
		scope:county.holder.top_liege = {
			NOT = {
				has_opinion_modifier = {
					target = scope:councillor_liege
					modifier = steward_convince_dejure_upset_modifier
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		scope:county.holder.top_liege = {
			save_scope_as = county_liege
		}
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}
	}
	option = {
		name = steward_task.4001.a
		add_prestige = minor_prestige_loss
		scope:county_liege = {
			add_opinion = {
				target = scope:councillor_liege
				modifier = steward_convince_dejure_upset_modifier
				days = steward_task_modifier_duration
			}
		}
	}
}

#Loss of Prestige
# by Claudia Baldassi
steward_task.4002 = {
	hidden = yes

	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			stewardship < high_skill_rating
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_bad
			title = steward_task.4002.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_bad_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_bad_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_convince_dejure_notification_tooltip

			add_prestige = medium_prestige_loss
		}
	}
}

###Good Side Effects

#Prestige Gained
# by Claudia Baldassi

steward_task.4101 = {
	hidden = yes
	
	trigger = {
		exists = cp:councillor_steward
		scope:councillor = cp:councillor_steward
		scope:councillor = {
			
			stewardship > mediocre_skill_rating
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = scope:councillor
			value = stewardship
			multiplier = -0.2
			offset = inverted_high_skill_rating
		}
	}

	immediate = {
		set_variable = {
			name = had_steward_task_side_effect
			value = yes
			days = steward_task_side_effect_cooldown
		}

		send_interface_message = {
			type = msg_steward_task_good
			title = steward_task.4101.notification
			desc = {
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship <= average_skill_level }
					}
					desc = task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:active_councillor = { stewardship > average_skill_level }
					}
					desc = task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:county
			right_icon = scope:councillor
			tooltip = task_convince_dejure_notification_tooltip

			add_prestige = medium_prestige_gain
		}
	}
}
