#events to give Soviet AI a chance against Germany and simulate the historical attrition of the German troops

add_namespace = gersovwar

#### NOT NEEDED IN LA RESISTANCE - GERMANY WAS NERFED
#### Brought back in No Step Back to give the Soviet AI a chance
#Word of warning for Germany and tick start
country_event = {
	id = gersovwar.0
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		#SOV = { surrender_progress > 0.0 } #it will activate even if the Soviets don't lose a single province
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		NOT = { has_country_flag = attrition_in_russia_0_flag }
		NOT = { has_country_flag = attrition_in_russia_1_flag }
		NOT = { has_country_flag = attrition_in_russia_2_flag }
		NOT = { has_country_flag = attrition_in_russia_3_flag }
		NOT = { has_country_flag = attrition_in_russia_4_flag }
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		add_ideas = attrition_in_russia_0
		set_country_flag = attrition_in_russia_0_flag
		set_country_flag = attrition_in_russia_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}

#5 events making the attrition worse
country_event = {
	id = gersovwar.1
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			SOV = { surrender_progress > 0.2 }
			AND = {			
				date > 1941.12.12
				is_historical_focus_on = yes #no other way to confirm the date when this happens
			}
		}
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		has_country_flag = attrition_in_russia_0_flag
		NOT = { has_country_flag = attrition_in_russia_1_flag }
		NOT = { has_country_flag = attrition_in_russia_2_flag }
		NOT = { has_country_flag = attrition_in_russia_3_flag }
		NOT = { has_country_flag = attrition_in_russia_4_flag }
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		swap_ideas = {
			remove_idea = attrition_in_russia_0
			add_idea = attrition_in_russia_1
		}
		clr_country_flag = attrition_in_russia_0_flag
		set_country_flag = attrition_in_russia_1_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}
country_event = {
	id = gersovwar.2
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			SOV = { surrender_progress > 0.35 }
			AND = {			
				date > 1942.12.12
				is_historical_focus_on = yes #no other way to confirm the date when this happens
			}
		}
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		NOT = { has_country_flag = attrition_in_russia_0_flag }
		has_country_flag = attrition_in_russia_1_flag
		NOT = { has_country_flag = attrition_in_russia_2_flag }
		NOT = { has_country_flag = attrition_in_russia_3_flag }
		NOT = { has_country_flag = attrition_in_russia_4_flag }
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		swap_ideas = {
			remove_idea = attrition_in_russia_1
			add_idea = attrition_in_russia_2
		}
		clr_country_flag = attrition_in_russia_1_flag
		set_country_flag = attrition_in_russia_2_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}

country_event = {
	id = gersovwar.3
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			SOV = { surrender_progress > 0.5 }
			AND = {			
				date > 1943.6.6
				is_historical_focus_on = yes #no other way to confirm the date when this happens
			}
		}
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		NOT = { has_country_flag = attrition_in_russia_0_flag }
		NOT = { has_country_flag = attrition_in_russia_1_flag }
		has_country_flag = attrition_in_russia_2_flag
		NOT = { has_country_flag = attrition_in_russia_3_flag }
		NOT = { has_country_flag = attrition_in_russia_4_flag }
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		swap_ideas = {
			remove_idea = attrition_in_russia_2
			add_idea = attrition_in_russia_3
		}
		clr_country_flag = attrition_in_russia_2_flag
		set_country_flag = attrition_in_russia_3_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}

country_event = {
	id = gersovwar.4
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			SOV = { surrender_progress > 0.65 }
			AND = {			
				date > 1943.12.12
				is_historical_focus_on = yes #no other way to confirm the date when this happens
			}
		}
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		NOT = { has_country_flag = attrition_in_russia_0_flag }
		NOT = { has_country_flag = attrition_in_russia_1_flag }
		NOT = { has_country_flag = attrition_in_russia_2_flag }
		has_country_flag = attrition_in_russia_3_flag
		NOT = { has_country_flag = attrition_in_russia_4_flag }
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		swap_ideas = {
			remove_idea = attrition_in_russia_3
			add_idea = attrition_in_russia_4
		}
		clr_country_flag = attrition_in_russia_3_flag
		set_country_flag = attrition_in_russia_4_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}

