namespace = mpo_nomads_season_events

mpo_nomads_season_events.0001 = { # Riding the Storm
	type = character_event
	title = mpo_nomads_season_events.0001.t
	desc = mpo_nomads_season_events.0001.desc

	theme = nomads

	override_background = { reference = mpo_steppe_evening }

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = scheme
	}

	right_portrait = {
		character = scope:storm_chaser
		animation = marshal_random_weapon
	}

	lower_right_portrait = {
		character = scope:raid_target
	}

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_available = yes
		any_character_situation = {
		    any_situation_sub_region = {
		        sub_region_current_phase = situation_steppe_severe_drought_season
		        situation_sub_region_has_county = root.capital_county  
		    }
		}
		any_councillor = {
			is_kurultai_trigger = yes
			is_available = yes
		}
		any_neighboring_top_liege_realm_owner = {
			is_ai = yes
			NOR = {
				is_at_war_with = root
				is_allied_to = root
				has_truce = root
				has_relation_friend = root
				has_relation_best_friend = root
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = -0.5
			is_ai = yes
		}
	}

	immediate = {
		random_councillor = {
			limit = {
				is_kurultai_trigger = yes
				is_available = yes
			}
			save_scope_as = storm_chaser
		}
		random_neighboring_top_liege_realm_owner = {
			limit = {
				is_ai = yes
				NOR = {
					is_at_war_with = root
					is_allied_to = root
					has_truce = root
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			save_scope_as = raid_target
		}
		scope:raid_target = {
			capital_county = {
				save_scope_as = raid_county
			}
		}
	}

	option = { # Tomorrow, we ride!
		name = mpo_nomads_season_events.0001.a
		scope:raid_target = {
			pay_herd = {
				target = root
				value = scope:raid_target.domicile.medium_herd_value
			}
			add_opinion = {
				target = root
				modifier = stole_my_herd
			}
		}
		add_dread = medium_dread_gain
		if = {
			limit = {
				can_set_relation_rival_trigger = { CHARACTER = scope:raid_target }
			}
			progress_towards_rival_effect = {
				REASON = stole_my_herd
				CHARACTER = scope:raid_target
				OPINION = 0
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = lazy
					has_trait = content
					has_trait = just
				}
				add = -50
			}
			ai_value_modifier = {
				ai_honor = -1			
			}
		}
	}

	option = { # We must see to our own shelter.
		name = mpo_nomads_season_events.0001.b

		root.capital_county = {
			add_county_modifier = {
				modifier = mpo_storm_shelter_modifier
				years = 5
			}
		}

		stress_impact = {
			vengeful = medium_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = vengeful
 					has_trait = sadistic
				}
				add = -50
			}
			ai_value_modifier = {
				ai_honor = 1			
			}
		}
	}
}

