﻿#Effects used in Statecraft Lifestyle Focus events


#####################################################################
# EFFECT LIST
#####################################################################
# !!! Remember to add all new effects with a short description here !!!
#
#  A Flaw of Character:
#	diplomacy_family_0008_appropriate_lesson_effect 											Used to evaluate if the lesson the player picked was suitable for their heir.
#
#  The Power of Words:																			Outcome for complimenting somebody
#	diplomacy_majesty_0004_outcome_effect
#
#  Manipulating a Vassal: 	
#	diplomacy_generic_0012_good_outcome_effect													Successful Manipulation, gain Hook and Opinion
#	diplomacy_generic_0012_bad_outcome_effect													Failed Manipulation, lose Opinion
#	diplomacy_generic_0012_terrible_outcome_effect												Failed Manipulation, lose Hook and Prestige
#	diplomacy_generic_0012_tooltip_effect														Tooltip-Only Summary of Possible Outcomes
#
#  Court Visit
#	diplomacy_foreign_special_1010_court_visit_outcome_preview_effect							Non-executing effect used to show the player a preview of possible event outcomes in a tooltip.
#	diplomacy_foreign_special_1010_court_visit_outcome_great_effect								The best possible outcome from this event chain
#	diplomacy_foreign_special_1010_court_visit_outcome_good_effect								The standard outcome from this event chain
#	diplomacy_foreign_special_1010_court_visit_outcome_bad_effect								The worst possible outcome from this event chain
#	diplomacy_foreign_special_1010_clean_up_court_visit_effect									Clears all flags and variables after the event chain has concluded.
#	diplomacy_foreign_special_1010_court_visit_interesting_relation_okay_effect					One of several effects for what your visitor does to your courtier behind closed doors. This one is neutral.
#	diplomacy_foreign_special_1010_court_visit_interesting_relation_befriend_effect				One of several effects for what your visitor does to your courtier behind closed doors. This one they become friends.
#	diplomacy_foreign_special_1010_court_visit_interesting_relation_manipulate_effect			One of several effects for what your visitor does to your courtier behind closed doors. This one they turn them against you.
#	diplomacy_foreign_special_1010_court_visit_interesting_relation_seduce_effect				One of several effects for what your visitor does to your courtier behind closed doors. This one they seduce them.
#	diplomacy_foreign_special_1010_court_visit_join_seduction_successfully_effect				If your visitor tried to seduce your courtier, and you're spying on them, you have the chance of joining in!
#	diplomacy_foreign_special_1010_court_visit_interesting_relation_outcome_effect				Finalized the closed door relationship effect.


diplomacy_majesty_0004_outcome_effect = {
	random_list = {
		1 = {
			desc = diplomacy_majesty.0004.success.tt
			show_chance = no

			show_as_tooltip = {
				add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				reverse_add_opinion = {
					target = scope:compliment_receiver
					modifier = kindness_opinion
					opinion = 25
				}
			}
		}
		1 = {
			desc = diplomacy_majesty.0004.neutral.tt
			show_chance = no
			show_as_tooltip = {
				add_diplomacy_lifestyle_xp = minor_lifestyle_xp
			}
		}
		1 = {
			desc = diplomacy_majesty.0004.failure.tt
			show_chance = no

			show_as_tooltip = {
				reverse_add_opinion = {
					target = scope:compliment_receiver
					modifier = cruelty_opinion
					opinion = -25
				}
			}
		}
	}

	hidden_effect = {
		if = {
			limit = {
				exists = scope:compliment_outcome
				scope:compliment_outcome = flag:good
			}
			trigger_event = { id = diplomacy_majesty.0005 days = 7 }
		}

		else_if = {
			limit = {
				exists = scope:compliment_outcome
				scope:compliment_outcome = flag:neutral
			}
			send_interface_toast = {
				left_icon = scope:compliment_receiver
				title = diplomacy_majesty.0004.neutral_outcome.desc

				add_diplomacy_lifestyle_xp = minor_lifestyle_xp
			}
		}

		else_if = {
			limit = {
				exists = scope:compliment_outcome
				scope:compliment_outcome = flag:bad
			}
			trigger_event = { id = diplomacy_majesty.0006 days = 7 }
		}
	}
}



# Court Visit Effects

