﻿namespace = orgy_main_group

############################
# The Group
# by Ban10
############################

# Group
# Lay with a group of your wives
# You can make them become friends, change sinful personality traits or Mutare corpus all of them
# Or just get some piety

####
# Weight and Setup Event
####
orgy_main_group.0001 = {
	type = activity_event
	hidden = yes

	trigger = {
		# Make sure this wasn't triggered last time
		trigger_if = {
			limit = { scope:activity.activity_host = { has_variable = last_orgy_was } }
			NOT = { scope:activity.activity_host.var:last_orgy_was = flag:group }
		}

		# Make sure we have at least two wives
		scope:activity = {
			any_attending_character = {
				count >= 2
				is_regula_leader_devoted_trigger = yes
			}
		}
	}

	immediate = {
		scope:activity = {
			activity_host = {
				# Set this as last main orgy activity
				set_variable = {
					name = last_orgy_was
					value = flag:group
				}
				trigger_event = orgy_main_group.0002
			}
		}
	}
}

###
# Event for Host (Magister)
###
orgy_main_group.0002 = {
	type = activity_event
	title = orgy_main_group.0002.t
	desc = {
		desc = orgy_main_group.0002.intro
		triggered_desc = {
			trigger = {
				exists = scope:group_wife_2
			}
			desc = orgy_main_group.0002.second_wife
		}
		triggered_desc = {
			trigger = {
				exists = scope:group_wife_3
			}
			desc = orgy_main_group.0002.third_wife
		}
		triggered_desc = {
			trigger = {
				exists = scope:group_wife_4
			}
			desc = orgy_main_group.0002.fourth_wife
		}
		desc = orgy_main_group.0002.intro_2
	}

	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:host
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_compassionate
	}

	right_portrait = {
		character = scope:main_wife
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = idle
	}

	lower_left_portrait = {
		character = scope:group_wife_2
	}

	lower_center_portrait = {
		character = scope:group_wife_3
	}

	lower_right_portrait = {
		character = scope:group_wife_4
	}

	immediate = {
		hidden_effect = {
			# Grab Main wife (Domina or Paelex)
			scope:activity = {
				random_attending_character = {
					limit = {
						has_trait = domina
					}
					save_scope_as = main_wife
				}
				# Otherwise fill slot with Paelex
				if = {
					limit = { NOT = { exists = scope:main_wife } }
					random_attending_character = {
						limit = {
							has_trait = paelex
						}
						save_scope_as = main_wife
					}
				}
			}
			# Then try to grab more Paelex
			scope:activity = {
				random_attending_character = {
					limit = {
						NOT = { this = scope:main_wife }
						has_trait = paelex
					}
					save_scope_as = group_wife_2
				}
			}
			scope:activity = {
				random_attending_character = {
					limit = {
						NOT = {
							this = scope:main_wife
							this = scope:group_wife_2
						}
						has_trait = paelex
					}
					save_scope_as = group_wife_3
				}
			}
			scope:activity = {
				random_attending_character = {
					limit = {
						NOT = {
							this = scope:main_wife
							this = scope:group_wife_2
							this = scope:group_wife_3
						}
						has_trait = paelex
					}
					save_scope_as = group_wife_4
				}
			}
		}

		scope:host = {
			stress_impact = {
				base = medium_stress_impact_loss
			}
		}
		# Sexy times
		# Dont run stress effects
		regula_sex_with_target_no_stress = { TARGET = scope:main_wife }
		regula_sex_with_target_no_stress = { TARGET = scope:group_wife_2 }

		if = {
			limit = { exists = scope:group_wife_3 }
			regula_sex_with_target_no_stress = { TARGET = scope:group_wife_3 }
		}

		if = {
			limit = { exists = scope:group_wife_4 }
			regula_sex_with_target_no_stress = { TARGET = scope:group_wife_4 }
		}

	}

	# Make them friends
	option = {
		name = orgy_main_group.0002.a

		show_as_tooltip = {
			scope:main_wife ?= {
				set_relation_friend = scope:group_wife_2
				if = {
					limit = { exists = scope:group_wife_3 }
					set_relation_friend = scope:group_wife_3
				}
				if = {
					limit = { exists = scope:group_wife_4 }
					set_relation_friend = scope:group_wife_4
				}
			}

			scope:group_wife_2 ?= {
				if = {
					limit = { exists = scope:group_wife_3 }
					set_relation_friend = scope:group_wife_3
				}
				if = {
					limit = { exists = scope:group_wife_4 }
					set_relation_friend = scope:group_wife_4
				}
			}

			scope:group_wife_3 ?= {
				if = {
					limit = { exists = scope:group_wife_4 }
					set_relation_friend = scope:group_wife_4
				}
			}
		}

		scope:activity = {
			activity_host = {
				trigger_event = orgy_main_group.0003
			}
		}
	}

	# Change sinful traits
	option = {
		name = orgy_main_group.0002.b

		show_as_tooltip = {
			scope:main_wife ?= {
				regula_remove_sinful_personality_traits_all_effect = yes
				regula_change_personality_to_virtuous_single_effect = yes
			}
			scope:group_wife_2 ?= {
				regula_remove_sinful_personality_traits_all_effect = yes
				regula_change_personality_to_virtuous_single_effect = yes
			}
			scope:group_wife_3 ?= {
				regula_remove_sinful_personality_traits_all_effect = yes
				regula_change_personality_to_virtuous_single_effect = yes
			}
			scope:group_wife_4 ?= {
				regula_remove_sinful_personality_traits_all_effect = yes
				regula_change_personality_to_virtuous_single_effect = yes
			}
		}

		scope:activity = {
			activity_host = {
				trigger_event = orgy_main_group.0004
			}
		}
	}

	# Mutare corpus all of them
	option = {
		name = orgy_main_group.0002.c
		flavor = orgy_main_group.0002.c.tt

		show_as_tooltip = {
			regula_mutare_corpus_mental_boost_effect = yes
		}

		scope:activity = {
			activity_host = {
				trigger_event = orgy_main_group.0005
			}
		}
	}

	# Just get some Piety
	option = {
		name = orgy_main_group.0002.d

		show_as_tooltip = {
			scope:host = {
				add_piety = 1500
			}
		}

		scope:activity = {
			activity_host = {
				trigger_event = orgy_main_group.0006
			}
		}
	}
}

