﻿#####################################################################
#
#  This file contains various scripted effects for comparing the  personalities of different characters, in order to generate more
#  believable character interactions (e.g., ensuring a Brave character would prefer to insult their rival for being Craven over
#  insulting them for a non-opposing personality trait).
#
#  Also see the '00_personality_trait_triggers.txt' file when using these in an event.

#####################################################################
#
#	check_if_chars_have_opposing_traits_effect:
#	 This scripted effect is for determining if two characters have opposing personality traits.
#	 If they do, it applies a parameterized flag to the 1st character for future usage in event scripts and localisation.
#
#	Parameters:
#	 CHAR1 - The primary character we want to compare the traits of, and the one who all flags will be applied to
#	 CHAR2 - The secondary character we are comparing to CHAR1
#	 TRAIT1 - The trait we are looking for on CHAR1
#	 TRAIT2 - Should always be set to the opposite trait of TRAIT1
#	 FLAG_PREFIX - The first half of the name the flag we will apply to CHAR1, i.e. "statecraft_progress_2200"
#	 FLAG_POSTFIX - The second half of the name the flag we will apply to CHAR1, i.e. "brave"
#	 SUCCESS_FLAG - A unique flag identifier indicating if this effect has successfully found a valid set of opposing traits on thew characters.
#	 STRICT - A boolean (yes/no) indicating if we should do the fallback check for only TRAIT1 on CHAR1 if CHAR1 and CHAR2 have no opposing traits at all
#		-This is useful if you simply want to ensure the characters do not share the specified trait(i.e., one Brave char insulting another char for being Brave).
#
#	By Sean Hughes

personality_check_if_chars_have_opposing_traits_effect = {
	$CHAR1$ = {
		if = {
			limit = {
				number_of_opposing_traits = {
					target = $CHAR2$
					value >= 1
				}
			}
			if = {
				#If CHAR1 and CHAR2 have these opposite traits, CHAR1 gets the appropriate flags added to them.
				limit = {
					has_trait = $TRAIT1$
					$CHAR2$ = {
						has_trait = $TRAIT2$
					}
				}
				save_scope_value_as = {
					name = $FLAG_PREFIX$
					value = flag:$FLAG_POSTFIX$
				}
				save_scope_value_as = {
					name = $FLAG_SUCCESS$
					value = yes
				}
			}
		}
		else = {
			if = {
				#Fallback option if the two characters have no opposing traits at all.
				limit = {
					#If we are strictly looking for only opposite traits, do not do this step.
					$STRICT$ = no

					#Otherwise, simply find a trait that CHAR1 has which CHAR2 does not, then add the appropriate flag to CHAR1.
					has_trait = $TRAIT1$
					$CHAR2$ = {
						NOT = { has_trait = $TRAIT1$ }
					}
				}
				save_scope_value_as = {
					name = $FLAG_PREFIX$
					value = flag:$FLAG_POSTFIX$
				}
				save_scope_value_as = {
					name = flag:$FLAG_SUCCESS$
					value = yes
				}
			}
		}
	}
}

#####################################################################
#
#	check_opposing_bad_ruler_traits_effect:
#	 This scripted effect uses the above effect to determine which trait a vassal would most dispise in their ruler.
#	 It was created for statecraft_progress.2200, but should be able to be used in any other event without an issue,
#	 as long as each event which uses this has NOT = {scope:opposing_trait_flag_applied = yes} in a trigger.
#
#	Parameters:
#	 CHAR1 - The primary character we want to compare the traits of (the ruler/heir/potential ruler)
#	 CHAR2 - The secondary character we are comparing to CHAR1 (the vassal/potential vassal)
#	 TRAIT1 - The trait we are looking for on CHAR1
#	 TRAIT2 - Should always be set to the opposite trait of TRAIT1
#	 STRICT - A boolean (yes/no) indicating if we should do the fallback check for only TRAIT1 on CHAR1 if CHAR1 and CHAR2 have no opposing traits at all
#		-This is useful if you simply want to ensure the characters do not share the specified trait(i.e., one Brave char insulting another char for being Brave).
#
#	By Sean Hughes

