#	Example:
# 
#	example_trigger = {
#		tag = GER
#		is_ai = no
#	}
#
#
#	In a script file:
#
#	trigger = {
#		exampel_trigger = yes
#	}
#

pd_calculate_province_cost = {
	if = {
		limit = {
			check_variable = { ROOT.pd_selected = 1 }
		}
		# Calculate cost
		set_temp_variable = { pts = THIS.state_strategic_value }
		round_temp_variable = pts
		clamp_temp_variable = {
			var = pts
			min = 1
		}
		# Cost modifiers
		if = {
			limit = { 
				NOT = { ROOT = { has_country_flag = pd_root_gives } }
				is_core_of = ROOT 
			}
			divide_temp_variable = { pts = 2 }
		}
		else_if = {
			limit = { 
				NOT = { ROOT = { has_country_flag = pd_root_gives } }
				is_claimed_by = ROOT 
			}
			divide_temp_variable = { pts = 1.5 }
		}
	}
	else_if = {
		limit = {
			check_variable = { ROOT.pd_selected = 2 }
		}
		# Calculate cost
		set_temp_variable = { pts = THIS.state_strategic_value }
		divide_temp_variable = { pts = 2 }
		round_temp_variable = pts
		clamp_temp_variable = {
			var = pts
			min = 1
		}
	}
	else_if = {
		limit = {
			check_variable = { ROOT.pd_selected = 3 }
		}
		# Calculate cost
		set_temp_variable = { pts = THIS.state_strategic_value }
		divide_temp_variable = { pts = 4 }
		round_temp_variable = pts
		clamp_temp_variable = {
			var = pts
			min = 1
		} 
	}
	else_if = {
		limit = {
			check_variable = { ROOT.pd_selected = 4 }
		}
		# Calculate cost
		set_temp_variable = { pts = THIS.state_strategic_value }
		divide_temp_variable = { pts = 3 }
		round_temp_variable = pts
		clamp_temp_variable = {
			var = pts
			min = 1
		} 
	}
	if = {
		limit = { is_owned_and_controlled_by = THIS.owner }
		multiply_temp_variable = { pts = 2 }
	}
	always = yes
}

pd_is_marked = {
	OR = {
		AND = {
			check_variable = { ROOT.pd_selected = 1 }
			ROOT = {
				is_in_array = {
					array = pd_take_array
					value = PREV
				}
			}
		}
		AND = {
			check_variable = { ROOT.pd_selected = 2 }
			ROOT = {
				is_in_array = {
					array = pd_puppet_array
					value = PREV
				}
			}
		}
		AND = {
			check_variable = { ROOT.pd_selected = 3 }
			ROOT = {
				is_in_array = {
					array = pd_demilitarize_array
					value = PREV
				}
			}
		}
		AND = {
			check_variable = { ROOT.pd_selected = 4 }
			ROOT = {
				is_in_array = {
					array = pd_liberate_array
					value = PREV
				}
			}
		}
	}
}

pd_is_invisible = {
	OR = {
		AND = {
			NOT = { check_variable = { ROOT.pd_selected = 1 } }
			ROOT = {
				is_in_array = {
					array = pd_take_array
					value = PREV
				}
			}
		}
		AND = {
			NOT = { check_variable = { ROOT.pd_selected = 2 } }
			ROOT = {
				is_in_array = {
					array = pd_puppet_array
					value = PREV
				}
			}
		}
		AND = {
			NOT = { check_variable = { ROOT.pd_selected = 3 } }
			ROOT = {
				is_in_array = {
					array = pd_demilitarize_array
					value = PREV
				}
			}
		}
		AND = {
			NOT = { check_variable = { ROOT.pd_selected = 4 } }
			ROOT = {
				is_in_array = {
					array = pd_liberate_array
					value = PREV
				}
			}
		}
		AND = {
			check_variable = { ROOT.pd_selected = 4 }
			
			NOT = {
				any_of_scopes = {
					array = THIS.core_countries
				
					NOT = { original_tag = PREV.owner }
					NOT = { tag = ROOT }
				}
			}
		}
	}
}