# v1.10: Old Gods Events: 62300 - 62999

# Written by Henrik Fhraeus

# Called from on_action: on_prepared_invasion_aborts
# The target character is in FROM
character_event = {

	id = 62300
	desc = EVTDESC62300
	
	picture = GFX_evt_viking_battle_oldgods
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	immediate = {
		remove_character_modifier = launched_prepared_invasion
		remove_opinion = {
			who = FROM
			modifier = preparing_to_invade
		}
		FROM = {
			remove_opinion = {
				who = ROOT
				modifier = preparing_to_invade_me
			}
		}
		disband_event_forces = prepared_invasion
	}

	option = {
		name = {
			text = EVTOPTA62300
			trigger = {
				OR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
			}
		}
		name = {
			text = EVTOPTB62300
			trigger = {
				NOR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
			}
		}
	}
}

# Called from on_action: on_prepared_invasion_expires
# The target character is in FROM
character_event = {

	id = 62310
	desc = EVTDESC62310
	
	picture = GFX_evt_viking_battle_oldgods
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	immediate = {
		remove_opinion = {
			who = FROM
			modifier = preparing_to_invade
		}
		FROM = {
			remove_opinion = {
				who = ROOT
				modifier = preparing_to_invade_me
			}
		}
		if = {
			limit = {
				NOT = {
					any_war = {
						any_attacker = { character = FROM } 
					}
				}
			}
			disband_event_forces = prepared_invasion
		}
	}

	option = {
		name = {
			text = EVTOPTA62310
			trigger = {
				OR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
			}
		}
		name = {
			text = EVTOPTB62310
			trigger = {
				NOR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
			}
		}
		if = {
			limit = {
				NOT = {
					any_war = {
						any_attacker = { character = FROM } 
					}
				}
			}
			prestige = -200
			piety = -50
			any_realm_lord = {
				limit = {
					religion = ROOT
				}
				opinion = {
					who = ROOT
					modifier = opinion_failed_invasion
				}
			}
		}
	}
}

# Troops flock to your banner
# Called from on_action: on_prepared_invasion_monthly
# The target character is in FROM
character_event = {
	id = 62320
	desc = {
        trigger = {
			NOT = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
			}
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
				has_religion_feature = religion_adventuring
			}
			any_realm_province = {
				region = world_europe_north
			}
		}
        text = EVTDESC62320
    }
	desc = {
        trigger = {
			OR = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
				NOR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
				AND = {
					OR = {
						religion = norse_pagan
						religion = norse_pagan_reformed
					}
					NOT = {
						any_realm_province = {
							region = world_europe_north
						}
					}
				}
			}
		}
        text = EVTDESC62320_alt
    }
	
	picture = GFX_evt_vikings_arriving_oldgods
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	# On_action, so BIG is MORE OFTEN!
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.25
			martial = 15
		}
		modifier = {
			factor = 1.25
			martial = 20
		}
		modifier = {
			factor = 1.25
			diplomacy = 15
		}
		modifier = {
			factor = 1.25
			diplomacy = 20
		}
		modifier = {
			factor = 1.25
			prestige = 1000
		}
		modifier = {
			factor = 0.75
			NOT = { martial = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { martial = 7 }
		}
		modifier = {
			factor = 0.75
			NOT = { diplomacy = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 0.5
			NOT = { prestige = 100 }
		}
		modifier = {
			factor = 0.75
			lower_tier_than = DUKE
		}
		modifier = {
			factor = 0
			relative_power = {
				who = FROM
				power = 4.0
			}
		}
		modifier = {
			factor = 0.5
			relative_power = {
				who = FROM
				power = 2.0
			}
		}
		modifier = {
			factor = 0.25
			relative_power = {
				who = FROM
				power = 3.0
			}
		}
	}

	option = {
		name = EVTOPTA62320
		capital_scope = {
			ROOT = {
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.1
					earmark = prepared_invasion
					attrition = 1.0
					cannot_inherit = yes
				}
				spawn_fleet = {
					province = closest_to_capital
					owner = ROOT
					match_character = ROOT
					match_mult = 0.1
					match_min = 7
					earmark = prepared_invasion
					cannot_inherit = yes
				}
			}
		}
	}
}

