﻿# Regula Activity Effects

# Orgy rewards based on number of servants
disburse_orgy_activity_rewards = {
	# for the loc
	save_scope_as = root_scope

	# Rewards based on Activity Options
    # Increased Relation with Zealot and Parochial
    # All other vassals get smaller relation increase
    # Then prestige increase
    # Number of Servants
    if = {
        limit = {
			scope:activity = {
				has_activity_option = {
					category = orgy_option_servant
					option = orgy_servants_normal
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = regula_servants_normal_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					# Increased Relation with Zealot, Parochial and Devoted
					every_vassal_or_below = {
						limit = {
							OR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 20
						}
					}
					# All other vassals get smaller relation increase
					every_vassal_or_below = {
						limit = {
							NOR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 10
						}
					}
					# All remaining attendees get relation increase
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								NOT = { this = root }
								NOT = { is_vassal_of = root}
							}
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 10
							}
						}
					}

					# Prestige increase
					add_prestige = 150
				}
			}
		}
    }
	else_if = {
        limit = {
			scope:activity = {
				has_activity_option = {
					category = orgy_option_servant
					option = orgy_servants_many
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = regula_servants_many_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					# Increased Relation with Zealot, Parochial and Devoted
					every_vassal_or_below = {
						limit = {
							OR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 30
						}
					}
					# All other vassals get smaller relation increase
					every_vassal_or_below = {
						limit = {
							NOR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 20
						}
					}
					# All remaining attendees get relation increase
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								NOT = { this = root }
								NOT = { is_vassal_of = root}
							}
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 20
							}
						}
					}

					# Prestige increase
					add_prestige = 225
				}
			}
		}
	}
	else_if = {
        limit = {
			scope:activity = {
				has_activity_option = {
					category = orgy_option_servant
					option = orgy_servants_charmed
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = regula_servants_charmed_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					# Increased Relation with Zealot, Parochial and Devoted
					every_vassal_or_below = {
						limit = {
							OR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 50
						}
					}
					# All other vassals get smaller relation increase
					every_vassal_or_below = {
						limit = {
							NOR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 35
						}
					}
					# All remaining attendees get relation increase
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								NOT = { this = root }
								NOT = { is_vassal_of = root}
							}
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 35
							}
						}
					}

					# Prestige increase
					add_prestige = 350
				}
			}
		}
	}
	else = {
		# Must be few servants
		scope:activity = {
			add_activity_log_entry = {
				key = regula_servants_few_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					# Increased Relation with Zealot, Parochial and Devoted
					every_vassal_or_below = {
						limit = {
							OR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 10
						}
					}
					# All other vassals get smaller relation increase
					every_vassal_or_below = {
						limit = {
							NOR = {
								has_vassal_stance = zealot
								has_vassal_stance = parochial
								has_vassal_stance = devoted
							}
							is_participant_in_activity = scope:activity
						}

						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 5
						}
					}
					# All remaining attendees get relation increase
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								NOT = { this = root }
								NOT = { is_vassal_of = root}
							}
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 5
							}
						}
					}

					# Prestige increase
					add_prestige = 50
				}
			}
		}
	}

    # County development
	scope:activity_location.county = {
		add_county_modifier = {
			modifier = regula_orgy_ritual_recent_modifier
			years = 5
		}
	}
}

# Increment a variable on the host to check how many times we've taken the Recruit intent for Orgys
# Scope should be the host (aka Magister/player)
increment_orgy_recruitment_variable = {
	if = {
		limit = {
			exists = var:orgy_recruit_number
		}
		change_variable = {
			name = orgy_recruit_number
			add = 1
		}
	}
	else = {
		# Create the variable
		# Let it last for a single year, so that it cleans itself up after a while
		set_variable = {
			name = orgy_recruit_number
			value = 1
			years = 1
		}
	}
}
