﻿###CHILD CONVERSION EFFECTS###

child_everpreg_witch_conversion_success_effect = {
	scope:guardian = {
		send_interface_toast = {
			title = child_everpreg_witch_conversion_success_effect.desc
			left_icon = scope:child
		}
		scope:child = {
			give_everpreg_witch_secret_or_trait_effect = yes
			random_secret = {
				limit = { secret_type = secret_everpreg_witch }
				reveal_to = scope:guardian
			}
			add_opinion = {
				target = scope:guardian
				modifier = impressed_opinion
				opinion = 30
			}
			add_trait = everpreg_1
		}
		scope:guardian = {
			random_secret = {
				limit = {
					NOT = { is_known_by = scope:child }
					secret_type = secret_everpreg_witch
				}
				reveal_to = scope:child
			}
			if = {
				limit = { this = root }
				hidden_effect = {
					add_opinion = {
						target = scope:child
						modifier = pleased_opinion
						opinion = 20
					}
				}
			}
			else = {
				add_opinion = {
					target = scope:child
					modifier = pleased_opinion
					opinion = 20
				}
			}
		}
	}
}

child_everpreg_witch_conversion_failure_effect = {
	scope:guardian = {
		send_interface_toast = {
			title = child_everpreg_witch_conversion_failure_effect.desc
			left_icon = scope:child
		}
		scope:child = {
		 	add_opinion = {
				target = scope:guardian
				modifier = suspicion_opinion
				opinion = -15
			}
		}
		scope:guardian = {
			if = {
				limit = { this = root }
				hidden_effect = {
					add_opinion = {
						target = scope:child
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
			else = {
				add_opinion = {
					target = scope:child
					modifier = disappointed_opinion
					opinion = -15
				}
			}
		}
	}
}

child_everpreg_witch_conversion_critical_failure_effect = {
	scope:guardian = {
		send_interface_toast = {
			title = child_everpreg_witch_conversion_critical_failure_effect.desc
			left_icon = scope:child

			scope:child = {
			 	add_opinion = {
					target = scope:guardian
					modifier = hate_opinion
					opinion = -30
				}
			}
		}
		scope:child = {
			scope:guardian = {
				random_secret = {
					limit = {
						secret_type = secret_everpreg_witch
					}
					save_scope_as = guardian_everpreg_witch_secret
					if = {
						limit = { NOT = { is_known_by = scope:child } }
						reveal_to = scope:child
					}
					if = {
						limit = {
							exists = scope:child.liege
							NOR = {
								is_known_by = scope:child.liege
								scope:child = { is_ruler = yes }
							}
						}
						scope:child.liege = {
							send_interface_message = {
								title = child_everpreg_witch_conversion_critical_failure_effect.liege.desc
								left_icon = scope:guardian
								right_icon = scope:child
								scope:guardian_everpreg_witch_secret = { reveal_to = scope:child.liege }
							}
						}
					}
				}
			}
		}
		scope:guardian = {
			if = {
				limit = { this = root }
				hidden_effect = {
					add_opinion = {
						target = scope:child
						modifier = hate_opinion
						opinion = -30
					}
				}
			}
			else = {
				add_opinion = {
					target = scope:child
					modifier = hate_opinion
					opinion = -30
				}
			}
		}
	}
}

#Creates a everpreg_witch and saves it as created_everpreg_witch
#WHO is character who will interact with the everpreg_witch and TEMPLATE is the character whose culture should be used
create_everpreg_witch_effect = {
	#Gender
	random_list = {
		100 = { #Female
			modifier = {
				$WHO$ = { is_attracted_to_women = yes }
				add = 30
			}
			dummy_female = { save_temporary_scope_as = everpreg_witch_gender }
		}
		#0 = { #Male
		#	modifier = {
		#		$WHO$ = { is_attracted_to_men = yes }
		#		add = 30
		#	}
		#	dummy_male = { save_temporary_scope_as = everpreg_witch_gender }
		#}
	}

	#Create them
	create_character = {
		save_temporary_scope_as = created_everpreg_witch
		location = $WHO$.capital_province
		culture = $WHO$.culture
		faith = faith:everpreg_antideleuvianism
		gender = scope:everpreg_witch_gender
		template = everpreg_witchy_template
		random_traits = no
	}

	scope:created_everpreg_witch = {
		give_everpreg_witch_secret_or_trait_effect = yes
	}

	#Sometimes adjust sexuality to create compatibility with WHO
	if = {
		limit = {
			$WHO$ = { is_attracted_to_gender_of = scope:created_everpreg_witch }
			NOT = { scope:created_everpreg_witch = { is_attracted_to_gender_of = $WHO$ } }
		}
		random = {
			chance = 65
			scope:created_everpreg_witch = {
				set_sexuality = bisexual
			}
		}
	}
}

give_everpreg_witch_secret_or_trait_effect = {
	save_temporary_scope_as = everpreg_witch_character
	#$CHARACTER$ = { save_scope_as = second_character }	
	if = {
		limit = { #Not already a witch
			NOR = {
				faith.religion = scope:owner.faith
				#any_secret = { secret_type = secret_everpreg_witch }
			}	
		}
		if = {
			limit = {
				trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = witch GENDER_CHARACTER = scope:everpreg_witch_character }
			}
			add_secret = {
				type = secret_everpreg_witch
			}
			add_trait = everpreg_1
		}
		####set this up as an if statement when you can figure out how to set up secret reveals to make the original enticer's religion the religion the character converts to.
			set_character_faith = root.faith#scope:owner.faith			
			#set_relation_lover = scope:everpreg_witch_character
			#progress_towards_lover_effect = {
			#	CHARACTER = root
			#	OPINION = 15
			#}
	}	
}

found_everpreg_witch_coven_decision_effects = {
	save_scope_as = founder
	#custom_tooltip = found_everpreg_witch_coven_decision_effects.children.tt
	#custom_tooltip = found_everpreg_witch_coven_decision_effects.convert.tt
	#custom_tooltip = found_everpreg_witch_coven_decision_effects.grand_rite.tt
	house = {
		add_house_modifier = {
			modifier = everpreg_witch_coven
		}
	}
}