sp_nuclear_reactor = {
	specialization = specialization_nuclear	
	icon = GFX_sp_nuclear_reactor
	complexity = sp_complexity.large 

	project_tags = sp_tag_nuclear_power

	allowed = {
		
	}
	available = { 
		FROM = { has_tech = atomic_research }
	}
	
	resource_cost = {
		resources = { steel=6 tungsten=3 chromium=6 }
	}

	prototype_time = sp_time.prototype.long	
	
	project_output = {
		country_effects = {
			custom_override_tooltip = {
				tooltip = {
					localization_key = SP_UNLOCK_BUILDING_ICON_DESC
					BUILDING = nuclear_reactor
					BUILDING_DESCRIPTION = nuclear_reactor_desc
					ICON_FRAME = 13
				}
				IF = {
					limit = {
						has_country_flag = nuclear_reactor_heavy_water_flag
					}
					set_technology = {
						nuclear_reactor_heavy_water = 1
						popup = no
					}
				}
				ELSE = {
					set_technology = {
						nuclear_reactor = 1
						popup = no
					}
				}
			}
		}
		facility_state_effects = {
			IF = {
				limit = {
					OWNER = { has_country_flag = nuclear_reactor_heavy_water_flag }
				}
				set_building_level = {
					type = nuclear_reactor_heavy_water
					level = 1
				}
			}
			ELSE = {
				set_building_level = {
					type = nuclear_reactor
					level = 1
				}
			}
		}
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_reactor_radioactive_leak_stabilized_reward
		sp_nuclear_reactor_minor_explosion_reward
	}

	unique_prototype_rewards = {
		sp_nuclear_design_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 25
				max = 45
			}

			weight = {
				base = 1000.0
			}

			option = {
				token = sp_nuclear_design_choice_reward_graphite
				
				iteration_output = {
					country_effects = {
						custom_effect_tooltip = {
							localization_key = SP_UNLOCK_BUILDING
							BUILDING = nuclear_reactor
						}
					}
				}
			}

			option = {
				token = sp_nuclear_design_choice_reward_heavy_water
				
				iteration_output = {
					country_effects = {
						custom_effect_tooltip = {
							localization_key = SP_UNLOCK_BUILDING
							BUILDING = nuclear_reactor_heavy_water
						}
						set_country_flag = nuclear_reactor_heavy_water_flag
					}
				}
			}
		}

		sp_nuclear_isotope_separation_choice_reward = {
			fire_only_once = yes

			threshold = { 
				min = 0
				max = 20
			}

			weight = {
				base = 1000.0
			}

			option = {
				token = sp_nuclear_isotope_separation_choice_reward_gaseous
				
				iteration_output = {
					country_effects = {
						#Do nothing, this is the default option
					}
				}
			}

			option = {
				token = sp_nuclear_isotope_separation_choice_reward_centrifugal
				
				iteration_output = {
					country_effects = {
						hidden_effect = {
							set_technology = {
								isotope_separation_centrifugal = 1
								popup = no
							}
						}
						#custom_effect_tooltip = sp_nuclear_isotope_separation_choice_reward_tt
						add_timed_idea = {
							idea = special_project_consumer_costs_high
							days = 365
						}
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.high }
					}
				}
			}
		}

		# First Successful Test of a Nuclear Reactor
		sp_nuclear_reactor_tested_reward = {
			fire_only_once = yes

			threshold = { 
				min = 60
				max = 90
			}

			weight = {
				base = 100
				modifier = {
					factor = 0
					FROM = {
						has_global_flag = nuclear_reactor_tested_flag
					}
				}
			}

			option = {
				token = nuclear_reactor_tested_reward_classify
				iteration_output = {
					country_effects = {
						set_global_flag = nuclear_reactor_tested_flag
						set_country_flag = nuclear_reactor_classify_flag
					}
				}
			}

			option = {
				token = sp_nuclear_reactor_tested_reward_public
				
				iteration_output = {
					country_effects = {
						set_global_flag = nuclear_reactor_tested_flag
						set_country_flag = nuclear_reactor_public_flag
						add_popularity = {
							ideology = ROOT
							popularity = 0.1
						}
						add_political_power = 100
						every_other_country = {
							custom_effect_tooltip = sp_nuclear_reactor_tested_reward_public_tt
							hidden_effect = {
								IF = {
									limit = {
										has_tech = atomic_research
										NOT = { is_special_project_completed = sp:sp_nuclear_reactor } # This could probably not be the case, but just to be sure
									}
									sp:sp_nuclear_reactor = { add_project_progress_ratio = 0.1 }
								}
								ELSE_IF = {
									limit = {
										NOT = {
											has_tech = atomic_research
										}
									}
									add_tech_bonus = {
										name = sp_nuclear_reactor_tested_tech_bonus
										bonus = 0.25
										uses = 1
										technology  = atomic_research
									}
								}
							}
						}
					}
				}
			}
		}

		sp_nuclear_major_breakthrough_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 10
				max = 50
			}

			weight = {
				base = 1.0
			}

			option = {
				token = ssp_nuclear_major_breakthrough_reward_option
				
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.medium }
					}
				}
			}
		}
		
	}
}