mpo_nomads_season_events.0005 = { # Hungry vassal
	type = character_event
	title = mpo_nomads_season_events.0005.t
	desc = mpo_nomads_season_events.0005.desc

	theme = nomads

	override_background = { reference = mpo_tent_interior_mongol }

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = shame
	}

	right_portrait = {
		character = scope:hungry_neighbour
		animation = obsequious_bow
	}

	trigger = {
		government_has_flag = government_is_nomadic
		has_mpo_dlc_trigger = yes
		is_available = yes
		any_character_situation = {
			NOR = {
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_abundant_grazing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_sky_blessing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_warm_nights_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			}
		}
		any_vassal = {
			is_available_ai = yes
			NOT = {
				has_opinion_modifier = {
					modifier = obedience_opinion
					target = root
				}
			}
			domicile ?= {
				herd < minor_herd_value
			}
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				is_available_ai = yes
				NOT = {
					has_opinion_modifier = {
						modifier = obedience_opinion
						target = root
					}
				}
				domicile ?= {
					herd < minor_herd_value
				}			
			}
			save_scope_as = hungry_neighbour
		}		
	}

	option = { # Give herd
		name = mpo_nomads_season_events.0005.a

		pay_herd = {
			target = scope:hungry_neighbour
			value = domicile.minor_herd_value
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = mpo_demand_obedience_interaction_toast
			left_icon = scope:hungry_neighbour
			scope:hungry_neighbour = {
				add_opinion = {
					target = root
					modifier = obedience_opinion
				}
			}
		}
		scope:hungry_neighbour = {
			add_character_flag = given_herd
		}

		stress_impact = {
			compassionate = medium_stress_impact_loss
			paranoid = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					domicile ?= {
						herd < medium_herd_value
					}
					has_trait = paranoid
					has_trait = greedy
				}
			}
			modifier = {
				factor = 20
				has_trait = compassionate
			}
			ai_value_modifier = {
				ai_sociability = 1
				ai_greed = -1
			}
		}
	}

	option = { # Arrange trade
		name = mpo_nomads_season_events.0005.b
		trigger = {
			scope:hungry_neighbour = {
				gold > root.medium_gold_value
			}
		}
		pay_herd = {
			target = scope:hungry_neighbour
			value = domicile.minor_herd_value
		}
		scope:hungry_neighbour = {
			pay_short_term_gold = {
				target = root
				gold = root.medium_gold_value
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
			modifier = {
				factor = 0
				domicile ?= {
					herd < medium_herd_value
				}
			}
		}
	}

	option = { # I think not!
		name = mpo_nomads_season_events.0005.c
 		reverse_add_opinion = {
			target = scope:hungry_neighbour
 			modifier = insulted_opinion
 			opinion = -15
 		}
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_sociability = -1
				ai_greed = -1
			}
		}
	}
}