# Make them friends
orgy_main_group.0003 = {
	type = activity_event
	title = orgy_main_group.0003.t
	desc = orgy_main_group.0003.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:host
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_compassionate
	}

	right_portrait = {
		character = scope:main_wife
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = idle
	}

	lower_left_portrait = {
		character = scope:group_wife_2
	}

	lower_center_portrait = {
		character = scope:group_wife_3
	}

	lower_right_portrait = {
		character = scope:group_wife_4
	}

	immediate = {
		scope:main_wife ?= {
			set_relation_friend = scope:group_wife_2
			if = {
				limit = { exists = scope:group_wife_3 }
				set_relation_friend = scope:group_wife_3
			}
			if = {
				limit = { exists = scope:group_wife_4 }
				set_relation_friend = scope:group_wife_4
			}
		}

		scope:group_wife_2 ?= {
			if = {
				limit = { exists = scope:group_wife_3 }
				set_relation_friend = scope:group_wife_3
			}
			if = {
				limit = { exists = scope:group_wife_4 }
				set_relation_friend = scope:group_wife_4
			}
		}

		scope:group_wife_3 ?= {
			if = {
				limit = { exists = scope:group_wife_4 }
				set_relation_friend = scope:group_wife_4
			}
		}
	}

	after = {
		hidden_effect = {
 			scope:activity = {
				add_activity_log_entry = {
					key = regula_orgy_group_log
					tags = { good }
					score = 25
					character = root
				}
			}
		}
	}

	# Make them best friends
	option = {
		name = orgy_main_group.0003.a
	}
}

