decisions = {

	conscript_merchant_ships = {
		ai_check_interval = 3
		only_playable = yes
		is_high_prio = yes
		potential = {
			is_playable = yes
			OR = {
				ai = no
				year = 1100
			}
			NOT = {
				has_earmarked_regiments = conscripted_merchant_ships
			}
			has_overseas_holdings = yes
		}
		allow = {
			war = yes
			wealth = 50
		}
		effect = {
			wealth = -50
			spawn_fleet = {
				province = closest # closest sea zone
				owner = ROOT
				disband_on_peace = yes
				earmark = conscripted_merchant_ships
				troops =
				{
					galleys = { 20 20 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					any_war = {
						OR = {
							defender = { character = ROOT }
							attacker = { character = ROOT }
						}
					}
				}
			}
		}
	}
	
	raise_tribal_units = {
		only_playable = yes
		is_high_prio = yes
		is_mercenary = yes
		potential = {
			is_playable = yes
			is_tribal = yes
			is_ruler = yes
			OR = {
				ai = no
				any_war = {
					OR = {
						any_defender = {
							character = ROOT
							is_primary_war_defender = yes
						}
						any_attacker = {
							character = ROOT
							is_primary_war_attacker = yes
						}
					}
				}
			}
		}
		allow = {
			war = yes
			prestige = 500
			custom_tooltip = {
				text = NOT_RECENTLY_RAISE_TRIBAL_UNITS
				hidden_tooltip = {
					NOT = { has_character_modifier = raise_tribal_units_timer }
				}
			}
		}
		effect = {
			prestige = -500
			custom_tooltip = {
				text = TRIBAL_ARMY_RAISED
				hidden_tooltip = {
					capital_scope = {
						ROOT = {
							spawn_unit = {
								owner = ROOT
								province = PREV
								home = PREV
								match_character = ROOT
								match_mult = 0.5
								match_min = 500
								match_max = 5000
								attrition = 1.0
								disband_on_peace = yes
								maintenance_multiplier = 0.5
							}
						}
					}
				}
			}
			hidden_tooltip = {
				add_character_modifier = {
					name = raise_tribal_units_timer
					duration = 30
					hidden = yes
				}
			}
		}
		ai_will_do = {
			factor = 0 # decisions with the "is_mercenary" will not be calculated from the script
		}
	}

	raise_defensive_unit = {
		only_playable = yes
		is_high_prio = yes
		is_mercenary = yes

		potential = {
			has_dlc = "The Old Gods"
			is_playable = yes
			is_tribal = yes
			is_landed = yes
			OR = {
				religion = finnish_pagan
				religion = finnish_pagan_reformed
				religion = west_african_pagan
				religion = west_african_pagan_reformed
				religion = baltic_pagan
				religion = baltic_pagan_reformed
				religion = slavic_pagan
				religion = slavic_pagan_reformed
			}
		}

		allow = {
			war = yes
			
			custom_tooltip = {
				text = raise_defensive_unit_tooltip

				hidden_tooltip = {
					any_war = {
						any_defender = {
							character = ROOT
							is_primary_war_defender = yes
						}

						#Defending against heathen
						OR = {
							#Defender is finnish pagan but attacker is not
							AND = {
								ROOT = {
									OR = {
										religion = finnish_pagan
										religion = finnish_pagan_reformed
									}
								}
								attacker = {
									NOR = {
										religion = finnish_pagan
										religion = finnish_pagan_reformed
									}
								}
							}

							#Defender is west african pagan but attacker is not
							AND = {
								ROOT = {
									OR = {
										religion = west_african_pagan
										religion = west_african_pagan_reformed
									}
								}
								attacker = {
									NOR = {
										religion = west_african_pagan
										religion = west_african_pagan_reformed
									}
								}
							}

							#Defender is baltic pagan but attacker is not
							AND = {
								ROOT = {
									OR = {
										religion = baltic_pagan
										religion = baltic_pagan_reformed
									}
								}
								attacker = {
									NOR = {
										religion = baltic_pagan
										religion = baltic_pagan_reformed
									}
								}
							}

							#Defender is slavic pagan but attacker is not
							AND = {
								ROOT = {
									OR = {
										religion = slavic_pagan
										religion = slavic_pagan_reformed
									}
								}
								attacker = {
									NOR = {
										religion = slavic_pagan
										religion = slavic_pagan_reformed
									}
								}
							}
						}
					}
				}
			}
			piety = 200	
		}

		effect = {
			custom_tooltip = { text = summon_defensive_unit }
			piety = -200

			hidden_tooltip = {
				capital_scope = {
					ROOT = {
						spawn_unit = {
							owner = ROOT
							home = PREV
							province = PREV
							disband_on_peace = yes
							maintenance_multiplier = 0.25
							attrition = 1.0 

							troops = {
								archers = { 400 400 }
								light_infantry = { 1000 1000 }
								heavy_infantry = { 350 350 }
								light_cavalry = { 250 250 }
							}
						}
					}
				}
			}
		}


		ai_will_do = {
			factor = 0
		}
	}	
}