mpo_nomads_season_events.0010 = { # Your vassal offers herd during a season of bounty
	type = character_event
	title = mpo_nomads_season_events.0010.t
	desc = {
		desc = mpo_nomads_season_events.0010.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rich_neighbour = { has_character_flag = given_herd }
				}
				desc = mpo_nomads_season_events.0010.desc_offered_herd
			}
			desc = mpo_nomads_season_events.0010.desc_fallback
		}
	}
	
	theme = nomads

	override_background = { reference = mpo_tent_interior_mongol }

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = cynical
			}
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = {
				scope:rich_neighbour = { has_character_flag = given_herd }
			}
			animation = flirtation
		}
		animation = personality_greedy
	}

	right_portrait = {
		character = scope:rich_neighbour
		triggered_animation = {
			trigger = {
				scope:rich_neighbour = { has_character_flag = given_herd }
			}
			animation = obsequious_bow
		}
		animation = steward
	}

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_available = yes
		any_character_situation = {
			OR = {
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_abundant_grazing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_sky_blessing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_warm_nights_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			}
		}
		any_vassal = {
			is_available_ai = yes
			trigger_if = {
				limit = {
					NOT = { has_character_flag = given_herd }
				}
				NOR = {
					is_councillor_of = root
					has_relation_blood_brother = root
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			domicile ?= {
				herd > minor_herd_value
			}
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				is_available_ai = yes
				trigger_if = {
					limit = {
						NOT = { has_character_flag = given_herd }
					}
					NOR = {
						is_councillor_of = root
						has_relation_blood_brother = root
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
				domicile ?= {
					herd > minor_herd_value
				}
			}
			save_scope_as = rich_neighbour
		}
	}

	option = { # Yes, I will buy herd from you.
		name = mpo_nomads_season_events.0010.a
		trigger = {
			NOT = {
				scope:rich_neighbour = {
					has_character_flag = given_herd
				}
			}
		}
		pay_short_term_gold = {
			target = scope:rich_neighbour
			gold = medium_gold_value
		}
		scope:rich_neighbour = {
			pay_herd = {
				target = root
				value = scope:rich_neighbour.domicile.minor_herd_value
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
			}
			modifier = {
				factor = 50
				domicile ?= {
					herd < minor_herd_value
				}
			}
            modifier = {
                gold <= major_gold_value
                factor = 0
            }
		}
	}

	option = { # Forget the herd, I want you as my bro!
		name = mpo_nomads_season_events.0010.c
		trigger = {
			scope:rich_neighbour = {
				has_character_flag = given_herd
			}
			can_set_relation_blood_brother_trigger = { CHARACTER = scope:rich_neighbour }
		}
		add_internal_flag = special
		reason = gave_herd

		set_relation_blood_brother = {
			reason = sworn_blood_brother
			target = scope:rich_neighbour
		}

		stress_impact = {
			paranoid = medium_stress_impact_gain
			gregarious = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {
				factor = 0
				has_trait = paranoid
			}
			modifier = {
				add = 50
				has_trait = gregarious
			}
		}
	}

	option = { # Free herd? Yes please!
		name = mpo_nomads_season_events.0010.b
		trigger = {
			scope:rich_neighbour = {
				has_character_flag = given_herd
			}
		}
		scope:rich_neighbour = {
			pay_herd = {
				target = root
				value = scope:rich_neighbour.domicile.medium_herd_value 
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}

	option = { # Give me your herd, or your head!
		name = mpo_nomads_season_events.0010.d
		trigger = {
			NOT = {
				scope:rich_neighbour = {
					has_character_flag = given_herd
				}
			}
			is_ai = no
		}
        duel = {
            skill = prowess
            target = scope:rich_neighbour
            50 = {
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = 3.5
                    min = -49
                }
                min = 5
                desc = mpo_nomads_season_events.0010.d.tt.success
				scope:rich_neighbour = {
					pay_herd = {
						target = root
						value = scope:rich_neighbour.domicile.medium_herd_value
					}
					increase_wounds_effect = { REASON = fight }
				}
                send_interface_toast = {
                    title = mpo_nomads_season_events.0010.d.tt.success
                    left_icon = root
                    right_icon = scope:rich_neighbour
                    scope:rich_neighbour = {
						add_opinion = {
							target = root
							modifier = stole_my_herd
						}
                    }
                }
            }
            50 = {
                compare_modifier = {
                    value = scope:duel_value
                    multiplier = -3.5
                    min = -49
                }
                min = 5
                desc = mpo_nomads_season_events.0010.d.tt.failure
                add_prestige = minor_prestige_loss
                send_interface_toast = {
                    title = mpo_nomads_season_events.0010.d.tt.failure
                    left_icon = scope:rich_neighbour
                    reverse_add_opinion = {
                        target = scope:rich_neighbour
                        modifier = insult_opinion 
                        opinion = -25
                    }
                }
            }
        }
		if = {
			limit = {
				can_set_relation_rival_trigger = { CHARACTER = scope:rich_neighbour }
			}
			progress_towards_rival_effect = {
				REASON = stole_my_herd
				CHARACTER = scope:rich_neighbour
				OPINION = 0
			}
		}
        stress_impact = {
        	just = medium_stress_impact_gain
        }

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
			}
			modifier = {
				factor = 0
				has_trait = just
			}
			modifier = {
				factor = 50
				prowess > mediocre_skill_rating
			}
		}
	}
	option = { # I have no need to trade.
		name = mpo_nomads_season_events.0010.e
		trigger = {
			NOT = {
				scope:rich_neighbour = {
					has_character_flag = given_herd
				}
			}
		}
 		reverse_add_opinion = {
			target = scope:rich_neighbour
 			modifier = insulted_opinion
 			opinion = -15
 		} 		
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}
	after = {
		scope:rich_neighbour = {
			if = {
				limit = {
					has_character_flag = given_herd
				}
				remove_character_flag = given_herd
			}
		}
	}
}