# ADVANDED NUCLEAR USAGE
sp_commercial_nuclear_reactor = {
	specialization = specialization_nuclear	
	icon = GFX_sp_commercial_nuclear_reactor

	project_tags = sp_tag_nuclear_power
	
	prototype_time = sp_time.prototype.long	 
	complexity = sp_complexity.large

	special_project_parent = {
		sp_nuclear_reactor
	}
	resource_cost = {
		resources = { steel=6 tungsten=4 chromium=7 }
	}
	allowed = {
		has_dlc = "Gotterdammerung"
	}
	available = { 
		FROM = {
			has_tech = construction4
		}
	}
	
	project_output = {
		country_effects = {
			custom_override_tooltip = {
				tooltip = {
					localization_key = SP_UNLOCK_BUILDING_ICON_DESC
					BUILDING = commercial_nuclear_reactor
					BUILDING_DESCRIPTION = commercial_nuclear_reactor_desc
					ICON_FRAME = 27
				}
				set_technology = {
					commercial_nuclear_reactor_tech = 1
					popup = no
				}
			}
		}

		facility_state_effects = {
			hidden_effect = {
				IF = {
					limit = {
						nuclear_reactor_heavy_water > 0
					}
					remove_building = {
						type = nuclear_reactor_heavy_water
						level = 1
					}
					set_building_level = {
						type = commercial_nuclear_reactor
						level = 1
					}
				}
				ELSE_IF = {
					limit = {
						nuclear_reactor > 0
					}
					remove_building = {
						type = nuclear_reactor
						level = 1
					}
					set_building_level = {
						type = commercial_nuclear_reactor
						level = 1
					}	
				}
				ELSE_IF = {
					limit = { 
						free_building_slots = {
							building = industrial_complex
							size > 0
							include_locked = yes 
						}
					}
					set_building_level = {
						type = commercial_nuclear_reactor
						level = 1
					}
				}
			}
		}
	}
	
	empty_reward_weight = {
		base = 0.5
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_reactor_radioactive_leak_stabilized_reward
		sp_nuclear_reactor_minor_explosion_reward
	}
	
	unique_prototype_rewards = {
		sp_commercial_nuclear_reactor_concerns_reward = {
			fire_only_once = yes
			
			threshold = { 
				min = 30
				max = 90
			}

			weight = {
				base = 1.0
			}

			option = {
				token = sp_commercial_nuclear_reactor_concerns_reward_option_safety
				iteration_output = {
					country_effects = {
						add_popularity = {
							ideology = ROOT
							popularity = 0.05
						}
						add_political_power = 50
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.medium }
						set_country_flag = no_filters_for_reactors_flag
					}
				}
			}

			option = {
				token = sp_commercial_nuclear_reactor_concerns_reward_option_ignore
				iteration_output = {
					country_effects = {
						add_popularity = {
							ideology = ROOT
							popularity = -0.05
						}
					}
				}
			}
		}
		
	}
}


