namespace = byzsla_slavic_event_swiatowid

############################
# Testy konia (do Arkony)
#####
# byzsla_slavic_event_swiatowid.1 - start
# byzsla_slavic_event_swiatowid.2 - koń przeszedł pomyślnie
# byzsla_slavic_event_swiatowid.3 - koń się potknął
# byzsla_slavic_event_swiatowid.4 - włócznia została naruszona
# byzsla_slavic_event_swiatowid.5 - ochotnicy do wojny
#####
# Piractwo pomorskie
#####
# byzsla_slavic_event_swiatowid.6 - piractwo (oferta)
# byzsla_slavic_event_swiatowid.7 - piractwo (frajer)
# byzsla_slavic_event_swiatowid.8 - piractwo (zyski)
# byzsla_slavic_event_swiatowid.9 - piractwo (zostajesz oszukany)
# byzsla_slavic_event_swiatowid.10 - dostajesz chaśnika do pomocy
# byzsla_slavic_event_swiatowid.11 - dzikie osadnictwo u frajera
# byzsla_slavic_event_swiatowid.12 - konflikt między piratami, kupcami a rzemieślnikami (miastowy)
# byzsla_slavic_event_swiatowid.13 - konflikt między piratami, kupcami a rzemieślnikami (senior)
############################