# A hero and his retinue appear in your court
# Called from on_action: on_prepared_invasion_monthly
# The target character is in FROM
character_event = {
	id = 62321
	desc = {
        trigger = {
			NOT = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
			}
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
				has_religion_feature = religion_adventuring
			}
			any_realm_province = {
				region = world_europe_north
			}
		}
        text = EVTDESC62321
    }
	desc = {
        trigger = {
			OR = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
				NOR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
				AND = {
					OR = {
						religion = norse_pagan
						religion = norse_pagan_reformed
					}
					NOT = {
						any_realm_province = {
							region = world_europe_north
						}
					}
				}
			}
		}
        text = EVTDESC62321_alt
    }
	
	hide_from = yes
	
	picture = GFX_evt_vikings_arriving_oldgods
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	# On_action, so BIG is MORE OFTEN
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.25
			martial = 15
		}
		modifier = {
			factor = 1.25
			martial = 20
		}
		modifier = {
			factor = 1.25
			diplomacy = 15
		}
		modifier = {
			factor = 1.25
			diplomacy = 20
		}
		modifier = {
			factor = 1.25
			prestige = 1000
		}
		modifier = {
			factor = 0.75
			NOT = { martial = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { martial = 7 }
		}
		modifier = {
			factor = 0.75
			NOT = { diplomacy = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 0.5
			NOT = { prestige = 100 }
		}
		modifier = {
			factor = 0.75
			lower_tier_than = DUKE
		}
		modifier = {
			factor = 0
			relative_power = {
				who = FROM
				power = 4.0
			}
		}
		modifier = {
			factor = 0.5
			relative_power = {
				who = FROM
				power = 2.0
			}
		}
		modifier = {
			factor = 0.25
			relative_power = {
				who = FROM
				power = 3.0
			}
		}
	}

	option = {
		name = EVTOPTA62321
		capital_scope = {
			create_character = {
				random_traits = yes
				dynasty = NONE
				religion = ROOT
				culture = ROOT
				female = no
				age = 30
				attributes = {
					martial = 8
				}
				trait = brave
				trait = zealous
				trait = brilliant_strategist
				trait = holy_warrior
			}
			new_character = {
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.15
#					earmark = prepared_invasion
					attrition = 1.0
					cannot_inherit = yes
				}
			}
		}
		
		spawn_fleet = {
			province = closest_to_capital
			owner = ROOT
			match_character = ROOT
			match_mult = 0.15
			match_min = 10
			earmark = prepared_invasion
			cannot_inherit = yes
		}
	}
}

# A smaller force arrives for the invasion
# Called from on_action: on_prepared_invasion_monthly
# The target character is in FROM
character_event = {
	id = 62322
	desc = {
        trigger = {
			NOT = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
			}
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
				has_religion_feature = religion_adventuring
			}
			any_realm_province = {
				region = world_europe_north
			}
		}
        text = EVTDESC62320
    }
	desc = {
        trigger = {
			OR = {
				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
				NOR = {
					religion = norse_pagan
					religion = norse_pagan_reformed
				}
				AND = {
					OR = {
						religion = norse_pagan
						religion = norse_pagan_reformed
					}
					NOT = {
						any_realm_province = {
							region = world_europe_north
						}
					}
				}
			}
		}
        text = EVTDESC62320_alt
    }
	
	picture = GFX_evt_vikings_arriving_oldgods
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	# On_action, so BIG is MORE OFTEN
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.25
			martial = 15
		}
		modifier = {
			factor = 1.25
			martial = 20
		}
		modifier = {
			factor = 1.25
			diplomacy = 15
		}
		modifier = {
			factor = 1.25
			diplomacy = 20
		}
		modifier = {
			factor = 1.25
			prestige = 1000
		}
		modifier = {
			factor = 0.75
			NOT = { martial = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { martial = 7 }
		}
		modifier = {
			factor = 0.75
			NOT = { diplomacy = 10 }
		}
		modifier = {
			factor = 0.5
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 0.5
			NOT = { prestige = 100 }
		}
		modifier = {
			factor = 0.75
			lower_tier_than = DUKE
		}
		modifier = {
			factor = 0
			relative_power = {
				who = FROM
				power = 4.0
			}
		}
		modifier = {
			factor = 0.5
			relative_power = {
				who = FROM
				power = 2.0
			}
		}
		modifier = {
			factor = 0.25
			relative_power = {
				who = FROM
				power = 3.0
			}
		}
	}

	option = {
		name = EVTOPTA62320
		capital_scope = {
			ROOT = {
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.075
					earmark = prepared_invasion
					attrition = 1.0
					cannot_inherit = yes
				}
				spawn_fleet = {
					province = closest_to_capital
					owner = ROOT
					match_character = ROOT
					match_mult = 0.075
					match_min = 5
					earmark = prepared_invasion
					cannot_inherit = yes
				}
			}
		}
	}
}

# Notification from decision 'convert_to_attacker_religion'
letter_event = {
	id = 62800
	desc = EVTDESC62800
	
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA62800
		if = {
			limit = {
				FROM = { tier = COUNT }
			}
			piety = 50
		}
		if = {
			limit = {
				FROM = { tier = DUKE }
			}
			piety = 100
		}
		if = {
			limit = {
				FROM = { tier = KING }
			}
			piety = 300
		}
		if = {
			limit = {
				FROM = { tier = EMPEROR }
			}
			piety = 1000
		}
	}
}

# Informed about the Creation of Leon
# Informed about the Creation of Castille

# Informed about the Creation of Portugal

# Informed about the Creation of Leon

# Informed about the Creation of Castille

# Informed about the Creation of Portugal
# Informed about the Creation of Aragon


# Special event for Middle Francia to be renamed to Austrasia - Since Lothair doesn't exist to name it Lotharingia


