
GGR_initialize_SAW = {

	custom_effect_tooltip = SGR_SAW_entry_tt
	hidden_effect = {
		add_dynamic_modifier = { modifier = GER_GGR_student_protests_dynamic_modifier }
		add_ideas = GER_GGR_student_protests_new
	
		set_variable = {GGR_SAW_max_stab_hit = 0.05}
		set_variable = {GGR_SAW_max_pp_hit = 0.1}

		activate_mission = GGR_SAW_war_report

		set_country_flag = GER_SAW_intervention
		TNO_fopo_add_saw_tab = yes
	
		GGR_SAW_protest_growth = yes

		set_temp_variable = { tension_WT = 5 }
		set_temp_variable = { tension_superpower_1 = GER }
		set_temp_variable = { tension_superpower_2 = USA }
		set_temp_variable = { tension_id = 27 }
		TNO_change_tension = yes

		set_variable = {GGR_SAW_involvement = 15 }
		set_variable = {GGR_SAW_civilian_protest = 10}
		set_variable = {GGR_SAW_civilian_protest_growth_base = 0.5}
		set_variable = {GGR_SAW_involvement_check = GGR_SAW_involvement}
		set_variable = {GER_advisor_level = 0}
	}
}

GGR_conclude_SAW = {

	remove_mission = GGR_SAW_war_report

	clr_country_flag = GGR_SAW_withdrawal

	clr_country_flag = GER_SAW_intervention

	custom_effect_tooltip = SGR_SAW_conclude_tt
	
	remove_ideas = GER_GGR_student_protests_new
	remove_dynamic_modifier = { modifier = GER_GGR_student_protests_dynamic_modifier }
	hidden_effect = {
		set_temp_variable = { target = COG }
		TNO_clear_num_volunteers = yes
		set_temp_variable = { target = ANG }
		TNO_clear_num_volunteers = yes
		set_temp_variable = { target = GRO }
		TNO_clear_num_volunteers = yes
	}
	GRO_REICHSSTAAT_calculate_cabal_power = yes
	clear_variable = GGR_SAW_involvement
	clear_variable = GGR_SAW_civilian_protest
	clear_variable = GGR_SAW_civilian_protest_growth_base
	clear_variable = GGR_civ_protest_soc_impact

	#Calculating how many soldiers end up returning

	set_temp_variable = {tempSoldiers = 1}

	randomize_temp_variable = {
		var = tempSoldiers
		distribution = uniform
		min = 0.5
		max = 0.8
	}

	multiply_variable = {GGR_SAW_manpower = tempSoldiers}

	round_variable = GGR_SAW_manpower

	TNO_fopo_remove_saw_tab = yes
	TNO_fopo_remove_saw_withdrawal_tab = yes
	COG = {	
		every_unit_leader = {
			limit = { has_id = 70 }
			set_nationality = GER
		}
	}

	add_ideas = GER_Hans_Speidel_army_chief

	promote_character = {
		character = GER_hans_speidel
		ideology = despotism_military_junta_subtype
	}

	remove_advisor_role = {
		character = GER_hans_speidel
		slot = army_chief
	}

	add_advisor_role = {
		character = GER_hans_speidel
		activate = yes
		advisor = {
			slot = army_chief
			idea_token = GER_Hans_Speidel_army_chief
			ledger = army
			traits = {
				army_chief
				army_chief_organizational_2
				army_chief_reform_2
			}
			cost = -1
			can_be_fired = no
		}
	}
	add_ideas = GER_Hans_Speidel_army_chief

	every_country = {
		limit = { has_idea = RK_speidel_in_africa }
		remove_ideas = RK_speidel_in_africa
	}
	every_country = {
		limit = { has_idea = RK_negiotiate_in_pretoria }
		remove_ideas = RK_negiotiate_in_pretoria
	}

	every_country = {
		limit = { has_idea = RK_army_group_afrika }
		remove_ideas = RK_army_group_afrika
	}

}

GGR_SAW_protest_growth = {

	clamp_variable = {
		var = GGR_SAW_civilian_protest_growth_base
		min = 0
		max = 10
	}
	
	add_to_variable = {GGR_SAW_civilian_protest = GGR_SAW_civilian_protest_growth_base}
	multiply_variable = {GGR_SAW_civilian_protest_growth_base = 1.5}

	GGR_SAW_calculate_idea_values = yes

	custom_effect_tooltip = GGR_SAW_war_report_predic_tt

	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}

	#Calculating the Social Outlook impact

	set_temp_variable = {tempProtest = GGR_SAW_civilian_protest}

	multiply_temp_variable = {tempProtest = 0.1}
	
	set_variable = {GGR_civ_protest_soc_impact = tempProtest}

	#Events

	if = {
		limit = {
			check_variable = {GGR_SAW_civilian_protest > 30}
		}
		country_event = {
			id = SpeerSAW.14
			days = 17
		}
	}
	else_if = {
		limit = {
			check_variable = {GGR_SAW_civilian_protest > 50}
		}
		country_event = {
			id = SpeerSAW.15
			days = 8
		}
	}
	else_if = {
		limit = {
			check_variable = {GGR_SAW_civilian_protest > 70}
		}
		country_event = {
			id = SpeerSAW.16
			days = 20
		}
	}
}