diplomacy_foreign_special_1010_court_visit_outcome_preview_effect = {
	show_as_tooltip = {
		$CHARACTER$ = {
			random_list = {
				1 = {
					show_chance = no
					desc = diplomacy_foreign_special.1017.great
					
					root = {
						reverse_add_opinion = {
							target = $CHARACTER$
							modifier = friendliness_opinion
							opinion = 30
						}
						if = {
							limit = { $CHARACTER$ = scope:target_list_member_a }
							custom_tooltip = diplomacy_foreign_special.1017.friends_a
						}
						else_if = {
							limit = { $CHARACTER$ = scope:target_list_member_b }
							custom_tooltip = diplomacy_foreign_special.1017.friends_b			
						}
						else = {
							custom_tooltip = diplomacy_foreign_special.1017.friends_c
						}
						add_diplomacy_lifestyle_perk_points = 1
					}
				}
				1 = {
					show_chance = no
					desc = diplomacy_foreign_special.1017.good

					root = {
						diplomacy_foreign_special_1010_court_visit_outcome_good_effect = { CHARACTER = $CHARACTER$ }
					}
				}
				1 = {
					show_chance = no
					desc = diplomacy_foreign_special.1017.bad

					root = {
						diplomacy_foreign_special_1010_court_visit_outcome_bad_effect = { CHARACTER = $CHARACTER$ }
					}
				}
			}
		}
	}

}

diplomacy_foreign_special_1010_court_visit_outcome_great_effect = {
	reverse_add_opinion = {
		target = $CHARACTER$
		modifier = friendliness_opinion
		opinion = 30
	}
	hidden_effect = {
		add_opinion = {
			target = $CHARACTER$
			modifier = friendliness_opinion
			opinion = 30
		}
	}
	progress_towards_friend_effect = {
		CHARACTER = $CHARACTER$
		OPINION = 0
		REASON = friend_court_visit
	}
	add_diplomacy_lifestyle_perk_points = 1
}

diplomacy_foreign_special_1010_court_visit_outcome_good_effect = {
	reverse_add_opinion = {
		target = $CHARACTER$
		modifier = respect_opinion
		opinion = 15
	}
	hidden_effect = {
		add_opinion = {
			target = $CHARACTER$
			modifier = friendliness_opinion
			opinion = 15
		}
	}
	add_diplomacy_lifestyle_perk_points = 1
}

diplomacy_foreign_special_1010_court_visit_outcome_bad_effect = {
	reverse_add_opinion = {
		target = $CHARACTER$
		modifier = disappointed_opinion
		opinion = -15	
	}
}


diplomacy_foreign_special_1010_clean_up_court_visit_effect = {
	remove_variable = court_visit_points
	remove_variable = no_of_court_visit_events
	remove_character_flag = is_in_diplomacy_foreign_special_event
	remove_character_flag = court_visit_hunt_or_dance
	remove_character_flag = court_visit_dance_or_holy_place
	remove_character_flag = private_dinner
	remove_character_flag = compliment
	remove_character_flag = in_success_event
	remove_character_flag = in_failure_event
}

diplomacy_foreign_special_1010_court_visit_interesting_relation_okay_effect = {
	scope:foreign_guest = {
		add_opinion = {
			target = scope:interesting_relation
			modifier = friendliness_opinion
			opinion = 15
		}
		reverse_add_opinion = {
			target = scope:interesting_relation
			modifier = friendliness_opinion
			opinion = 15
		}	
	}
}

diplomacy_foreign_special_1010_court_visit_interesting_relation_befriend_effect = {
	scope:interesting_relation = {
		set_relation_friend = { reason = friend_court_visit target = scope:foreign_guest }
	}
	scope:foreign_guest = {
		hidden_effect = {
			add_opinion = {
				target = scope:interesting_relation
				modifier = friendliness_opinion
				opinion = 30
			}
			reverse_add_opinion = {
				target = scope:interesting_relation
				modifier = friendliness_opinion
				opinion = 30
			}
		}
	}		
}

diplomacy_foreign_special_1010_court_visit_interesting_relation_manipulate_effect = {
	scope:foreign_guest = {
		if = {
			limit = {
				can_add_hook = {
					target = scope:interesting_relation
					type = manipulation_hook
				}
			}
			add_hook = {
				target = scope:interesting_relation
				type = manipulation_hook
			}	
		}
	}	
	scope:interesting_relation = {
		add_opinion = {
			target = scope:foreign_guest
			modifier = trust_opinion
			opinion = 30
		}
		add_opinion = {
			target = scope:host_ruler
			modifier = suspicion_opinion
			opinion = -20
		}
		hidden_effect = { if = { limit = { NOT = { has_relation_potential_rival = scope:host_ruler } } set_relation_potential_rival = scope:host_ruler } }
	}
}

