#	Example:
# 
#	example_effect = {
#		add_political_power = 66
#		add_popularity = {
#			ideology = fascism
#			popularity = 0.33
#		}
#	}
#
#
#	In a script file:
#
#	effect = {
#		example_effect = yes
#	}
#

SS_set_templates = {
	if = {
		limit = {
			NOT = {
				has_country_flag = SS_motorised_division
			}
			NOT = {
				has_tech = mechanised_infantry
			}
		}
		SS_motorised_division = yes
	}
	if = {
		limit = {
			NOT = {
				has_country_flag = SS_mechanised_division_early
			}
			has_tech = mechanised_infantry	
		}
		SS_mechanised_division_early = yes
	}
	if = {
		limit = {
			NOT = {
				has_country_flag = SS_mechanised_division_late
			}
			AND = {
				has_tech = mechanised_infantry
				has_tech = basic_medium_td
				has_tech = basic_medium_art
			}
		}
		SS_mechanised_division_late = yes
	}
	if = {
		limit = {
			AND = {
				NOT = { has_country_flag = SS_armored_division_early }
				NOT = {
					OR = {
						has_tech = basic_medium_tank
						has_tech = improved_medium_tank
						has_tech = advanced_medium_tank
						has_tech = basic_medium_tank_chassis #just one needed because nsb medium tree has no bypasses
					}
				}
				NOT = {
					has_tech = mechanised_infantry
				}
			}
		}
		SS_armored_division_early = yes
	}
	if = {
		limit = {
			AND = {
				NOT = { has_country_flag = SS_armored_division_improved }
				OR = {
					has_tech = basic_medium_tank
					has_tech = improved_medium_tank
					has_tech = advanced_medium_tank
					has_tech = basic_medium_tank_chassis #just one needed because nsb medium tree has no bypasses
				}
				NOT = {
					has_tech = mechanised_infantry
				}
			}
		}
		SS_armored_division_improved = yes
	}
	if = {
		limit = {
			AND = {
				NOT = { has_country_flag = SS_armored_division_late }
				OR = {
					has_tech = basic_medium_tank
					has_tech = improved_medium_tank
					has_tech = advanced_medium_tank
					has_tech = basic_medium_tank_chassis #just one needed because nsb medium tree has no bypasses
				}
				has_tech = mechanised_infantry
			}
		}
		SS_armored_division_late = yes
	}
}

SS_motorised_division = {
	set_country_flag = SS_motorised_division
	division_template = {
		name = "SS Motorisierte Division"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			SS_motorized = { x = 0 y = 0 }
			SS_motorized = { x = 0 y = 1 }
			SS_motorized = { x = 0 y = 2 }

			SS_motorized = { x = 1 y = 0 }
			SS_motorized = { x = 1 y = 1 }
			SS_motorized = { x = 1 y = 2 }

			SS_motorized = { x = 2 y = 0 }
			SS_motorized = { x = 2 y = 1 }
			SS_motorized = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
		override_model = GER_infantry_alt_0_entity
	}
}
SS_mechanised_division_early = {
	set_country_flag = SS_mechanised_division_early
	division_template = {
		name = "SS Panzergrenadier Division"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			SS_mechanized = { x = 0 y = 0 }
			SS_mechanized = { x = 0 y = 1 }
			SS_mechanized = { x = 0 y = 2 }

			SS_mechanized = { x = 1 y = 0 }
			SS_mechanized = { x = 1 y = 1 }
			SS_mechanized = { x = 1 y = 2 }
			
			SS_mechanized = { x = 2 y = 0 }
			SS_mechanized = { x = 2 y = 1 }
			SS_mechanized = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
		override_model = GER_infantry_alt_0_entity
	}
}

SS_mechanised_division_late = {
	set_country_flag = SS_mechanised_division_late
	division_template = {
		name = "SS Panzergrenadier Division (n.A.)"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			SS_mechanized = { x = 0 y = 0 }
			SS_mechanized = { x = 0 y = 1 }
			SS_mechanized = { x = 0 y = 2 }

			SS_mechanized = { x = 1 y = 0 }
			SS_mechanized = { x = 1 y = 1 }
			SS_mechanized = { x = 1 y = 2 }

			medium_tank_destroyer_brigade = { x = 2 y = 0 }
			medium_sp_artillery_brigade = { x = 2 y = 1 }
			medium_sp_artillery_brigade = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
		override_model = GER_infantry_alt_0_entity
	}
}

