﻿#Effects used in Lifestyle Focus events


#####################################################################
# EFFECT LIST
#####################################################################
# !!! Remember to add all new effects with a short description here !!!
#


#####################
# COMPLIMENT SYSTEM #
#####################
#This system evaluates whether a character would accept a certain type of compliment (types listed below) from another character. It will set a compliment_outcome varaible with a flag value of either good, neutral or bad which can be used to trigger follow up events.

#randomize_available_compliment_effect - as there are more compliment types than option buttons, you can use this effect to randomize a number of flags to trigger options (12 types of compliments).
#randomize_good_available_compliment_effect - this one will do its best to pick a good compliment option, recommended to use this one for at least one of the randomized options so that the player has at least one option which is likely to be successful. Defaults to randomize_available_compliment_effect if nothing good can be found.
#randomize_available_ai_value_compliment_effect - as the one above, but only uses the ai value compliments (8 types), the "light" version.
#clear_available_compliments_effect - clears all available compliment flags.
#evaluate_compliment_effect - evaluates the outcome of the compliment with a random_list and sets a compliment_outcome variable.
#evaluate_compliment_with_type_variable_effect - the same as the one above but also saves a variable containing the type of comliment used.

#COMPLIMENT TYPES
#compassionate (ai value)
#bold (ai value)
#honorable (ai value)
#rational (ai value)
#zealous (ai value)
#energetic (ai value)
#forgiving (ai value)
#beautiful
#strong
#extroverted
#dominant

#If you don't want to specify the available compliments, you can use this to get a selection relative to your root.diplomacy skill and your target's preferences.
#Run the effect as many times as the amount of compliment options you need.
#More diplomatically skilled characters has a higher chance to receive options which have a high likelihood of success.
#If you want to block a certain compliment, you can add that flag yourself before randomizing and then removing it afterwards.
#Use in scope of compliment giver.
#Needs arguments COMPLIMENT_RECEIVER
randomize_available_compliment_effect = {
	random_list = {
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_compassionate } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_compassion >= low_positive_compassion }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_compassion < 0 }
			}
			add_character_flag = available_compliment_compassionate
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_bold } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_boldness >= low_positive_boldness }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_boldness < 0 }
			}
			add_character_flag = available_compliment_bold
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_honorable } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_honor >= low_positive_honor }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_honor < 0 }
			}
			add_character_flag = available_compliment_honorable
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_greedy } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_greed >= low_positive_greed }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_greed < 0 }
			}
			add_character_flag = available_compliment_greedy
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_rational } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_rationality >= low_positive_rationality }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_rationality < 0 }
			}
			add_character_flag = available_compliment_rational
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_zealous } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_zeal >= low_positive_zeal }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_zeal < 0 }
			}
			add_character_flag = available_compliment_zealous
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_energetic } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_energy >= low_positive_energy }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_energy < 0 }
			}
			add_character_flag = available_compliment_energetic
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_forgiving } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_vengefulness <= low_negative_vengefulness }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { ai_vengefulness > 0 }
			}
			add_character_flag = available_compliment_forgiving
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_beautiful } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { attraction >= 10  }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { attraction < -10  }
			}
			add_character_flag = available_compliment_beautiful
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_strong } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = {
					OR = {
						has_trait = strong
						has_trait = physique_good_1
						has_trait = physique_good_2
						has_trait = physique_good_3
					}
				}
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = {
					OR = {
						has_trait = weak
						has_trait = physique_bad_1
						has_trait = physique_bad_2
						has_trait = physique_bad_3
					}
				}
			}
			add_character_flag = available_compliment_strong
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_extroverted } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { has_personality_extroverted_trigger = yes  }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { has_personality_introverted_trigger = yes }
			}
			add_character_flag = available_compliment_extroverted
		}
		1 = {
			trigger = { NOT = { has_character_flag = available_compliment_dominant } }
			modifier = {
				factor = 3
				root.diplomacy >= decent_skill_rating
				$COMPLIMENT_RECEIVER$ = { has_personality_dominant_trigger = yes  }
			}
			modifier = {
				factor = 2
				root.diplomacy < medium_skill_rating
				$COMPLIMENT_RECEIVER$ = { has_personality_submissive_trigger = yes }
			}
			add_character_flag = available_compliment_dominant
		}
	}
}