country_event = {
	id = gersovwar.5
	title = gersovwar.0.t
	desc = gersovwar.0.d

	picture = GFX_report_german_soviet_war
	
	#fire_only_once = yes

	trigger = {
		tag = GER
		has_war_with = SOV
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			SOV = { surrender_progress > 0.8 }
			AND = {			
				date > 1944.6.6
				is_historical_focus_on = yes #no other way to confirm the date when this happens
			}
		}
		has_government = fascism
		SOV = { has_government = communism }
		GER = { is_faction_leader = yes }
		SOV = { is_faction_leader = yes }
		SOV = {
			OR = {
				controls_state = 219 # Moscow
				#controls_state = 214 # Arkhangelsk
				controls_state = 195 # Leningrad 
				controls_state = 217 # Stalingrad
			}
		}
		NOT = { has_country_flag = attrition_in_russia_0_flag }
		NOT = { has_country_flag = attrition_in_russia_1_flag }
		NOT = { has_country_flag = attrition_in_russia_2_flag }
		NOT = { has_country_flag = attrition_in_russia_3_flag }
		has_country_flag = attrition_in_russia_4_flag
		NOT = { has_country_flag = attrition_in_russia_5_flag }
	}

	immediate = {
		swap_ideas = {
			remove_idea = attrition_in_russia_4
			add_idea = attrition_in_russia_5
		}
		clr_country_flag = attrition_in_russia_4_flag
		set_country_flag = attrition_in_russia_5_flag
	}

	option = {
		name = gersovwar.0.a
	}	
}

country_event = {
	id = gersovwar.6
	title = gersovwar.6.t
	desc = gersovwar.6.d

	picture = GFX_report_german_soviet_war
	
	fire_only_once = yes

	trigger = {
		tag = GER
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		has_country_flag = attrition_in_russia_flag
		OR = {
			NOT = { has_war_with = SOV }
			AND = {
				NOT = {	SOV = {	controls_state = 219 } } # Moscow 
				NOT = {	SOV = {	controls_state = 195 } }
				NOT = {	SOV = {	controls_state = 217 } }
			}
		}
		OR = {
			has_country_flag = attrition_in_russia_0_flag
			has_country_flag = attrition_in_russia_1_flag
			has_country_flag = attrition_in_russia_2_flag
			has_country_flag = attrition_in_russia_3_flag
			has_country_flag = attrition_in_russia_4_flag
			has_country_flag = attrition_in_russia_5_flag
		}
	}

	immediate = {
		remove_ideas = {
			attrition_in_russia_0
			attrition_in_russia_1
			attrition_in_russia_2
			attrition_in_russia_3
			attrition_in_russia_4
			attrition_in_russia_5
		}
		clr_country_flag = attrition_in_russia_0_flag
		clr_country_flag = attrition_in_russia_1_flag
		clr_country_flag = attrition_in_russia_2_flag
		clr_country_flag = attrition_in_russia_3_flag		
		clr_country_flag = attrition_in_russia_4_flag
		clr_country_flag = attrition_in_russia_5_flag
		clr_country_flag = attrition_in_russia_flag
	}

	option = {
		name = gersovwar.6.a
	}	
}

country_event = {
	id = gersovwar.21
	title = gersovwar.21.t
	desc = gersovwar.21.d

	picture = GFX_report_german_soviet_war
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		has_war_with = GER
		NOT = { has_global_flag = block_hiep_ideas_soviets }
		OR = {
			controls_state = 219 # Moscow
			#controls_state = 214 # Arkhangelsk
			controls_state = 195 # Leningrad 
			controls_state = 217 # Stalingrad
		}
		date > 1943.8.8
	}

	option = {
		name = gersovwar.21.a
		ai_chance = { factor = 100 }
		add_timed_idea = {
			idea = major_soviet_offensive_1944
			days = 1195
		}
	}	

	option = {
		name = gersovwar.21.b
	}	
}

#Soviet Union clean-up
country_event = {
	id = gersovwar.22
	title = gersovwar.22.t
	desc = gersovwar.22.d

	picture = GFX_report_german_soviet_war
	
	fire_only_once = yes

	trigger = {
		tag = SOV
		GER = { is_ai = yes }
		NOT = { owns_state = 219 }
		NOT = { owns_state = 195 }
		NOT = { owns_state = 217 }
		is_puppet = no
		OR = {
			219 = { is_owned_by = GER }
			195 = { is_owned_by = GER }
			217 = { is_owned_by = GER }
		}
	}

	option = {
		name = gersovwar.22.a
		GER = {
			annex_country = {
				target = SOV
				transfer_troops = no
			}
		}	
	}
}