personality_check_opposing_bad_ruler_traits_effect = {
	save_scope_value_as = {
		name = opposing_trait_flag_applied
		value = no
	}
	save_scope_value_as = {
		name = has_opposing_trait
		value = flag:none
	}
	#The first 11 trait pairings are selected from "Bad Ruler" traits, which vassals either dislike more than other traits or directly hurt diplomacy.
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = arbitrary
			TRAIT2 = just
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = arbitrary
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = craven
			TRAIT2 = brave
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = craven
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = sadistic
			TRAIT2 = compassionate
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = sadistic
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = lazy
			TRAIT2 = diligent
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = lazy
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = stubborn
			TRAIT2 = fickle
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = stubborn
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = paranoid
			TRAIT2 = trusting
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = paranoid
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = vengeful
			TRAIT2 = forgiving
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = vengeful
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = callous
			TRAIT2 = compassionate
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = callous
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = wrathful
			TRAIT2 = calm
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = wrathful
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = arrogant
			TRAIT2 = humble
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = arrogant
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = shy
			TRAIT2 = gregarious
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = shy
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	# The next 14 traits are neutral traits, which aren't considered "Bad Ruler" traits but an individual CHAR2 may dislike.
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = cynical
			TRAIT2 = zealous
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = cynical
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = zealous
			TRAIT2 = cynical
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = zealous
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = deceitful
			TRAIT2 = honest
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = deceitful
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = honest
			TRAIT2 = deceitful
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = honest
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = generous
			TRAIT2 = greedy
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = generous
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = greedy
			TRAIT2 = generous
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = greedy
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = gluttonous
			TRAIT2 = temperate
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = gluttonous
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = temperate
			TRAIT2 = gluttonous
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = temperate
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = impatient
			TRAIT2 = patient
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = impatient
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = patient
			TRAIT2 = impatient
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = patient
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = lustful
			TRAIT2 = chaste
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = lustful
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = chaste
			TRAIT2 = lustful
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = chaste
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = content
			TRAIT2 = ambitious
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = content
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = ambitious
			TRAIT2 = content
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = ambitious
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	#The last 11 traits are opposites of the "Bad Ruler" traits, I.E., things the player is unlikely to want tCHAR1 CHAR1 to lose.
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = gregarious
			TRAIT2 = shy
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = gregarious
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = diligent
			TRAIT2 = lazy
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = diligent
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = humble
			TRAIT2 = arrogant
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = humble
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = brave
			TRAIT2 = craven
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = brave
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = calm
			TRAIT2 = wrathful
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = calm
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = compassionate
			TRAIT2 = sadistic
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = compassionate
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = compassionate
			TRAIT2 = callous
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = compassionate
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = fickle
			TRAIT2 = stubborn
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = fickle
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = forgiving
			TRAIT2 = vengeful
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = forgiving
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = trusting
			TRAIT2 = paranoid
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = trusting
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:opposing_trait_flag_applied = yes } }
		personality_check_if_chars_have_opposing_traits_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = just
			TRAIT2 = arbitrary
			FLAG_PREFIX = has_opposing_trait
			FLAG_POSTFIX = just
			FLAG_SUCCESS = opposing_trait_flag_applied
			STRICT = $STRICT$
		}
	}
}

#####################################################################
#
#	personality_minor_shift_effect:
#	 Designed to be used in tandem with 'check_opposing_bad_ruler_traits_effect', but can be used with other scripts.
#	 Checks if a character has the specified flag and, if so, removes the corresponding personality trait.
#
#	By Sean Hughes

