@base_reward_weight = 2 #Base Reward weight value
@reward_weight_factor_theme = 0.25 # Applied to factor - Used to reduce chances of repeating the same reward theme within the same project (ie. Failure 1 & Failure 2)



#Low Scientist XP gain
sp_naval_generic_reward_scientist_xp_1 = {

	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_scientist_xp_flag
		}
		modifier = {
			factor = 0
			var:scientist = {
				has_scientist_level = {
					level > 4
					specialization = specialization_naval
				}
			}
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_scientist_xp
		
		iteration_output = {
			scientist_effects = {
				if = {
					limit = {
						
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
				FROM = { set_project_flag = sp_naval_generic_reward_scientist_xp_flag }
			}
		}
	}
}

#Medium Scientist XP gain
sp_naval_generic_reward_scientist_xp_2 = {

	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_scientist_xp_flag
		}
		modifier = {
			factor = 0
			var:scientist = {
				has_scientist_level = {
					level > 4
					specialization = specialization_naval
				}
			}
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_scientist_xp
		
		iteration_output = {
			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.medium
						specialization = specialization_naval
					}
				}
				FROM = { set_project_flag = sp_naval_generic_reward_scientist_xp_flag }
			}
		}
	}
}

#High Scientist XP gain
sp_naval_generic_reward_scientist_xp_3 = {

	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_scientist_xp_flag
		}
		modifier = {
			factor = 0
			var:scientist = {
				has_scientist_level = {
					level > 4
					specialization = specialization_naval
				}
			}
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_scientist_xp
		
		iteration_output = {
			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.high
						specialization = specialization_naval
					}
				}
				FROM = { set_project_flag = sp_naval_generic_reward_scientist_xp_flag }
			}

			country_effects = {
				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}
			}
		}
	}
}

#Low navy XP
sp_naval_generic_reward_navy_xp_1 = {
	fire_only_once = yes
	
	threshold = {
		min = 50
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_navy_xp_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_navy_xp
		
		iteration_output = {
			country_effects = {
				navy_experience = constant:sp_military_xp_gain.low
				FROM = { set_project_flag = sp_naval_generic_reward_navy_xp_flag }
			}
		}
	}
}

#medium navy XP
sp_naval_generic_reward_navy_xp_2 = {
	fire_only_once = yes
	
	threshold = {
		min = 50
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_navy_xp_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_navy_xp
		
		iteration_output = {
			country_effects = {
				navy_experience = constant:sp_military_xp_gain.medium
				FROM = { set_project_flag = sp_naval_generic_reward_navy_xp_flag }
			}
		}
	}
}

#High navy XP
sp_naval_generic_reward_navy_xp_3 = {
	fire_only_once = yes
	
	threshold = {
		min = 50
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_navy_xp_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_navy_xp
		
		iteration_output = {
			country_effects = {
				navy_experience = constant:sp_military_xp_gain.high
				
				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}

				FROM = { set_project_flag = sp_naval_generic_reward_navy_xp_flag }
			}
		}
	}
}

