

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


sp_rockets_flying_bomb = {
	specialization = specialization_air 
	icon = GFX_sp_rockets_flying_bomb

	project_tags = {
		sp_tag_rocket
		sp_tag_guided_bomb
	}

	breakthrough_cost = {
		specialization_air = 2
	}

	resource_cost = {
		resources = { 
			steel = 8
			aluminium = 8
			tungsten = 2
		 }
	}

	ai_will_do = {
		base = 1
		modifier = {
			factor = 0.5
			ROOT = { is_major = no }
		}
		modifier = {
			factor = 0.5 # Play a bit safe until we have radar
			ROOT = { NOT = { has_tech = radio_detection } }
		}
	}

	complexity = sp_complexity.medium

	available = { 
		FROM = {
			has_tech = experimental_rockets
		}
	}

	
	prototype_time = sp_time.prototype.medium

	project_output = {
		country_effects = {
			custom_effect_tooltip = {
				localization_key = SP_UNLOCK_TECH
				TECH = sp_rockets_improved_guidance	
			}
			if = { 
				limit = {
					has_dlc = "By Blood Alone"
				}
				custom_effect_tooltip = {
					localization_key = SP_UNLOCK_TECH
					TECH = sp_rockets_rocket_bomber	
				}		
			}
		}
		enable_equipments = {
			guided_missile_equipment_1
		}
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3
	}

	unique_prototype_rewards = {
		
		# Design Choice
		sp_rocket_design_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 0
				max = 50
			}

			weight = {
				base = 50
			}
			
			option = {
				token = sp_rocket_design_choice_reward_balanced
				
				iteration_output = {
	
				}
			}

			option = {
				token = sp_rocket_design_choice_reward_range
				
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							maximum_speed = 0.05
							air_range = 0.1
							air_bombing = -0.05
						}
					}
				}
			}
			option = {
				token = sp_rocket_design_choice_reward_payload
				
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							air_bombing = 0.15
							air_range = -0.05
						}
					}
				}
			}

		}

		# Pulsejet Design
		sp_rockets_flying_bomb_technical_breakthrough_in_pulsejet_design_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 50
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_technical_breakthrough_in_pulsejet_design_reward_option
						
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							maximum_speed = 0.03
							air_range = 0.03
						}
					}
				}
			}
		}

		# Launch ramp innovations
		sp_rockets_flying_bomb_launch_ramp_innovations_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_launch_ramp_innovations_reward_option
						
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.low }
					}
				}
			}
		}

		# Mass Production
		sp_rockets_flying_bomb_mass_production_scaling_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_mass_production_scaling_reward_option
						
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							build_cost_ic = -0.05
						}
					}
				}
			}
		}

		# Engine Optimization
		sp_rockets_flying_bomb_engine_optimization_breakthrough_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_engine_optimization_breakthrough_reward_option
						
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							air_range = 0.03
						}
					}
				}
			}
		}

		# Technological Innovations
		sp_rockets_flying_bomb_technological_innovation_in_guidance_systems_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_technological_innovation_in_guidance_systems_reward_option
						
				iteration_output = {
					equipment_bonus = {
						guided_missile_equipment = {
							air_range = 0.03
							air_bombing = 0.03
						}
					}
				}
			}
		}
		# Test Flight Failures
		sp_rockets_flying_bomb_test_flight_failures_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_test_flight_failures_reward_option
						
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.low }
					}
					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.very_high
							specialization = specialization_air
						}
					}
				}
			}
		}
	}
}


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


# Ballistic Missiles - The V2 programme
sp_rockets_ballistic_missile = {
	specialization = specialization_air 
	breakthrough_cost = {
		specialization_air = 3
	}
	
	icon = GFX_sp_rockets_ballistic_missile
	
	project_tags = sp_tag_rocket

	complexity = sp_complexity.large

	resource_cost = {
		resources = {
			steel = 9 
			aluminium = 9
			chromium = 9
		}
	}

	available = { 
		FROM = {
			has_tech = experimental_rockets
		}
	}

	ai_will_do = {
		base = 1
		modifier = {
			factor = 0.5
			ROOT = { is_major = no }
		}
		modifier = {
			factor = 0.5 # Play a bit safe until we have radar
			ROOT = { NOT = { has_tech = radio_detection } }
		}
	}
	
	prototype_time = sp_time.prototype.medium

	project_output = {
		enable_equipments = {
			limit = {
				has_dlc = "Gotterdammerung"
			}
			ballistic_missile_equipment_1
		}
		enable_equipments = {
			limit = {
				NOT = { has_dlc = "Gotterdammerung" }
			}
			guided_missile_equipment_2
		}
		
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3	
	}

	unique_prototype_rewards = {
		sp_rocket_wind_tunnel_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 0
				max = 20
			}

			weight = {
				base = 1000.0
			}

			option = {
				token = sp_rocket_wind_tunnel_choice_reward_reject
				
				iteration_output = {
					country_effects = {
						
					}
				}
			}

			option = {
				token = sp_rocket_wind_tunnel_choice_reward_agree
				
				iteration_output = {
					country_effects = {
						add_timed_idea = {
							idea = special_project_consumer_costs_medium
							days = 365
						}
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.medium }
					}
				}
			}
		}

		sp_rocket_glass_wool_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 70
				max = 90
			}

			weight = {
				base = 10
			}

			option = {
				token = sp_rocket_glass_wool_choice_reward_accept
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.low }
					}
					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.low
							specialization = specialization_air
						}
					}
				}
			}
		}

		sp_rocket_guidance_system_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 30
				max = 60
			}

			weight = {
				base = 1000.0
				modifier = {
					factor = 0
					FROM = {	
						NOT = {
							AND = {
								has_tech = radio
								has_tech = mechanical_computing
							}
						}
					}
				}
				modifier = {
					factor = 0
					FROM = { has_country_flag = rocket_guidance_system_picked }
				}
			}

			option = {
				token = sp_rocket_guidance_system_choice_reward_mechanical
				iteration_output = {
					country_effects = { set_country_flag = rocket_guidance_system_picked }
					equipment_bonus = {
						ballistic_missile_equipment = {
							build_cost_ic = -0.1
						}
					}
				}
			}

			option = {
				token = sp_rocket_guidance_system_choice_reward_radio
				iteration_output = {
					country_effects = { set_country_flag = rocket_guidance_system_picked }
					equipment_bonus = {
						ballistic_missile_equipment = {
							air_bombing = 0.05
							build_cost_ic = 0.1
						}
					}
				}
			}
		}
	}
}