personality_shift_effect = {
	if = {
		limit = { scope:has_opposing_trait = flag:arrogant }
		remove_trait = arrogant
		add_trait_force_tooltip = humble
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:humble }
		remove_trait = humble
		add_trait_force_tooltip = arrogant
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:lustful }
		remove_trait = lustful
		add_trait_force_tooltip = chaste
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:chaste }
		remove_trait = chaste
		add_trait_force_tooltip = lustful
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:gregarious }
		remove_trait = gregarious
		add_trait_force_tooltip = shy
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:shy }
		remove_trait = shy
		add_trait_force_tooltip = gregarious
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:generous }
		remove_trait = generous
		add_trait_force_tooltip = greedy
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:greedy }
		remove_trait = greedy
		add_trait_force_tooltip = generous
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:ambitious }
		remove_trait = ambitious
		add_trait_force_tooltip = content
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:content }
		remove_trait = content
		add_trait_force_tooltip = ambitious
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:impatient }
		remove_trait = impatient
		add_trait_force_tooltip = patient
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:patient }
		remove_trait = patient
		add_trait_force_tooltip = impatient
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:temperate }
		remove_trait = temperate
		add_trait_force_tooltip = gluttonous
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:gluttonous }
		remove_trait = gluttonous
		add_trait_force_tooltip = temperate
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:diligent }
		remove_trait = diligent
		add_trait_force_tooltip = lazy
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:lazy }
		remove_trait = lazy
		add_trait_force_tooltip = diligent
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:wrathful }
		remove_trait = wrathful
		add_trait_force_tooltip = calm
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:calm }
		remove_trait = calm
		add_trait_force_tooltip = wrathful
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:deceitful }
		remove_trait = deceitful
		add_trait_force_tooltip = honest
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:honest }
		remove_trait = honest
		add_trait_force_tooltip = deceitful
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:craven }
		remove_trait = craven
		add_trait_force_tooltip = brave
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:brave }
		remove_trait = brave
		add_trait_force_tooltip = craven
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:arbitrary }
		remove_trait = arbitrary
		add_trait_force_tooltip = just
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:just }
		remove_trait = just
		add_trait_force_tooltip = arbitrary
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:cynical }
		remove_trait = cynical
		add_trait_force_tooltip = zealous
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:zealous }
		remove_trait = zealous
		add_trait_force_tooltip = cynical
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:paranoid }
		remove_trait = paranoid
		add_trait_force_tooltip = trusting
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:trusting }
		remove_trait = trusting
		add_trait_force_tooltip = paranoid
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:compassionate }
		remove_trait = compassionate
		add_trait_force_tooltip = callous
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:callous }
		remove_trait = callous
		add_trait_force_tooltip = compassionate
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:sadistic }
		remove_trait = sadistic
		add_trait_force_tooltip = compassionate
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:forgiving }
		remove_trait = forgiving
		add_trait_force_tooltip = vengeful
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:vengeful }
		remove_trait = vengeful
		add_trait_force_tooltip = forgiving
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:stubborn }
		remove_trait = stubborn
		add_trait_force_tooltip = fickle
	}
	else_if = {
		limit = { scope:has_opposing_trait = flag:fickle }
		remove_trait = fickle
		add_trait_force_tooltip = stubborn
	}
}

#####################################################################
#
#	personality_check_if_chars_have_shared_trait_effect:
#	 This scripted effect is for determining if two characters share a personality trait.
#	 If they do, it applies a parameterized flag to the 1st character for future usage in event scripts and localisation.
#
#	Parameters:
#	 CHAR1 - The primary character we want to compare the traits of, and the one who all flags will be applied to
#	 CHAR2 - The secondary character we are comparing to CHAR1
#	 TRAIT1 - The trait we are looking for on both the characters
#	 TRAIT2 - The opposite trait of trait 1, in case we need to rely on our fallback.
#	 FLAG_PREFIX - The first half of the name the flag we will apply to CHAR1, i.e. "statecraft_progress_2200"
#	 FLAG_POSTFIX - The second half of the name the flag we will apply to CHAR1, i.e. "brave"
#	 SUCCESS_FLAG - A unique flag identifier indicating if this effect has successfully found a valid set of shared traits on the characters.
#	 STRICT - A boolean (yes/no) indicating if we should do the fallback check for CHAR2 not having TRAIT2 if there are no shared traits.
#
#	By Sean Hughes

