society_decisions = { #only available to members of a society
	request_to_rank_up_within_viking_society = { #this is the new rank up decision if you want one, you do not need this if you use de default one

		hide_in_decisions_list = yes # This is shown in the Society View
		
		potential = {
			hidden_tooltip = {
				society_rank <= 3 #is not max rank
				days_in_society > 365 #days requirement
				is_in_society = yes #obviously
				OR = { #Players can always rank up (if they have the power), AI won't if there is no room
					ai = no
					AND = {
						ai = yes
						society_can_rank_up = yes
					}
				}
			}
		}

		allow = {
			#Rank requirements. IMPORTANT!!! If you change the requirements, the customizable loc keys "GetSocietyRankUpTooltip" 1, 2, 3, and 4 must be updated, as it displays these requirements.
			custom_tooltip = { # Sufficient currency
				text = request_to_rank_up_within_viking_society_tt
				OR = {
					AND = {
						society_rank == 1
						society_currency >= 750
					}
					AND = {
						society_rank == 2
						society_currency >= 1000
					}
					AND = {
						society_rank == 3
						society_currency >= 2000
					}
				}
			}

			custom_tooltip = {
				text = must_not_have_sent_request_already_tooltip 
				NOT = { has_character_flag = has_sent_request_to_rank_up }
			}

			custom_tooltip = {
				text = must_be_allowed_to_rank_up_tooltip 
				days_at_current_society_rank >= 1095 #IMPORTANT! Update tooltip.
			}

			custom_tooltip = {
				text = must_have_grandmaster_tooltip #You must have a grand master
				any_society_member = {
					is_society_grandmaster = yes
					same_society_as = ROOT
				}
			}
		}

		effect = {
			#Rank up cost
			if = {
				limit = { society_rank == 1 }
				change_society_currency = -750
			}
			if = {
				limit = { society_rank == 2 }
				change_society_currency = -1000
			}
			if = {
				limit = { society_rank == 3 }
				change_society_currency = -2000
			}

			#Perform rank up
			hidden_tooltip = {
				save_event_target_as = rank_up_target #mark the character as the one ranking up
				set_character_flag = has_sent_request_to_rank_up
				character_event = { id = VIKSOC.120 days = 20 random = 10 } # sends hidden delayed event to self, which then sends request to Leader of the society
				
			}
		}

		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
		
	viking_invite_warrior = {
		only_playable = yes
		potential = {
			has_dlc = "Mystics"
			society_member_of = viking_society
			society_rank >= 4
			NOT = { has_character_flag = warrior_arriving }
		}
		
		allow = {
			has_society_currency_medium_trigger = yes
			is_inaccessible_trigger = no
		}
		effect = {
			set_character_flag = warrior_arriving
			detract_society_currency_medium_effect = yes
			
			custom_tooltip = {
				text = viking_invite_warrior_tt
				character_event = { id = VIKSOC.160 days = 7 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.001
			modifier = {
				factor = 0.1
				any_courtier = { society_member_of = viking_society } #Less likely to invite if there is already someone else at court
			}
			modifier = {
				any_courtier = { has_job_title = job_martial martial = 16 }
				factor = 0.01
			}
		}		
	}
}
targetted_decisions = {
	viking_build_courage = {
		ai_check_interval = 12
		potential = {
			NOT = { trait = incapable }
			OR = {
				same_realm = FROM
				same_society_as = FROM
			}
			is_within_diplo_range = FROM
		}
		
		from_potential = {
			has_DLC = "Mystics"
			society_rank >= 3
			society_member_of = viking_society
			is_adult = yes
			NOT = { trait = incapable }
			religion = ROOT
		}
		
		allow = {
			FROM = {
				has_society_currency_major_trigger = yes	###requires 500SocCur
				is_inaccessible_trigger = no
				prisoner = no
				in_command = no
			}
			is_inaccessible_trigger = no
			prisoner = no
			in_command = no
			same_realm = FROM
			OR = {
				is_landed = yes
				is_patrician = yes
				is_close_relative = FROM
			}
			NOT = {
				has_opinion_modifier = {	###opinion modifier 10yrs cooldown
					who =  FROM
					modifier = opinion_build_courage
				}
			}
			custom_tooltip = {
				text = build_courage_tooltip
				OR ={
					AND = {
						NOT = { trait = brave }
						FROM = { trait = brave }
					}
					AND = {
						NOT = { trait = gregarious }
						FROM = { trait = gregarious }
					}
					AND = {
						NOT = { trait = berserker }
						FROM = { trait = berserker }
					}
					AND = {
						NOT = { trait = ambitious }
						FROM = { trait = ambitious }
					}
				}
			}
		}
		
		effect = {
			FROM = {
				detract_society_currency_major_effect = yes	###lose 500SocCur
			}
			random_list = {				###Will randomly add one virtue that you have and target doesn't
				40 = {
					modifier = {
						factor = 0
						OR = {
							trait = brave
							FROM = { NOT = { trait = brave } }
						}
					}
					set_character_flag = build_courage_brave
					add_trait = brave
				}
				40 = {
					modifier = {
						factor = 0
						OR = {
							trait = gregarious
							FROM = { NOT = { trait = gregarious } }
						}
					}
					set_character_flag = build_courage_gregarious
					add_trait = gregarious
				}
				5 = {
					modifier = {
						factor = 0
						OR = {
							trait = berserker
							FROM = { NOT = { trait = berserker } }
						}
					}
					set_character_flag = build_courage_brave
					add_trait = brave
				}
				15 = {
					modifier = {
						factor = 0
						OR = {
							trait = ambitious
							FROM = { NOT = { trait = ambitious } }
						}
					}
					set_character_flag = build_courage_brave
					add_trait = brave
				}				
			}
			opinion = {										###opinion mostly serves as a 10 years cooldown ; +10 Opinion
				who = FROM
				modifier = opinion_build_courage
				months = 120
			}
			FROM = { character_event = { id = VIKSOC.000 } }
			character_event = { id = VIKSOC.000 }
		}
		
		revoke_allowed = {
		always = no
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 0
				NOT = {
					AND = {
						is_close_relative = FROM						###AI will only target landed relatives in the same realm
						same_realm = FROM
						OR = {
							is_landed = yes
							is_patrician = yes
						}
					}
				}
			}
		}		
	}
	viking_rid_cowardice = {
		potential = {
			NOT = { trait = incapable }
			OR = {
				same_realm = FROM
				same_society_as = FROM
			}
			is_within_diplo_range = FROM
		}
		from_potential = {
			has_DLC = "Mystics"
			society_rank >= 2
			society_member_of = viking_society
			is_adult = yes
			NOT = { trait = incapable }
		}
		allow = {

			FROM = {
				has_society_currency_medium_trigger = yes	###requires 300SocCur
				is_inaccessible_trigger = no
				prisoner = no
				in_command = no
			}
			is_inaccessible_trigger = no
			prisoner = no
			in_command = no
			same_realm = FROM
			OR = {
				is_landed = yes
				is_patrician = yes
				is_close_relative = FROM
			}
			NOT = {
				has_opinion_modifier = {	###opinion modifier 10yrs cooldown
					who =  FROM
					modifier = opinion_rid_cowardice
				}
			}
			custom_tooltip = {
				text = rid_cowardice_tooltip
				OR ={
					AND = {
						trait = craven
						FROM = { NOT = { trait = craven } }
					}
					AND = {
						trait = paranoid
						FROM = { NOT = { trait = paranoid } }
					}
					AND = {
						trait = shy
						FROM = { NOT = { trait = shy } }
					}
					AND = {
						trait = stutter
						FROM = { NOT = { trait = stutter } }
					}
				}
			}
		}		
		effect = {
			FROM = {
				detract_society_currency_medium_effect = yes	###lose 300SocCur
			}
			random_list = {				###Will randomly remove one sin that target has and you don't
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = craven }
							FROM = { trait = craven }
						}
					}
					set_character_flag = rid_cowardice_craven
					remove_trait = craven
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = paranoid }
							FROM = { trait = paranoid }
						}
					}
					set_character_flag = rid_cowardice_paranoid
					remove_trait = paranoid
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = shy }
							FROM = { trait = shy }
						}
					}
					set_character_flag = rid_cowardice_shy
					remove_trait = shy
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = stutter }
							FROM = { trait = stutter }
						}
					}
					set_character_flag = rid_cowardice_stutter
					remove_trait = stutter
				}
			}
			opinion = {										###opinion mostly serves as a 10 years cooldown ; +5 Opinion
				who = FROM
				modifier = opinion_rid_cowardice
				months = 120
			}
			FROM = { character_event = { id = VIKSOC.000 } }
			character_event = { id = VIKSOC.000 }
		}	
	
	}
}