﻿namespace = BWLaG_fix_yourself

BWLaG_fix_yourself.0001 = {
	type = character_event
	title = BWLaG_fix_yourself.0001.title
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = BWLAG_tried_to_fix_self_before
				}
				desc = BWLaG_fix_yourself.0001.tried_to_fix_self_before
			}
			triggered_desc = {
				trigger = {
					has_character_flag = BWLAG_doubled_down_or_ignored_before
				}
				desc = BWLaG_fix_yourself.0001.BWLAG_doubled_down_or_ignored_before
			}
			desc = BWLaG_fix_yourself.0001.desc.fallback
		}
	}

	theme = physical_health

	right_portrait = {
		character = root
		animation = worry
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { no_clothes nightgown }
		}
	}

	lower_center_portrait = {
		trigger = { exists = scope:bad_influence_spouse }
		character = scope:bad_influence_spouse
	}

	override_background = { reference = bedchamber }

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					any_spouse = {
						BWLaG_bad_influence = yes
					}
				}
				random_spouse = {
					limit = {
						BWLaG_bad_influence = yes
					}
					save_scope_as = bad_influence_spouse
				}
			}
		}
	}

	# Option 1 - Double Down
	option = {
		name = BWLaG_fix_yourself.0001.double_down
		ai_chance = {
			base = 75
			modifier = {
				add = 50
				has_trait = comfort_eater
			}
			modifier = {
				add = 100
				has_trait = gluttonous
			}
			modifier = {
				add = 50
				has_trait = greedy
			}
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = 50
				has_trait = gregarious
			}
			modifier = {
				add = 50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = -50
				has_trait = paranoid
			}
			modifier = {
				add = -50
				has_trait = diligent
			}
			modifier = {
				add = -100
				has_trait = temperate
			}
			modifier = {
				add = -50
				has_trait = content
			}
			modifier = {
				add = -25
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = -25
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = -25
				has_trait = tourney_participant
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -50
				has_trait = athletic
			}
			modifier = {
				add = -50
				has_trait = whole_of_body
			}
			modifier = {
				add = 50
				has_trait = stubborn
			}
			modifier = {
				add = -25
				has_trait = calm
			}
			modifier = {
				add = 50
				has_trait = arrogant
			}
			modifier = {
				add = 100
				stress >= higher_than_baseline_stress
			}
			modifier = {
				add = 100
				is_landed = no
				any_parent = {
					is_alive = yes
					BWLaG_bad_influence = yes
				}
			}
		}
		trigger = {
			NOT = {
				AND = {
					has_character_modifier = BWLaG_loves_food_modifier
					has_trait = comfort_eater
					has_trait = gluttonous
				}
			}
		}
		if = {
			limit = {
				NOT = { has_character_modifier = BWLaG_loves_food_modifier }
				has_trait = comfort_eater
				has_trait = gluttonous
			}
			add_character_modifier = {
				modifier = BWLaG_loves_food_modifier
			}
			add_stress = major_stress_loss
		}
		else_if = {
			limit = {
				NOT = { has_trait = comfort_eater }
				has_trait = gluttonous
			}
			add_trait = comfort_eater
			add_stress = major_stress_loss
			add_character_flag = BWLAG_comfort_eater_protected
		}
		else = {
			if = {
				limit = {
					has_trait = temperate
				}
				remove_trait = temperate
				custom_tooltip = BWLaG_fix_yourself.0001.double_down.gain_glut_tooltip
				add_stress = massive_stress_gain
			}
			else = {
				add_stress = major_stress_loss
			}
			add_trait = gluttonous
		}
		hidden_effect = {
			BWLAG_doubled_down_or_ignored_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 2 - Temperate
	option = {
		name = BWLaG_fix_yourself.0001.temperate
		ai_chance = {
			base = 60
			modifier = {
				add = -50
				has_trait = comfort_eater
			}
			modifier = {
				add = -100
				has_trait = gluttonous
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				add = -50
				has_trait = lazy
			}
			modifier = {
				add = -50
				has_trait = gregarious
			}
			modifier = {
				add = -50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = 100
				has_trait = diligent
			}
			modifier = {
				add = 25
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = 25
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = 25
				has_trait = tourney_participant
			}
			modifier = {
				add = 50
				has_trait = athletic
			}
			modifier = {
				add = 50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = -100
				has_trait = impatient
			}
			modifier = {
				add = -100
				stress >= higher_than_baseline_stress
			}
		}
		trigger = {
			NOT = { 
				has_trait = temperate
			}
		}
		if = {
			limit = {
				has_trait = gluttonous
			}
			remove_trait = gluttonous
			custom_tooltip = BWLaG_fix_yourself.0001.double_down.gain_temp_tooltip
			add_stress = massive_stress_gain
		}
		add_trait = temperate
		hidden_effect = {
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 3 - Inappetetic
	option = {
		name = BWLaG_fix_yourself.0001.inappetetic
		ai_chance = {
			base = -100
			modifier = {
				add = -100
				has_trait = comfort_eater
			}
			modifier = {
				add = -100
				has_trait = gluttonous
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				add = -50
				has_trait = gregarious
			}
			modifier = {
				add = -50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = 50
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -25
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = -25
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = -25
				has_trait = tourney_participant
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -25
				has_trait = athletic
			}
			modifier = {
				add = -50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = 200
				has_trait = impatient
			}
			modifier = {
				add = 150
				stress >= higher_than_baseline_stress
			}
		}
		trigger = {
			has_trait = temperate
			NOR = { 
				has_trait = inappetetic
				has_trait = comfort_eater
				has_trait = gluttonous
			}
		}

		add_trait = inappetetic
		add_stress = major_stress_loss
		hidden_effect = {
			add_character_flag = BWLAG_inappetetic_protected
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 4 - Comfort Eater
	option = {
		name = BWLaG_fix_yourself.0001.comfort_eater
		ai_chance = {
			base = 0
			modifier = {
				add = -100
				has_trait = gluttonous
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				add = -50
				has_trait = lazy
			}
			modifier = {
				add = -50
				has_trait = gregarious
			}
			modifier = {
				add = -50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 200
				has_trait = diligent
			}
			modifier = {
				add = 200
				has_trait = temperate
			}
			modifier = {
				add = 50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = -100
				has_trait = impatient
			}
			modifier = {
				add = -150
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			has_trait = comfort_eater
			NOT = { has_character_flag = BWLAG_comfort_eater_protected }
		}

		remove_trait = comfort_eater
		add_stress = major_stress_gain
		hidden_effect = {
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 5 - Drunkard
	option = {
		name = BWLaG_fix_yourself.0001.drunkard
		ai_chance = {
			base = 0
			modifier = {
				add = -50
				has_trait = comfort_eater
			}
			modifier = {
				add = -50
				has_trait = gluttonous
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				add = -50
				has_trait = lazy
			}
			modifier = {
				add = -100
				has_trait = gregarious
			}
			modifier = {
				add = -100
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = 200
				has_trait = diligent
			}
			modifier = {
				add = 200
				has_trait = temperate
			}
			modifier = {
				add = 50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = -100
				has_trait = impatient
			}
			modifier = {
				add = -150
				stress >= higher_than_baseline_stress
			}
		}
		trigger = {
			has_trait = drunkard
		}
		remove_trait = drunkard
		add_stress = major_stress_gain
		hidden_effect = {
			if = {
				limit = {
					NOT = { has_character_flag = BWLAG_tried_to_fix_self_before }
				}
				add_character_flag = BWLAG_tried_to_fix_self_before
			}
			add_character_flag = {
				flag = BWLAG_fix_self_cooldown
				days = 1800
			}
		}
	}

	# Option 6 - Divorce Spouse for bad influence
	option = {
		name = BWLaG_fix_yourself.0001.divorce_spouse
		custom_tooltip = BWLaG_fix_yourself.0001.divorce_spouse.tooltip
		trigger = {
			exists = scope:bad_influence_spouse
			NOT = { faith = { has_doctrine = doctrine_divorce_disallowed } }
		}
		show_as_unavailable = {
		}
		ai_chance = {
			base = -1000
		}
		if = { # This should supress the error?
			limit = {	
				exists = scope:bad_influence_spouse
			}
			divorce = scope:bad_influence_spouse
		}
		add_piety = -100
		hidden_effect = {
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 7 - Athletic
	option = {
		name = BWLaG_fix_yourself.0001.athletic
		ai_chance = {
			base = 0
			modifier = {
				add = -200
				has_trait = lazy
			}
			modifier = {
				add = 100
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = temperate
			}
			modifier = {
				add = 100
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = 100
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = 100
				has_trait = tourney_participant
			}
			modifier = {
				add = 50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = 50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = -100
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = patient
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = 50
				has_trait = impatient
			}
		}

		trigger = {
			NOT = { has_trait = athletic }
		}

		add_trait = athletic
		add_stress = major_stress_gain
		hidden_effect = {
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 8 - Reclusive
	option = {
		name = BWLaG_fix_yourself.0001.reclusive
		custom_tooltip = BWLaG_fix_yourself.0001.reclusive.tooltip
		ai_chance = {
			base = -100
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = -100
				has_trait = gregarious
			}
			modifier = {
				add = -100
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = -50
				has_trait = temperate
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = -100
				has_trait = impatient
			}
			modifier = {
				add = 300
				has_trait = shy
			}
			modifier = {
				add = 150
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			NOR = {
				has_trait = reclusive
				has_trait = gregarious
				has_trait = lifestyle_reveler
			}
		}

		add_trait = reclusive
		add_stress = major_stress_loss

		hidden_effect = {
			BWLAG_tried_to_fix_self_before_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 9 - Do nothing
	option = { 
		name = BWLaG_fix_yourself.0001.do_nothing
		ai_chance = {
			base = -50
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = -100
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -50
				has_trait = athletic
			}
			modifier = {
				add = -100
				has_trait = whole_of_body
			}
			modifier = {
				add = 200
				has_trait = stubborn
			}
			modifier = {
				add = 100
				has_trait = calm
			}
			modifier = {
				add = 100
				has_trait = cynical
			}
			modifier = {
				add = 200
				has_trait = patient
			}
			modifier = {
				add = 200
				has_trait = arrogant
			}
			modifier = {
				add = -200
				has_trait = impatient
			}
			modifier = {
				add = -200
				stress >= higher_than_baseline_stress
			}
		}
		hidden_effect = {
			BWLAG_doubled_down_or_ignored_before_effect = yes
			add_character_flag = {
				flag = BWLAG_fix_self_cooldown
				days = 720
			}
		}
	}
}

BWLaG_fix_yourself.0002 = {
	type = character_event
	title = BWLaG_fix_yourself.0002.title
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = BWLAG_malnourished_tried_to_fix
				}
				desc = BWLaG_fix_yourself.0002.BWLAG_malnourished_tried_to_fix
			}
			desc = BWLaG_fix_yourself.0002.desc.fallback
		}
	}

	theme = physical_health

	right_portrait = {
		character = root
		animation = worry
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { no_clothes nightgown }
		}
	}

	override_background = { reference = bedchamber }

	# Option 1 - inappetetic
	option = {
		name = BWLaG_fix_yourself.0002.inappetetic
		ai_chance = {
			base = 50
			modifier = {
				add = -100
				has_trait = comfort_eater
			}
			modifier = {
				add = -100
				has_trait = gluttonous
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				add = -50
				has_trait = gregarious
			}
			modifier = {
				add = -50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = 50
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -25
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = -25
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = -25
				has_trait = tourney_participant
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -25
				has_trait = athletic
			}
			modifier = {
				add = -50
				has_trait = whole_of_body
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = 200
				has_trait = impatient
			}
			modifier = {
				add = -200
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			has_trait = inappetetic
			NOT = { has_character_flag = BWLAG_inappetetic_protected }
			BWLaG_has_health_issue = no
		}

		remove_trait = inappetetic
		add_stress = major_stress_gain

		hidden_effect = {
			BWLAG_malnourished_tried_to_fix_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 2 - reclusive
	option = {
		name = BWLaG_fix_yourself.0002.reclusive
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = -100
				has_trait = gregarious
			}
			modifier = {
				add = -100
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			modifier = {
				add = -50
				has_trait = temperate
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = calm
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
			modifier = {
				add = -100
				has_trait = impatient
			}
			modifier = {
				add = 300
				has_trait = shy
			}
			modifier = {
				add = -200
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			has_trait = reclusive
			BWLaG_has_health_issue = no
		}

		remove_trait = reclusive
		add_stress = major_stress_gain

		hidden_effect = {
			BWLAG_malnourished_tried_to_fix_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 3 - paranoid
	option = {
		name = BWLaG_fix_yourself.0002.paranoid
		ai_chance = {
			base = 1500
		}

		trigger = {
			has_trait = paranoid
			BWLaG_has_health_issue = no
		}

		add_stress = massive_stress_loss

		hidden_effect = {
			add_character_flag = BWLaG_paranoid_blocks_malnourised_event
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 4 - weak
	option = {
		name = BWLaG_fix_yourself.0002.weak
		ai_chance = {
			base = 50
			modifier = {
				add = -100
				has_trait = lazy
			}
			modifier = {
				add = 50
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = temperate
			}
			modifier = {
				add = -50
				has_trait = content
			}
			modifier = {
				add = 50
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = 50
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = 50
				has_trait = tourney_participant
			}
			modifier = {
				add = 50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = 100
				has_trait = athletic
			}
			modifier = {
				add = 100
				has_trait = whole_of_body
			}
			modifier = {
				add = -50
				has_trait = calm
			}
			modifier = {
				add = 100
				has_trait = impatient
			}
			modifier = {
				add = -200
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			has_trait = weak
			BWLaG_has_health_issue = no
		}

		remove_trait = weak
		add_stress = major_stress_gain

		hidden_effect = {
			BWLAG_malnourished_tried_to_fix_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 5 - gluttonous
	option = {
		name = BWLaG_fix_yourself.0002.gluttonous
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				has_trait = comfort_eater
			}
			modifier = {
				add = 100
				has_trait = greedy
			}
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = 50
				has_trait = gregarious
			}
			modifier = {
				add = 50
				has_trait = lifestyle_reveler
			}
			modifier = {
				add = -50
				has_trait = paranoid
			}
			modifier = {
				add = -50
				has_trait = diligent
			}
			modifier = {
				add = -200
				has_trait = temperate
			}
			modifier = {
				add = -50
				has_trait = content
			}
			modifier = {
				add = -25
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = -25
				has_trait = lifestyle_blademaster
			}
			modifier = {
				add = -25
				has_trait = tourney_participant
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -50
				has_trait = athletic
			}
			modifier = {
				add = -50
				has_trait = whole_of_body
			}
			modifier = {
				add = 50
				has_trait = stubborn
			}
			modifier = {
				add = -25
				has_trait = calm
			}
			modifier = {
				add = 50
				has_trait = arrogant
			}
			modifier = {
				add = 100
				stress >= higher_than_baseline_stress
			}
		}

		trigger = {
			NOT = {
				has_trait = gluttonous
				has_trait = inappetetic
			}
			BWLaG_has_health_issue = no
		}

		if = {
			limit = {
				has_trait = temperate
			}
			remove_trait = temperate
			custom_tooltip = BWLaG_fix_yourself.0001.double_down.gain_glut_tooltip
			add_stress = massive_stress_gain
		}
		add_trait = gluttonous

		hidden_effect = {
			BWLAG_malnourished_tried_to_fix_effect = yes
			BWLAG_fix_self_normal_cooldown = yes
		}
	}

	# Option 6 - unwell
	option = { 
		name = BWLaG_fix_yourself.0002.unwell
		trigger = {
			BWLaG_has_health_issue = yes
		}
		ai_chance = {
			base = 1500
		}
		hidden_effect = {
			add_character_flag = {
				flag = BWLAG_fix_self_cooldown
				days = 720
			}
		}
	}

	# Option 7 - Do nothing
	option = { 
		name = BWLaG_fix_yourself.0001.do_nothing
		trigger = {
			BWLaG_has_health_issue = no
		}
		ai_chance = {
			base = -50
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = -100
				has_trait = diligent
			}
			modifier = {
				add = 50
				has_trait = content
			}
			modifier = {
				add = -50
				has_trait = lifestyle_physician
			}
			modifier = {
				add = -50
				has_trait = athletic
			}
			modifier = {
				add = -100
				has_trait = whole_of_body
			}
			modifier = {
				add = 200
				has_trait = stubborn
			}
			modifier = {
				add = 100
				has_trait = calm
			}
			modifier = {
				add = 100
				has_trait = cynical
			}
			modifier = {
				add = 200
				has_trait = patient
			}
			modifier = {
				add = 200
				has_trait = arrogant
			}
			modifier = {
				add = -200
				has_trait = impatient
			}
			modifier = {
				add = -200
				stress >= higher_than_baseline_stress
			}
		}
		hidden_effect = {
			add_character_flag = {
				flag = BWLAG_fix_self_cooldown
				days = 720
			}
		}
	}
}