﻿namespace = orgy_main_challenge

############################
# The Domina Challenge
# by Ban10
############################

# Domina Challenge
# Your Domina is challenged by a Paelex, or a group of Paelexs
# Choose to back up your Domina, or choose a new Paelex

####
# Weight and Setup Event
####
orgy_main_challenge.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:Challenge }
		}
		# Make sure we have a Domina, and that the Domina has a reason that she is challenged
		scope:activity = {
			any_attending_character = {
				# Is the domina here?
				has_trait = domina

				# Do we have a good reason for switching her?
				# Bad Personality
				# Age
				# Injurys
				# Bad Mental Traits
			}
		}
	}

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

###
# Event for Host (Magister)
###
orgy_main_challenge.0002 = {
	type = activity_event
	title = orgy_main_offering.0002.t
	desc = orgy_main_offering.0002.desc
	theme = regula_orgy_theme
	override_background = {
		reference = corridor_night
	}

	left_portrait = {
		character = scope:inviter
		animation = flirtation
	}

	right_portrait = {
		character = scope:offering
		animation = admiration
	}

	immediate = {
		hidden_effect = {
			scope:activity = {
				random_attending_character = {
					limit = {
						is_regula_leader_devoted_trigger = yes
					}
					save_scope_as = inviter
				}
			}

			regula_create_orgy_guest_effect = { WHO = scope:inviter }
			scope:created_orgy_guest = { save_scope_as = offering }
		}
	}

	#You are very welcome!
	option = {
		name = orgy_main_offering.0002.a
		# Entrance the guest
		scope:offering = {
			fascinare_success_effect = { CHARACTER = root }
			create_memory_fascinare_scheme = { CHARACTER = root }
		}
		reverse_add_opinion = {
			target = scope:offering
			modifier = grateful_opinion
			opinion = 30
		}
		reverse_add_opinion = {
			target = scope:inviter
			modifier = grateful_opinion
			opinion = 20
		}

		# Move on to sexy times
		scope:activity = {
			activity_host = {
				trigger_event = orgy_main_offering.0003
			}
		}
	}

	#Invite only, sorry
	option = {
		name = orgy_main_offering.0002.b

		reverse_add_opinion = {
			target = scope:offering
			modifier = disappointed_opinion
			opinion = -15
		}
	}
}

# Keep current Domina
orgy_main_challenge.0003 = {
	type = activity_event
	title = orgy_main_offering.0003.t
	desc = orgy_main_offering.0003.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:offering
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_content
	}

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

	option = {
		name = orgy_main_offering.0003.a
		regula_sex_with_target_normal = { TARGET = scope:offering }
		scope:offering = {
			add_to_activity = scope:activity
		}
		add_courtier = scope:offering
	}
}

# Choose new Domina
orgy_main_challenge.0004 = {
	type = activity_event
	title = orgy_main_offering.0003.t
	desc = orgy_main_offering.0003.desc
	theme = regula_orgy_theme
	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = scope:offering
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_content
	}

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

	option = {
		name = orgy_main_offering.0003.a
		regula_sex_with_target_normal = { TARGET = scope:offering }
		scope:offering = {
			add_to_activity = scope:activity
		}
		add_courtier = scope:offering
	}
}
