#########################################################
#
# Landless Character Adventures for The Old Gods DLC
# ( TOG.1200 to TOG.1499)
#
#
#########################################################

# Written by Henrik Fhraeus

namespace = RLO



# An ambitious character with no inheritance begins to plan an adventure for a foreign title: Rollo
character_event = {
	id = RLO.1
	
	only_independent = yes
	is_triggered_only = yes
	hide_window = yes
	
	trigger = {
		NOT = {year = 900}
		year = 888
		NOT = {has_global_flag = normandie_attack}
		culture = norse
		OR = {
			religion = norse_pagan
			religion = norse_pagan_reformed
		}
		ai =yes
	}
	immediate = {
		set_global_flag = normandie_attack
		create_character = {
			name="Hrolfr" # Hrolf Gange - founder of Normandy
			dynasty=752
			age = 43
			dna = gzsspmswdty
			properties = eb0dcd00000000
			attributes = {
				martial=7
				diplomacy=6
				intrigue=8
				stewardship=7
				learning=5
			}
			random_traits = no
			religion=norse_pagan
			culture=norse
			trait=lustful
			trait=proud
			trait=strong
			trait=brave
			trait=brilliant_strategist
		}
		new_character = {
			add_trait = ambitious
			add_trait = ulfberht5
			add_trait = combat_exp
			add_trait = robust
			add_trait = stubborn
			set_character_flag = wpn
			set_character_flag = h_cmd
			set_character_flag = is_rollo
			fertility = -100.0
			health = 2
			
			character_event = {id = RLO.999 days = 3670} #Viking settlement revolt
			character_event = {id = RLO.5000 days = 165 random = 100} #Marriage
		}
	}
}


character_event = {
	id = RLO.1000
	
	is_triggered_only = yes
	hide_window = yes
	
	trigger = {
		NOT = {year = 869}
		character = 242
		NOT = {has_global_flag = normandie_attack}
	}
	immediate = {
		add_trait = ambitious
		set_character_flag = is_rollo
		fertility = -100.0
		health = 2
		set_global_flag = normandie_attack
		character_event = {id = RLO.999 days = 11700} #Viking settlement revolt
		character_event = {id = RLO.5000 days = 8030} #Marriage
	}
}

character_event = { #889
	id = RLO.5000
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		fertility = 100.0
		create_character = {
			name="Papia"
			female=yes
			dynasty=100097
			age = 19
			martial=7
			diplomacy=7
			intrigue=5
			stewardship=7
			religion="chalcedonian"
			culture="frankish"
			trait = "scholarly_theologian"
			trait = kind
			trait = chaste
			trait = content
			trait = humble
		}
		new_character = {
			health = 1
			set_character_flag = pap
			add_spouse = ROOT
			opinion = {
				modifier = opinion_forced_consort
				who = ROOT
				months = 12
			}
			character_event = {id = RLO.5001 days = 1460}
		}
	}
}


character_event = { #891 William
	id = RLO.5001
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		if = {
			limit = {
				is_pregnant = no
				FROM = {is_alive = yes}
			}
			impregnate = FROM
		}
	}
}

character_event = { #William birth
	id = RLO.5002
	
	is_triggered_only = yes
	hide_window = yes
	
	trigger = {
		father = {has_character_flag = is_rollo}
		is_female = no
		mother = {has_character_flag = pap}
		NOT = {has_global_flag = will_born}
	}
	
	immediate = {
		set_global_flag = will_born
		set_character_flag = will
		add_trait = harelip
		cure_illness = yes
		health = 0.5
		character_event = {id = RLO.5003 days = 1825} #at 5 becomes the longsword
	}
}

character_event = { #William the naive_appeaser -> underhanded rogue
	id = RLO.5003
	desc = RLO5003
	picture = "GFX_evt_child_play"
	
	is_triggered_only = yes

	option = {
		add_trait = naive_appeaser
		add_trait = swordsman1
		set_character_flag = wpn
		give_nickname = nick_the_longsword
		if = {
			limit = {
				religion_group = christian
				has_character_flag = will
			}
			set_name = "William"
		}
		hidden_tooltip = {
			add_character_modifier = {
				name = gedu
				duration = 4500
				hidden = yes
			}
		}
		father = {
			character_event = {id = RLO.5004 days = 1}
		}
		name = RLO5003A
	}
}

character_event = { #William the underhanded rogue
	id = RLO.5004
	desc = RLO5004
	picture = "GFX_evt_child_play"
	
	is_triggered_only = yes

	option = {
		tooltip = {
			FROM = {
				add_trait = underhanded_rogue
				add_trait = swordsman1
				set_character_flag = wpn
				give_nickname = nick_the_longsword
			}
		}
		name = RLO5004A
	}
}


