##########################################
# Rise of the Ghaznavids under Shinji
##########################################

#edited for wakame

# Shinji distinguishes himself at a probably norse court
character_event = {
	id = 999110 #starting at 110, and onward. illya ended at 107
	desc = EVTDESC60400 #leaving descriptions because only ai should see them 90% of the time
	
	picture = GFX_evt_mongols
	border = GFX_event_normal_frame_war
	
	only_playable = yes
	
	trigger = {
		
		higher_tier_than = count
		
		NOT = { has_global_flag = shinji_spawned }
		
		OR = {
			290 = { # uppland cap of sweden
				owner = {
					same_realm = ROOT
				}
			}
			272 = { # vingulsmark cap of norway
				owner = {
					same_realm = ROOT
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
	
		create_character = {
			random_traits = no
			name = "Shinji"
			dynasty = 999155 ###makiri
			religion = pagan
			culture = japanese
			female = no
			age = 18
			attributes = {
				martial = 30
				diplomacy = 16
				stewardship = 22
				intrigue = 70
				learning = 33
			}
			health = 6
			fertility = 1
			trait = elusive_shadow
			trait = shinjitrait
			trait = fair
			trait = strong
			trait = genius
			trait = adventurer
			trait = proud
			trait = lustful
			trait = envious
			trait = wroth
			trait = greedy
		}
		
		new_character = {
			set_character_flag = shinji_himself
			character_event = {
				id = 999111
				days = 7
				random = 1
			}
			add_claim = k_denmark
			add_claim = k_norway
			add_claim = k_scotland
			add_claim = d_saxony
			add_claim = d_holland
			add_claim = d_flanders
			add_artifact = holy_grail
			add_artifact = sword_of_heroes_2
			add_artifact = emerald_scepter_2
			add_artifact = crown_of_majesty_2
			add_artifact = ruby_bracelets_2
			add_artifact = dagger_of_glory_2
			add_artifact = celestial_necklace_2
			add_artifact = lance_tier_4_impaler
			add_artifact = scimitar_tier_4_golden
			add_artifact = mace_tier_4_shatterer
			add_artifact = bow_tier_4_silent_wind
			add_artifact = armor_tier_4_warden
			add_artifact = silk_shroud
			add_artifact = art_of_war
			add_artifact = the_bestiary
			add_artifact = random_world_mythological_heart_1
			add_artifact = antiquity_book_play
			add_artifact = magnificent_painting
			add_artifact = jade_dragon
			add_artifact = water_clock
			add_artifact = hermetic_compass
		}
		
	}
	
	option = { # A most capable young man
		name = EVTOPTA60300
		
		set_global_flag = shinji_spawned
		set_global_flag = shinji_spawned_by_event
		
		tooltip = {
			create_character = {
				random_traits = no
				name = "Shinji"
				dynasty = 790
				religion = ROOT
				culture = ROOT
				female = no
				age = 18
				attributes = {
					martial = 12
					diplomacy = 8
					stewardship = 9
					intrigue = 9
					learning = 6
				}
				health = 6
				fertility = 0.8
				trait = brilliant_strategist
				trait = diligent
				trait = ambitious
				trait = proud
				trait = quick
			}
		}
	}
}

# Shinji and his men consider starting an adventure
character_event = {
	id = 999111
	desc = EVTDESC60201
	
	picture = GFX_evt_mongols
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	prisoner = no
	only_capable = yes
	
	trigger = {
		is_alive = yes
		NOT = { trait = blinded }
		NOT = { trait = eunuch }
		NOT = { trait = infirm }
		lower_tier_than = king
		
		OR = {
			84 = { # friesland
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
			1683 = { # varde part of jylland
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
		}
	}
	
	option = { # friesland it is!
		name = EVTOPTA60401
		trigger = {
			84 = { # friesland
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
		}
		
		ai_chance = {
			factor = 100
		}
		
		84 = {
			province_event = {
				id = 999112
				days = 2
			}
		}
	}
	option = { # jylland
		name = EVTOPTB60401
		trigger = {
			1683 = { # jylland
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
		}
		
		ai_chance = {
			factor = 10000
		}
		
		1683 = {
			province_event = {
				id = 999112
				days = 2
			}
		}
	}
}

# Ping the target province
province_event = {
	id = 999112
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				FROM = {
					is_ruler = yes
				}
			}
			FROM = {
				character_event = {
					id = 999114
				}
			}
		}
		if = {
			limit = {
				FROM = {
					is_ruler = no
				}
			}
			FROM = {
				character_event = {
					id = 999113
				}
				character_event = {
					id = 999117 ###added to make a really big event for everyone so they will know fear
				}
			}
		}
	}
}

# The landless Shinji and his men start an adventure
character_event = {
	id = 999113
	hide_window = yes
	
	is_triggered_only = yes
	
	prisoner = no
	only_capable = yes
	
	trigger = {
		is_alive = yes
		NOT = { trait = blinded }
		NOT = { trait = eunuch }
		NOT = { trait = infirm }
		lower_tier_than = king
	}
	
	immediate = {
		wealth = 500
		
		any_liege = {
			character_event = {
				id = 999115
				days = 1
			}
		}
		
		liege = {
			capital_scope = {
				FROM = {
					owner = {
						top_liege = {
							ROOT = {
								set_defacto_liege = ROOT
								create_title = {
									tier = DUKE
									landless = yes
									temporary = yes
									culture = ROOT
									name = "CLAIMANT_ADVENTURE"
									holder = ROOT
								}
								
								set_character_flag = duchy_adventurer
							
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									#leader = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
								spawn_unit = {
									province = PREVPREVPREVPREV
									home = PREVPREVPREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 2
									match_min = 2000
									match_max = 20000
									attrition = 0
								}
			FROM = {
				sea_zone = {
					ROOT = {
						spawn_unit = {
							province = PREV
							home = FROM
							owner = ROOT
							troops =
							{
								galleys = { 1000 1000 }
							}
						}
					}
				}
			}
								war = {
									target = PREV
									casus_belli = duchy_adventure
									thirdparty_title = PREVPREVPREV
									tier = DUKE
								}
							}
						}
					}
				}
			}
		}
		
		# Create some characters
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 28
			attributes = {
				martial = 24
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 24
			attributes = {
				martial = 28
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 23
			attributes = {
				martial = 22
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
			attributes = {
				martial = 26
			}
			trait = brilliant_strategist
		}
		
		create_character = {
			random_traits = no
			name = "Sakura"
			dynasty = 999155 ###makiri
			religion = catholic
			culture = japanese
			female = yes
			age = 16
			attributes = {
				martial = 0
				diplomacy = 5
				stewardship = 12
				intrigue = 2
				learning = 11
			}
			trait = fortune_builder
			trait = sakuratrait
			trait = fair
			trait = lustful
			trait = diligent
			trait = humble
			trait = shy
			trait = depressed
			trait = possessed
			trait = cannibal_trait
		}
		
		new_character = {
			move_character = k_bohemia ###in 1066 this would be rin but if its not then w/e thats not game breaking
			imprison = ROOT
			add_friend = d_franconia ##and this would be shirou
			set_father = 999130
			add_rival = ROOT
		}
		
		
		c_999128 = {
				set_father = 999130
			}
		
		log = "999113: Shinji starts his first war (landless)!"
	}
}

# The landed Shinji and his men start an adventure THIS IS UNEDITED FOR MOD AND WONT WORK VERY WELL SO DONT LAND HIM
character_event = {
	id = 999114
	desc = EVTDESC60304
	
	picture = GFX_evt_mongols
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	prisoner = no
	only_capable = yes
	
	trigger = {
		is_alive = yes
		NOT = { trait = blinded }
		NOT = { trait = eunuch }
		NOT = { trait = infirm }
		lower_tier_than = king
	}
	
	immediate = {
		if = {
			limit = {
				tier = BARON
			}
			abdicate = yes
			character_event = { id = 999113 }
			break = yes
		}
		wealth = 500
		
		any_liege = {
			character_event = {
				id = 60405
				days = 1
			}
		}
		
		FROM = {
			owner = {
				top_liege = {
					ROOT = {
						capital_scope = {
							ROOT = {
								set_character_flag = duchy_adventurer
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									#leader = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
								spawn_unit = {
									province = PREV
									home = PREV
									owner = THIS
									match_character = PREVPREVPREV
									match_mult = 0.33
									match_min = 500
									match_max = 10000
									attrition = 0.25
								}
							}
						}
						
						war = {
							target = PREV
							casus_belli = duchy_adventure
							thirdparty_title = PREVPREVPREV
							tier = DUKE
						}
					}
				}
			}
		}
		
		# Create some characters
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 28
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 24
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 23
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = yes
			age = 16
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = yes
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = yes
			age = 18
		}
		
		log = "60404: Shinji starts his first war (landed)!"
	}
	
	option = {
		name = EVTOPTA60204
	}
}

# Notify Shinji's old liege
character_event = {
	id = 999115
	desc = EVTDESC60205
	picture = GFX_evt_mongols
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	trigger = {
		FROM = { is_ruler = yes } # The DoW worked and the adventurer has a temporary title
	}
	
	option = {
		name = EVTOPTA60305
	}
}

# Shinji is successful!
# Fired from the duchy_adventure CB
narrative_event = {
	id = 999116
	title = EVTNAME60406
	desc = EVTDESC60406
	picture = GFX_evt_mongols
	border = GFX_event_narrative_frame_war
	
	is_triggered_only = yes
	
	major = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					independent = yes
					liege = {
						ai = yes
					}
				}
			}
			set_defacto_liege = ROOT
		}
		
		prestige = 1000
		
		if = {
			limit = {
				uses_decadence = yes
			}
			decadence = -25
		}
		
		capital_scope = {
			religion = ROOT
			culture = ROOT
			
			ROOT = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 2250 2250 }
						light_cavalry = { 2000 2000 }
						horse_archers = { 1500 1500 }
						knights = { 50 50 }
					}
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 2250 2250 }
						light_cavalry = { 2000 2000 }
						horse_archers = { 1500 1500 }
						knights = { 50 50 }
					}
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 2250 2250 }
						light_cavalry = { 2000 2000 }
						horse_archers = { 1500 1500 }
						knights = { 50 50 }
					}
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 2250 2250 }
						light_cavalry = { 2000 2000 }
						horse_archers = { 1500 1500 }
						knights = { 50 50 }
					}
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 2250 2250 }
						light_cavalry = { 2000 2000 }
						horse_archers = { 1500 1500 }
						knights = { 50 50 }
					}
				}
				
				random = {
					chance = 50
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						troops = {
							light_infantry = { 2250 2250 }
							light_cavalry = { 2000 2000 }
							horse_archers = { 1500 1500 }
							knights = { 50 50 }
						}
					}
				}
				random = {
					chance = 50
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						troops = {
							light_infantry = { 2250 2250 }
							light_cavalry = { 2000 2000 }
							horse_archers = { 1500 1500 }
							knights = { 50 50 }
						}
					}
				}
				random = {
					chance = 100
					spawn_unit = {
						province = PREV
						home = PREV
						owner = THIS
						troops = {
							light_infantry = { 2250 2250 }
							light_cavalry = { 2000 2000 }
							horse_archers = { 1500 1500 }
							knights = { 6000 6000 }
						}
					}
				}
			}
		}
		
		random_realm_province = {
			limit = {
				OR = {
					NOT = { culture = ROOT }
					NOT = { religion = ROOT }
				}
			}
			religion = ROOT
			culture = ROOT
		}
		
		log = "60406: Shinji wins his first war!"
	}
	
	option = {
		name = EVTOPTA60406
		trigger = {
			has_character_flag = shinji_himself
		}
	}
	option = {
		name = EVTOPTB60406
		trigger = {
			NOT = { has_character_flag = shinji_himself }
		}
	}
}



narrative_event = {
	id = 999117 ##edited version of hashshashin popup
	title = "SHINJI01"
	picture = GFX_evt_merchant_ship_at_sea_republic

	desc = {
		text = SHINJI02
	}

	major = yes
	
	hide_from = no
	
	is_triggered_only = yes
	

	option = {
		name = {
			text = SHINJI03
		}
	}
}