﻿namespace = tgp_travel_danger_events
#You encounter an orphan while traveling trough an area struck by natural disaster
tgp_travel_danger_events.0001 = {
	type = character_event
	title = tgp_travel_danger_events.0001.t
	desc = {
		desc = tgp_travel_danger_events.0001.intro
		#Triggered desc based on success
		first_valid = {
			triggered_desc ={
				trigger = {
					location = {
						county = {
							any_county_situation = {
			    				situation_type = natural_disaster_flood 
			    			}
						}
					}
				}
				desc = tgp_travel_danger_events.0001.flood
			}
			triggered_desc ={
				trigger = {
					location = {
						county = {
							any_county_situation = {
			    				situation_type = natural_disaster_earthquake 
			    			}
						}
					}
				}
				desc = tgp_travel_danger_events.0001.earthquake
			}			
		}

		desc = tgp_travel_danger_events.0001.desc
	}
	theme = travel_danger

	override_background = {
		trigger = {
			location = {
				geographical_region = world_asia
				county = {
					any_county_situation = {
			    		situation_type = natural_disaster_earthquake 
			    	}
				}
			}
		}
		reference = tgp_ruined_holding
	}
	override_background = {
		trigger = {
			location = {
				geographical_region = world_asia
				county = {
					any_county_situation = {
			    		situation_type = natural_disaster_flood 
			    	}
				}
			}
		}
		reference = tgp_overflowing_river
	}
	override_background = {
		trigger = {
			location = {
				NOT = { geographical_region = world_asia }
				 county = {
					any_county_situation = {
			    			situation_type = natural_disaster_earthquake 
			    	}
				}
			}
		}
		reference = burning_building
	}
	override_background = {
		trigger = {
			location = {
				NOT = { geographical_region = world_asia }
				county = {
					any_county_situation = {
			    			situation_type = natural_disaster_flood
			    	}
				}
			}
		}
		reference = bp3_riverside
	}	
	override_effect_2d = {
		trigger = { scope:disaster_situation = { situation_type = natural_disaster_earthquake } }
		reference = smoke
	}
	override_effect_2d = {
		trigger = { scope:disaster_situation = { situation_type = natural_disaster_flood } }
		reference = rain
	}	
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait_benevolent_trigger = yes
			}
			animation = stunned
		}
		triggered_animation = {
			trigger = {
				has_trait_malicious_trigger = yes
			}
			animation = dismissal
		}		

		animation = disbelief
		camera = camera_event_scheme_left
	}
	right_portrait = {
		character = scope:peasant_character_child
		animation = sadness
		camera = camera_event_right_pointing_left
	}
	cooldown = { years = 20 }

	trigger = {
		is_location_valid_for_travel_event_on_land = yes
		is_available_travelling_adult = yes

		location = {
			county = {
				any_county_situation = {
			    	tgp_natural_disaster_situation_is_disaster_trigger = yes
			    }
			}
		}
	}

	immediate = {
		location.county = {
			random_county_situation = {
				limit = {
					tgp_natural_disaster_situation_is_disaster_trigger = yes
				}
				save_scope_as = disaster_situation
			}
		}
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					age = { 8 12 }
					has_trait = diligent
					faith = root.location.faith
					culture = root.location.culture
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					age = { 8 12 }
					has_trait = diligent
					faith = root.location.faith
					culture = root.location.culture
				}
				save_scope_as = peasant_character_child				
			}
		} 
		else = {
			create_character = {
				template = peasant_child_character
				age = { 8 12 }
				trait = diligent
				faith = root.location.faith
				culture = root.location.culture
				location = root.location

				save_scope_as = peasant_character_child
			}
		}
		scope:peasant_character_child = {
			remove_character_flag ?= peasant_outfit
		}
	}
	#Send men to clear the rubble
	option = {
		name = tgp_travel_danger_events.0001.a
		current_travel_plan = { 
			delay_travel_plan = { days = 10 }
		}
		if = {
			limit = {
				government_allows = merit
			}
			change_merit = medium_merit_gain
		}	
		else = {
			add_prestige = medium_prestige_gain
		}
       stress_impact = {
       		impatient = medium_stress_impact_gain
       		compassionate = medium_stress_impact_loss
       }
       scope:peasant_character_child = {
       		if = {
       			limit = {
       				is_pool_character = no
				} 
				silent_disappearance_ai_effect = yes
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_vengefulness = -1
			}
			modifier = {
				factor = 0
				has_trait = impatient
			}			
		}
	}
	
	#Take the child on as a ward
	option = {
		name = tgp_travel_danger_events.0001.b
		trigger = {
			num_of_relation_ward < 2
		}
		show_as_tooltip = { add_courtier = scope:peasant_character_child }
		hidden_effect = {
			scope:peasant_character_child = {
				add_to_court_and_entourage_effect = yes
			}
		}
		scope:peasant_character_child = { set_relation_guardian = root }

		if = {
			limit = {
				root.current_travel_plan = {
					any_entourage_character = { has_trait = compassionate }
				}
			}
			root.current_travel_plan = {
				every_entourage_character = {
					custom = custom.every_compassionate_entourage_character
					limit = { has_trait = compassionate }
					add_opinion = {
						target = root
						modifier = impressed_by_kindness
						opinion = 15
					}
				}	
			}			
		}
        if = {
            limit = { faith = { trait_is_virtue = compassionate } }
            add_piety = medium_piety_gain
        }		
		stress_impact = {
			callous = major_stress_impact_gain
       		sadistic = major_stress_impact_gain
       		compassionate = major_stress_impact_loss
       	}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_vengefulness = -1
			}				
			modifier = {
				factor = 5
				has_trait = compassionate
			}
			modifier = {
				factor = 5
				OR = {
					has_trait = wrathful
					has_trait = callous
					has_trait = sadistic
				}			
			}
		}
	}
	#Ignore the child
	option = {
		name = tgp_travel_danger_events.0001.c

		current_travel_plan ?= {
			add_destination_progress = { days = 5 }
		}
		
		scope:peasant_character_child = {
			if = {
				limit = {
					is_pool_character = no
				} 
				silent_disappearance_ai_effect = yes
			}
		}
		stress_impact = {
       		compassionate = major_stress_impact_gain
       		impatient = major_stress_impact_loss
       	}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
				ai_vengefulness = 1
			}			
			modifier = {
				factor = 0
				has_trait = compassionate
			}
		}       	
	}
}