#Randomizes an available compliment which is likely to work, needs argument COMPLIMENT_RECEIVER.
randomize_good_available_compliment_effect = {
	random_list = {
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_compassion >= low_positive_compassion }
				NOT = { has_character_flag = available_compliment_compassionate }
			}
			add_character_flag = available_compliment_compassionate
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_boldness >= low_positive_boldness }
				NOT = { has_character_flag = available_compliment_bold }
			}
			add_character_flag = available_compliment_bold
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_honor >= low_positive_honor }
				NOT = { has_character_flag = available_compliment_honorable }
			}
			add_character_flag = available_compliment_honorable
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_greed >= low_positive_greed }
				NOT = { has_character_flag = available_compliment_greedy }
			}
			add_character_flag = available_compliment_greedy
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_rationality >= low_positive_rationality }
				NOT = { has_character_flag = available_compliment_rational }
			}
			add_character_flag = available_compliment_rational
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_zeal >= low_positive_zeal }
				NOT = { has_character_flag = available_compliment_zealous }
			}
			add_character_flag = available_compliment_zealous
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_energy >= low_positive_energy }
				NOT = { has_character_flag = available_compliment_energetic }
			}
			add_character_flag = available_compliment_energetic
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { ai_vengefulness <= low_negative_vengefulness }
				NOT = { has_character_flag = available_compliment_forgiving }
			}
			add_character_flag = available_compliment_forgiving
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { attraction >= 10 }
				NOT = { has_character_flag = available_compliment_beautiful }
			}
			add_character_flag = available_compliment_beautiful
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = {
					OR = {
						has_trait = strong
						has_trait = physique_good
					}
				}
				NOT = { has_character_flag = available_compliment_strong }
			}
			add_character_flag = available_compliment_strong
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { has_personality_extroverted_trigger = yes  }
				NOT = { has_character_flag = available_compliment_extroverted }
			}
			add_character_flag = available_compliment_extroverted
		}
		100 = {
			trigger = {
				$COMPLIMENT_RECEIVER$ = { has_personality_dominant_trigger = yes }
				NOT = { has_character_flag = available_compliment_dominant }
			}
			add_character_flag = available_compliment_dominant
		}
		1 = { #Fallback
			randomize_available_compliment_effect = { COMPLIMENT_RECEIVER = $COMPLIMENT_RECEIVER$ }
		}
	}
}

#Same as randomize_available_compliment_effect but it only uses the 8 ai value compliments. Required argument COMPLIMENT_RECEIVER (not tested)
randomize_available_ai_value_compliment_effect = {
	add_character_flag = available_compliment_beautiful
	add_character_flag = available_compliment_strong
	add_character_flag = available_compliment_extroverted
	add_character_flag = available_compliment_dominant

	randomize_available_compliment_effect = { COMPLIMENT_RECEIVER = $COMPLIMENT_RECEIVER$ }

	remove_character_flag = available_compliment_beautiful
	remove_character_flag = available_compliment_strong
	remove_character_flag = available_compliment_extroverted
	remove_character_flag = available_compliment_dominant
}

#Clears all the compliment flags after the event
clear_available_compliments_effect = {
	remove_character_flag = available_compliment_compassionate
	remove_character_flag = available_compliment_bold
	remove_character_flag = available_compliment_honorable
	remove_character_flag = available_compliment_greedy
	remove_character_flag = available_compliment_rational
	remove_character_flag = available_compliment_zealous
	remove_character_flag = available_compliment_energetic
	remove_character_flag = available_compliment_forgiving
	remove_character_flag = available_compliment_beautiful
	remove_character_flag = available_compliment_strong
	remove_character_flag = available_compliment_extroverted
	remove_character_flag = available_compliment_dominant
}

