namespace = LessPAB	# pussy assed bitch

character_event = { # ruler declaring war on behalf of pope gets flagged as a PAB
	id = LessPAB.101
	desc = EVTDESC_LessPAB_101
	hide_window = yes
	
	mean_time_to_happen = { days = 20 }						# not immediate, for safety in case of delays
	
	trigger = {
		has_character_flag = flag_pepin_for_coronation		# warring for the pope's claim
		war = yes											
		NOT = { has_character_flag = PAB_flag }
	}
	
	option = {	# i am a PAB
		name = EVTOPTA_LessPAB_101
		ai_chance = { factor = 10 }
		set_character_flag = PAB_flag
	}
}

character_event = { # remove flag if crowned 
	id = LessPAB.102
	desc = EVTDESC_LessPAB_102
	hide_window = yes
	
	mean_time_to_happen = { days = 50 }						# not immediate, for safety in case of delays

	trigger = {
		OR = {
			has_character_flag = PAB_flag
			has_character_flag = mega_PAB_flag
		}
		OR = {							# crowned by any means
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
		war = no
	}
	
	option = {	# i am not a PAB anymore
		name = EVTOPTA_LessPAB_102
		ai_chance = { factor = 10 }
		clr_character_flag = PAB_flag
		clr_character_flag = mega_PAB_flag
	}
}

character_event = { # remove flag if papal war concluded in defeat, apply mega PAB flag 
	id = LessPAB.103
	desc = EVTDESC_LessPAB_103
	hide_window = yes
	
	mean_time_to_happen = { days = 100 }						# not immediate, for safety in case of delays
	
	trigger = {
		has_character_flag = PAB_flag
		NOR = {							# PHW unsuccessful, remains uncrowned 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			has_character_flag = flag_preparing_coronation		# gained immediately after winning a PHW, lacking
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
		war = no
	}
	
	option = {	# i am the biggest PAB
		name = EVTOPTA_LessPAB_103
		ai_chance = { factor = 10 }
		clr_character_flag = PAB_flag
		if = {
			limit = { 
				higher_tier_than = DUKE			# king or emperor
				is_ruler = yes					# hasn't been deposed or nuffin
				prisoner = no					# still a happy camper
			}
			set_character_flag = mega_PAB_flag
			character_event = { id = LessPAB.201 days = 3 }
			any_player = {
				limit = {
					NOT = { character = ROOT }
				}
				narrative_event = { id = LessPAB.202 days = 3 }
			}
		}
	}
}

character_event = { # king/emperor notified that his actions as a PAB may lead to losing title
	id = LessPAB.201
	desc = EVTDESC_LessPAB_201
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	
	option = {	# i'd better crown myself quickly
		name = EVTOPTA_LessPAB_201
		ai_chance = { factor = 10 }
		add_character_modifier = {				# happens auto every 5 years, applies now for certainty
			name = uncrowned_modifier			# vassal_opinion = -2
			duration = -1
			stacking = yes
		}
	}
}

narrative_event = { # player notified of king/emperor's imminent failure, presumably to point and laugh at them
	id = LessPAB.202
	desc = EVTDESC_LessPAB_202
	title = EVTTITL_LessPAB_202
	picture = GFX_evt_emissary
	border = GFX_event_narrative_frame_diplomacy
	portrait = FROM

	is_triggered_only = yes
	
	option = {	# the fool risks everything for the pope's favour
		name = EVTOPTA_LessPAB_202
		ai_chance = { factor = 10 }
	}
}

narrative_event = { # title destroyed, shouldn't have been such a PAB
	id = LessPAB.203
	desc = EVTDESC_LessPAB_203
	title = EVTTITL_LessPAB_202
	picture = GFX_evt_end_of_days
	border = GFX_event_narrative_frame_diplomacy
	
	immediate = {
		sound_effect = assassins_occupy_infidel_holding
	}
	
	trigger = {
		has_character_flag = mega_PAB_flag
		controls_religion = no			# doesn't affect the pope himself, even if he is a PAB 
		NOR = {							# subverted by any kind of coronation
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
		NOT = {
			has_character_flag = flag_preparing_coronation		# gained immediately after winning a PHW
		}
	}

	mean_time_to_happen = {		# being more in debt increases imminency of collapse
		years = 3
		modifier = {			
			factor = 0.95
			wealth < 0			
		}
		modifier = {			
			factor = 0.9
			wealth < -50			
		}
		modifier = {			
			factor = 0.85
			wealth < -100			
		}
		modifier = {			
			factor = 0.8
			wealth < -150			
		}
		modifier = {			# poor empires die super quickly -> cumulative avg 1.3 years
			factor = 0.75
			wealth < -200			
		}
		modifier = {			
			factor = 1.05
			wealth = 100			
		}
		modifier = {			
			factor = 1.1
			wealth = 200			
		}
		modifier = {			
			factor = 1.2
			wealth = 300			
		}
		modifier = {			
			factor = 1.25
			wealth = 400			
		}
		modifier = {			# rich empires die slower -> cumulative avg 6.8 years
			factor = 1.3
			wealth = 500			
		}
		modifier = {			# kings have longer to gain a crown because they have less to fall back on 
			factor = 1.25
			lower_tier_than = EMPEROR 
		}
	}
	
	option = {	# after everything I've done 
		name = EVTOPTA_LessPAB_203
		ai_chance = { factor = 10 }
		
		if = {			# if king, destroys any held kingdoms
			limit = { 
				higher_tier_than = DUKE
				lower_tier_than = EMPEROR
			}
			any_demesne_title = {
				limit = { higher_tier_than = DUKE }
				unsafe_destroy_landed_title = THIS
			}
		}
		if = {			# if emperor, destroys any held empires
			limit = { 
				higher_tier_than = KING
			}
			any_demesne_title = {
				limit = { higher_tier_than = KING }
				unsafe_destroy_landed_title = THIS
			}
		}
		hidden_tooltip = {
			remove_character_modifier = uncrowned_modifier		# so newly demoted dukes don't get stuck with it
			clr_character_flag = mega_PAB_flag
		}
	}
}