GGR_SAW_calculate_idea_values = {
	
	set_temp_variable = {tempStab = GGR_SAW_max_stab_hit}
	set_temp_variable = {tempPP = GGR_SAW_max_pp_hit}
	set_temp_variable = {tempProtest = GGR_SAW_civilian_protest}
	
	multiply_temp_variable = {tempProtest = 0.01}
	divide_temp_variable = {tempProtest = 2}

	multiply_temp_variable = {tempStab = tempProtest}
	multiply_temp_variable = {tempStab = -1}
	multiply_temp_variable = {tempPP = tempProtest}
	multiply_temp_variable = {tempPP = -1}

	set_variable = {GGR_protests_severity_pp = tempPP}
	set_variable = {GGR_protests_severity_stab = tempStab}
}

GGR_SAW_robbery_policy = {
	set_country_flag = GGR_SAW_strat_rob
	add_timed_idea = {
		idea = GER_GGR_defensive_strat_SAW
		days = 90
	}
	set_temp_variable = { gdp_growth_temp = 1.25 }
	econ_gdp_growth_change = yes
	custom_effect_tooltip = SGR_SAW_strat_rob_tt
}

GGR_SAW_victory_policy = {
	set_country_flag = SGR_SAW_strat_win
	add_timed_idea = {
		idea = GER_GGR_offensive_strat_SAW
		days = 90
	}
	GRO = {
		add_timed_idea = {
			idea = GER_GGR_offensive_strat_SAW
			days = 90
		}
	}
	COG = {
		add_timed_idea = {
			idea = GER_GGR_offensive_strat_SAW
			days = 90
		}
	}
	ANG = {
		add_timed_idea = {
			idea = GER_GGR_offensive_strat_SAW
			days = 90
		}
	}
	TNO_improve_army_professionalism_low = yes
	TNO_improve_military_supervision_policy_effectiveness_monthly_low = yes
	custom_effect_tooltip = SGR_SAW_strat_win_tt
}

GGR_SAW_involvement_increase_small = {
	custom_effect_tooltip = SGR_SAW_involvement_increase_small_tt
	add_to_variable = {GGR_SAW_involvement = 2.5}
	add_to_variable = {GGR_SAW_civilian_protest = 2.5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_involvement_increase_med = {
	custom_effect_tooltip = SGR_SAW_involvement_increase_med_tt
	add_to_variable = {GGR_SAW_involvement = 5}
	add_to_variable = {GGR_SAW_civilian_protest = 5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_involvement_increase_big = {
	custom_effect_tooltip = SGR_SAW_involvement_increase_big_tt
	add_to_variable = {GGR_SAW_involvement = 10}
	add_to_variable = {GGR_SAW_civilian_protest = 10}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_involvement_decrease_small = {
	custom_effect_tooltip = SGR_SAW_involvement_decrease_small_tt
	subtract_from_variable = {GGR_SAW_involvement = 2.5}
	subtract_from_variable = {GGR_SAW_civilian_protest = 2.5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_involvement_decrease_med = {
	custom_effect_tooltip = SGR_SAW_involvement_decrease_med_tt
	subtract_from_variable = {GGR_SAW_involvement = 5}
	subtract_from_variable = {GGR_SAW_civilian_protest = 5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_involvement_decrease_big = {
	custom_effect_tooltip = SGR_SAW_involvement_decrease_big_tt
	subtract_from_variable = {GGR_SAW_involvement = 10}
	subtract_from_variable = {GGR_SAW_civilian_protest = 10}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_increase_small = {
	custom_effect_tooltip = SGR_SAW_protests_increase_small_tt
	add_to_variable = {GGR_SAW_civilian_protest = 2.5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_increase_med = {
	custom_effect_tooltip = SGR_SAW_protests_increase_med_tt
	add_to_variable = {GGR_SAW_civilian_protest = 5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_increase_big = {
	custom_effect_tooltip = SGR_SAW_protests_increase_big_tt
	add_to_variable = {GGR_SAW_civilian_protest = 10}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_decrease_small = {
	custom_effect_tooltip = SGR_SAW_protests_decrease_small_tt
	subtract_from_variable = {GGR_SAW_civilian_protest = 2.5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_decrease_med = {
	custom_effect_tooltip = SGR_SAW_protests_decrease_med_tt
	subtract_from_variable = {GGR_SAW_civilian_protest = 5}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}

GGR_SAW_protest_decrease_big = {
	custom_effect_tooltip = SGR_SAW_protests_decrease_big_tt
	subtract_from_variable = {GGR_SAW_civilian_protest = 10}
	clamp_variable = {
		var = GGR_SAW_civilian_protest
		min = 0
		max = 100
	}
	clamp_variable = {
		var = GGR_SAW_involvement
		min = 0
		max = 100
	}
}


GGR_fuck_huttig = {
	every_country = { goto_province = 13729 }
	launch_nuke = {
		province = 13729
	}
	hidden_effect = {		
		set_temp_variable_to_random = {
			var = GGR_lost_manpower
			min = -800000
			max = -600000
		}
		544 = {
			add_manpower = GGR_lost_manpower
			set_temp_variable = { state_value_multiplier_temp = 0.05 }
			econ_state_value_change_multiply = yes
		}
		add_victory_points = { province = 13729 value = -30 }
		GER = {
			country_event = goering_huttig.7
		}
		GRO = {
			country_event = goering_huttig.7
			load_focus_tree = {
				tree = GER_blankfocus
			}
		}
		every_country = {
			limit = { is_ai = no }
			news_event = { id = WORLD_REICH.308 days = 2 }
		}
	}
}