character_event = {
	id = RLO.999
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		if = {
			limit = {
				NOT = {
					any_independent_ruler = {

						NOT = {
							culture = breton
							culture = norman
							culture = norse
						}
						in_revolt = no
						higher_tier_than = COUNT
						any_realm_province = {
							duchy = {
								title = d_normandy
							}
						}
					}
				}
			}
			character_event = {id = RLO.999 days = 60}
			break = yes
		}
		character_event = {id = RLO.1210 days = 1}
	}
}

character_event = {
	id = RLO.1210
	
	hide_window = yes # Only fires for unplayable landless characters
	
	is_triggered_only = yes
	
	trigger = {
		is_landed = no
		NOT = { has_character_modifier = planning_duchy_adventure }
	}
	
	immediate = {
		if = {
			limit = { prisoner = yes }
			imprison = no
		}
		random_independent_ruler = {
			limit = {
				#NOT = { is_vassal_or_below = ROOT }
				

				NOT = {
					culture = breton
					culture = norman
					culture = norse
				}
				in_revolt = no
				higher_tier_than = COUNT
				any_realm_province = {
					duchy = {
						title = d_normandy
					}
				}
				
			}
			
			random_realm_province = {
				limit = {
					duchy = {
						title = d_normandy
					}
				}
				
				ROOT = {
					character_event = {
						id = RLO.1212 # Fire the attack
						days = 60
					}
					opinion = {
						who = PREVPREV
						months = 4
						modifier = opinion_duchy_adventure_target
					}
					reverse_opinion = {
						who = PREVPREV
						months = 4
						modifier = rsp
					}
					add_character_modifier = {
						name = planning_duchy_adventure
						hidden = yes
						duration = 90
					}
					
				}
				PREV = {
					character_event = {
						id = TOG.1211 # Warn the target
					}
				}
			}
		}
		if = {
			limit = { trait = in_hiding	}
			remove_trait = in_hiding
			add_character_modifier = {
				name = went_out_of_hiding_timer
				duration = 180
				hidden = yes
			}
			hidden_tooltip = { character_event = { id = CM.6400 } } # Notify plotters and family
		}
		character_event = { id = TOG.1215 days = 30 }
	}
	
	option = {
		name = OK
	}
}



# An ambitious character with no inheritance starts an adventure for a foreign title
# (Temporary title created and a war declared)
character_event = {
	id = RLO.1212
	
	hide_window = yes # Only fires for unplayable landless characters
	
	is_triggered_only = yes
	prisoner = no
	
	trigger = {
		is_landed = no
		
		NOT = { trait = incapable }
		
		religion = norse_pagan
		
		any_independent_ruler = {
			has_opinion_modifier = {
				who = ROOT
				modifier = rsp
			}
			any_realm_province = {
				duchy = {
					title = d_normandy
				}
			}
			
		 }
	}
	
	immediate = {
		wealth = 1000
		clr_character_flag = do_not_disturb
		
		liege = {
			character_event = {
				id = TOG.1213
				days = 1
			}
		}
		
		liege = {
			capital_scope = {
				random_independent_ruler = {
					limit = {
						has_opinion_modifier = {
							who = ROOT
							modifier = rsp
						}
						any_realm_province = {
							duchy = {
								title = d_normandy
							}
						}
						
					}
					random_realm_province = {
						limit = {
							duchy = {
								title = d_normandy
							}
						}
						
						ROOT = {
							set_defacto_liege = ROOT
							set_government_type = feudal_government
							create_title = {
								tier = DUKE
								landless = yes
								temporary = yes
								culture = ROOT
								name = "VIKING_CONQUEST"
								holder = ROOT
							}

							add_trait = seaking
							add_trait = wroth
							add_trait = berserker
							set_character_flag = duchy_adventurer
							any_child = {
								limit = {
									has_character_flag = will
								}
								set_guardian = ROOT
							}
							
							
							spawn_unit = {
								province = PREVPREVPREV
								
								owner = THIS
								leader = THIS
								match_character = PREVPREV
								match_mult = 2.0
								match_min = 10000
								match_max = 30000
								attrition = 0.25
								disband_on_peace = yes
							}
							
							# Create a fleet, just to be sure
							spawn_fleet = {
								province = 965 # closest sea zone
								owner = ROOT
								disband_on_peace = yes
								troops =
								{
									galleys = { 150 150 }
								}
							}
							
							
							
							spawn_unit = {
								province = PREVPREVPREV
								
								owner = THIS
								match_character = PREVPREV
								match_mult = 0.7
								match_min = 6000
								match_max = 10000
								attrition = 0.25
								disband_on_peace = yes
							}
							spawn_fleet = {
								province = 965 # closest sea zone
								owner = ROOT
								disband_on_peace = yes
								troops =
								{
									galleys = { 100 100 }
								}
							}
							
							spawn_unit = {
								province = PREVPREVPREV
								
								owner = THIS
								match_character = PREVPREV
								match_mult = 0.7
								match_min = 6000
								match_max = 10000
								attrition = 0.25
								disband_on_peace = yes
							}
							spawn_unit = {
								province = PREVPREVPREV
								
								owner = THIS
								match_character = PREVPREV
								match_mult = 0.7
								match_min = 2000
								match_max = 3000
								attrition = 0.25
								#disband_on_peace = yes
							}
							spawn_fleet = {
								province = 965 # closest sea zone
								owner = ROOT
								disband_on_peace = yes
								troops =
								{
									galleys = { 100 100 }
								}
							}
							add_character_modifier = { 
								name = launched_prepared_invasion
								hidden = yes
								days = -1 
							}
							war = {
								target = PREVPREV
								casus_belli = duchy_adventure
								thirdparty_title = PREV
								tier = DUKE
							}
							remove_opinion = {
								who = PREVPREV
								modifier = opinion_duchy_adventure_target
							}
							reverse_remove_opinion = {
								who = PREVPREV
								modifier = rsp
							}
						}
					}
				}
			}
		}
		
		# Create some decent commander characters
		create_character = {
			random_traits = no
			dynasty = none
			religion = ROOT
			culture = ROOT
			name = "Hooni"
			female = no
			age = 28
			trait = underhanded_rogue
			trait = cruel
			trait = honest
			trait = just
			trait = slothful
		}
		new_character = {
			add_trait = combat_exp
			add_trait = axe4
			set_character_flag = wpn
			add_trait = ravager
			add_trait = genius #This is given
			add_trait = ambitious #I am!
			add_trait = born_lowborn
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
		}
		new_character = {
			add_trait = combat_exp
			add_trait = spear3
			set_character_flag = wpn
			add_trait = viking
			add_trait = ambitious
			add_trait = born_lowborn
		}
		
		
		
	}
	
	option = {
		name = OK
	}
}