# Medium range Missiles
sp_rockets_medium_range_ballistic_missile = {
	specialization = specialization_air 
	
	icon = GFX_sp_rockets_medium_range_ballistic_missiles
	
	project_tags = sp_tag_rocket

	complexity = sp_complexity.large

	resource_cost = {
		resources = {
			steel = 12 
			aluminium = 9
			chromium = 9
		}
	}

	special_project_parent = {
		sp_rockets_ballistic_missile
	}

	available = { 
		
	}

	ai_will_do = {
		base = 1
	}
	
	prototype_time = sp_time.prototype.medium	

	project_output = {
		enable_equipments = {
			limit = {
				has_dlc = "Gotterdammerung"
			}
			ballistic_missile_equipment_2
		}
		enable_equipments = {
			limit = {
				NOT = { has_dlc = "Gotterdammerung" }
			}
			guided_missile_equipment_3
		}
		
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3		
	}

	unique_prototype_rewards = {
		sp_rocket_turbo_pump_froth_reward = {
			fire_only_once = yes

			threshold = { 
				min = 40
				max = 70
			}

			weight = {
				base = 10
			}

			option = {
				token = sp_rocket_turbo_pump_froth_reward_accept
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.medium }
					}
					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.low
							specialization = specialization_air
						}
					}
				}
			}
		}	

		sp_rocket_relay_failure_reward = {
			fire_only_once = yes

			threshold = { 
				min = 70
				max = 95
			}

			weight = {
				base = 10
			}

			option = {
				token = sp_rocket_relay_failure_reward_accept
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.low }
					}
				}
			}

			option = {
				token = sp_rocket_relay_failure_reward_reject
				iteration_output = {
					country_effects = {
						hidden_effect = {
							set_country_flag = refused_to_replace_relay_flag
						}
					}
				}
			}
		}
	}
}

# Long range Missiles
sp_rockets_long_range_ballistic_missile = {
	specialization = specialization_air 
	
	icon = GFX_sp_rockets_icbm
	
	project_tags = {
		sp_tag_rocket
		sp_tag_nuclear_warfare
	}

	complexity = sp_complexity.large
	resource_cost = {
		resources = {
			steel = 12 
			aluminium = 12
			chromium = 12
		}
	}
	allowed = {
		has_dlc = "Gotterdammerung"
	}

	special_project_parent = {
		sp_rockets_medium_range_ballistic_missile
		# ICBMs are intended to be only nuclear warhead carriers, so need to be able to do create these in order to complete project
		sp_nuclear_warheads
	}

	available = {
	}
	ai_will_do = {
		base = 1
	}
	
	prototype_time = sp_time.prototype.medium

	project_output = {
		enable_equipments = {
			#ballistic_missile_equipment_3
			nuclear_missile_equipment_2
		}
		
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3		
	}

	unique_prototype_rewards = {
		sp_rocket_outercoating_reward = {
			fire_only_once = yes

			threshold = { 
				min = 40
				max = 90
			}

			weight = {
				base = 50
			}

			option = {
				token = sp_rocket_outercoating_reward_accept
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.low }
					}
				}
			}
		}

		sp_rocket_launch_site_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 30
				max = 60
			}

			weight = {
				base = 10
			}

			option = {
				token = sp_rocket_launch_site_choice_reward_reject
				
				iteration_output = {
					country_effects = {
						#Do nothing, this is the default option
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.low }
					}
				}
			}

			option = {
				token = sp_rocket_launch_site_choice_reward_accept
				
				iteration_output = {

					country_effects = {
						set_country_flag = no_new_rocket_facility_built
						add_timed_idea = {
							idea = special_project_consumer_costs_low
							days = 365
						}
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.medium }
						random_owned_controlled_state = {
								limit = {
									free_building_slots = {
										building = industrial_complex
										size > 0
										include_locked = yes
									}
									rocket_site < 2
								}
							
							add_building_construction = {
								type = rocket_site
								level = 2
								instant_build = yes
							}
						}
					}
				}
			}
		}
	}
}

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


