namespace = scan_djm

country_event = {
	id = scan_djm.1
	title = scan_djm.1.t
	desc = scan_djm.1.d
	picture = QUEEN_MARGARET_eventPicture
	
	fire_only_once = yes
	major = yes

	trigger = {
		tag = NOR
		government = elective_feudal_monarchy
		OR = {
			marriage_with = DAN
			marriage_with = SWE
		}
		NOT = { is_year = 1430 }
	}
	
	mean_time_to_happen = {
		years = 40
		
		modifier = {
			factor = 0.05
			DAN = {
				has_ruler = "Margaret"
			}
		}

		modifier = {
			factor = 0.2
			is_year = 1400
		}
		
	}
	
	option = {
		ai_chance = { 
			factor = 50 
			
			modifier = {
				factor = 2
				AND = {
					NOT = { alliance_with = SWE }
					alliance_with = DAN
				}
			}
			modifier = {
				factor = 2
				DAN = {
					dynasty = "Estridsen"
				}
			}
			
			modifier = {
				factor = 2
				DAN = {
					DIP = 5
				}
			}			
			
		}
		name = scan_djm.1.a
		add_adm_power = 100
		add_dip_power = 100
		add_mil_power = 100
		change_government = early_feudal_monarchy
		DAN = {
			create_union = NOR
		}
	}
	
	option = {
		ai_chance = { 
			factor = 20 
			
			modifier = {
				factor = 2
				AND = {
					NOT = { alliance_with = DAN }
					alliance_with = SWE
				}
			}
			
			modifier = {
				factor = 2
				SWE = {
					DIP = 5
				}
			}			
		}
		name = scan_djm.1.c
		add_adm_power = 100
		add_dip_power = 100
		add_mil_power = 100
		change_government = early_feudal_monarchy
		SWE = {
			create_union = NOR
		}
	}	
	
	option = {
		name = scan_djm.1.b
		ai_chance = { 
			factor = 30
			
			modifier = {
				factor = 2
				AND = {
					alliance_with = DAN
					alliance_with = SWE
				}
			}
			
		}
	
		add_stability = -1
		define_ruler = {
			adm = 1
			dip = 1
			mil = 1
		}
		DAN = {
			add_casus_belli = {
				type = cb_restore_personal_union
				months = 120
				target = NOR
			}
		}
		SWE = {
			add_casus_belli = {
				type = cb_restore_personal_union
				months = 120
				target = NOR
			}
		}
		add_republican_tradition = 0.50
	}
}

country_event = {
	id = scan_djm.2
	title = scan_djm.2.t
	desc = scan_djm.2.d
	picture = QUEEN_MARGARET_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = DAN
		NOT = { DAN = { senior_union_with = SWE } }
		OR = {
			SWE = { senior_union_with = MKL }
			DAN = { senior_union_with = NOR }
		}
		is_year = 1387
		NOT = { is_year = 1444 }
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	option = {
		name = scan_djm.2.a
		add_casus_belli = {
			type = cb_restore_personal_union
			months = 120
			target = SWE
		}
		add_country_modifier = {
			name = "swedish_noble_support"
			duration = 1825
		}
	}
}

country_event = {
	id = scan_djm.3
	title = scan_djm.3.t
	desc = scan_djm.3.d
	picture = QUEEN_MARGARET_eventPicture
	
	fire_only_once = yes

	trigger = {
		OR = {
			tag = NOR
			tag = SWE
		}
		is_lesser_in_union = yes
		government = elective_feudal_monarchy
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = scan_djm.3.a
		change_government = early_feudal_monarchy
	}
}

country_event = {
	id = scan_djm.4
	title = scan_djm.4.t
	desc = scan_djm.4.d
	picture = LIBERUM_VETO_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = SWE
		NOT = { has_spawned_rebels = pretender_rebels }
		has_ruler = "Magnus IV"
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = scan_djm.4.a
		change_government = early_feudal_monarchy		
		kill_heir = yes
		define_heir = {
			name = "Erik"
			monarch_name = "Erik XII"
			dynasty = "Bjelbo"
			birth_date = 1339.1.1
			claim = 75
			adm = 3
			dip = 3
			mil = 4
		}
	}
	
	option = {
		name = scan_djm.4.b
		add_stability = 1
		add_prestige = -15
	}
	
}