#EVALUATION
#Use in scope of compliment receiver.
#2 types, regular evaluate_compliment_effect and evaluate_compliment_with_type_variable_effect which saves the variable containing the type (evaluated_compliment_type)
#Needs arguments COMPLIMENT_TYPE (see compliment type list above) and COMPLIMENT_GIVER (the name of the scope).

evaluate_compliment_effect = {

	save_scope_value_as = {
		name = evaluated_compliment_type
		value = flag:$COMPLIMENT_TYPE$
	}

	if = {
		limit = { exists = scope:evaluated_compliment_type } #Because there are error messages otherwise
		
		random_list = {
			# BAD OUTCOME
			0 = { # Base chance of 0, since we don't ever want to randomly penalize the player due to bad luck even if they picked the right compliment.
				modifier = {
					add = 100 #Incorrect type of compliment significantly increases chances of being insulted.
					OR = {
						AND = {
							scope:evaluated_compliment_type = flag:compassionate
							ai_compassion < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:bold
							ai_boldness < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:honorable
							ai_honor < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:greedy
							ai_greed < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:rational
							ai_rationality < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:zealous
							ai_zeal < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:energetic
							ai_energy < 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:forgiving
							ai_vengefulness > 0
						}
						AND = {
							scope:evaluated_compliment_type = flag:beautiful
							attraction < -10
						}
						AND = {
							scope:evaluated_compliment_type = flag:strong
							OR = {
								has_trait = weak
								has_trait = physique_bad_1
								has_trait = physique_bad_2
								has_trait = physique_bad_3
							}
						}
						AND = {
							scope:evaluated_compliment_type = flag:extroverted
							has_personality_introverted_trigger = yes
						}
						AND = {
							scope:evaluated_compliment_type = flag:dominant
							has_personality_submissive_trigger = yes
						}
					}
				}
				modifier = { #Humble people struggle with compliments
					factor = 1.5
					has_trait = humble
				}

				save_scope_value_as = {
					name = compliment_outcome
					value = flag:bad
				}
			}

			60 = { #NEUTRAL OUTCOME
				modifier = {
					factor = 1.3
					has_trait = arrogant
				}
				modifier = {
					factor = 1.3
					has_trait = humble
				}

				save_scope_value_as = {
					name = compliment_outcome
					value = flag:neutral
				}
			}

			25 = { #GOOD OUTCOME
				modifier = { #Great compliment (not step-based)
					factor = 8
					OR = {
						AND = {
							scope:evaluated_compliment_type = flag:extroverted
							has_personality_extroverted_trigger = yes
						}
						AND = {
							scope:evaluated_compliment_type = flag:dominant
							has_personality_dominant_trigger = yes
						}
					}
				}
				modifier = { #Great compliment (step-based)
					factor = 2 #Adds up to 8 with the two modifiers below
					OR = {
						AND = {
							scope:evaluated_compliment_type = flag:compassionate
							ai_compassion >= high_positive_compassion
						}
						AND = {
							scope:evaluated_compliment_type = flag:bold
							ai_boldness >= high_positive_boldness
						}
						AND = {
							scope:evaluated_compliment_type = flag:honorable
							ai_honor >= high_positive_honor
						}
						AND = {
							scope:evaluated_compliment_type = flag:greedy
							ai_greed >= high_positive_greed
						}
						AND = {
							scope:evaluated_compliment_type = flag:rational
							ai_rationality >= high_positive_rationality
						}
						AND = {
							scope:evaluated_compliment_type = flag:zealous
							ai_zeal >= high_positive_zeal
						}
						AND = {
							scope:evaluated_compliment_type = flag:energetic
							ai_energy >= high_positive_energy
						}
						AND = {
							scope:evaluated_compliment_type = flag:forgiving
							ai_vengefulness <= high_negative_vengefulness
						}
						AND = {
							scope:evaluated_compliment_type = flag:beautiful
							attraction >= 30
						}
						AND = {
							scope:evaluated_compliment_type = flag:strong
							has_trait = physique_good_3
						}
					}
				}
				modifier = { #Good compliment (step-based)
					factor = 2 #Adds up to 4 with the modifier below
					OR = {
						AND = {
							scope:evaluated_compliment_type = flag:compassionate
							ai_compassion >= medium_positive_compassion
						}
						AND = {
							scope:evaluated_compliment_type = flag:bold
							ai_boldness >= medium_positive_boldness
						}
						AND = {
							scope:evaluated_compliment_type = flag:honorable
							ai_honor >= medium_positive_honor
						}
						AND = {
							scope:evaluated_compliment_type = flag:greedy
							ai_greed >= medium_positive_greed
						}
						AND = {
							scope:evaluated_compliment_type = flag:rational
							ai_rationality >= medium_positive_rationality
						}
						AND = {
							scope:evaluated_compliment_type = flag:zealous
							ai_zeal >= medium_positive_zeal
						}
						AND = {
							scope:evaluated_compliment_type = flag:energetic
							ai_energy >= medium_positive_energy
						}
						AND = {
							scope:evaluated_compliment_type = flag:forgiving
							ai_vengefulness <= medium_negative_vengefulness
						}
						AND = {
							scope:evaluated_compliment_type = flag:beautiful
							attraction >= 20
						}
						AND = {
							scope:evaluated_compliment_type = flag:strong
							OR = {
								has_trait = physique_good_2
								has_trait = physique_good_3
								has_trait = strong
							}
						}
					}
				}
				modifier = { #Good compliment (step-based)
					factor = 4
					OR = {
						AND = {
							scope:evaluated_compliment_type = flag:compassionate
							ai_compassion >= low_positive_compassion
						}
						AND = {
							scope:evaluated_compliment_type = flag:bold
							ai_boldness >= low_positive_boldness
						}
						AND = {
							scope:evaluated_compliment_type = flag:honorable
							ai_honor >= low_positive_honor
						}
						AND = {
							scope:evaluated_compliment_type = flag:greedy
							ai_greed >= low_positive_greed
						}
						AND = {
							scope:evaluated_compliment_type = flag:rational
							ai_rationality >= low_positive_rationality
						}
						AND = {
							scope:evaluated_compliment_type = flag:zealous
							ai_zeal >= low_positive_zeal
						}
						AND = {
							scope:evaluated_compliment_type = flag:energetic
							ai_energy >= low_positive_energy
						}
						AND = {
							scope:evaluated_compliment_type = flag:forgiving
							ai_vengefulness <= low_negative_vengefulness
						}
						AND = {
							scope:evaluated_compliment_type = flag:beautiful
							attraction >= 10
						}
						AND = {
							scope:evaluated_compliment_type = flag:strong
							OR = {
								has_trait = physique_good_1
								has_trait = physique_good_2
								has_trait = physique_good_3
								has_trait = strong
							}
						}
					}
				}
				modifier = { #Arrogant people like compliments
					factor = 1.5
					has_trait = arrogant
				}
				modifier = { #Diplomacy affects success chance
					factor = {
						value = $COMPLIMENT_GIVER$.diplomacy
						subtract = diplomacy
						multiply = 0.05 #I.e. 0.5 if 10 skill difference
						add = 1 #To bring it to something like 1.5
					}
				}

				save_scope_value_as = {
					name = compliment_outcome
					value = flag:good
				}
			}	
		}		
	}
}

compliment_to_love_letter_effect = {
	if = {
		limit = { exists = scope:compliment_outcome }

		if = {
			limit = { scope:compliment_outcome = flag:good }
			set_variable = {
				name = love_letter_quality
				value = 4
				days = 150
			}
		}
		else_if = {
			limit = { scope:compliment_outcome = flag:neutral }
			set_variable = {
				name = love_letter_quality
				value = 2
				days = 150
			}
		}
		else_if = {
			limit = { scope:compliment_outcome = flag:bad }
			set_variable = {
				name = love_letter_quality
				value = 1
				days = 150
			}
		}

		set_variable = {
			name = love_letter_compliment_type
			value = scope:evaluated_compliment_type
		}
	}
}

compliment_to_love_letter_cleanup_effect = {
	if = {
		limit = { has_variable = love_letter_quality }
		remove_variable = love_letter_quality
	}
	if = {
		limit = { has_variable = love_letter_quality }
		remove_variable = love_letter_compliment_type
	}
}