sp_nuclear_engines = {
	specialization = specialization_nuclear	
	icon = GFX_sp_nuclear_engines

	project_tags = sp_tag_nuclear_power
	
	prototype_time = sp_time.prototype.long	 
	complexity = sp_complexity.medium

	resource_cost = {
		resources = { steel=4 tungsten=2 chromium=5 }
	}

	special_project_parent = {
		sp_commercial_nuclear_reactor
	}
	allowed = {
		has_dlc = "Gotterdammerung"
	}
	available = { 
		
	}
	
	project_output = {
		country_effects = {
			
		}

		enable_equipment_modules = {
			sub_ship_nuclear_engine_1
			heavy_ship_nuclear_engine_1
			carrier_ship_nuclear_engine_1
		}
	}
	
	empty_reward_weight = {
		base = 0.5
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_war_support_generic_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_reactor_radioactive_leak_stabilized_reward
		sp_nuclear_reactor_minor_explosion_reward
	}
	
	unique_prototype_rewards = {
		
	}
}



# ATOMIC BOMBS
sp_nuclear_bomb = {
	specialization = specialization_nuclear	
	icon = GFX_sp_nuclear_bomb

	project_tags = sp_tag_nuclear_warfare
	
	prototype_time = sp_time.prototype.long	
	complexity = sp_complexity.large
	resource_cost = {
		resources = { steel=2 tungsten=8 chromium=2 }
	}
	special_project_parent = {
		sp_nuclear_reactor
	}
	allowed = {
		
	}
	available = { 
		
	}
	
	project_output = {
		country_effects = {
			add_nuclear_bombs = 1
			custom_effect_tooltip = sp_nuclear_bomb_tt
			hidden_effect = {
				set_technology = {
					nukes = 1
					popup = no
				}
			}
		}	
	}
	
	empty_reward_weight = {
		base = 0.5
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_war_support_generic_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_major_political_interference_generic_reward
		sp_nuclear_bomb_theoretical_breakthrough_generic_reward
		sp_nuclear_bomb_critical_mass_generic_reward
		sp_nuclear_bomb_accident_generic_reward
	}
	
	unique_prototype_rewards = {
	
		sp_nuclear_bomb_test_prototype_reward = {
			fire_only_once = yes

			threshold = { 
				min = 70
				max = 84
			}

			weight = {
				base = 100
			}
			
			option = {
				token = sp_nuclear_bomb_test_prototype_reward_test_bomb
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.medium }
					}
				}
			}

			option = {
				token = sp_nuclear_bomb_test_prototype_reward_keep_bomb
				
				iteration_output = {
					country_effects = {
						add_nuclear_bombs = 1
					}
				}
			}
		}

		sp_nuclear_bomb_espionage_threats_reward = {
			fire_only_once = yes

			threshold = { 
				min = 0
				max = 80
			}

			weight = {
				base = 1
				modifier = {
					factor = 10 
					FROM = {
						has_war = yes 
					}
				}
			}
			
			option = {
				token = sp_nuclear_bomb_espionage_threats_reward_no
				
				iteration_output = {
					country_effects = { 
						set_country_flag = nuclear_bomb_low_security_flag
					}
					scientist_effects = {
						add_scientist_xp = {
							experience = constant:sp_scientist_xp_gain.low
							specialization = specialization_nuclear
						}
					}
				}
			}

			option = {
				token = sp_nuclear_bomb_espionage_threats_reward_increase_security
				
				iteration_output = {
					country_effects = {
						set_country_flag = nuclear_bomb_high_security_flag
						custom_effect_tooltip = sp_nuclear_bomb_espionage_threats_reward_increase_security_tt
						FROM = { add_project_progress_ratio = constant:sp_progress.loss.low }
					}
				}
			}
		}

		sp_nuclear_bomb_information_leak_reward = {
			fire_only_once = yes

			threshold = { 
				min = 30
				max = 100
			}

			weight = {
				base = 0.2
				modifier = {
					factor = 2
					FROM = { has_country_flag = nuclear_reactor_public_flag }
				}
				modifier = {
					factor = 0
					FROM = { has_war = no }
				}
				modifier = {
					factor = 5
					FROM = { has_country_flag = nuclear_bomb_low_security_flag }
				}
				modifier = {
					factor = 0.5
					FROM = { has_country_flag = nuclear_bomb_high_security_flag }
				}
				
			}
			
			option = {
				token = sp_nuclear_bomb_information_leak_reward_option
				
				iteration_output = {
					country_effects = {
						random_enemy_country = {
							limit = {
								NOT = { is_special_project_completed = sp:sp_nuclear_bomb }
							}
							custom_effect_tooltip = sp_nuclear_bomb_information_leak_reward_tt
							hidden_effect = {
								country_event = {
									id = sp_nuclear_project_events.1
									hours = 8 
									random_hours = 4 
								}
							}
						}
					}
				}
			}
		}
		sp_nuclear_bomb_breakthrough_plutonium_reward = {
			fire_only_once = yes

			threshold = { 
				min = 20
				max = 60
			}

			weight = {
				base = 1
				modifier = {
					factor = 0.5
					FROM = { has_country_flag = nuclear_bomb_high_security_flag }
				}
			}
			
			option = {
				token = sp_nuclear_bomb_breakthrough_plutonium_reward_option
				
				iteration_output = {
					country_effects = {
						FROM = { add_project_progress_ratio = constant:sp_progress.gain.low }
					}
				}
			}
		}		
	}
}

