﻿###################
# Siege Perk Event
#
###################

namespace = nht_ml_sack_holding_event

nht_ml_sack_holding_event.0001 = {
	type = character_event

	title = {
		random_valid = {
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.first }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.sec }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.third }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.fourth }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.fifth }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.sixth }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.seventh }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.eighth }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.nineth }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.tenth }	
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.t.eleventh }
			triggered_desc = {
				trigger = { 	
					scope:county = { this = this.holder.top_liege.capital_county }
				} 
				desc = nht_ml_sack_holding_event.0001.desc_warning_holysite
			}			
		}
	}

	desc = {
		random_valid = {
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.desc.first }	
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.desc.sec }
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.desc.third }	
			triggered_desc = { desc = nht_ml_sack_holding_event.0001.desc.fourth }				
		}
		triggered_desc = {
			trigger = { 
				scope:barony = { is_holy_site = yes } 
			} 
			desc = nht_ml_sack_holding_event.0001.desc_warning_holysite
		}		
	}
	
	theme = war
	override_background = { reference = burning_building }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:nht_sack_previous_owner
		animation = fear
		triggered_animation = {
			trigger = {
				ai_vengefulness >= medium_positive_ai_value
				ai_boldness > high_negative_ai_value
			}
			animation = rage
		}
	}
	

	immediate = {
		scope:county = { save_scope_as = nht_sacked_county }
		#For loc.		
		scope:barony = { save_scope_as = nht_sacked_barony }		
		scope:previous_controller = { save_scope_as = nht_sack_previous_owner }	
	}

	#Won't do it
	option = {
		name = nht_ml_sack_holding_event.0001.a

		scope:nht_sack_previous_owner = {			
			add_opinion = {
				modifier = nht_not_sacked_holding_grateful_opinion
				target = root
				opinion = 10
				years = 5
			}	
		}
		if = {
			limit = {
				faith = {
					OR = {
						trait_is_sin = compassionate
						trait_is_sin = forgiving
					}
				}
			}
			add_piety = minor_piety_loss
		}
		else = { add_piety = medium_piety_gain }
		stress_impact = {
			sadistic = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
		custom_tooltip = nht_ml_sack_holding_event.0001.a_tt		
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
				ai_greed = -0.25
			}
			modifier = {
				add = -20
				has_trait = sadistic
			}
			modifier = {
				add = -20
				has_trait = vengeful
			}
			modifier = {
				add = -20
				has_trait = wrathful
			}
			modifier = {
				add = -10
				has_trait = aggressive_attacker
			}
			modifier = {
				add = -10
				has_trait = possessed
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:nht_sack_previous_owner.faith
						value < faith_hostile_level
					}
				}
				add = 60
			}
		}
	}

	option = {
		name = nht_ml_sack_holding_event.0001.b
		add_gold = minor_gold_value
		scope:nht_sack_previous_owner = {			
			add_opinion = {
				modifier = nht_sacked_holding_angry_opinion
				target = root
				opinion = -10
				years = 5
			}	
		}
		scope:nht_sacked_county = {
			add_county_modifier = {	#Prevent the county from being sacked again for quite a while.
				modifier = nht_recently_sacked_modifier
				years = 10
			}
		}
		scope:barony.title_province = {			
			add_province_modifier = {
				modifier = nht_recently_looted_barony_modifier
				years = 10
			}
			hidden_effect = {
				destroy_random_building_effect = yes
			}
			custom_tooltip = nht_ml_sack_holding_event.0001.b_tt			
		}

	}
	
	option = {
		name = nht_ml_sack_holding_event.0001.c
		add_gold = medium_gold_value
		scope:nht_sack_previous_owner = {			
			add_opinion = {
				modifier = nht_sacked_holding_angry_opinion
				target = root
				opinion = -20
				years = 10
			}	
		}
		scope:nht_sacked_county = {
			add_county_modifier = {	#Prevent the county from being sacked again for quite a while.
				modifier = nht_recently_sacked_modifier
				years = 20
			}
			change_county_control = -50
			change_development_progress = -50
			change_development_level = {
				subtract = this.development_level
				multiply = 0.3
				floor = yes
			}
		}
		scope:barony.title_province = {			
			add_province_modifier = {
				modifier = nht_recently_sacked_barony_modifier
				years = 30
			}
			hidden_effect = {
				while = {
					count = half_buildings_destroyed_value
					random_list = {
						50 = {
							nht_destroy_random_building_variable_effect = yes
							nht_destroy_random_building_effect = yes
						}
						50 = {
							destroy_random_building_variable_effect = yes
							destroy_random_building_effect = yes
						}
					}
				}
			}
			custom_tooltip = nht_ml_sack_holding_event.0001.c_tt				
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			sadistic = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss		
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -1
			}
			modifier = {
				add = -30
				has_trait = compassionate
			}
			modifier = {
				add = -30
				has_trait = forgiving
			}
			modifier = {
				add = -20
				has_trait = just
			}
			modifier = {
				add = 15
				has_trait = wrathful
			}
			modifier = {
				add = 15
				has_trait = vengeful
			}
			modifier = {
				add = 15
				has_trait = sadistic
			}
			### Is two years in debt.
			modifier = {
				add = 25
				debt_level >= 2
			}
		}
	}

	option = { #Destroy everything
		name = nht_ml_sack_holding_event.0001.d
		add_gold = major_gold_value
		scope:nht_sack_previous_owner = {			
			add_opinion = {
				modifier = nht_sacked_holding_angry_opinion
				target = root
				opinion = -40
				years = 20
			}	
		}		
		scope:nht_sacked_county = {
			add_county_modifier = {	#Prevent the county from being sacked again for quite a while.
				modifier = nht_recently_sacked_modifier
				years = 30
			}
			change_county_control = -100
			change_development_progress = -100
			change_development_level = {
				subtract = this.development_level
				multiply = 0.9
				floor = yes
			}
		}
		scope:barony.title_province = {			
			add_province_modifier = {
				modifier = nht_reduced_to_ashes_barony_modifier
				years = 30
			}
			hidden_effect = {
				nht_destroy_every_buildings_effect = yes	
			}
			custom_tooltip = nht_ml_sack_holding_event.0001.d_tt
			custom_tooltip = nht_ml_sack_holding_event.0001.d_warning_tt			
		}		
		if = {
			limit = {
				scope:nht_sacked_barony = { is_holy_site = yes } 
			}
			hidden_effect = {
				every_ruler = {
					limit = {
						scope:nht_sacked_barony = { is_holy_site_of = prev.faith }
						is_landed = yes
						highest_held_title_tier >= tier_county
						this != root
						capital_province = {
							squared_distance = {
								target = scope:nht_sacked_county
								value <= squared_distance_almost_massive
							}
						}
					}
					add_opinion = {
						modifier = nht_sacked_holy_site_opinion
						target = root
						opinion = -30
					}				
				}
			}
			custom_tooltip = nht_ml_sack_holding_event.0001.d_holy_site_tt	
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			forgiving = major_stress_impact_gain
			sadistic = major_stress_impact_loss
			vengeful = medium_stress_impact_loss
			wrathful = major_stress_impact_loss		
		}
		
		ai_chance = {
			base = -50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 25
				has_trait = wrathful
			}
			modifier = {
				add = 25
				has_trait = vengeful
			}
			modifier = {
				add = 25
				has_trait = sadistic
			}
			modifier = {
				add = 20
				has_trait = aggressive_attacker
			}
			modifier = {
				add = 20
				has_trait = possessed
			}
			modifier = {
				add = 10
				has_trait = lunatic
			}		
			### Negative traits
			modifier = {
				add = -30
				has_trait = forgiving
			}
			modifier = {
				add = -30
				has_trait = compassionate
			}
			modifier = {
				add = -30
				has_trait = just
			}
			modifier = {
				NOT = { any_secret = { secret_type = secret_non_believer } }
				faith = {
					faith_hostility_level = {
						target = scope:nht_sack_previous_owner.faith
						value >= faith_hostile_level
					}
				}
				add = 60
			}
			### Is two years in debt.
			modifier = {
				add = 40
				debt_level >= 3
			}			
		}
	}

	### Never in my lifetime
	option = {
		name = nht_ml_sack_holding_event.0001.e
		
		scope:nht_sack_previous_owner = {			
			add_opinion = {
				modifier = nht_not_sacked_holding_grateful_opinion
				target = root
				opinion = 10
				years = 5
			}	
		}
		if = {
			limit = {
				faith = {
					OR = {
						trait_is_sin = compassionate
						trait_is_sin = forgiving
					}
				}
			}
			add_piety = medium_piety_loss
		}
		else = { add_piety = major_piety_gain }		
		custom_tooltip = nht_ml_sack_holding_event.0001.e_tt
		add_character_flag = {
			flag = nht_choose_no_sacking
		}	
		
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_honor = 1
				ai_boldness = 0.25
				ai_compassion = 0.5
			}
			modifier = {
				add = -25
				has_trait = wrathful
			}
			modifier = {
				add = -25
				has_trait = vengeful
			}
			modifier = {
				add = -25
				has_trait = sadistic
			}
			modifier = {
				add = 40
				has_trait = forgiving
			}
			modifier = {
				add = 40
				has_trait = compassionate
			}
			modifier = {
				add = 40
				has_trait = just
			}
		}
	}
}