# Change personalitys (Remove sinful traits for virtues)
orgy_main_group.0004 = {
	type = activity_event
	title = orgy_main_group.0004.t
	desc = orgy_main_group.0004.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:host
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_compassionate
	}

	right_portrait = {
		character = scope:main_wife
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = idle
	}

	lower_left_portrait = {
		character = scope:group_wife_2
	}

	lower_center_portrait = {
		character = scope:group_wife_3
	}

	lower_right_portrait = {
		character = scope:group_wife_4
	}

	immediate = {
		scope:main_wife ?= {
			regula_remove_sinful_personality_traits_all_effect = yes
			regula_change_personality_to_virtuous_single_effect = yes
		}
		scope:group_wife_2 ?= {
			regula_remove_sinful_personality_traits_all_effect = yes
			regula_change_personality_to_virtuous_single_effect = yes
		}
		scope:group_wife_3 ?= {
			regula_remove_sinful_personality_traits_all_effect = yes
			regula_change_personality_to_virtuous_single_effect = yes
		}
		scope:group_wife_4 ?= {
			regula_remove_sinful_personality_traits_all_effect = yes
			regula_change_personality_to_virtuous_single_effect = yes
		}
	}

	after = {
		hidden_effect = {
 			scope:activity = {
				add_activity_log_entry = {
					key = regula_orgy_group_log
					tags = { good }
					score = 25
					character = root
				}
			}
		}
	}

	# Mold their Minds
	option = {
		name = orgy_main_group.0004.a
	}
}

# Mutare Corpus all of your wives
orgy_main_group.0005 = {
	type = activity_event
	title = orgy_main_group.0005.t
	desc = orgy_main_group.0005.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:host
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_compassionate
	}

	right_portrait = {
		character = scope:main_wife
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = idle
	}

	lower_left_portrait = {
		character = scope:group_wife_2
	}

	lower_center_portrait = {
		character = scope:group_wife_3
	}

	lower_right_portrait = {
		character = scope:group_wife_4
	}

	immediate = {
		scope:host = {
			save_scope_as = actor
		}


		scope:main_wife = {
			save_scope_as = recipient
		}
		random_list = {
			1 = { regula_mutare_corpus_mental_boost_effect = yes }
			1 = { regula_mutare_corpus_physical_boost_effect = yes }
			1 = { regula_mutare_corpus_sexual_boost_effect = yes }
		}

		scope:group_wife_2 = {
			save_scope_as = recipient
		}
		random_list = {
			1 = { regula_mutare_corpus_mental_boost_effect = yes }
			1 = { regula_mutare_corpus_physical_boost_effect = yes }
			1 = { regula_mutare_corpus_sexual_boost_effect = yes }
		}

		if = {
			limit = { exists = scope:group_wife_3 }
			scope:group_wife_3 = {
				save_scope_as = recipient
			}
			random_list = {
				1 = { regula_mutare_corpus_mental_boost_effect = yes }
				1 = { regula_mutare_corpus_physical_boost_effect = yes }
				1 = { regula_mutare_corpus_sexual_boost_effect = yes }
			}
		}

		if = {
			limit = { exists = scope:group_wife_4 }
			scope:group_wife_4 = {
				save_scope_as = recipient
			}
			random_list = {
				1 = { regula_mutare_corpus_mental_boost_effect = yes }
				1 = { regula_mutare_corpus_physical_boost_effect = yes }
				1 = { regula_mutare_corpus_sexual_boost_effect = yes }
			}
		}
	}

	after = {
		hidden_effect = {
 			scope:activity = {
				add_activity_log_entry = {
					key = regula_orgy_group_log
					tags = { good }
					score = 25
					character = root
				}
			}
		}
	}

	# Mutare Corpus them
	option = {
		name = orgy_main_group.0005.a
	}
}

# Just get some Piety
orgy_main_group.0006 = {
	type = activity_event
	title = orgy_main_group.0006.t
	desc = orgy_main_group.0006.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:host
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_compassionate
	}

	right_portrait = {
		character = scope:main_wife
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = idle
	}

	lower_left_portrait = {
		character = scope:group_wife_2
	}

	lower_center_portrait = {
		character = scope:group_wife_3
	}

	lower_right_portrait = {
		character = scope:group_wife_4
	}

	after = {
		hidden_effect = {
 			scope:activity = {
				add_activity_log_entry = {
					key = regula_orgy_group_log
					tags = { good }
					score = 25
					character = root
				}
			}
		}
	}

	# Just Piety
	option = {
		name = orgy_main_group.0006.a

		add_piety = 1500
	}
}