sp_thermo_nuclear_bomb = {
	specialization = specialization_nuclear	
	icon = GFX_sp_thermo_nuclear_bomb

	project_tags = sp_tag_nuclear_warfare
	
	prototype_time = sp_time.prototype.long 
	complexity = sp_complexity.insane

	resource_cost = {
		resources = { steel=2 tungsten=10 chromium=3 }
	}

	special_project_parent = {
		sp_nuclear_bomb
	}
	allowed = {
		has_dlc = "Gotterdammerung"
	}
	available = { 
		
	}
	
	project_output = {
		country_effects = {
			custom_effect_tooltip = sp_thermo_nuclear_bomb_tt
			hidden_effect = {
				set_technology = {
					thermonuclear_bombs = 1
					popup = no
				}
			}
		}
	}
	
	empty_reward_weight = {
		base = 0.5
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_war_support_generic_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_major_political_interference_generic_reward
		sp_nuclear_bomb_theoretical_breakthrough_generic_reward
		sp_nuclear_bomb_critical_mass_generic_reward
		sp_nuclear_bomb_accident_generic_reward
	}
	
	unique_prototype_rewards = {
		sp_thermonuclear_bomb_test_reward = {
			fire_only_once = yes

			threshold = { 
				min = 50
				max = 80
			}

			weight = {
				base = 1000
				modifier = {
					factor = 0
					FROM = {
						num_of_nukes < 5 # To minimize the risk of this not being a good option to get
					}
				}
			}
			option = {
				token = sp_thermonuclear_bomb_test_reward_option_no
				
				iteration_output = {
					country_effects = {
					}
				}
			}
			option = {
				token = sp_thermonuclear_bomb_test_reward_option_yes
				
				iteration_output = {
					country_effects = {
						IF = {
							limit = {
								num_of_nukes > 0
							}
							add_nuclear_bombs = -1
							FROM = { add_project_progress_ratio = constant:sp_progress.gain.high }
							set_country_flag = thermonuclear_weapon_test_flag
						}
						ELSE = {
							custom_effect_tooltip = "sp_no_nukes_available_tt"
						}
						
					}
				}
			}
		}
	}
}

sp_nuclear_warheads = {
	specialization = specialization_nuclear	
	icon = GFX_sp_nuclear_warheads

	project_tags = sp_tag_nuclear_warfare
	
	prototype_time = sp_time.prototype.long	 
	complexity = sp_complexity.large

	resource_cost = {
		resources = { aluminium=4 tungsten=4 chromium=2 }
	}

	special_project_parent = {
		sp_nuclear_bomb
		# Country must have Medium range ballistic missiles to be able to start this project
		sp_rockets_medium_range_ballistic_missile
	}
	allowed = {
		has_dlc = "Gotterdammerung"
	}
	available = {
	}
	
	project_output = {
		country_effects = {
			
		}
		enable_equipments = {
			nuclear_missile_equipment_1
		}
	}
	
	empty_reward_weight = {
		base = 0.5
	}

	generic_prototype_rewards = {
		sp_nuclear_scientist_xp_generic_reward
		sp_nuclear_minor_progress_generic_reward
		sp_nuclear_generic_electronics_tech_reward
		sp_nuclear_war_support_generic_reward
		sp_nuclear_generic_industry_tech_reward
		sp_nuclear_major_political_interference_generic_reward
		sp_nuclear_bomb_theoretical_breakthrough_generic_reward
		sp_nuclear_bomb_critical_mass_generic_reward
		sp_nuclear_bomb_accident_generic_reward
	}
	
	unique_prototype_rewards = {
		
	}
}

