decisions = {

	conscript_merchant_ships = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 12

		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
		ai_check_interval = 12

		potential = {
			NOT = {
				has_dlc = "Legacy of Rome"
			}
			is_playable = yes
			is_tribal = yes
			is_landed = yes
			OR = {
				ai = no
				AND = {
					any_war = {
						OR = {
							any_defender = {
								character = ROOT
								is_primary_war_defender = yes
							}
							any_attacker = {
								character = ROOT
								is_primary_war_attacker = yes
							}
						}
					}
					NOT = {
						has_game_rule = {
							name = smart_tribal
							value = smart_off
						}
					}
				}
			}
		}
		allow = {
			war = yes
			prestige = 500
		}
		effect = {
			prestige = -500
			if = {
				limit = {
					OR = {
						religion = tengri_pagan
						religion = tengri_pagan_reformed
						culture_group = altaic
					}
				}
				if = {
					limit = {
						has_game_rule = {
						  name = smart_tribal
						  value = smart_balanced
						}
					}
					capital_scope = {
						PREV = {
							spawn_unit = {
								owner = ROOT
								province = PREV
								home = PREV
								troops = {
									archers = { 100 100 }
									light_infantry = { 650 650 }
									light_cavalry = { 100 100 }
								}
								attrition = 1.0
								disband_on_peace = yes
								maintenance_multiplier = 0.5
							}
						}
					}
					break = yes
				}
				if = {
					limit = {
						has_game_rule = {
						  name = smart_tribal
						  value = smart_crazy
						}
					}
					capital_scope = {
						PREV = {
							spawn_unit = {
								owner = ROOT
								province = PREV
								home = PREV
								troops = {
									archers = { 1500 1500 }
									light_infantry = { 7500 7500 }
									light_cavalry = { 1000 1000 }
								}
								attrition = 1.0
								disband_on_peace = yes
								maintenance_multiplier = 0.5
							}
						}
					}
					break = yes
				}
				capital_scope = {
					PREV = {
						spawn_unit = {
							owner = ROOT
							province = PREV
							home = PREV
							troops = {
								archers = { 500 500 }
								light_infantry = { 1500 1500 }
								light_cavalry = { 500 500 }
							}
							attrition = 1.0
							disband_on_peace = yes
							maintenance_multiplier = 0.5
						}
					}
				}
				break = yes
			}
			if = {
				limit = {
					has_game_rule = {
					  name = smart_tribal
					  value = smart_balanced
					}
				}
				capital_scope = {
					PREV = {
						spawn_unit = {
							owner = ROOT
							province = PREV
							home = PREV
							troops = {
								archers = { 100 100 }
								light_infantry = { 650 650 }
								heavy_infantry = { 60 60 }
								light_cavalry = { 40 40 }
							}
							attrition = 1.0
							disband_on_peace = yes
							maintenance_multiplier = 0.5
						}
					}
				}				
				break = yes
			}
			if = {
				limit = {
					has_game_rule = {
					  name = smart_tribal
					  value = smart_crazy
					}
				}
				capital_scope = {
					PREV = {
						spawn_unit = {
							owner = ROOT
							province = PREV
							home = PREV
							troops = {
								archers = { 1500 1500 }
								light_infantry = { 7500 7500 }
								heavy_infantry = { 600 600 }
								light_cavalry = { 400 400 }
							}
							attrition = 1.0
							disband_on_peace = yes
							maintenance_multiplier = 0.5
						}
					}
				}				
				break = yes
			}
			capital_scope = {
				PREV = {
					spawn_unit = {
						owner = ROOT
						province = PREV
						home = PREV
						troops = {
							archers = { 500 500 }
							light_infantry = { 1500 1500 }
							heavy_infantry = { 300 300 }
							light_cavalry = { 200 200 }
						}
						attrition = 1.0
						disband_on_peace = yes
						maintenance_multiplier = 0.5
					}
				}
			}
		}
		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
		ai_check_interval = 12

		potential = {
			has_dlc = "The Old Gods"
			NOT = {
				has_dlc = "Legacy of Rome"
			}
			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
			}
			OR = {
				ai = no
				NOT = {
					has_game_rule = {
						name = smart_tribal
						value = smart_off
					}
				}
			}
		}

		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 = {
				if = {
					limit = {
						has_game_rule = {
						  name = smart_tribal
						  value = smart_balanced
						}
					}
					capital_scope = {
						ROOT = {
							spawn_unit = {
								owner = ROOT
								home = PREV
								province = PREV
								disband_on_peace = yes
								maintenance_multiplier = 0.25
								attrition = 1.0 

								troops = {
									archers = { 150 150 }
									light_infantry = { 700 700 }
									heavy_infantry = { 100 100 }
									light_cavalry = { 50 50 }
								}
							}
						}
					}
					break = yes
				}
				if = {
					limit = {
						has_game_rule = {
						  name = smart_tribal
						  value = smart_crazy
						}
					}
					capital_scope = {
						ROOT = {
							spawn_unit = {
								owner = ROOT
								home = PREV
								province = PREV
								disband_on_peace = yes
								maintenance_multiplier = 0.25
								attrition = 1.0 

								troops = {
									archers = { 1500 1500 }
									light_infantry = { 7000 7000 }
									heavy_infantry = { 1000 1000 }
									light_cavalry = { 500 500 }
								}
							}
						}
					}
					break = yes
				}
				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 }
							}
						}
					}
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}	
}
