﻿##### Tech&Res  T&R
#Find Commonores #DONE Ho sostituito commonore -> commonores perché altrimenti il journal entry non funzionava come dovuto.
je_agassiz_find_commonores_project = {
	icon = "gfx/interface/icons/goods_icons/commonores.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_tt
			scope:target = {
				has_modifier = agassiz_building_production_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.101
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 18
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

#Find Copper
je_agassiz_find_copper_project = {
	icon = "gfx/interface/icons/goods_icons/copper.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_tt
			scope:target = {
				has_modifier = agassiz_building_production_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.101
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 18
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

#Find Bauxite
je_agassiz_find_bauxite_project = {
	icon = "gfx/interface/icons/goods_icons/bauxite.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_tt
			scope:target = {
				has_modifier = agassiz_building_production_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.101
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 30
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

#Find Rare Earths
je_agassiz_find_rare_earths_project = {
	icon = "gfx/interface/icons/goods_icons/rare_earths.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_tt
			scope:target = {
				has_modifier = agassiz_building_production_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.101
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 30
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

#Find Advanced Ores
je_agassiz_find_advancedores_project = {
	icon = "gfx/interface/icons/goods_icons/advancedores.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_tt
			scope:target = {
				has_modifier = agassiz_building_production_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.101
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 30
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

#Find Gas
je_agassiz_find_gas_project = {
	icon = "gfx/interface/icons/goods_icons/gas.dds"

	scripted_button = agassiz_stop_geologist_project_button

	group = je_group_agassiz_geology

	on_monthly_pulse = {
		effect = {
			#Calculates the Progress added (see agassiz_scripted_effects for calculation)
			agassiz_geologist_improvement_progress = yes
			#Adds the monthly progress to the variable
			change_variable = {
				name = agassiz_geologist_improvement_progress_var
				add = var:agassiz_monthly_geologist_improvement_progress_var
			}
			if = {
				limit = { var:agassiz_geologist_improvement_progress_var > agassiz_improvement_progress_cost }
				scope:target = {
					add_modifier = {
						name = agassiz_building_production_2_mult_modifier
					}
				}
				change_variable = {
					name = agassiz_geologist_improvement_progress_var
					subtract = agassiz_improvement_progress_cost
				}
			}
		}
	}

	immediate = {
		set_variable = agassiz_can_stop_active_improvement_project_var #This is used to check if the country has a project already
		#Sets the Geologist Improvement Progress at the beginning
		set_variable = {
			name = agassiz_geologist_improvement_progress_var
			value = 0
		}
		agassiz_geologist_improvement_progress = yes #Determines how much Geologist Improvement Progress will be added next month
	}

	complete = {
		custom_tooltip = {
			text = agassiz_building_has_production_modifier_2_tt
			scope:target = {
				has_modifier = agassiz_building_production_2_mult_modifier
			}
		}
	}

	on_complete = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		show_as_tooltip = {
			scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
		trigger_event = {
			id = agassiz.102
			popup = yes
		}
	}

	current_value = {
		#Keeps track of the Geology Progress. If the Progress reaches the progress_cost, a modifier will be added.
		value = var:agassiz_geologist_improvement_progress_var
	}

	goal_add_value = {
		#Normal value for Coal and Iron: 24
		value = 30
	}

	invalid = {
		OR = {
			custom_tooltip = {
				text = je_geologist_dies_tt
				NOT = {
					has_variable = agassiz_geologist_var
				}
			}
			custom_tooltip = {
				text = agassiz_stop_geologist_improving_project_tt
				OR = {
					trigger_if = {
						limit = { is_ai = yes }
						agassiz_has_geologist_trigger = yes
						agassiz_has_geologist_no_tooltip_trigger = yes
					}
					has_variable = agassiz_stop_geologist_improving_project_var
				}
			}
		}
	}

	on_invalid = {
		remove_variable = agassiz_can_stop_active_improvement_project_var #Needs to be removed, when the JE is removed
		show_as_tooltip = {
			scope:journal_entry = {
			remove_modifier = agassiz_ore_search_cost_modifier
		}
		}
		
		#Those should be removed in every geology je
		remove_variable = agassiz_geologist_improvement_progress_var
		remove_variable = agassiz_monthly_geologist_improvement_progress_var
		remove_variable = geologist_experience_add_var

		remove_variable = agassiz_stop_geologist_improving_project_var
		var:agassiz_geologist_var ?= {
			set_character_busy_and_immortal = no
		}
	}

	progressbar = yes

	weight = 30

	should_be_pinned_by_default = yes
}

######################################################################################