diplomacy_foreign_special_1010_court_visit_interesting_relation_seduce_effect = {
	scope:foreign_guest = {
		set_relation_lover = { reason = lover_court_visit_seduction target = scope:interesting_relation involved_character = root }

		hidden_effect = {
			intercourse_with_character_effect = { INTERCOURSE_CHARACTER = scope:interesting_relation }
			add_opinion = {
				target = scope:interesting_relation
				modifier = romance_opinion
				opinion = 30
			}
			reverse_add_opinion = {
				target = scope:interesting_relation
				modifier = romance_opinion
				opinion = 30
			}
		}
	}
}

diplomacy_foreign_special_1010_court_visit_join_seduction_successfully_effect = {
	$CHARACTER$ = {
		if = {
			limit = {
				matching_gender_and_sexuality_trigger = {
					CHARACTER_1 = $CHARACTER$
					CHARACTER_2 = root
				}
				NOR = {
					has_relation_lover = root
					is_consort_of = root
				}
			}
			set_relation_lover = { reason = lover_court_visit_seduction target = root }
		}
		add_opinion = {
			target = root
			modifier = pleased_opinion
			opinion = 30
		}
		hidden_effect = {
			reverse_add_opinion = {
				target = $CHARACTER$
				modifier = pleased_opinion
				opinion = 30
			}
		}
	}
}

diplomacy_foreign_special_1010_court_visit_interesting_relation_outcome_effect = {
	if = {
		limit = { scope:private_dinner_outcome = flag:okay }
		diplomacy_foreign_special_1010_court_visit_interesting_relation_okay_effect = yes
	}
	else_if = {
		limit = { scope:private_dinner_outcome = flag:befriend }
		diplomacy_foreign_special_1010_court_visit_interesting_relation_befriend_effect = yes
	}
	else_if = {
		limit = { scope:private_dinner_outcome = flag:manipulate }
		diplomacy_foreign_special_1010_court_visit_interesting_relation_manipulate_effect = yes
	}
	else_if = {
		limit = { scope:private_dinner_outcome = flag:seduce }
		diplomacy_foreign_special_1010_court_visit_interesting_relation_seduce_effect = yes
	}
}

diplomacy_foreign_1150_successful_county_switch_effect = {
	# Give your county/vassal to the neighbor
	if = {
		limit = {
			scope:county.holder = scope:neighbor
		}
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:county = {
			change_title_holder = {
				holder = scope:ruler
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
	else_if = {
		limit = {
			scope:ruler_vassal = {
				highest_held_title_tier = tier_county
			}
		}
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:ruler_vassal = {
			change_liege = {
				liege = scope:ruler
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
	else = {
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:county = {
			change_title_holder = {
				holder = scope:ruler
				change = scope:change
			}
		}
	}
	# The neighbor gives his county/vassal to you.
	if = {
		limit = {
			scope:neighbor_county.holder = scope:ruler
		}
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:neighbor_county = {
			change_title_holder = {
				holder = scope:neighbor
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
	else = {
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:neighbor_vassal = {
			change_liege = {
				liege = scope:neighbor
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
	}
	# Add xp
	scope:ruler = { add_diplomacy_lifestyle_xp = major_lifestyle_experience }
	# Add positive opinion
	scope:neighbor = {
		add_opinion = {
			modifier = respect_opinion
			target = scope:ruler
			opinion = low_positive_opinion
		}
	}
}

diplomacy_foreign_1150_failed_county_switch_effect = {
	# Add xp
	scope:ruler = { add_diplomacy_lifestyle_xp = miniscule_lifestyle_experience }
	# Add negative opinion (both neighbor and possible vassal)
	scope:neighbor = {
		add_opinion = {
			modifier = respect_opinion
			target = scope:ruler
			opinion = low_negative_opinion
		}
	}
	if = {
		limit = {
			exists = scope:neighbor_vassal
		}
		scope:neighbor_vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = scope:ruler
				opinion = medium_negative_opinion
			}
		}
	}
	# Reduce control in your county (...sell-out)
	scope:neighbor_county = {
		change_county_control = major_county_control_loss
	}
}