SS_armored_division_early = {
	set_country_flag = SS_armored_division_early
	division_template = {
		name = "SS Panzer Division"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			light_armor = { x = 0 y = 0 }
			light_armor = { x = 0 y = 1 }
			light_armor = { x = 0 y = 2 }
			light_armor = { x = 0 y = 3 }

			SS_motorized = { x = 1 y = 0 }
			SS_motorized = { x = 1 y = 1 }
			SS_motorized = { x = 1 y = 2 }

			SS_motorized = { x = 2 y = 0 }
			SS_motorized = { x = 2 y = 1 }
			SS_motorized = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
	}
}

SS_armored_division_improved = {
	set_country_flag = SS_armored_division_improved
	division_template = {
		name = "SS Panzer Division (n.A.)"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			medium_armor = { x = 0 y = 0 }
			medium_armor = { x = 0 y = 1 }
			medium_armor = { x = 0 y = 2 }
			medium_armor = { x = 0 y = 3 }
			
			SS_motorized = { x = 1 y = 0 }
			SS_motorized = { x = 1 y = 1 }
			SS_motorized = { x = 1 y = 2 }

			SS_motorized = { x = 2 y = 0 }
			SS_motorized = { x = 2 y = 1 }
			SS_motorized = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
	}
}
SS_armored_division_late = {
	set_country_flag = SS_armored_division_late
	division_template = {
		name = "SS Panzer Division (vollgep.)"
		priority = 2
		division_names_group = GER_SS_01
		is_locked = yes
		regiments = {
			medium_armor = { x = 0 y = 0 }
			medium_armor = { x = 0 y = 1 }
			medium_armor = { x = 0 y = 2 }
			medium_armor = { x = 0 y = 3 }

			SS_mechanized = { x = 1 y = 0 }
			SS_mechanized = { x = 1 y = 1 }
			SS_mechanized = { x = 1 y = 2 }

		SS_mechanized = { x = 2 y = 0 }
	    SS_mechanized = { x = 2 y = 1 }
	    SS_mechanized = { x = 2 y = 2 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			mot_recon = { x = 0 y = 2 }
		}
	}
}
SS_infantry_division = {
	set_country_flag = SS_infantry_division
	division_template = {
		name = "SS Waffen-Grenadier-Division"
		priority = 2
		division_names_group = GER_SS_01
		template_counter = 101
		is_locked = yes
		regiments = {
			SS_infantry = { x = 0 y = 0 }
			SS_infantry = { x = 0 y = 1 }
			SS_infantry = { x = 0 y = 2 }
			SS_infantry = { x = 0 y = 3 }
		
			SS_infantry = { x = 1 y = 0 }
			SS_infantry = { x = 1 y = 1 }
			SS_infantry = { x = 1 y = 2 }

			artillery_brigade = { x = 2 y = 0 }
			artillery_brigade = { x = 2 y = 1 }
		}
		support = {
			artillery = { x = 0 y = 0 }
			engineer = { x = 0 y = 1 }
			recon = { x = 0 y = 2 }
		}
		override_model = GER_militia
	}
}
SS_resolve_effects_wehrmacht = {
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 0 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 10 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.10 days = 1 } } #generals protest
			50 = {}
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 10 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 20 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.10 days = 1 } } #generals protest
			25 = { country_event = { id = ss_recruitment_event.11 days = 1 } } #general resigns in protest
			25 = {}
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 20 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 30 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.10 days = 1 } } #generals protest
			25 = { country_event = { id = ss_recruitment_event.11 days = 1 } } #general resigns in protest
			25 = { country_event = { id = ss_recruitment_event.12 days = 1 } } #generals plot
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 30 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 40 }
			}
		}
		random_list = {
			35 = { country_event = { id = ss_recruitment_event.10 days = 1 } } #generals protest
			35 = { country_event = { id = ss_recruitment_event.11 days = 1 } } #general resign
			30 = { country_event = { id = ss_recruitment_event.12 days = 1 } } #generals plot
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 40 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 50 }
			}
		}
		random_list = {
			35 = { country_event = { id = ss_recruitment_event.11 days = 1 } } #general resigns
			55 = { country_event = { id = ss_recruitment_event.12 days = 1 } } #generals plot
			10 = { 
				modifier = {
					NOT = {
						any_unit_leader = {
							has_unit_leader_flag = GER_SS_conspirator
						}
					}
					factor = 0
				}
				country_event = { id = ss_recruitment_event.13 days = 1 } 
			} #assassination attempt
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = wehrmacht_anger value = 50 compare = greater_than_or_equals }
				check_variable = { wehrmacht_anger < 60 }
			}
		}
		random_list = {
			75 = { country_event = { id = ss_recruitment_event.12 days = 1 } } #generals plot
			15 = { 
				modifier = {
					NOT = {
						any_unit_leader = {
							has_unit_leader_flag = GER_SS_conspirator
						}
					}
					factor = 0
				}
				country_event = { id = ss_recruitment_event.13 days = 1 } 
			} #assassination attempt
			10 = { country_event = { id = ss_recruitment_event.14 days = 1 } } #civil war
		}
	}
	if = {
		limit = {
			check_variable = { var = wehrmacht_anger value = 60 compare = greater_than_or_equals }
		}
		random_list = {
			15 = { 
				modifier = {
					NOT = {
						any_unit_leader = {
							has_unit_leader_flag = GER_SS_conspirator
						}
					}
					factor = 0
				}
				country_event = { id = ss_recruitment_event.13 days = 1 } 
			} #assassination attempt
			10 = { country_event = { id = ss_recruitment_event.14 days = 1 } } #civil war
		}
	}
}

