#To use one of them, refer to them elsewhere in script via "value:<value>" e.g. value:example_value
#IMPORTANT NOTE: Be mindful of performance when using these in triggers that are checked often!

# example_value = {
# 	base = 10 #default: 0

# 	# List of valid mathematical operations:
# 	# 	Numerical (modifying by a number):
# 	# 	- set/weight (both do the same, replaces the current result with this value)
# 	# 	- add
# 	# 	- subtract
# 	# 	- factor/mult/multiply ("multiply" fits the name scheme of the rest better, but the other two were kept for historical reasons)
# 	# 	- divide
# 	# 	- modulo
# 	# 	- round_to (rounds to nearest of that value, e.g. 10.7 round_to 5 gives you 10)
# 	# 	- max (sets to specified value if currently above it)
# 	# 	- min (sets to specified value if currently below it)
# 	# 	- pow (value is multiplied by itself to the power of x; be careful, you can get overflows if you are not careful)
# 	# 	Simple (do not need a number, but just "yes", e.g. "round = yes")
# 	# 	- round (sets to nearest full number)
# 	# 	- ceiling (rounds up)
# 	# 	- floor (rounds down)
# 	# 	- abs (multiply by -1 if negative)
# 	# 	- square (multiply by itself)
# 	# 	- square_root

# 	#All mathematical operations except weight and factor can be used inline e.g.
# 	add = 100
# 	multiply = value:some_other_script_value
# 	round = yes
# 	#(Note: weight and factor will instead overwrite the base value - use set, mult or multiply instead)

# 	#They can also be used in modifier = {} fields, which lets you only apply them if triggers are true
# 	modifier = {
# 		max = owner.max_example_variable 					#Variable set by set_variable
# 		owner = { is_variable_set = max_example_variable }	#Only applied if this trigger is true
# 	}
# 	# What works for right hand side values of mathematical operations? See events/00_how_to_use_variables for full list.

# 	complex_trigger_modifier = { 	#This lets you get the value of a trigger that you can't use in one-liners because it uses {}
# 		trigger = count_owned_planet
# 		trigger_scope = owner 		#Lets you get the result of the trigger on a different scope. Default is "this"
# 		parameters = { 				#Stick any further information necessary in here, like you'd do within the {} of the trigger normally
# 			limit = { num_pops > 10 }
# 		}
# 		mode = add 					#Allows all numerical operations
# 		mult = 5 					#Multiplies the outcome by this. In this example, this means adding 5 for each planet with more than 10 pops
# 	}
# }

# Final note: script_values use the same metascript system as scripted_triggers and scripted_effects
# This means that you can input parameters into them, in a similar fashion as described in scripted_effects/99_advanced_documentation.txt
# For format for doing so is value:my_value|PARAM1|value1|PARAM2|value2|.
# Then you can use $PARAM1$ in the script value and it will replace it with value1

negative_modifier_mult = {
	base = -1
	subtract = modifier:$MODIFIER$
	max = -0.1
}

positive_modifier_mult = {
	base = 1
	add = modifier:$MODIFIER$
	min = 0.1
}

days_to_months_speed_converter = {
	base = $DAYS$
	divide = value:speed_modifier_helper|MODIFIER|$MODIFIER$|
	divide = 30
	round = yes
	min = 0
}

time_modifier_mult = {
	base = 1
	divide = value:speed_modifier_helper|MODIFIER|$MODIFIER$|
}

speed_modifier_mult = {
	base = $DAYS$
	# modifier = {
	# 	set = 360
	# 	prev = {
	# 		has_global_flag = has_nsc_active
	# 	}
	# }
	divide = value:speed_modifier_helper|MODIFIER|$MODIFIER$|
}

speed_modifier_helper = {
	base = 1
	add = modifier:$MODIFIER$
	modifier = {
		add = 1
		prev = {
			is_scope_type = starbase
			has_global_flag = has_nsc_active
			has_starbase_building = construction_office
		}
	}
	modifier = {
		add = 1.5
		prev = {
			is_scope_type = starbase
			has_starbase_building = adv_space_engineers
		}
	}
}

mega_cap_modifier = {
	base = 1
	add = modifier:country_megastructure_build_cap_add
	min = 0
}

starbases_upgrading_cap_trigger = {
	base = 0
	complex_trigger_modifier = {
		trigger = count_owned_starbase
		trigger_scope = owner
		parameters = {
			limit = {
				has_starbase_size = starbase_outpost
				has_starbase_flag = auto_upgrading_starbase_flag
			}
		}
		mode = add
	}
	add = trigger:used_starbase_capacity_integer
	min = 0
}

leader_official_cap_trigger = {
	base = 3
	add = modifier:country_leader_cap_add
	complex_trigger_modifier = {
		trigger = count_owned_leader
		trigger_scope = owner
		parameters = {
			limit = {
				leader_class = official
			}
		}
		mode = subtract
	}
	min = 0
}

leader_commander_cap_trigger = {
	base = 3
	add = modifier:country_leader_cap_add
	complex_trigger_modifier = {
		trigger = count_owned_leader
		trigger_scope = owner
		parameters = {
			limit = {
				leader_class = commander
			}
		}
		mode = subtract
	}
	min = 0
}

leader_scientist_cap_trigger = {
	base = 3
	add = modifier:country_leader_cap_add
	complex_trigger_modifier = {
		trigger = count_owned_leader
		trigger_scope = owner
		parameters = {
			limit = {
				leader_class = scientist
			}
		}
		mode = subtract
	}
	min = 0
}

posivite_mega_upgrading_alloy_cost = {
	base = 1
	add = modifier:megastructures_cost_mult
	modifier = {
		prev = {
			has_megastructure_flag = auto_upgrading_bio_megastructure_flag
		}
		mult = 0.5
	}
	min = 0.1
}

negative_mega_upgrading_alloy_cost = {
	base = -1
	subtract = modifier:megastructures_cost_mult
	modifier = {
		prev = {
			has_megastructure_flag = auto_upgrading_bio_megastructure_flag
		}
		mult = 0.5
	}
	max = -0.1
}

posivite_mega_upgrading_bio_cost = {
	base = 1
	add = modifier:megastructures_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = @halved_alloy_to_food_cost_ratio
	}
	min = 0.1
}

negative_mega_upgrading_bio_cost = {
	base = -1
	subtract = modifier:megastructures_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = @halved_alloy_to_food_cost_ratio
	}
	max = 0.1
}

posivite_starbase_upgrading_alloy_cost = {
	base = 1
	add = modifier:starbase_upgrade_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = 0.5
	}
	min = 0.1
}

negative_starbase_upgrading_alloy_cost = {
	base = -1
	subtract = modifier:starbase_upgrade_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = 0.5
	}
	max = -0.1
}

posivite_starbase_upgrading_bio_cost = {
	base = 1
	add = modifier:starbase_upgrade_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = @halved_alloy_to_food_cost_ratio
	}
	min = 0.1
}

negative_starbase_upgrading_bio_cost = {
	base = -1
	subtract = modifier:starbase_upgrade_cost_mult
	modifier = {
		country_uses_bio_ships = yes
		mult = @halved_alloy_to_food_cost_ratio
	}
	max = 0.1
}