personality_check_if_chars_have_shared_trait_effect = {
	$CHAR1$ = {
		if = {
			limit = {
				number_of_personality_traits_in_common = {
					target = $CHAR2$
					value >= 1
				}
			}
			if = {
				#If CHAR1 and both have this trait, set the appropriate flag.
				limit = {
					has_trait = $TRAIT1$
					$CHAR2$ = {
						has_trait = $TRAIT1$					}
				}
				save_scope_value_as = {
					name = $FLAG_PREFIX$
					value = flag:$FLAG_POSTFIX$
				}
				save_scope_value_as = {
					name = $FLAG_SUCCESS$
					value = yes
				}
			}
		}
		else = {
			if = {
				#Fallback option if the two characters have no shared traits at all.
				limit = {
					#If we are strictly looking for only shared traits, do not do this step.
					$STRICT$ = no

					#Otherwise, simply find a trait that CHAR1 has which CHAR2 does not have the opposite trait for, then add the appropriate flag to CHAR1.
					has_trait = $TRAIT1$
					$CHAR2$ = {
						NOT = { has_trait = $TRAIT2$ }
					}
				}
				save_scope_value_as = {
					name = $FLAG_PREFIX$
					value = flag:$FLAG_POSTFIX$
				}
				save_scope_value_as = {
					name = $FLAG_SUCCESS$
					value = yes
				}
			}
		}
	}
}

#####################################################################
#
#	personality_check_shared_good_ruler_traits_effect:
#	 This scripted effect uses the above effect to determine which trait a vassal would most approve of in their ruler.
#
#	Parameters:
#	 CHAR1 - The primary character we want to compare the traits of (the ruler/heir/potential ruler)
#	 CHAR2 - The secondary character we are comparing to CHAR1 (the vassal/potential vassal)
#	 TRAIT1 - The trait we are looking for on CHAR1
#	 TRAIT2 - Should always be set to the opposite trait of TRAIT1
#	 STRICT - A boolean (yes/no) indicating if we should do the fallback check for only TRAIT1 on CHAR1 if CHAR1 and CHAR2 have no opposing traits at all
#		-This is useful if you simply want to ensure the characters do not share the specified trait(i.e., one Brave char insulting another char for being Brave).
#
#	By Sean Hughes

personality_check_shared_good_ruler_traits_effect = {
	save_scope_value_as = {
		name = shared_trait_flag_applied
		value = no
	}

	#The first 11 trait pairings are selected from "Good Ruler" traits, which vassals either like more than other traits or directly help diplomacy.
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = just
			TRAIT2 = arbitrary
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = just
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = brave
			TRAIT2 = craven
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = brave
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = compassionate
			TRAIT2 = sadistic
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = compassionate
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = diligent
			TRAIT2 = lazy
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = diligent
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = fickle
			TRAIT2 = stubborn
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = fickle
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = trusting
			TRAIT2 = paranoid
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = trusting
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = forgiving
			TRAIT2 = vengeful
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = forgiving
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = compassionate
			TRAIT2 = callous
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = compassionate
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = calm
			TRAIT2 = wrathful
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = calm
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = humble
			TRAIT2 = arrogant
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = humble
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = gregarious
			TRAIT2 = shy
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = gregarious
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	# The next 14 traits are neutral traits, which aren't considered "Good Ruler" traits but an individual CHAR2 may dislike.
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = cynical
			TRAIT2 = zealous
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = cynical
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = zealous
			TRAIT2 = cynical
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = zealous
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = deceitful
			TRAIT2 = honest
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = deceitful
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = honest
			TRAIT2 = deceitful
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = honest
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = generous
			TRAIT2 = greedy
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = generous
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = greedy
			TRAIT2 = generous
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = greedy
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = gluttonous
			TRAIT2 = temperate
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = gluttonous
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = temperate
			TRAIT2 = gluttonous
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = temperate
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = impatient
			TRAIT2 = patient
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = impatient
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = patient
			TRAIT2 = impatient
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = patient
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = lustful
			TRAIT2 = chaste
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = lustful
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = chaste
			TRAIT2 = lustful
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = chaste
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = content
			TRAIT2 = ambitious
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = content
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = ambitious
			TRAIT2 = content
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = ambitious
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	#The last 11 traits are opposites of the "Good Ruler" traits, I.E., things CHAR2 is unlikely to appreciate unless they themselves are that way.
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = shy
			TRAIT2 = gregarious
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = shy
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = lazy
			TRAIT2 = diligent
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = lazy
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = arrogant
			TRAIT2 = humble
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = arrogant
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = craven
			TRAIT2 = brave
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = craven
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = wrathful
			TRAIT2 = calm
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = wrathful
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = sadistic
			TRAIT2 = compassionate
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = sadistic
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = callous
			TRAIT2 = compassionate
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = callous
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = stubborn
			TRAIT2 = fickle
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = stubborn
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = vengeful
			TRAIT2 = forgiving
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = vengeful
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = paranoid
			TRAIT2 = trusting
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = paranoid
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
	if = {
		limit = { NOT = { scope:shared_trait_flag_applied = yes } }
		personality_check_if_chars_have_shared_trait_effect = {
			CHAR1 = $CHAR1$
			CHAR2 = $CHAR2$
			TRAIT1 = arbitrary
			TRAIT2 = just
			FLAG_PREFIX = has_shared_trait
			FLAG_POSTFIX = arbitrary
			FLAG_SUCCESS = shared_trait_flag_applied
			STRICT = $STRICT$
		}
	}
}