#Low Extra Progress
sp_naval_generic_reward_major_progress_1 = {
	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_major_progress_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_major_breakthrough
		
		iteration_output = {
			country_effects = {
				FROM = {
					add_project_progress_ratio = constant:sp_progress.gain.low				
					
					set_project_flag = sp_naval_generic_reward_major_progress_flag
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#Medium Extra Progress
sp_naval_generic_reward_major_progress_2 = {
	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_major_progress_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_major_breakthrough
		
		iteration_output = {
			country_effects = {
				FROM = {
					add_project_progress_ratio = constant:sp_progress.gain.medium				
					
					set_project_flag = sp_naval_generic_reward_major_progress_flag
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#High Extra Progress
sp_naval_generic_reward_major_progress_3 = {
	fire_only_once = yes

	threshold = {
		min = 0
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_major_progress_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_major_breakthrough
		
		iteration_output = {
			country_effects = {
				FROM = {
					add_project_progress_ratio = constant:sp_progress.gain.high				
					
					set_project_flag = sp_naval_generic_reward_major_progress_flag
				}

				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#Low Progress Loss
sp_naval_generic_reward_test_failure_1 = {
	fire_only_once = yes
	
	threshold = {
		min = 15 #Loss is 5
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_test_failure_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_test_failure
		
		iteration_output = {
			country_effects = { 
				FROM = {
					add_project_progress_ratio = constant:sp_progress.loss.low

					set_project_flag = sp_naval_generic_reward_test_failure_flag
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#Medium Progress Loss
sp_naval_generic_reward_test_failure_2 = {
	fire_only_once = yes
	
	threshold = {
		min = 30 #Loss is 10
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_test_failure_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_test_failure
		
		iteration_output = {
			country_effects = { 
				FROM = {
					add_project_progress_ratio = constant:sp_progress.loss.medium

					set_project_flag = sp_naval_generic_reward_test_failure_flag
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#High Progress Loss
sp_naval_generic_reward_test_failure_3 = {
	fire_only_once = yes
	
	threshold = {
		min = 50 #Loss is 15
		max = 100
	}
	
	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_test_failure_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_test_failure
		
		iteration_output = {
			country_effects = { 
				FROM = {
					add_project_progress_ratio = constant:sp_progress.loss.high

					set_project_flag = sp_naval_generic_reward_test_failure_flag
				}

				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}
			}

			scientist_effects = {
				if = {
					limit = {
						has_scientist_level = {
							level < 5
							specialization = specialization_naval
						}
					}
					add_scientist_xp = {
						experience = constant:sp_scientist_xp_gain.low
						specialization = specialization_naval
					}
				}
			}
		}
	}
}

#Low Tech Bonus
sp_naval_generic_reward_armor_tech_1 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_equipment_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_equipment_tech
		
		iteration_output = {
			country_effects = { 
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_armor_tech_bonus_name
					bonus = 0.1
					uses = 1
					category = naval_armor
					category = bb_tech
					category = bc_tech
				}

				FROM = { set_project_flag = sp_naval_generic_reward_equipment_tech_flag }
			}
		}
	}
}

#Medium Tech Bonus
sp_naval_generic_reward_armor_tech_2 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_armor_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_armor_tech
		
		iteration_output = {
			country_effects = { 
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_armor_tech_bonus_name
					bonus = 0.2
					uses = 1
					category = naval_armor
					category = bb_tech
					category = bc_tech
				}

				FROM = { set_project_flag = sp_naval_generic_reward_armor_tech_flag }
			}
		}
	}
}

#High Tech Bonus
sp_naval_generic_reward_armor_tech_3 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_armor_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_armor_tech
		
		iteration_output = {
			country_effects = { 
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_armor_tech_bonus_name
					bonus = 0.35
					uses = 1
					category = naval_armor
					category = bb_tech
					category = bc_tech
				}

				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}

				FROM = { set_project_flag = sp_naval_generic_reward_armor_tech_flag }
			}
		}
	}
}

#Low Tech Bonus
sp_naval_generic_reward_artillery_tech_1 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_artillery_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_artillery_tech
		
		iteration_output = {
			country_effects = {
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_artillery_tech_bonus_name
					bonus = 0.1
					uses = 1
					category = naval_artillery
				}

				FROM = { set_project_flag = sp_naval_generic_reward_artillery_tech_flag }
			}
		}
	}
}

#Medium Tech Bonus
sp_naval_generic_reward_artillery_tech_2 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_artillery_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_artillery_tech
		
		iteration_output = {
			country_effects = {
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_artillery_tech_bonus_name
					bonus = 0.2
					uses = 1
					category = naval_artillery
				}

				FROM = { set_project_flag = sp_naval_generic_reward_artillery_tech_flag }
			}
		}
	}
}

#High Tech Bonus
sp_naval_generic_reward_artillery_tech_3 = {
	fire_only_once = yes
	
	threshold = {
		min = 0
		max = 100
	}

	# ROOT is the project
	# FROM is the Country
	# var:facility_state is the State where the facility is (ensured to be set in this case)
	# var:facility_province_id is the province ID where the facility is (ensured to be set in this case)
	# var:scientist is the Scientist (ensured to be set in this case)
	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_reward_artillery_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_reward_option_artillery_tech
		
		iteration_output = {
			country_effects = {
				add_tech_bonus = {
					name = sp_naval_generic_reward_option_artillery_tech_bonus_name
					bonus = 0.35
					uses = 1
					category = naval_artillery
				}

				add_breakthrough_progress = {
					specialization = specialization_naval
					value = sp_breakthrough_progress.medium
				}

				FROM = { set_project_flag = sp_naval_generic_reward_artillery_tech_flag }
			}
		}
	}
}

sp_naval_generic_failure_nuclear_accident = {

	fire_only_once = yes

	threshold = { 
		min = 0
		max = 100
	}

	weight = {
		base = 200
	}
	
	option = {
		token = sp_naval_generic_failure_nuclear_accident_option
		
		iteration_output = {
			facility_state_effects = {
				damage_building = {
					tags = facility
					damage = 0.25 # levels of damage
				}
			}
		}
	}
}

sp_naval_generic_failure_torpedo_accident = {

	fire_only_once = yes

	threshold = { 
		min = 0
		max = 100
	}

	weight = {
		base = @base_reward_weight
		modifier = {
			factor = @reward_weight_factor_theme
			has_project_flag = sp_naval_generic_failure_torpedo_tech_flag
		}
	}
	
	option = {
		token = sp_naval_generic_failure_torpedo_option
		
		iteration_output = {
			facility_state_effects = {
				damage_building = {
					tags = facility
					damage = 0.15 # levels of damage
				}
			}

			country_effects = {
				FROM = { set_project_flag = sp_naval_generic_failure_torpedo_tech_flag }
			}
		}
	}
}