SS_resolve_effects_ss = {
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 0 compare = greater_than_or_equals }
				check_variable = { SS_anger < 10 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.20 days = 1 } } #Himmler protests
			50 = {}
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 10 compare = greater_than_or_equals }
				check_variable = { SS_anger < 20 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.20 days = 1 } } #Himmler protest
			25 = { country_event = { id = ss_recruitment_event.21 days = 1 } } #secret meeting of SS officers
			25 = {}
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 20 compare = greater_than_or_equals }
				check_variable = { SS_anger < 30 }
			}
		}
		random_list = {
			50 = { country_event = { id = ss_recruitment_event.20 days = 1 } } #Himmler protest
			25 = { country_event = { id = ss_recruitment_event.21 days = 1 } } #SS officials meet
			25 = { country_event = { id = ss_recruitment_event.22 days = 1 } } #SS reroutes factory output
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 30 compare = greater_than_or_equals }
				check_variable = { SS_anger < 40 }
			}
		}
		random_list = {
			35 = { country_event = { id = ss_recruitment_event.21 days = 1 } } #SS officials meet
			35 = { country_event = { id = ss_recruitment_event.22 days = 1 } } #SS reroutes factory output
			30 = { country_event = { id = ss_recruitment_event.23 days = 1 } } #Himmler plots plot
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 40 compare = greater_than_or_equals }
				check_variable = { SS_anger < 50 }
			}
		}
		random_list = {
			35 = { country_event = { id = ss_recruitment_event.21 days = 1 } } #SS officials meet
			55 = { country_event = { id = ss_recruitment_event.23 days = 1 } } #Himmler plots
			10 = { country_event = { id = ss_recruitment_event.24 days = 1 } } #assassination attempt - SS
		}
	}
	if = {
		limit = {
			AND = {
				check_variable = { var = SS_anger value = 50 compare = greater_than_or_equals }
				check_variable = { SS_anger < 60 }
			}
		}
		random_list = {
			75 = { country_event = { id = ss_recruitment_event.23 days = 1 } } #Himmler plots
			15 = { country_event = { id = ss_recruitment_event.24 days = 1 } } #assassination attempt - SS
			10 = { country_event = { id = ss_recruitment_event.25 days = 1 } } #fascist on fascist violence
		}
	}
	if = {
		limit = {
			check_variable = { var = SS_anger value = 60 compare = greater_than_or_equals }
		}
		random_list = {
			15 = { country_event = { id = ss_recruitment_event.24 days = 1 } } #assassination attempt - SS
			10 = { country_event = { id = ss_recruitment_event.25 days = 1 } } #fascist on fascist violence
		}
	}
}