flip_sinful_trait_effect = {
	if = {
		limit = {
			has_trait = lustful
			faith = { trait_is_sin = lustful }
		}
		remove_trait = lustful
		add_trait_force_tooltip = chaste
	}
	else_if = {
		limit = {
			has_trait = chaste
			faith = { trait_is_sin = chaste }
		}
		remove_trait = chaste
		add_trait_force_tooltip = lustful
	}
	else_if = {
		limit = {
			has_trait = temperate
			faith = { trait_is_sin = temperate }
		}
		remove_trait = temperate
		add_trait_force_tooltip = gluttonous
	}
	else_if = {
		limit = {
			has_trait = gluttonous
			faith = { trait_is_sin = gluttonous }
		}
		remove_trait = gluttonous
		add_trait_force_tooltip = temperate
	}
	else_if = {
		limit = {
			has_trait = greedy
			faith = { trait_is_sin = greedy }
		}
		remove_trait = greedy
		add_trait_force_tooltip = generous
	}
	else_if = {
		limit = {
			has_trait = generous
			faith = { trait_is_sin = generous }
		}
		remove_trait = generous
		add_trait_force_tooltip = greedy
	}
	else_if = {
		limit = {
			has_trait = lazy
			faith = { trait_is_sin = lazy }
		}
		remove_trait = lazy
		add_trait_force_tooltip = diligent
	}
	else_if = {
		limit = {
			has_trait = diligent
			faith = { trait_is_sin = diligent }
		}
		remove_trait = diligent
		add_trait_force_tooltip = lazy
	}
	else_if = {
		limit = {
			has_trait = wrathful
			faith = { trait_is_sin = wrathful }
		}
		remove_trait = wrathful
		add_trait_force_tooltip = calm
	}
	else_if = {
		limit = {
			has_trait = calm
			faith = { trait_is_sin = calm }
		}
		remove_trait = calm
		add_trait_force_tooltip = wrathful
	}
	else_if = {
		limit = {
			has_trait = humble
			faith = { trait_is_sin = humble }
		}
		remove_trait = humble
		add_trait_force_tooltip = arrogant
	}
	else_if = {
		limit = {
			has_trait = arrogant
			faith = { trait_is_sin = arrogant }
		}
		remove_trait = arrogant
		add_trait_force_tooltip = humble
	}
	else_if = {
		limit = {
			has_trait = impatient
			faith = { trait_is_sin = impatient }
		}
		remove_trait = impatient
		add_trait_force_tooltip = patient
	}
	else_if = {
		limit = {
			has_trait = patient
			faith = { trait_is_sin = patient }
		}
		remove_trait = patient
		add_trait_force_tooltip = impatient
	}
	else_if = {
		limit = {
			has_trait = craven
			faith = { trait_is_sin = craven }
		}
		remove_trait = craven
		add_trait_force_tooltip = brave
	}
	else_if = {
		limit = {
			has_trait = brave
			faith = { trait_is_sin = brave }
		}
		remove_trait = brave
		add_trait_force_tooltip = craven
	}
	else_if = {
		limit = {
			has_trait = shy
			faith = { trait_is_sin = shy }
		}
		remove_trait = shy
		add_trait_force_tooltip = gregarious
	}
	else_if = {
		limit = {
			has_trait = gregarious
			faith = { trait_is_sin = gregarious }
		}
		remove_trait = gregarious
		add_trait_force_tooltip = shy
	}
	else_if = {
		limit = {
			has_trait = ambitious
			faith = { trait_is_sin = ambitious }
		}
		remove_trait = ambitious
		add_trait_force_tooltip = content
	}
	else_if = {
		limit = {
			has_trait = content
			faith = { trait_is_sin = content }
		}
		remove_trait = content
		add_trait_force_tooltip = ambitious
	}	
	else_if = {
		limit = {
			has_trait = arbitrary
			faith = { trait_is_sin = arbitrary }
		}
		remove_trait = arbitrary
		add_trait_force_tooltip = just
	}
	else_if = {
		limit = {
			has_trait = just
			faith = { trait_is_sin = just }
		}
		remove_trait = just
		add_trait_force_tooltip = arbitrary
	}	
	else_if = {
		limit = {
			has_trait = zealous
			faith = { trait_is_sin = zealous }
		}
		remove_trait = zealous
		add_trait_force_tooltip = cynical
	}
	else_if = {
		limit = {
			has_trait = cynical
			faith = { trait_is_sin = cynical }
		}
		remove_trait = cynical
		add_trait_force_tooltip = zealous
	}		
	else_if = {
		limit = {
			has_trait = trusting
			faith = { trait_is_sin = trusting }
		}
		remove_trait = trusting
		add_trait_force_tooltip = paranoid
	}
	else_if = {
		limit = {
			has_trait = paranoid
			faith = { trait_is_sin = paranoid }
		}
		remove_trait = paranoid
		add_trait_force_tooltip = trusting
	}		
	else_if = {
		limit = {
			has_trait = callous
			faith = { trait_is_sin = callous }
		}
		remove_trait = callous
		add_trait_force_tooltip = compassionate
	}
	else_if = {
		limit = {
			has_trait = sadistic
			faith = { trait_is_sin = sadistic }
		}
		remove_trait = sadistic
		add_trait_force_tooltip = compassionate
	}
	else_if = {
		limit = {
			has_trait = compassionate
			faith = { trait_is_sin = compassionate }
		}
		remove_trait = compassionate
		add_trait_force_tooltip = callous
	}
	else_if = {
		limit = {
			has_trait = stubborn
			faith = { trait_is_sin = stubborn }
		}
		remove_trait = stubborn
		add_trait_force_tooltip = fickle
	}
	else_if = {
		limit = {
			has_trait = fickle
			faith = { trait_is_sin = fickle }
		}
		remove_trait = fickle
		add_trait_force_tooltip = stubborn
	}
	else_if = {
		limit = {
			has_trait = vengeful
			faith = { trait_is_sin = vengeful }
		}
		remove_trait = vengeful
		add_trait_force_tooltip = forgiving
	}
	else_if = {
		limit = {
			has_trait = forgiving
			faith = { trait_is_sin = forgiving }
		}
		remove_trait = forgiving
		add_trait_force_tooltip = vengeful
	}
	else_if = {
		limit = {
			has_trait = honest
			faith = { trait_is_sin = honest }
		}
		remove_trait = honest
		add_trait_force_tooltip = deceitful
	}
	else_if = {
		limit = {
			has_trait = deceitful
			faith = { trait_is_sin = deceitful }
		}
		remove_trait = deceitful
		add_trait_force_tooltip = honest
	}
}
		
		
# Checks if the scoped character and the target character have any diametrically opposed personality traits.
#	Saves a scope with the selected trait held by CHARACTER_1 		
#	Should use the following trigger number_of_opposing_personality_traits to check that an opposing personality trait exists
get_diametrically_opposed_trait_trigger = {
	random_list = {
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = brave }
				$CHARACTER_2$ = { has_trait = craven }
			}
			trait:brave = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = craven }
				$CHARACTER_2$ = { has_trait = brave }
			}
			trait:craven = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = calm }
				$CHARACTER_2$ = { has_trait = wrathful }
			}
			trait:calm = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = wrathful }
				$CHARACTER_2$ = { has_trait = calm }
			}
			trait:wrathful = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = lustful }
				$CHARACTER_2$ = { has_trait = chaste }
			}
			trait:lustful = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = chaste }
				$CHARACTER_2$ = { has_trait = lustful }
			}
			trait:chaste = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = ambitious }
				$CHARACTER_2$ = { has_trait = content }
			}
			trait:ambitious = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = content }
				$CHARACTER_2$ = { has_trait = ambitious }
			}
			trait:content = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = diligent }
				$CHARACTER_2$ = { has_trait = lazy }
			}
			trait:diligent = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = lazy }
				$CHARACTER_2$ = { has_trait = diligent }
			}
			trait:lazy = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = stubborn }
				$CHARACTER_2$ = { has_trait = fickle }
			}
			trait:stubborn = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = fickle }
				$CHARACTER_2$ = { has_trait = stubborn }
			}
			trait:fickle = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = vengeful }
				$CHARACTER_2$ = { has_trait = forgiving }
			}
			trait:vengeful = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = forgiving }
				$CHARACTER_2$ = { has_trait = vengeful }
			}
			trait:forgiving = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = greedy }
				$CHARACTER_2$ = { has_trait = generous }
			}
			trait:greedy = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = generous }
				$CHARACTER_2$ = { has_trait = greedy }
			}
			trait:generous = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = gregarious }
				$CHARACTER_2$ = { has_trait = shy }
			}
			trait:gregarious = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = shy }
				$CHARACTER_2$ = { has_trait = gregarious }
			}
			trait:shy = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = honest }
				$CHARACTER_2$ = { has_trait = deceitful }
			}
			trait:honest = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = deceitful }
				$CHARACTER_2$ = { has_trait = honest }
			}
			trait:deceitful = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = humble }
				$CHARACTER_2$ = { has_trait = arrogant }
			}
			trait:humble = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = arrogant }
				$CHARACTER_2$ = { has_trait = humble }
			}
			trait:arrogant = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = just }
				$CHARACTER_2$ = { has_trait = arbitrary }
			}
			trait:just = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = arbitrary }
				$CHARACTER_2$ = { has_trait = just }
			}
			trait:arbitrary = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = patient }
				$CHARACTER_2$ = { has_trait = impatient }
			}
			trait:patient = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = impatient }
				$CHARACTER_2$ = { has_trait = patient }
			}
			trait:impatient = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = temperate }
				$CHARACTER_2$ = { has_trait = gluttonous }
			}
			trait:temperate = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = gluttonous }
				$CHARACTER_2$ = { has_trait = temperate }
			}
			trait:gluttonous = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = trusting }
				$CHARACTER_2$ = { has_trait = paranoid }
			}
			trait:trusting = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = paranoid }
				$CHARACTER_2$ = { has_trait = trusting }
			}
			trait:paranoid = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = zealous }
				$CHARACTER_2$ = { has_trait = cynical }
			}
			trait:zealous = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = cynical }
				$CHARACTER_2$ = { has_trait = zealous }
			}
			trait:cynical = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = compassionate }
				$CHARACTER_2$ = {
					OR = {
						has_trait = callous
						has_trait = sadistic 
					}
				}
			}
			trait:compassionate = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = callous }
				$CHARACTER_2$ = { has_trait = compassionate }
			}
			trait:callous = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = sadistic }
				$CHARACTER_2$ = { has_trait = compassionate }
			}
			trait:sadistic = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = loyal }
				$CHARACTER_2$ = { has_trait = disloyal }
			}
			trait:loyal = { save_scope_as = opposed_personality_trait }
		}
		1 = {
			trigger = {
				$CHARACTER_1$ = { has_trait = disloyal }
				$CHARACTER_2$ = { has_trait = loyal }
			}
			trait:disloyal = { save_scope_as = opposed_personality_trait }
		}
	}
}
