﻿setup_agotma_rebel_title_effect = {
	create_landless_adventurer_title_effect = {
		REASON = flag:voluntary
		FLAVOR_CHAR = root
	}
}


setup_agotma_rebel_army_spawner = {
	scope:target = {
		start_war = {
			cb = agotma_royal_rebel
			target = scope:agotma_war_target_land.holder
			claimant = scope:target
			target_title = scope:agotma_war_target_land
		}

		if = {
			limit = {
				is_claimant = yes
				scope:wartargetperson.primary_title.tier = tier_duchy
			}
			if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_1
						has_trait = education_martial_1
						has_trait = education_stewardship_1
						has_trait = education_intrigue_1
						has_trait = education_learning_1
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 2
					}
					men_at_arms = {
						type = light_footmen
						stacks = 4
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_2
						has_trait = education_martial_2
						has_trait = education_stewardship_2
						has_trait = education_intrigue_2
						has_trait = education_learning_2
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 3
					}
					men_at_arms = {
						type = light_footmen
						stacks = 6
					}
					men_at_arms = {
						type = bowmen
						stacks = 1
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_3
						has_trait = education_martial_3
						has_trait = education_stewardship_3
						has_trait = education_intrigue_3
						has_trait = education_learning_3
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 6
					}
					men_at_arms = {
						type = light_footmen
						stacks = 12
					}
					men_at_arms = {
						type = bowmen
						stacks = 2
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_4
						has_trait = education_martial_4
						has_trait = education_stewardship_4
						has_trait = education_intrigue_4
						has_trait = education_learning_4
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 9
					}
					men_at_arms = {
						type = light_footmen
						stacks = 18
					}
					men_at_arms = {
						type = bowmen
						stacks = 3
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_5
						has_trait = education_martial_5
						has_trait = education_stewardship_5
						has_trait = education_intrigue_5
						has_trait = education_learning_5
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 12
					}
					men_at_arms = {
						type = light_footmen
						stacks = 24
					}
					men_at_arms = {
						type = bowmen
						stacks = 4
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
		}

		#ENEMY IS KING OR EMPIRE TIER

		if = {
			limit = {
				is_claimant = yes
				scope:wartargetperson.primary_title.tier > tier_duchy
			}
			if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_1
						has_trait = education_martial_1
						has_trait = education_stewardship_1
						has_trait = education_intrigue_1
						has_trait = education_learning_1
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 9
					}
					men_at_arms = {
						type = light_footmen
						stacks = 18
					}
					men_at_arms = {
						type = bowmen
						stacks = 3
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_2
						has_trait = education_martial_2
						has_trait = education_stewardship_2
						has_trait = education_intrigue_2
						has_trait = education_learning_2
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 18
					}
					men_at_arms = {
						type = light_footmen
						stacks = 36
					}
					men_at_arms = {
						type = bowmen
						stacks = 6
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_3
						has_trait = education_martial_3
						has_trait = education_stewardship_3
						has_trait = education_intrigue_3
						has_trait = education_learning_3
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 30
					}
					men_at_arms = {
						type = light_footmen
						stacks = 60
					}
					men_at_arms = {
						type = bowmen
						stacks = 10
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_4
						has_trait = education_martial_4
						has_trait = education_stewardship_4
						has_trait = education_intrigue_4
						has_trait = education_learning_4
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 45
					}
					men_at_arms = {
						type = light_footmen
						stacks = 90
					}
					men_at_arms = {
						type = bowmen
						stacks = 15
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_5
						has_trait = education_martial_5
						has_trait = education_stewardship_5
						has_trait = education_intrigue_5
						has_trait = education_learning_5
					}
				}
				spawn_army = {
					levies = 0
					men_at_arms = {
						type = armored_footmen
						stacks = 60
					}
					men_at_arms = {
						type = light_footmen
						stacks = 120
					}
					men_at_arms = {
						type = bowmen
						stacks = 20
					}
					inheritable = no
					location = scope:agotma_landless_random_holder.location
					name = agotma_spawn_army_name
				}
			}
		}
	}
}