﻿#Values used for checking distance with the 'squared_distance' trigger.

ttd_squared_distance_small = 40000 #200 map-pixels
ttd_squared_distance_medium = 160000 #400 map-pixels
ttd_squared_distance_large = 640000 #800 map-pixels
ttd_squared_distance_huge = 2560000 #1600 map-pixels
ttd_squared_distance_massive = 10240000 #3200 map-pixels
ttd_squared_distance_vast = 40960000 #6400 map-pixels

ttd_squared_distance_none_small = 10000 #100 map-pixels
ttd_squared_distance_small_medium = 90000 #300 map-pixels
ttd_squared_distance_medium_large = 360000 #600 map-pixels
ttd_squared_distance_large_huge = 1440000 #1200 map-pixels
ttd_squared_distance_huge_massive = 5760000 #2400 map-pixels
ttd_squared_distance_massive_vast = 23040000 #4800 map-pixels
ttd_squared_distance_vast_infinite = 64000000 #8000 map-pixels

ttd_major_distance_factor_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = 0.5
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = 0.25
	}
	else = {
		add = 0.125
	}
}


ttd_medium_distance_factor_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = 0.75
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = 0.5
	}
	else = {
		add = 0.25
	}
}


ttd_minor_distance_factor_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = 0.875
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = 0.75
	}
	else = {
		add = 0.5
	}
}


ttd_major_distance_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_small
				}
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_small_medium
				}
			}
		}
		add = -10
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_medium
				}
			}
		}
		add = -15
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_medium_large
				}
			}
		}
		add = -20
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_large
				}
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_large_huge
				}
			}
		}
		add = -30
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = -35
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge_massive
				}
			}
		}
		add = -40
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_massive
				}
			}
		}
		add = -45
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_massive_vast
				}
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = -55
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast_infinite
				}
			}
		}
		add = -60
	}
	else = {
		add = -65
	}
}

ttd_medium_distance_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_medium
				}
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			scope:ttd_location_2 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_large
				}
			}
		}
		add = -10
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = -15
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_massive
				}
			}
		}
		add = -20
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = -25
	}
	else = {
		add = -30
	}
}

ttd_minor_distance_value = {
	value = 0
	if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_huge
				}
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			scope:ttd_location_1 = {
				squared_distance = {
					target = scope:ttd_location_2
					value < ttd_squared_distance_vast
				}
			}
		}
		add = -10
	}
	else = {
		add = -15
	}
}

# ttd_agent_distance_penalty = {
	# value = 0
	# desc = TTD_AGENT_DISTANCE_PENALTY_DESC
	# if = {
		# limit = {
			# scope:ttd_agent_residence = {
				# squared_distance = {
					# target = scope:ttd_target_residence
					# value < ttd_squared_distance_medium
				# }
			# }
		# }
		# add = -5
	# }
	# else_if = {
		# limit = {
			# scope:ttd_agent_residence = {
				# squared_distance = {
					# target = scope:ttd_target_residence
					# value < ttd_squared_distance_large
				# }
			# }
		# }
		# add = -10
	# }
	# else_if = {
		# limit = {
			# scope:ttd_agent_residence = {
				# squared_distance = {
					# target = scope:ttd_target_residence
					# value < ttd_squared_distance_huge
				# }
			# }
		# }
		# add = -15
	# }
	# else_if = {
		# limit = {
			# scope:ttd_agent_residence = {
				# squared_distance = {
					# target = scope:ttd_target_residence
					# value < ttd_squared_distance_massive
				# }
			# }
		# }
		# add = -20
	# }
	# else_if = {
		# limit = {
			# scope:ttd_agent_residence = {
				# squared_distance = {
					# target = scope:ttd_target_residence
					# value < ttd_squared_distance_vast
				# }
			# }
		# }
		# add = -25
	# }
	# else = {
		# add = -30
	# }
# }