﻿# Determines the modifier to be given for positive modifier side effect.
#
# SAVE_AS = the name of the scope value to save the result to
# scope = the character for whom we are picking a modifier
regula_task_sparring_partners_positive_modifier_pick_modifier_effect = {
	random_list = {
		30 = {
			trigger = {
				NOT = { has_character_modifier = sparring_honed_skills_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_honed_skills_modifier
			}
		}
		20 = {
			trigger = {
				NOT = { has_character_modifier = sparring_valiant_knight_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_valiant_knight_modifier
			}
		}
		20 = {
			trigger = {
				NOT = { has_character_modifier = sparring_noble_defender_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_noble_defender_modifier
			}
		}
		20 = {
			trigger = {
				NOT = { has_character_modifier = sparring_full_of_confidence_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_full_of_confidence_modifier
			}
		}
		5 = {
			trigger = {
				NOT = { has_character_modifier = sparring_chivalric_motivation_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_chivalric_motivation_modifier
			}
		}
		5 = {
			trigger = {
				NOT = { has_character_modifier = sparring_leader_of_knights_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_leader_of_knights_modifier
			}
		}
	}
}

# Determines the modifier to be given for negative modifier side effect.
#
# SAVE_AS = the name of the scope value to save the result to
# scope = the character for whom we are picking a modifier
regula_task_sparring_partners_negative_modifier_pick_modifier_effect = {
	random_list = {
		50 = {
			trigger = {
				NOT = { has_character_modifier = sparring_delusions_of_superiority_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_delusions_of_superiority_modifier
			}
		}
		50 = {
			trigger = {
				NOT = { has_character_modifier = sparring_sprained_ankle_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:sparring_sprained_ankle_modifier
			}
		}
	}
}

# Applies the modifier to be given for modifier side effect.
#
# This is a NOOP if MODIFIER_SCOPE is unset / null.
#
# MODIFIER_SCOPE = the name of the scope to which the selected modifier was saved
# scope = the character to whom we are applying the modifier
regula_task_sparring_partners_modifier_apply_modifier_effect = {
	if = {
		limit = {
			exists = scope:$MODIFIER_SCOPE$
		}
		switch = {
			trigger = scope:$MODIFIER_SCOPE$
			flag:sparring_honed_skills_modifier = {
				add_character_modifier = {
					modifier = sparring_honed_skills_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_valiant_knight_modifier = {
				add_character_modifier = {
					modifier = sparring_valiant_knight_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_noble_defender_modifier = {
				add_character_modifier = {
					modifier = sparring_noble_defender_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_full_of_confidence_modifier = {
				add_character_modifier = {
					modifier = sparring_full_of_confidence_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_chivalric_motivation_modifier = {
				add_character_modifier = {
					modifier = sparring_chivalric_motivation_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_leader_of_knights_modifier = {
				add_character_modifier = {
					modifier = sparring_leader_of_knights_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_delusions_of_superiority_modifier = {
				add_character_modifier = {
					modifier = sparring_delusions_of_superiority_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
			flag:sparring_sprained_ankle_modifier = {
				add_character_modifier = {
					modifier = sparring_sprained_ankle_modifier
					years = task_sparring_partners_side_effect_modifier_years
				}
			}
		}
	}
}

# Determines the modifier to be given for task_beasts_of_burden as a positive
# county modifier side effect.
#
# SAVE_AS = the name of the scope value to save the result to
# scope = the county for which we are picking a modifier
regula_task_beasts_of_burden_pick_positive_county_modifier_side_effect = {
	random_list = {
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_thankful_populace_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_thankful_populace_modifier
			}
		}
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_obedient_populace_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_obedient_populace_modifier
			}
		}
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_enriched_populace_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_enriched_populace_modifier
			}
		}
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_efficient_workforce_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_efficient_workforce_modifier
			}
		}
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_developed_workforce_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_developed_workforce_modifier
			}
		}
	}
}

# Determines the modifier to be given for task_beasts_of_burden as a negative
# county modifier side effect.
#
# SAVE_AS = the name of the scope value to save the result to
# scope = the county for which we are picking a modifier
regula_task_beasts_of_burden_pick_negative_county_modifier_side_effect = {
	random_list = {
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_offended_populace_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_offended_populace_modifier
			}
		}
		1 = {
			trigger = {
				county_control < 100
				NOT = { has_county_modifier = regula_beasts_of_burden_squandered_resources_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_squandered_resources_modifier
			}
		}
		1 = {
			trigger = {
				NOT = { has_county_modifier = regula_beasts_of_burden_clumsy_workforce_modifier }
			}
			save_temporary_scope_value_as = {
				name = $SAVE_AS$
				value = flag:regula_beasts_of_burden_clumsy_workforce_modifier
			}
		}
	}
}

# Applies the modifier to be given for task_beasts_of_burden as a county
# modifier side effect.
#
# MODIFIER_SCOPE = the scope containing the flag indicating which modifier to apply. May be unset.
# scope = the county for which we are picking a modifier
regula_task_beasts_of_burden_apply_county_modifier_side_effect = {
	if = {
		limit = {
			exists = scope:$MODIFIER_SCOPE$
		}
		switch = {
			trigger = scope:$MODIFIER_SCOPE$
			flag:regula_beasts_of_burden_thankful_populace_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_thankful_populace_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_obedient_populace_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_obedient_populace_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_enriched_populace_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_enriched_populace_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_efficient_workforce_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_efficient_workforce_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_developed_workforce_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_developed_workforce_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_offended_populace_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_offended_populace_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_squandered_resources_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_squandered_resources_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
			flag:regula_beasts_of_burden_clumsy_workforce_modifier = {
				add_county_modifier = {
					modifier = regula_beasts_of_burden_clumsy_workforce_modifier
					years = task_beasts_of_burden_side_effect_modifier_years
				}
			}
		}
	}
}