character_event = {
	id = byzsla_slavic_event_swiatowid.1
	desc = desc_byzsla_slavic_event_swiatowid.1
	
	picture = GFX_evt_balwan
	is_triggered_only = yes
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.1
		custom_tooltip = {
			text = byzsla_slavic_event_swiatowid.1_TT
		}
		hidden_tooltip = {
			random_list = {
				70 = { 
					character_event = {
						id = byzsla_slavic_event_swiatowid.2
						days = 4
					}
				}
				20 = { 
					character_event = {
						id = byzsla_slavic_event_swiatowid.3
						days = 4
					}
				}
				10 = { 
					character_event = {
						id = byzsla_slavic_event_swiatowid.4
						days = 4
					}
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.2 - koń przeszedł pomyślnie
character_event = {
	id = byzsla_slavic_event_swiatowid.2
	desc = desc_byzsla_slavic_event_swiatowid.2
	
	picture = GFX_evt_balwan
	is_triggered_only = yes
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.2
		add_character_modifier = {
			name = byzsla_swiatowid_1
			duration = 365
		}
		piety = 10
		hidden_tooltip = {
			random = {
				chance = 70 
				character_event = {
					id = byzsla_slavic_event_swiatowid.5
					days = 50
				}
			}
		}
	}
}
# byzsla_slavic_event_swiatowid.3 - koń się potknął
character_event = {
	id = byzsla_slavic_event_swiatowid.3
	desc = desc_byzsla_slavic_event_swiatowid.3
	
	picture = GFX_evt_balwan
	is_triggered_only = yes
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.3
		add_character_modifier = {
			name = byzsla_swiatowid_2
			duration = 365
		}
		piety = -10
		hidden_tooltip = {
			random = {
				chance = 10 
				character_event = {
					id = byzsla_slavic_event_swiatowid.5
					days = 50
				}
			}
		}
	}
}
# byzsla_slavic_event_swiatowid.4 - włócznia została naruszona
character_event = {
	id = byzsla_slavic_event_swiatowid.4
	desc = desc_byzsla_slavic_event_swiatowid.4
	
	picture = GFX_evt_balwan
	is_triggered_only = yes
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.4
		hidden_tooltip = {
			random = {
				chance = 20 
				character_event = {
					id = byzsla_slavic_event_swiatowid.5
					days = 50
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.5 - ochotnicy do wojny
character_event = {
	id = byzsla_slavic_event_swiatowid.5
	desc = desc_byzsla_slavic_event_swiatowid.5
	
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	hide_from = yes
	is_triggered_only = yes
	trigger = {
		is_slav_religion = yes
		OR = {
			is_primary_war_attacker = yes
			is_primary_war_defender = yes
		}
		owns = 304		#Arkona
		304 = { controlled_by = ROOT }
	}
	immediate = {
		character_event = { id = 20220 days = 365 random = 90 }
		304 = {
			ROOT = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					#leader = none
					match_character = THIS
					match_mult = 0.15
					match_min = 100
					match_max = 3000
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					#leader = none
					match_character = THIS
					match_mult = 0.15
					match_min = 100
					match_max = 3000
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					#leader = none
					troops = {
						archers = { 100 20 }
						light_infantry = { 300 100 }
						heavy_infantry = { 75 20 }
						light_cavalry = { 90 30 }
						pikemen = { 30 5 }
					}
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
			}
		}
	}
	option = {
		name = optA_byzsla_slavic_event_swiatowid.5
	}
}

# Piractwo pomorskie
#####
# byzsla_slavic_event_swiatowid.6 - piractwo (oferta)

character_event = {
	id = byzsla_slavic_event_swiatowid.6
	desc = desc_byzsla_slavic_event_swiatowid.6
	
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	is_triggered_only = yes
	
	
	min_age = 16
	capable_only = yes
	only_playable = yes
	prisoner = no
	religion_group = pagan_group
	trigger = {
		NOT = { has_character_flag = bspm_piraci_flaga }
		is_slav_religion = yes
		any_demesne_province = {
			port = yes
			is_slav_religion = yes
		}
		any_independent_ruler = {
			is_within_diplo_range = ROOT
			any_realm_province = {
				port = yes
				NOT = { has_province_modifier = marauding_pirates }
			}
		}
	}
	immediate = {
		random_independent_ruler = {
			limit = {
				is_within_diplo_range = ROOT
				any_realm_province = {
					port = yes
					NOT = { has_province_modifier = marauding_pirates }
				}
			}
			random_realm_province = {
				limit = {
					port = yes
					NOT = { has_province_modifier = marauding_pirates }
				}
			}
		}
		set_character_flag = bspm_piraci_flaga
	}
	option = {
		name = optB_byzsla_slavic_event_swiatowid.6
		prestige = 10
	}
	option = {
		name = optA_byzsla_slavic_event_swiatowid.6
		if = {
			limit = {
				is_tribal = yes
			}
			scaled_wealth = -0.4
		}
		if = {
			limit = {
				is_tribal = no
			}
			scaled_wealth = -0.5
		}
		custom_tooltip = {
			text = byzsla_slavic_event_swiatowid.6_TT
		}
		hidden_tooltip = {
			random_independent_ruler = {
				limit = {
					is_within_diplo_range = ROOT
					any_realm_province = {
						port = yes
						NOT = { has_province_modifier = marauding_pirates }
					}
				}
				random_realm_province = {
					limit = {
						port = yes
						NOT = { has_province_modifier = marauding_pirates }
					}
				}
				province_event = {
					id = byzsla_slavic_event_swiatowid.7
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.7 - piractwo (frajer)


character_event = {
	id = byzsla_slavic_event_swiatowid.7
	desc = desc_byzsla_slavic_event_swiatowid.7
	
	hide_from = yes
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	is_triggered_only = yes
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.7
		add_province_modifier = {
			name = marauding_pirates
			duration = -1
		}
		hidden_tooltip = {
			if = {
				limit = { has_dlc = "Reapers" }
				change_variable = { which = prosperity_value value = -50 }
			}
			random = {
				chance = 25
				province_event = {
					id = byzsla_slavic_event_swiatowid.11
					days = 1000
					random = 1000
				}
			}
			FROM = {
				capital_scope = {
					random_list = {
						60 = {
							province_event = { 
								id = byzsla_slavic_event_swiatowid.8
								days = 300
								random = 200
							}
						}
						40 = {
							province_event = { 
								id = byzsla_slavic_event_swiatowid.9
								days = 300
								random = 200
							}
						}
					}
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.8 - piractwo (zyski)

province_event = {
	id = byzsla_slavic_event_swiatowid.8
	desc = desc_byzsla_slavic_event_swiatowid.8
	
	hide_from = yes
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			remove_province_modifier = marauding_pirates
		}
		
	}
	option = {
		name = optA_byzsla_slavic_event_swiatowid.8
		owner = {
			if = {
				limit = { is_tribal = yes }
				scaled_wealth = 2
			}
			if = {
				limit = { is_tribal = no }
				scaled_wealth = 3
			}
			add_province_modifier = {
				name = loot_prosperity_boost
				duration = 1825
			}
			hidden_tooltip = {
				if = {
					limit = { has_dlc = "Reapers" }
					change_variable = { which = prosperity_value value = 12 }
				}
			}
			prestige = 150
			hidden_tooltip = {
				random = {
					chance = 45
					character_event = {
						id = byzsla_slavic_event_swiatowid.10
						days = 30
						random = 30
					}
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.9 - piractwo (zostajesz oszukany)


province_event = {
	id = byzsla_slavic_event_swiatowid.9
	desc = desc_byzsla_slavic_event_swiatowid.9
	
	hide_from = yes
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			remove_province_modifier = marauding_pirates
		}
		
	}
	option = {
		name = optA_byzsla_slavic_event_swiatowid.7
		owner = {
			prestige = -200
		}
	}
	option = {
		trigger = {
			society_member_of = neurowie
		}
		custom_tooltip = {
			text = neuri_czlonek_TT
		}
		name = optB_byzsla_slavic_event_swiatowid.9
		owner = {
			prestige = -50
			change_society_currency = -30
			if = {
				limit = { trait = cruel }
				random = {
					chance = 25
					add_trait = cruel
				}
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.10 - dostajesz chaśnika do pomocy


character_event = {
	id = byzsla_slavic_event_swiatowid.10
	desc = desc_byzsla_slavic_event_swiatowid.10
	
	hide_from = yes
	picture = GFX_evt_bitwa
	border = GFX_event_normal_frame_war
	is_triggered_only = yes
	
	only_playable = yes
	has_character_flag = bspm_piraci_flaga
	trigger = {
		NOT = {
			any_courtier = {
				trait = byzsla_slavic_chasnik
			}
		}
	}
	
	immediate = {
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
			attributes = {
				martial = 10
			}
		}
		new_character = {
			add_trait = byzsla_slavic_chasnik
			remove_trait = weak
			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull
			remove_trait = craven
			
			if = {
				limit = {
					trait = misguided_warrior
				}
				remove_trait = misguided_warrior
				add_trait = tough_soldier
			}
			
			remove_trait = mystic
			remove_trait = socializer
			remove_trait = gamer
			remove_trait = hedonist
			remove_trait = duelist
			remove_trait = hunter
			remove_trait = strategist
			remove_trait = administrator
			remove_trait = architect
			remove_trait = gardener
			remove_trait = schemer
			remove_trait = impaler
			remove_trait = seducer
			remove_trait = seductress
			remove_trait = theologian
			remove_trait = scholar
			save_event_target_as = chasnik_dworski
			random_list = { # Flavor Randomization
				15 = {
					change_martial = 2
				}
				10 = {
					add_trait = robust
				}
				10 = {
					add_trait = duelist
				}
				10 = {
					add_trait = hunter
				}
				5 = {
					add_trait = strategist
				}
				5 = {
					change_martial = 4
				}
				5 = {
					if = {
						limit = {
							has_dlc = "Reapers"
						}
						add_trait = one_eyed
						change_martial = 1
					}
				}
				5 = { 
					add_trait = shrewd
				}
			}
		}
	}
	option = {
		name = optA_byzsla_slavic_event_swiatowid.10
		event_target:chasnik_dworski = {
			add_friend = ROOT
		}
	}
	option = {
		name = optB_byzsla_slavic_event_swiatowid.10
		event_target:chasnik_dworski = {
			death = {
				death_reason = death_missing
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.11 - dzikie osadnictwo u frajera

province_event = {
	id = byzsla_slavic_event_swiatowid.11
	desc = desc_byzsla_slavic_event_swiatowid.11
	
	hide_from = yes
	picture = GFX_evt_slavic_tribal
	is_triggered_only = yes
	
	trigger = {
		owner = {
			is_tribal = yes
		}
	}
	
	option = {
		name = optA_byzsla_slavic_event_swiatowid.11
		owner = {
			prestige = -100
		}
		culture = pommeranian
		if = {
			limit = { has_global_flag = slavic_reformation }
			religion = chram_vales
		}
		if = {
			limit = { NOT = { has_global_flag = slavic_reformation } }
			religion = slavic_pagan
		}
		if = {
			limit = { has_dlc = "Reapers" }
			change_variable = { which = prosperity_value value = 35 }
		}
	}
	option = {
		name = optB_byzsla_slavic_event_swiatowid.11
		trigger = {
			owner = {
				religion_group = pagan_group
				NOT = {
					trait = zealous
					has_crusade_trait_trigger = yes
				}
			}
		}
		owner = {	
			culture = pommeranian
			if = {
				limit = { has_global_flag = slavic_reformation }
				religion = chram_vales
			}
			if = {
				limit = { NOT = { has_global_flag = slavic_reformation } }
				religion = slavic_pagan
			}
			piety = -300
			capital_scope = {
				if = {
					limit = { has_global_flag = slavic_reformation }
					religion = chram_vales
				}
				if = {
					limit = { NOT = { has_global_flag = slavic_reformation } }
					religion = slavic_pagan
				}
			}
		}
		culture = pommeranian
		if = {
			limit = { has_global_flag = slavic_reformation }
			religion = slavic_pagan
		}
		if = {
			limit = { NOT = { has_global_flag = slavic_reformation } }
			religion = chram_vales
		}
		if = {
			limit = { has_dlc = "Reapers" }
			change_variable = { which = prosperity_value value = 35 }
		}
	}
}

# byzsla_slavic_event_swiatowid.12 - konflikt między piratami, kupcami a rzemieślnikami (miastowy)

character_event = {
	id = byzsla_slavic_event_swiatowid.12
	desc = desc_byzsla_slavic_event_swiatowid.12
	
	hide_from = yes
	picture = GFX_evt_council_quarrelling
	is_triggered_only = yes
	hide_window = yes

	only_rulers = yes
	min_age = 16
	only_independent = no
	religion_group = pagan_group
	
	trigger = {
		ai = no
		is_republic = yes
		capital_holding = {
			location = {
				port = yes
				is_slav_religion = yes
			}
		}
		NOT = { has_character_flag = bspm_piraci_2_flaga }
		liege = { NOT = { has_character_flag = bspm_piraci_3_flaga } }
	}
	immediate = {
		set_character_flag = bspm_piraci_2_flaga
		liege = { set_character_flag = bspm_piraci_3_flaga }
		liege = {
			character_event = {
				id = byzsla_slavic_event_swiatowid.13
			}
		}
	}
}

# byzsla_slavic_event_swiatowid.13 - konflikt między piratami, kupcami a rzemieślnikami (senior)


character_event = {
	id = byzsla_slavic_event_swiatowid.13
	desc = desc_byzsla_slavic_event_swiatowid.13
	
	picture = GFX_evt_council_quarrelling
	is_triggered_only = yes

	option = {
		name = optA_byzsla_slavic_event_swiatowid.13	#piraci
		FROM = {
			capital_holding = {
				location = {
					add_province_modifier = {
						name = byzsla_slavic_support_piraci
						duration = 4000
					}
				}
			}
		}
	}
	option = {
		name = optB_byzsla_slavic_event_swiatowid.13	#kupcy
		FROM = {
			capital_holding = {
				location = {
					add_province_modifier = {
						name = byzsla_slavic_support_kupcy
						duration = 4000
					}
				}
			}
		}
	}
	option = {
		name = optC_byzsla_slavic_event_swiatowid.13	#rzemieślnicy
		FROM = {
			capital_holding = {
				location = {
					add_province_modifier = {
						name = byzsla_slavic_support_rzemioslo
						duration = 4000
					}
				}
			}
		}
	}
}