# Ground to Air Missiles - The Wasserfall Project
sp_rockets_ground_to_air_missile = {
	specialization = specialization_air 
	breakthrough_cost = {
		specialization_air = 2
	}
	
	icon = GFX_sp_rockets_surface_to_air_missiles 

	project_tags = {
		sp_tag_rocket
		sp_tag_guided_bomb
	}
	resource_cost = {
		resources = {
			steel = 6 
			aluminium = 9
			tungsten = 6
		}
	}	
	complexity = sp_complexity.large 

	allowed = {
		has_dlc = "Gotterdammerung"
	}

	special_project_parent = {
		sp_rockets_ballistic_missile
	}

	available = { 
		FROM = {
			has_tech = experimental_rockets
		}
	}
	
	ai_will_do = {
		base = 1
	}
	
	prototype_time = sp_time.prototype.medium	 

	project_output = {
		enable_equipments = {
			sam_missile_equipment_1
		}
		
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3		
	}

	unique_prototype_rewards = {
		# Ground control improvements
		sp_rockets_ground_control_improvements_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 75
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_launch_ramp_innovations_reward_option
						
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.low }
					}
				}
			}
		}

		# Ground control improvements
		sp_rockets_vertical_launch_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 0
				max = 30
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_launch_ramp_innovations_reward_option
						
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.low }
					}

					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.low
							specialization = specialization_air
						}
					}
				}
			}
		}

		# High Speed Flight Control
		sp_rockets_high_speed_flight_control_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 25
				max = 80
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_launch_ramp_innovations_reward_option
						
				iteration_output = {
					country_effects = {
						add_tech_bonus = {
							name = sp_rockets_high_speed_flight_control_bonus
							bonus = 0.15
							uses = 1
							category = air_equipment 
						}
					}
				}
			}
		}

		# Warhead Detonation Mechanisms
		sp_rockets_warhead_detonation_mechanisms_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 30
				max = 100
			}
			
			weight = {
				base = 1
			}
			
			option = {
				token = sp_rockets_flying_bomb_launch_ramp_innovations_reward_option
						
				iteration_output = {
					country_effects = {
						add_equipment_bonus = {
							name = sp_surface_air_missile_warhead_detonation_bonus
							bonus = {
								sam_missile_equipment = {
									air_attack = 0.1
								}
							}
						}
					}

					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.low
							specialization = specialization_air
						}
					}
				}
			}
		}
	}
}


sp_rocket_interceptor = {
	specialization = specialization_air 
	
	icon = GFX_sp_rockets_rocket_interceptor 

	project_tags = {
		sp_tag_rocket
	}

	complexity = sp_complexity.large
	resource_cost = {
		resources = {
			tungsten = 6 
			aluminium = 12
			chromium = 6
		}
	}

	available = { 
		FROM = {
			has_tech = experimental_rockets
		}
	}

	ai_will_do = {
		base = 1
		modifier = {
			factor = 0.5
			ROOT = { is_major = no }
		}
	}
	
	prototype_time = sp_time.prototype.medium

	project_output = {
		country_effects = {
			custom_effect_tooltip = {
				localization_key = SP_UNLOCK_TECH
				TECH = improved_rocket_engines	
			}
			custom_effect_tooltip = {
				localization_key = SP_UNLOCK_TECH
				TECH = advanced_rocket_engines	
			}
			if = {
				limit = { has_dlc = "By Blood Alone" }
				 SP_create_variant_based_on_country_improved_small_airframe_rocket_engine = yes	
			}		
		}
		enable_equipments = {
			limit = {
				NOT = { has_dlc = "By Blood Alone" }
			}
			rocket_interceptor_equipment_1
		}
		enable_equipment_modules = {
			limit = { 
				has_dlc = "By Blood Alone" 
			}
			rocket_engine_1
		}
		
	}

	generic_prototype_rewards = {
		sp_rockets_scientist_xp_generic_reward
		sp_rockets_political_interference_generic_reward
		sp_rockets_onsite_explosion_generic_reward
		sp_rockets_generic_major_breakthrough_reward
		sp_rockets_generic_avionics_advancements_reward
		sp_air_generic_reward_scientist_xp_1
		sp_air_generic_reward_scientist_xp_2
		sp_air_generic_reward_scientist_xp_3
		sp_air_generic_reward_air_xp_1
		sp_air_generic_reward_air_xp_2
		sp_air_generic_reward_air_xp_3
		sp_air_generic_reward_major_progress_1
		sp_air_generic_reward_major_progress_2
		sp_air_generic_reward_major_progress_3
		sp_air_generic_reward_test_failure_1
		sp_air_generic_reward_test_failure_2
		sp_air_generic_reward_test_failure_3		
	}
}


	