character_event = {
	id = RLO.2000
	
	hide_window = yes
	
	only_independent = yes
	
	trigger = {
		NOT = {year = 1030} #Let it go if it is too far in the future
		is_female = no
		prisoner = no
		dynasty = 752
		num_of_count_titles = 1
		lower_tier_than = KING
		OR = {
			culture = norse
			culture = norman
		}
		NOT = {trait = incapable}
		OR = {
			any_war = {
				defender = {
					character = ROOT
				}
				attacker = {
					top_liege = {
						higher_tier_than = ROOT
					}
				}
				war_score = 25
			}
			any_war = {
				attacker = {
					character = ROOT
				}
				defender = {
					top_liege = {
						higher_tier_than = ROOT
					}
				}
				NOT = {war_score = -40}
			}
		}
		NOT = {has_character_flag = rcvt}
	}
	
	mean_time_to_happen = {
		days = 20
	}
	
	immediate = {
		set_character_flag = rcvt
		
		
		any_war = {
			limit = {
				defender = {
					character = ROOT
				}
				attacker = {
					top_liege = {
						higher_tier_than = ROOT
						NOT = {any_demesne_title = {temporary = yes}}
					}
				}
				war_score = 25
			}
			
			attacker = {
				top_liege = {
					character_event = {id = RLO.2001 days = 1}
					break = yes
				}
			}
		}
		
		
		any_war = {
			limit = {
				attacker = {
					character = ROOT
				}
				defender = {
					top_liege = {
						higher_tier_than = ROOT
						NOT = {any_demesne_title = {temporary = yes}}
					}
				}
				NOT = {war_score = -40}
			}
			
			defender = {
				top_liege = {
					character_event = {id = RLO.2001 days = 1}
					break = yes
				}
			}
		}
	}

}

narrative_event = {
	id = RLO.2001
	desc = RLO2001
	title = RLO2001T
	picture = GFX_evt_knight_kneeling
	border = GFX_event_narrative_frame_diplomacy

	is_triggered_only = yes
	
	option = {
		ai_chance = {
			factor = 100
		}
		name = RLO2001A #Only if you kiss my foot
		prestige = 100
		piety = 100
		FROM = {
			any_courtier = {
				limit = {
					dynasty = FROM
					NOT = {character = FROM}
					NOT = {religion = ROOT}
				}
				religion = ROOT
				
			}
			if = {
				limit = {ROOT = {religion_group = christian}}
				any_courtier = {
					limit = {
						has_character_flag = will
					}
					set_name = "William"

				}
			}
		}
		
		FROM = {religion = ROOT}
		
		if = {
			limit = {
				religion_group = christian
				FROM = {has_character_flag = is_rollo}
			}
			FROM = {set_name = "Robert"}
		}
		
		if = {
			limit = {
				FROM = {has_character_flag = is_rollo}
			}
			FROM = {give_nickname = nick_viking_rollo}
		}
		FROM = {
			set_defacto_liege = ROOT
		}
		
		reverse_opinion = {
			modifier = swn
			who = FROM
			months = 1200
		}
		
		hidden_tooltip = {
			opinion = {
				modifier = flpd
				who = FROM
				months = 1200
			}
		}
	}
	
	option = {
		ai_chance = {
			factor = 0
		}
		piety = -25
		name = RLO2001B #FAT CHANCE!
	}

}