#Germany is weak as hell in La Resistance (so we have to give them just a little boost against France)
#country_event = {
#	id = gersovwar.23
#	
#	fire_only_once = yes
#
#	trigger = {
#		tag = GER
#		is_historical_focus_on = yes
#		NOT = { has_global_flag = block_hiep_ideas }
#		has_war = yes
#		is_ai = yes
#		POL = { is_ai = yes }
#		#FRA = { is_ai = yes }
#	}
#
#	mean_time_to_happen = {
#		days = 2
#	}
#
#	hidden = yes
#
#	immediate = {
#		add_timed_idea = {
#			idea = blitzkrieg_1939_1941
#			days = 580
#		}
#	}
#}

#Help the poor AI with equipment so that the Anschluss may happen - workaround bugfix (no longer needed for 1.11)
#country_event = {
#	id = gersovwar.24
#	
#	fire_only_once = yes
#
#	trigger = {
#		tag = GER
#		NOT = { has_global_flag = disable_AI_tweaks_hiep }
#		is_historical_focus_on = yes
#		date > 1937.1.1
#		date < 1938.1.1
#		is_ai = yes
#	}
#
#	mean_time_to_happen = {
#		days = 2
#	}
#
#	hidden = yes
#
#	immediate = {
#		add_equipment_to_stockpile = {
#			type = anti_air_equipment
#			amount = 1500
#    			producer = GER
#		}
#		add_equipment_to_stockpile = {
#			type = artillery_equipment
#			amount = 8000
#    			producer = GER
#		}
#	}
#}

#Turkey in the Axis - part I
country_event = {
	id = gersovwar.31
	title = gersovwar.31.t
	desc = gersovwar.31.d
	picture = GFX_report_event_german_turkish_pact

	fire_only_once = yes

	trigger = {
		tag = GER
		has_government = fascism
		AND = {
			TUR = { 
				OR = {
					is_in_faction = no
					is_in_faction_with = GER
				}
			}
			country_exists = TUR
			OR = {
				AND = {
					219 = { is_controlled_by = GER } #Moscow
					195 = { is_controlled_by = GER } #Leningrad
					217 = { is_controlled_by = GER } #Stalingrad
				}
				NOT = { country_exists = SOV }
			}
		}
	}

	option = {
		name = gersovwar.31.a
		ai_chance = { factor = 100 }
		TUR = { country_event = { id = gersovwar.32 } }
	}

	option = {
		name = gersovwar.31.b
	}
}

#Turkey in the Axis - part II
country_event = {
	id = gersovwar.32
	title = gersovwar.32.t
	desc = gersovwar.32.d
	picture = GFX_report_event_german_turkish_pact

	#fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = gersovwar.32.a
		ai_chance = { factor = 100 }
		GER = { add_to_faction = TUR }
	}

	option = {
		name = gersovwar.32.b
	}
}

#Spain in the Axis - part I
country_event = {
	id = gersovwar.33
	title = gersovwar.33.t
	desc = gersovwar.33.d
	picture = GFX_report_event_spr_franco_victory

	fire_only_once = yes

	trigger = {
		tag = GER
		has_government = fascism
		AND = {
			SPR = { 
				OR = {
					is_in_faction = no
					is_in_faction_with = GER
				}
			}
			country_exists = SPR
			OR = {
				AND = {
					219 = { is_controlled_by = GER } #Moscow
					195 = { is_controlled_by = GER } #Leningrad
					217 = { is_controlled_by = GER } #Stalingrad
				}
				NOT = { country_exists = SOV }
			}
		}
	}

	option = {
		name = gersovwar.33.a
		ai_chance = { factor = 100 }
		SPR = { country_event = { id = gersovwar.34 } }
	}

	option = {
		name = gersovwar.33.b
	}
}

#Spain in the Axis - part II
country_event = {
	id = gersovwar.34
	title = gersovwar.34.t
	desc = gersovwar.34.d
	picture = GFX_report_event_spr_franco_victory

	#fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = gersovwar.34.a
		ai_chance = { factor = 100 }
		GER = { add_to_faction = SPR }
	}

	option = {
		name = gersovwar.34.b
	}
}