@MAN_HUNT_BANDITS_EQUIPMENT_COST_TRIGGER = 499
@MAN_HUNT_BANDITS_EQUIPMENT_COST_EFFECT = -500

MAN_banditry_category = {

	MAN_pacify_bandits_in_the_northern_countryside = {
		
		available = {
			has_completed_focus = pacify_the_countryside
			has_country_flag = MAN_northern_bandits
			divisions_in_state = {
				state = 714	
				size > 5
			}
		}

		highlight_states = {
			highlight_state_targets = {
				state = 714
			} 
		}

		cost = 0

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 714	
					size > 5
				}
			}
		}

		visible = {
			NOT = { has_active_mission = MAN_maintain_northern_control }
			has_country_flag = MAN_northern_bandits
		}

		is_good = yes

		complete_effect = {
			activate_mission = MAN_maintain_northern_control
			custom_effect_tooltip = MAN_pacify_bandits_mission_explanation
		}
	}

	MAN_hunt_down_northern_bandits = {

		icon = generic_oppression

		available = {
			has_completed_focus = pacify_the_countryside
			has_equipment = { infantry_equipment > @MAN_HUNT_BANDITS_EQUIPMENT_COST_TRIGGER }
			has_country_flag = MAN_northern_bandits
		}

		cost = 0

		highlight_states = {
 highlight_state_targets = {
			state = 714
		} 
}
		visible = {
			has_country_flag = MAN_northern_bandits
		}
		is_good = yes

		fire_only_once = yes

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 714	
					size < 6
				}
			}
		}

		complete_effect = {
			custom_effect_tooltip = MAN_hunt_down_northern_bandits_tt
			add_manpower = -1000
			
			add_equipment_to_stockpile = {
				type = infantry_equipment
				amount = @MAN_HUNT_BANDITS_EQUIPMENT_COST_EFFECT
			}

			army_experience = 10

			remove_mission = MAN_maintain_northern_control
			clr_country_flag = MAN_northern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_western_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

	MAN_maintain_northern_control = {

		icon = generic_civil_support

		available = {
			always = no
		}

		days_mission_timeout = MAN_main_control_timer?180

		activation = {
			always = no #Triggered from effect
		}

		cancel_trigger = {
			divisions_in_state = {
				state = 714	
				size < 6
			}
		}

		highlight_states = {
 highlight_state_targets = {
			state = 714
		} 
}

		visible = {
			
		}

		is_good = yes

		timeout_effect = {
			custom_effect_tooltip = MAN_hunt_down_northern_bandits_tt
			army_experience = 10
			clr_country_flag = MAN_northern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_western_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

###  ##   ## ### ### ###  #  # 
#   #  # #    #  #   #  # ## # 
##  ####  #   #  ##  ###  # ## 
#   #  #   #  #  #   #  # #  # 
### #  # ##   #  ### #  # #  # 

	MAN_pacify_bandits_in_the_eastern_countryside = {

		icon = generic_oppression
		
		available = {
			has_completed_focus = pacify_the_countryside
			has_country_flag = MAN_eastern_bandits
			divisions_in_state = {
				state = 717
				size > 5
			}
		}

		highlight_states = {
 highlight_state_targets = {
			state = 717
		} 
}

		cost = 0

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 717	
					size > 5
				}
			}
		}

		visible = {
			NOT = { has_active_mission = MAN_maintain_eastern_control }
			has_country_flag = MAN_eastern_bandits
		}

		is_good = yes

		complete_effect = {
			activate_mission = MAN_maintain_eastern_control
			custom_effect_tooltip = MAN_pacify_bandits_mission_explanation
		}
	}

	MAN_hunt_down_eastern_bandits = {

		icon = generic_oppression

		available = {
			has_completed_focus = pacify_the_countryside
			has_equipment = { infantry_equipment > @MAN_HUNT_BANDITS_EQUIPMENT_COST_TRIGGER }
			has_country_flag = MAN_eastern_bandits
		}

		visible = {
			has_country_flag = MAN_eastern_bandits
		}

		cost = 0

		highlight_states = {
 highlight_state_targets = {
			state = 717
		} 
}

		is_good = yes

		fire_only_once = yes

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 717	
					size < 6
				}
			}
		}

		complete_effect = {
			custom_effect_tooltip = MAN_hunt_down_eastern_bandits_tt
			add_manpower = -1000
			
			add_equipment_to_stockpile = {
				type = infantry_equipment
				amount = @MAN_HUNT_BANDITS_EQUIPMENT_COST_EFFECT
			}

			army_experience = 10

			remove_mission = MAN_maintain_eastern_control
			clr_country_flag = MAN_eastern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_northern_bandits }
					NOT = { has_country_flag = MAN_western_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

	MAN_maintain_eastern_control = {

		icon = generic_civil_support

		available = {			
			always = no
		}

		days_mission_timeout = MAN_main_control_timer?180

		activation = {
			always = no #Triggered from effect
		}

		cancel_trigger = {
			divisions_in_state = {
				state = 717	
				size < 6
			}
		}

		highlight_states = {
 highlight_state_targets = {
			state = 717
		} 
}

		visible = {
			
		}

		is_good = yes

		timeout_effect = {
			custom_effect_tooltip = MAN_hunt_down_eastern_bandits_tt
			army_experience = 10
			clr_country_flag = MAN_eastern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_northern_bandits }
					NOT = { has_country_flag = MAN_western_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

#   # ###  ## ### ### ###  #  # 
#   # #   #    #  #   #  # ## # 
# # # ##   #   #  ##  ###  # ## 
# # # #     #  #  #   #  # #  # 
 # #  ### ##   #  ### #  # #  # 
	
	MAN_pacify_bandits_in_the_western_countryside = {

		icon = generic_oppression
		
		available = {
			has_completed_focus = pacify_the_countryside
			has_country_flag = MAN_western_bandits
			divisions_in_state = {
				state = 610	
				size > 5
			}
		}

		highlight_states = {
 highlight_state_targets = {
			state = 610
		} 
}

		cost = 0

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 610	
					size > 5
				}
			}
		}

		visible = {
			NOT = { has_active_mission = MAN_maintain_western_control }
			has_country_flag = MAN_western_bandits
		}

		is_good = yes

		complete_effect = {
			activate_mission = MAN_maintain_western_control
			custom_effect_tooltip = MAN_pacify_bandits_mission_explanation
		}
	}

	MAN_hunt_down_western_bandits = {

		icon = generic_oppression

		available = {
			has_completed_focus = pacify_the_countryside
			has_equipment = { infantry_equipment > @MAN_HUNT_BANDITS_EQUIPMENT_COST_TRIGGER }
			has_country_flag = MAN_western_bandits
		}

		cost = 0

		highlight_states = {
 highlight_state_targets = {
			state = 610
		} 
}

		visible = {
			has_country_flag = MAN_western_bandits
		}

		is_good = yes

		fire_only_once = yes

		ai_will_do = {
			factor = 0
			modifier = {
				add = 200
				divisions_in_state = {
					state = 610	
					size < 6
				}
			}
		}

		complete_effect = {
			custom_effect_tooltip = MAN_hunt_down_western_bandits_tt
			add_manpower = -1000
			
			add_equipment_to_stockpile = {
				type = infantry_equipment
				amount = @MAN_HUNT_BANDITS_EQUIPMENT_COST_EFFECT
			}

			army_experience = 10

			remove_mission = MAN_maintain_western_control
			clr_country_flag = MAN_western_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_northern_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

	MAN_maintain_western_control = {

		icon = generic_civil_support

		available = {			
			always = no
		}

		days_mission_timeout = MAN_main_control_timer?180

		activation = {
			always = no #Triggered from effect
		}

		cancel_trigger = {
			divisions_in_state = {
				state = 610	
				size < 6
			}
		}

		highlight_states = {
 highlight_state_targets = {
			state = 610
		} 
}

		visible = {
			
		}

		is_good = yes

		timeout_effect = {
			custom_effect_tooltip = MAN_hunt_down_western_bandits_tt
			army_experience = 10
			clr_country_flag = MAN_western_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_northern_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}

	MAN_bandit_raids = {

		icon = generic_civil_support

		available = {
			NOT = { has_idea = MAN_banditry }
		}

		days_mission_timeout = 180

		activation = {
			has_idea = MAN_banditry
		}

		visible = {
			
		}		

		fixed_random_seed = no

		fire_only_once = no

		is_good = no

		timeout_effect = {
			random_list = {
				25 = {
					country_event = wtt_manchukou_bandit_sabotage.21
				}
				25 = {
					country_event = wtt_manchukou_bandit_sabotage.22
				}
				25 = {
					country_event = wtt_manchukou_bandit_sabotage.23
				}
				25 = {
					
				}
			}
		}
	}
	MAN_recruit_bandits_north = {
		icon = generic_civil_support

		available = {
			has_country_flag = MAN_northern_bandits
			has_completed_focus = connect_with_the_banditry
		}
		visible = {
			has_country_flag = MAN_northern_bandits
		}
		ai_will_do = {
			factor = 10
		}
		cost = 50
		complete_effect = {
			if = {
				limit = {
					not = {
						has_country_flag = MAN_bandits_recruited
					}
				}
				division_template = {
					name = "Redemption Army"
					priority = 1
					is_locked = yes
					division_names_group = MAN_CAV_01
					regiments = {
						cavalry = { x = 0 y = 0 }
						cavalry = { x = 0 y = 1 }
						cavalry = { x = 0 y = 2 }

						cavalry = { x = 1 y = 0 }
						cavalry = { x = 1 y = 1 }
						cavalry = { x = 1 y = 2 }
					}
				}
				set_country_flag = MAN_bandits_recruited
			}
			random_owned_controlled_state = {
				limit = { ROOT = { has_full_control_of_state = PREV } }
				prioritize = { 714 }
				create_unit = {
					division = "name = \"1. Northern Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
				create_unit = {
					division = "name = \"2. Northern Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
			}
			clr_country_flag = MAN_northern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_western_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}
	MAN_recruit_bandits_west = {
		icon = generic_civil_support

		available = {
			has_country_flag = MAN_western_bandits
			has_completed_focus = connect_with_the_banditry
		}
		visible = {
			has_country_flag = MAN_western_bandits
		}
		ai_will_do = {
			factor = 10
		}
		cost = 50
		complete_effect = {
			if = {
				limit = {
					not = {
						has_country_flag = MAN_bandits_recruited
					}
				}
				division_template = {
					name = "Redemption Army"
					priority = 1
					is_locked = yes
					division_names_group = MAN_CAV_01
					regiments = {
						cavalry = { x = 0 y = 0 }
						cavalry = { x = 0 y = 1 }
						cavalry = { x = 0 y = 2 }

						cavalry = { x = 1 y = 0 }
						cavalry = { x = 1 y = 1 }
						cavalry = { x = 1 y = 2 }
					}
				}
				set_country_flag = MAN_bandits_recruited
			}
			random_owned_controlled_state = {
				limit = { ROOT = { has_full_control_of_state = PREV } }
				prioritize = { 610 }
				create_unit = {
					division = "name = \"1. Western Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
				create_unit = {
					division = "name = \"2. Western Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
			}
			clr_country_flag = MAN_western_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_eastern_bandits }
					NOT = { has_country_flag = MAN_northern_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}
	MAN_recruit_bandits_east = {
		icon = generic_civil_support

		available = {
			has_country_flag = MAN_eastern_bandits
			has_completed_focus = connect_with_the_banditry
		}
		visible = {
			has_country_flag = MAN_eastern_bandits
		}
		ai_will_do = {
			factor = 10
		}
		cost = 50
		complete_effect = {
			if = {
				limit = {
					not = {
						has_country_flag = MAN_bandits_recruited
					}
				}
				division_template = {
					name = "Redemption Army"
					priority = 1
					is_locked = yes
					division_names_group = MAN_CAV_01
					regiments = {
						cavalry = { x = 0 y = 0 }
						cavalry = { x = 0 y = 1 }
						cavalry = { x = 0 y = 2 }

						cavalry = { x = 1 y = 0 }
						cavalry = { x = 1 y = 1 }
						cavalry = { x = 1 y = 2 }
					}
				}
				set_country_flag = MAN_bandits_recruited
			}
			random_owned_controlled_state = {
				limit = { ROOT = { has_full_control_of_state = PREV } }
				prioritize = { 717 }
				create_unit = {
					division = "name = \"1. Eastern Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
				create_unit = {
					division = "name = \"2. Eastern Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
			}
			clr_country_flag = MAN_eastern_bandits
			if = {
				limit = {
					NOT = { has_country_flag = MAN_western_bandits }
					NOT = { has_country_flag = MAN_northern_bandits }
				}
				remove_ideas = MAN_banditry
			}
		}
	}
	MAN_recruit_bandits_generic = {
		icon = generic_civil_support

		available = {
		}
		visible = {
			has_completed_focus = connect_with_the_banditry
		}
		ai_will_do = {
			factor = 10
		}
		cost = 50
		fire_only_once = yes
		complete_effect = {
			if = {
				limit = {
					not = {
						has_country_flag = MAN_bandits_recruited
					}
				}
				division_template = {
					name = "Redemption Army"
					priority = 1
					is_locked = yes
					division_names_group = MAN_CAV_01
					regiments = {
						cavalry = { x = 0 y = 0 }
						cavalry = { x = 0 y = 1 }
						cavalry = { x = 0 y = 2 }

						cavalry = { x = 1 y = 0 }
						cavalry = { x = 1 y = 1 }
						cavalry = { x = 1 y = 2 }
					}
				}
				set_country_flag = MAN_bandits_recruited
			}
			random_owned_controlled_state = {
				limit = { ROOT = { has_full_control_of_state = PREV } }
				prioritize = { 328 }
				create_unit = {
					division = "name = \"1. Manchu Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
				create_unit = {
					division = "name = \"2. Manchu Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
				create_unit = {
					division = "name = \"3. Manchu Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
					owner = MAN
				}
			}
		}
	}
	MAN_release_bandits = {
		icon = generic_civil_support

		available = {
			
		}
		visible = {
			has_country_flag = MAN_bandits_recruited
		}
		ai_will_do = {
			factor = 1
			modifier = {
				OR = {
					not = {
						has_completed_focus = loyal_no_more
					}
					has_war = yes	
				}
				factor = 0
			}
		}
		cost = 0
		
		complete_effect = {
			add_manpower = 10000
			delete_unit_template_and_units = { division_template = "Redemption Army" }
			clr_country_flag = MAN_bandits_recruited
		}
	}
}