mpo_nomads_season_events.0015 = { # Two Kurultai members fight over food
	type = character_event
	title = mpo_nomads_season_events.0015.t
	desc = mpo_nomads_season_events.0015.desc

	theme = nomads

	override_background = { reference = mpo_campfire_steppe }

	cooldown = { years = 10 }

	left_portrait = {
		character = scope:kurultai_1
		animation = war_attacker
	}

	right_portrait = {
		character = scope:kurultai_2
		animation = aggressive_unarmed
	}

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_available = yes
		any_character_situation = {
			NOR = {
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_abundant_grazing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_sky_blessing_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			    any_situation_sub_region = {
			    	sub_region_current_phase = situation_steppe_warm_nights_season
			        situation_sub_region_has_county = root.capital_county  
			    }
			}
		}
		OR = {
			domicile ?= {
				herd <= minor_herd_value
			}
		}
		any_councillor = {
			count >= 2
			is_kurultai_trigger = yes
			is_available_ai = yes
			NOT = { is_spouse_of = root }
		}
	}

	immediate = {
		random_councillor = {
			limit = {
				is_kurultai_trigger = yes
				is_available_ai = yes
				NOT = { is_spouse_of = root }
			}
			save_scope_as = kurultai_1
		}
		random_councillor = {
			limit = {
				is_kurultai_trigger = yes
				is_available_ai = yes
				NOT = {
					this = scope:kurultai_1
					is_spouse_of = root
				}
			}
			save_scope_as = kurultai_2
		}
	}

	option = { # Do not cry over spilled kumis.
		name = mpo_nomads_season_events.0015.a
 		reverse_add_opinion = {
			target = scope:kurultai_1
 			modifier = grateful_opinion
 			opinion = 30
 		}
 		add_prestige = minor_prestige_loss
 		stress_impact = {
 			calm = medium_stress_impact_loss
 			wrathful = medium_stress_impact_gain
 		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 20
				has_trait = calm
			}
			modifier = {
				factor = 0
				has_trait = wrathful
			}
		}
	}

	option = { # Go on, fight! Entertain the rest of us.
		name = mpo_nomads_season_events.0015.b
 		reverse_add_opinion = {
			target = scope:kurultai_2
 			modifier = grateful_opinion
 			opinion = 30
 		}
 		scope:kurultai_2 = {
	        duel = {
	            skill = prowess
	            target = scope:kurultai_1
	            50 = {
	                compare_modifier = {
	                    value = scope:duel_value
	                    multiplier = 3.5
	                    min = -49
	                }
	                min = 5
	                desc = mpo_nomads_season_events.0015.b.tt.success
	                scope:kurultai_1 = {
	                	add_trait = wounded_1
	                }
	                send_interface_toast = {
	                    title = mpo_nomads_season_events.0015.b.tt.success
	                    left_icon = scope:kurultai_1
	                }
	            }
	            50 = {
	                compare_modifier = {
	                    value = scope:duel_value
	                    multiplier = -3.5
	                    min = -49
	                }
	                min = 5
	                desc = mpo_nomads_season_events.0015.b.tt.failure
	                scope:kurultai_2 = {
	                	add_trait = wounded_1
	                }
	                send_interface_toast = {
	                    title = mpo_nomads_season_events.0015.b.tt.failure
	                    left_icon = scope:kurultai_2
	                }
	            }
	        }
 		}

 		stress_impact = {
 			wrathful = medium_stress_impact_loss
 			calm = medium_stress_impact_gain
 		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 20
				has_trait = wrathful
			}
			modifier = {
				factor = 0
				has_trait = calm
			}
		}
	}

	option = { # Let it go, both of you.
		name = mpo_nomads_season_events.0015.c
        reverse_add_opinion = {
            target = scope:kurultai_1
            modifier = disappointed_opinion
            opinion = -15
        }
        reverse_add_opinion = {
            target = scope:kurultai_2
            modifier = disappointed_opinion
            opinion = -15
        }
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1			
			}
		}
	}
}
